| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| node-npmtest-highcharts/ | 100% | (153 / 153) | 100% | (126 / 126) | 100% | (28 / 28) | 100% | (153 / 153) | |
| node-npmtest-highcharts/node_modules/highcharts/ | 0.54% | (200 / 36809) | 0.1% | (42 / 43482) | 0.15% | (10 / 6580) | 0.74% | (180 / 24385) | |
| node-npmtest-highcharts/node_modules/highcharts/adapters/ | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (0 / 0) | |
| node-npmtest-highcharts/node_modules/highcharts/lib/ | 3.03% | (233 / 7689) | 1.87% | (92 / 4914) | 3.63% | (38 / 1047) | 3.44% | (160 / 4655) | |
| node-npmtest-highcharts/node_modules/highcharts/modules/ | 2.08% | (291 / 14013) | 1.03% | (132 / 12866) | 1.66% | (44 / 2645) | 2.58% | (233 / 9041) | |
| node-npmtest-highcharts/node_modules/highcharts/themes/ | 38.71% | (24 / 62) | 75% | (24 / 32) | 32% | (8 / 25) | 38.71% | (24 / 62) |
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| example.js | 100% | (83 / 83) | 100% | (73 / 73) | 100% | (12 / 12) | 100% | (83 / 83) | |
| lib.npmtest_highcharts.js | 100% | (16 / 16) | 100% | (14 / 14) | 100% | (3 / 3) | 100% | (16 / 16) | |
| test.js | 100% | (54 / 54) | 100% | (39 / 39) | 100% | (13 / 13) | 100% | (54 / 54) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | 2 2 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 2 3 3 3 3 1 3 3 3 1 3 1 1 1 1 1 1 1 1 1 1 1 1 6 6 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /*
example.js
quickstart example
instruction
1. save this script as example.js
2. run the shell command:
$ npm install npmtest-highcharts && PORT=8081 node example.js
3. play with the browser-demo on http://127.0.0.1:8081
*/
/* istanbul instrument in package npmtest_highcharts */
/*jslint
bitwise: true,
browser: true,
maxerr: 8,
maxlen: 96,
node: true,
nomen: true,
regexp: true,
stupid: true
*/
(function () {
'use strict';
var local;
// run shared js-env code - pre-init
(function () {
// init local
local = {};
// init modeJs
local.modeJs = (function () {
try {
return typeof navigator.userAgent === 'string' &&
typeof document.querySelector('body') === 'object' &&
typeof XMLHttpRequest.prototype.open === 'function' &&
'browser';
} catch (errorCaughtBrowser) {
return module.exports &&
typeof process.versions.node === 'string' &&
typeof require('http').createServer === 'function' &&
'node';
}
}());
// init global
local.global = local.modeJs === 'browser'
? window
: global;
// init utility2_rollup
local = local.global.utility2_rollup || (local.modeJs === 'browser'
? local.global.utility2_npmtest_highcharts
: global.utility2_moduleExports);
// export local
local.global.local = local;
}());
switch (local.modeJs) {
// post-init
// run browser js-env code - post-init
/* istanbul ignore next */
case 'browser':
local.testRunBrowser = function (event) {
Eif (!event || (event &&
event.currentTarget &&
event.currentTarget.className &&
event.currentTarget.className.includes &&
event.currentTarget.className.includes('onreset'))) {
// reset output
Array.from(
document.querySelectorAll('body > .resettable')
).forEach(function (element) {
switch (element.tagName) {
case 'INPUT':
case 'TEXTAREA':
element.value = '';
break;
default:
element.textContent = '';
}
});
}
switch (event && event.currentTarget && event.currentTarget.id) {
case 'testRunButton1':
// show tests
Eif (document.querySelector('#testReportDiv1').style.display === 'none') {
document.querySelector('#testReportDiv1').style.display = 'block';
document.querySelector('#testRunButton1').textContent =
'hide internal test';
local.modeTest = true;
local.testRunDefault(local);
// hide tests
} else {
document.querySelector('#testReportDiv1').style.display = 'none';
document.querySelector('#testRunButton1').textContent = 'run internal test';
}
break;
// custom-case
default:
break;
}
Iif (document.querySelector('#inputTextareaEval1') && (!event || (event &&
event.currentTarget &&
event.currentTarget.className &&
event.currentTarget.className.includes &&
event.currentTarget.className.includes('oneval')))) {
// try to eval input-code
try {
/*jslint evil: true*/
eval(document.querySelector('#inputTextareaEval1').value);
} catch (errorCaught) {
console.error(errorCaught);
}
}
};
// log stderr and stdout to #outputTextareaStdout1
['error', 'log'].forEach(function (key) {
console[key + '_original'] = console[key];
console[key] = function () {
var element;
console[key + '_original'].apply(console, arguments);
element = document.querySelector('#outputTextareaStdout1');
Iif (!element) {
return;
}
// append text to #outputTextareaStdout1
element.value += Array.from(arguments).map(function (arg) {
return typeof arg === 'string'
? arg
: JSON.stringify(arg, null, 4);
}).join(' ') + '\n';
// scroll textarea to bottom
element.scrollTop = element.scrollHeight;
};
});
// init event-handling
['change', 'click', 'keyup'].forEach(function (event) {
Array.from(document.querySelectorAll('.on' + event)).forEach(function (element) {
element.addEventListener(event, local.testRunBrowser);
});
});
// run tests
local.testRunBrowser();
break;
// run node js-env code - post-init
/* istanbul ignore next */
case 'node':
// export local
module.exports = local;
// require modules
local.fs = require('fs');
local.http = require('http');
local.url = require('url');
// init assets
local.assetsDict = local.assetsDict || {};
/* jslint-ignore-begin */
local.assetsDict['/assets.index.template.html'] = '\
<!doctype html>\n\
<html lang="en">\n\
<head>\n\
<meta charset="UTF-8">\n\
<meta name="viewport" content="width=device-width, initial-scale=1">\n\
<title>{{env.npm_package_name}} (v{{env.npm_package_version}})</title>\n\
<style>\n\
/*csslint\n\
box-sizing: false,\n\
universal-selector: false\n\
*/\n\
* {\n\
box-sizing: border-box;\n\
}\n\
body {\n\
background: #dde;\n\
font-family: Arial, Helvetica, sans-serif;\n\
margin: 2rem;\n\
}\n\
body > * {\n\
margin-bottom: 1rem;\n\
}\n\
.utility2FooterDiv {\n\
margin-top: 20px;\n\
text-align: center;\n\
}\n\
</style>\n\
<style>\n\
/*csslint\n\
*/\n\
textarea {\n\
font-family: monospace;\n\
height: 10rem;\n\
width: 100%;\n\
}\n\
textarea[readonly] {\n\
background: #ddd;\n\
}\n\
</style>\n\
</head>\n\
<body>\n\
<!-- utility2-comment\n\
<div id="ajaxProgressDiv1" style="background: #d00; height: 2px; left: 0; margin: 0; padding: 0; position: fixed; top: 0; transition: background 0.5s, width 1.5s; width: 25%;"></div>\n\
utility2-comment -->\n\
<h1>\n\
<!-- utility2-comment\n\
<a\n\
{{#if env.npm_package_homepage}}\n\
href="{{env.npm_package_homepage}}"\n\
{{/if env.npm_package_homepage}}\n\
target="_blank"\n\
>\n\
utility2-comment -->\n\
{{env.npm_package_name}} (v{{env.npm_package_version}})\n\
<!-- utility2-comment\n\
</a>\n\
utility2-comment -->\n\
</h1>\n\
<h3>{{env.npm_package_description}}</h3>\n\
<!-- utility2-comment\n\
<h4><a download href="assets.app.js">download standalone app</a></h4>\n\
<button class="onclick onreset" id="testRunButton1">run internal test</button><br>\n\
<div id="testReportDiv1" style="display: none;"></div>\n\
utility2-comment -->\n\
\n\
\n\
\n\
<label>stderr and stdout</label>\n\
<textarea class="resettable" id="outputTextareaStdout1" readonly></textarea>\n\
<!-- utility2-comment\n\
{{#if isRollup}}\n\
<script src="assets.app.js"></script>\n\
{{#unless isRollup}}\n\
utility2-comment -->\n\
<script src="assets.utility2.rollup.js"></script>\n\
<script src="jsonp.utility2._stateInit?callback=window.utility2._stateInit"></script>\n\
<script src="assets.npmtest_highcharts.rollup.js"></script>\n\
<script src="assets.example.js"></script>\n\
<script src="assets.test.js"></script>\n\
<!-- utility2-comment\n\
{{/if isRollup}}\n\
utility2-comment -->\n\
<div class="utility2FooterDiv">\n\
[ this app was created with\n\
<a href="https://github.com/kaizhu256/node-utility2" target="_blank">utility2</a>\n\
]\n\
</div>\n\
</body>\n\
</html>\n\
';
/* jslint-ignore-end */
Iif (local.templateRender) {
local.assetsDict['/'] = local.templateRender(
local.assetsDict['/assets.index.template.html'],
{
env: local.objectSetDefault(local.env, {
npm_package_description: 'the greatest app in the world!',
npm_package_name: 'my-app',
npm_package_nameAlias: 'my_app',
npm_package_version: '0.0.1'
})
}
);
} else {
local.assetsDict['/'] = local.assetsDict['/assets.index.template.html']
.replace((/\{\{env\.(\w+?)\}\}/g), function (match0, match1) {
// jslint-hack
String(match0);
switch (match1) {
case 'npm_package_description':
return 'the greatest app in the world!';
case 'npm_package_name':
return 'my-app';
case 'npm_package_nameAlias':
return 'my_app';
case 'npm_package_version':
return '0.0.1';
}
});
}
// run the cli
Eif (local.global.utility2_rollup || module !== require.main) {
break;
}
local.assetsDict['/assets.example.js'] =
local.assetsDict['/assets.example.js'] ||
local.fs.readFileSync(__filename, 'utf8');
// bug-workaround - long $npm_package_buildCustomOrg
/* jslint-ignore-begin */
local.assetsDict['/assets.npmtest_highcharts.rollup.js'] =
local.assetsDict['/assets.npmtest_highcharts.rollup.js'] ||
local.fs.readFileSync(
local.npmtest_highcharts.__dirname + '/lib.npmtest_highcharts.js',
'utf8'
).replace((/^#!/), '//');
/* jslint-ignore-end */
local.assetsDict['/favicon.ico'] = local.assetsDict['/favicon.ico'] || '';
// if $npm_config_timeout_exit exists,
// then exit this process after $npm_config_timeout_exit ms
if (Number(process.env.npm_config_timeout_exit)) {
setTimeout(process.exit, Number(process.env.npm_config_timeout_exit));
}
// start server
if (local.global.utility2_serverHttp1) {
break;
}
process.env.PORT = process.env.PORT || '8081';
console.error('server starting on port ' + process.env.PORT);
local.http.createServer(function (request, response) {
request.urlParsed = local.url.parse(request.url);
if (local.assetsDict[request.urlParsed.pathname] !== undefined) {
response.end(local.assetsDict[request.urlParsed.pathname]);
return;
}
response.statusCode = 404;
response.end();
}).listen(process.env.PORT);
break;
}
}());
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 2 2 2 2 2 2 2 1 2 2 2 2 1 1 1 1 | /* istanbul instrument in package npmtest_highcharts */
/*jslint
bitwise: true,
browser: true,
maxerr: 8,
maxlen: 96,
node: true,
nomen: true,
regexp: true,
stupid: true
*/
(function () {
'use strict';
var local;
// run shared js-env code - pre-init
(function () {
// init local
local = {};
// init modeJs
local.modeJs = (function () {
try {
return typeof navigator.userAgent === 'string' &&
typeof document.querySelector('body') === 'object' &&
typeof XMLHttpRequest.prototype.open === 'function' &&
'browser';
} catch (errorCaughtBrowser) {
return module.exports &&
typeof process.versions.node === 'string' &&
typeof require('http').createServer === 'function' &&
'node';
}
}());
// init global
local.global = local.modeJs === 'browser'
? window
: global;
// init utility2_rollup
local = local.global.utility2_rollup || local;
// init lib
local.local = local.npmtest_highcharts = local;
// init exports
if (local.modeJs === 'browser') {
local.global.utility2_npmtest_highcharts = local;
} else {
module.exports = local;
module.exports.__dirname = __dirname;
module.exports.module = module;
}
}());
}());
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | 2 2 2 2 2 2 2 1 2 2 1 1 1 1 2 2 2 2 1 1 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 2 1 2 2 1 2 2 1 1 1 1 1 | /* istanbul instrument in package npmtest_highcharts */
/*jslint
bitwise: true,
browser: true,
maxerr: 8,
maxlen: 96,
node: true,
nomen: true,
regexp: true,
stupid: true
*/
(function () {
'use strict';
var local;
// run shared js-env code - pre-init
(function () {
// init local
local = {};
// init modeJs
local.modeJs = (function () {
try {
return typeof navigator.userAgent === 'string' &&
typeof document.querySelector('body') === 'object' &&
typeof XMLHttpRequest.prototype.open === 'function' &&
'browser';
} catch (errorCaughtBrowser) {
return module.exports &&
typeof process.versions.node === 'string' &&
typeof require('http').createServer === 'function' &&
'node';
}
}());
// init global
local.global = local.modeJs === 'browser'
? window
: global;
switch (local.modeJs) {
// re-init local from window.local
case 'browser':
local = local.global.utility2.objectSetDefault(
local.global.utility2_rollup || local.global.local,
local.global.utility2
);
break;
// re-init local from example.js
case 'node':
local = (local.global.utility2_rollup || require('utility2'))
.requireExampleJsFromReadme();
break;
}
// export local
local.global.local = local;
}());
// run shared js-env code - function
(function () {
return;
}());
switch (local.modeJs) {
// run browser js-env code - function
case 'browser':
break;
// run node js-env code - function
case 'node':
break;
}
// run shared js-env code - post-init
(function () {
return;
}());
switch (local.modeJs) {
// run browser js-env code - post-init
case 'browser':
local.testCase_browser_nullCase = local.testCase_browser_nullCase || function (
options,
onError
) {
/*
* this function will test browsers's null-case handling-behavior-behavior
*/
onError(null, options);
};
// run tests
local.nop(local.modeTest &&
document.querySelector('#testRunButton1') &&
document.querySelector('#testRunButton1').click());
break;
// run node js-env code - post-init
/* istanbul ignore next */
case 'node':
local.testCase_buildApidoc_default = local.testCase_buildApidoc_default || function (
options,
onError
) {
/*
* this function will test buildApidoc's default handling-behavior-behavior
*/
options = { modulePathList: module.paths };
local.buildApidoc(options, onError);
};
local.testCase_buildApp_default = local.testCase_buildApp_default || function (
options,
onError
) {
/*
* this function will test buildApp's default handling-behavior-behavior
*/
local.testCase_buildReadme_default(options, local.onErrorThrow);
local.testCase_buildLib_default(options, local.onErrorThrow);
local.testCase_buildTest_default(options, local.onErrorThrow);
local.testCase_buildCustomOrg_default(options, local.onErrorThrow);
options = [];
local.buildApp(options, onError);
};
local.testCase_buildCustomOrg_default = local.testCase_buildCustomOrg_default ||
function (options, onError) {
/*
* this function will test buildCustomOrg's default handling-behavior
*/
options = {};
local.buildCustomOrg(options, onError);
};
local.testCase_buildLib_default = local.testCase_buildLib_default || function (
options,
onError
) {
/*
* this function will test buildLib's default handling-behavior
*/
options = {};
local.buildLib(options, onError);
};
local.testCase_buildReadme_default = local.testCase_buildReadme_default || function (
options,
onError
) {
/*
* this function will test buildReadme's default handling-behavior-behavior
*/
options = {};
local.buildReadme(options, onError);
};
local.testCase_buildTest_default = local.testCase_buildTest_default || function (
options,
onError
) {
/*
* this function will test buildTest's default handling-behavior
*/
options = {};
local.buildTest(options, onError);
};
local.testCase_webpage_default = local.testCase_webpage_default || function (
options,
onError
) {
/*
* this function will test webpage's default handling-behavior
*/
options = { modeCoverageMerge: true, url: local.serverLocalHost + '?modeTest=1' };
local.browserTest(options, onError);
};
// run test-server
local.testRunServer(local);
break;
}
}());
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| highcharts-3d.js | 2.46% | (12 / 488) | 0.74% | (3 / 403) | 0.98% | (1 / 102) | 20.93% | (9 / 43) | |
| highcharts-3d.src.js | 2.11% | (15 / 711) | 0.72% | (3 / 416) | 0.96% | (1 / 104) | 2.11% | (15 / 711) | |
| highcharts-more.js | 1.01% | (4 / 395) | 0.55% | (3 / 547) | 0.83% | (1 / 120) | 3.77% | (2 / 53) | |
| highcharts-more.src.js | 0.62% | (5 / 806) | 0.53% | (3 / 563) | 0.83% | (1 / 120) | 0.62% | (5 / 806) | |
| highcharts.js | 0.54% | (21 / 3894) | 0.08% | (5 / 6180) | 0.11% | (1 / 907) | 4.45% | (17 / 382) | |
| highcharts.src.js | 0.42% | (27 / 6443) | 0.08% | (5 / 6477) | 0.11% | (1 / 915) | 0.42% | (27 / 6443) | |
| highmaps.js | 0.59% | (24 / 4101) | 0.08% | (5 / 6415) | 0.1% | (1 / 997) | 4.36% | (18 / 413) | |
| highmaps.src.js | 0.42% | (29 / 6826) | 0.07% | (5 / 6730) | 0.1% | (1 / 1005) | 0.42% | (29 / 6826) | |
| highstock.js | 0.57% | (28 / 4936) | 0.07% | (5 / 7688) | 0.09% | (1 / 1149) | 4.61% | (23 / 499) | |
| highstock.src.js | 0.43% | (35 / 8209) | 0.06% | (5 / 8063) | 0.09% | (1 / 1161) | 0.43% | (35 / 8209) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 1 1 1 1 1 1 1 1 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
3D features for Highcharts JS
@license: www.highcharts.com/license
*/
(function(E){"object"===typeof module&&module.exports?module.exports=E:E(Highcharts)})(function(E){(function(a){var q=a.deg2rad,k=a.pick;a.perspective=function(p,n,u){var m=n.options.chart.options3d,g=u?n.inverted:!1,h=n.plotWidth/2,r=n.plotHeight/2,e=m.depth/2,f=k(m.depth,1)*k(m.viewDistance,0),d=n.scale3d||1,b=q*m.beta*(g?-1:1),m=q*m.alpha*(g?-1:1),c=Math.cos(m),w=Math.cos(-b),x=Math.sin(m),y=Math.sin(-b);u||(h+=n.plotLeft,r+=n.plotTop);return a.map(p,function(b){var a,m;m=(g?b.y:b.x)-h;var n=(g?
b.x:b.y)-r,k=(b.z||0)-e;a=w*m-y*k;b=-x*y*m+c*n-w*x*k;m=c*y*m+x*n+c*w*k;n=0<f&&f<Number.POSITIVE_INFINITY?f/(m+e+f):1;a=a*n*d+h;b=b*n*d+r;return{x:g?b:a,y:g?a:b,z:m*d+e}})};a.pointCameraDistance=function(a,n){var p=n.options.chart.options3d,m=n.plotWidth/2;n=n.plotHeight/2;p=k(p.depth,1)*k(p.viewDistance,0)+p.depth;return Math.sqrt(Math.pow(m-a.plotX,2)+Math.pow(n-a.plotY,2)+Math.pow(p-a.plotZ,2))}})(E);(function(a){function q(b){var d=0,l,C;for(l=0;l<b.length;l++)C=(l+1)%b.length,d+=b[l].x*b[C].y-
b[C].x*b[l].y;return d/2}function k(b){var d=0,l;for(l=0;l<b.length;l++)d+=b[l].z;return b.length?d/b.length:0}function p(b,d,l,C,a,c,e,f){var g=[],H=c-a;return c>a&&c-a>Math.PI/2+.0001?(g=g.concat(p(b,d,l,C,a,a+Math.PI/2,e,f)),g=g.concat(p(b,d,l,C,a+Math.PI/2,c,e,f))):c<a&&a-c>Math.PI/2+.0001?(g=g.concat(p(b,d,l,C,a,a-Math.PI/2,e,f)),g=g.concat(p(b,d,l,C,a-Math.PI/2,c,e,f))):["C",b+l*Math.cos(a)-l*t*H*Math.sin(a)+e,d+C*Math.sin(a)+C*t*H*Math.cos(a)+f,b+l*Math.cos(c)+l*t*H*Math.sin(c)+e,d+C*Math.sin(c)-
C*t*H*Math.cos(c)+f,b+l*Math.cos(c)+e,d+C*Math.sin(c)+f]}var n=Math.cos,u=Math.PI,m=Math.sin,g=a.animObject,h=a.charts,r=a.color,e=a.defined,f=a.deg2rad,d=a.each,b=a.extend,c=a.inArray,w=a.map,x=a.merge,y=a.perspective,F=a.pick,A=a.SVGElement,G=a.SVGRenderer,B=a.wrap,t=4*(Math.sqrt(2)-1)/3/(u/2);G.prototype.toLinePath=function(b,a){var c=[];d(b,function(b){c.push("L",b.x,b.y)});b.length&&(c[0]="M",a&&c.push("Z"));return c};G.prototype.cuboid=function(b){var d=this.g(),c=d.destroy;b=this.cuboidPath(b);
d.attr({"stroke-linejoin":"round"});d.front=this.path(b[0]).attr({"class":"highcharts-3d-front",zIndex:b[3]}).add(d);d.top=this.path(b[1]).attr({"class":"highcharts-3d-top",zIndex:b[4]}).add(d);d.side=this.path(b[2]).attr({"class":"highcharts-3d-side",zIndex:b[5]}).add(d);d.fillSetter=function(b){this.front.attr({fill:b});this.top.attr({fill:r(b).brighten(.1).get()});this.side.attr({fill:r(b).brighten(-.1).get()});this.color=b;return this};d.opacitySetter=function(b){this.front.attr({opacity:b});
this.top.attr({opacity:b});this.side.attr({opacity:b});return this};d.attr=function(b,d){if("string"===typeof b&&"undefined"!==typeof d){var c=b;b={};b[c]=d}if(b.shapeArgs||e(b.x))b=this.renderer.cuboidPath(b.shapeArgs||b),this.front.attr({d:b[0],zIndex:b[3]}),this.top.attr({d:b[1],zIndex:b[4]}),this.side.attr({d:b[2],zIndex:b[5]});else return a.SVGElement.prototype.attr.call(this,b);return this};d.animate=function(b,d,c){e(b.x)&&e(b.y)?(b=this.renderer.cuboidPath(b),this.front.attr({zIndex:b[3]}).animate({d:b[0]},
d,c),this.top.attr({zIndex:b[4]}).animate({d:b[1]},d,c),this.side.attr({zIndex:b[5]}).animate({d:b[2]},d,c),this.attr({zIndex:-b[6]})):b.opacity?(this.front.animate(b,d,c),this.top.animate(b,d,c),this.side.animate(b,d,c)):A.prototype.animate.call(this,b,d,c);return this};d.destroy=function(){this.front.destroy();this.top.destroy();this.side.destroy();return c.call(this)};d.attr({zIndex:-b[6]});return d};G.prototype.cuboidPath=function(b){function d(b){return m[b]}var c=b.x,a=b.y,e=b.z,f=b.height,
g=b.width,r=b.depth,m=[{x:c,y:a,z:e},{x:c+g,y:a,z:e},{x:c+g,y:a+f,z:e},{x:c,y:a+f,z:e},{x:c,y:a+f,z:e+r},{x:c+g,y:a+f,z:e+r},{x:c+g,y:a,z:e+r},{x:c,y:a,z:e+r}],m=y(m,h[this.chartIndex],b.insidePlotArea),e=function(b,c){var a=[];b=w(b,d);c=w(c,d);0>q(b)?a=b:0>q(c)&&(a=c);return a};b=e([3,2,1,0],[7,6,5,4]);c=[4,5,2,3];a=e([1,6,7,0],c);e=e([1,2,5,6],[0,7,4,3]);return[this.toLinePath(b,!0),this.toLinePath(a,!0),this.toLinePath(e,!0),k(b),k(a),k(e),9E9*k(w(c,d))]};a.SVGRenderer.prototype.arc3d=function(a){function e(b){var d=
!1,a={};b=x(b);for(var e in b)-1!==c(e,n)&&(a[e]=b[e],delete b[e],d=!0);return d?a:!1}var l=this.g(),m=l.renderer,n="x y r innerR start end".split(" ");a=x(a);a.alpha*=f;a.beta*=f;l.top=m.path();l.side1=m.path();l.side2=m.path();l.inn=m.path();l.out=m.path();l.onAdd=function(){var b=l.parentGroup,a=l.attr("class");l.top.add(l);d(["out","inn","side1","side2"],function(d){l[d].addClass(a+" highcharts-3d-side").add(b)})};l.setPaths=function(b){var d=l.renderer.arc3dPath(b),a=100*d.zTop;l.attribs=b;l.top.attr({d:d.top,
zIndex:d.zTop});l.inn.attr({d:d.inn,zIndex:d.zInn});l.out.attr({d:d.out,zIndex:d.zOut});l.side1.attr({d:d.side1,zIndex:d.zSide1});l.side2.attr({d:d.side2,zIndex:d.zSide2});l.zIndex=a;l.attr({zIndex:a});b.center&&(l.top.setRadialReference(b.center),delete b.center)};l.setPaths(a);l.fillSetter=function(b){var d=r(b).brighten(-.1).get();this.fill=b;this.side1.attr({fill:d});this.side2.attr({fill:d});this.inn.attr({fill:d});this.out.attr({fill:d});this.top.attr({fill:b});return this};d(["opacity","translateX",
"translateY","visibility"],function(b){l[b+"Setter"]=function(b,a){l[a]=b;d(["out","inn","side1","side2","top"],function(d){l[d].attr(a,b)})}});B(l,"attr",function(d,a){var c;"object"===typeof a&&(c=e(a))&&(b(l.attribs,c),l.setPaths(l.attribs));return d.apply(this,[].slice.call(arguments,1))});B(l,"animate",function(b,d,a,c){var l,f=this.attribs,m;delete d.center;delete d.z;delete d.depth;delete d.alpha;delete d.beta;m=g(F(a,this.renderer.globalAnimation));m.duration&&(l=e(d),d.dummy=1,l&&(m.step=
function(b,d){function a(b){return f[b]+(F(l[b],f[b])-f[b])*d.pos}"dummy"===d.prop&&d.elem.setPaths(x(f,{x:a("x"),y:a("y"),r:a("r"),innerR:a("innerR"),start:a("start"),end:a("end")}))}),a=m);return b.call(this,d,a,c)});l.destroy=function(){this.top.destroy();this.out.destroy();this.inn.destroy();this.side1.destroy();this.side2.destroy();A.prototype.destroy.call(this)};l.hide=function(){this.top.hide();this.out.hide();this.inn.hide();this.side1.hide();this.side2.hide()};l.show=function(){this.top.show();
this.out.show();this.inn.show();this.side1.show();this.side2.show()};return l};G.prototype.arc3dPath=function(b){function d(b){b%=2*Math.PI;b>Math.PI&&(b=2*Math.PI-b);return b}var a=b.x,c=b.y,e=b.start,f=b.end-.00001,g=b.r,r=b.innerR,w=b.depth,h=b.alpha,k=b.beta,x=Math.cos(e),q=Math.sin(e);b=Math.cos(f);var y=Math.sin(f),v=g*Math.cos(k),g=g*Math.cos(h),t=r*Math.cos(k),B=r*Math.cos(h),r=w*Math.sin(k),z=w*Math.sin(h),w=["M",a+v*x,c+g*q],w=w.concat(p(a,c,v,g,e,f,0,0)),w=w.concat(["L",a+t*b,c+B*y]),w=
w.concat(p(a,c,t,B,f,e,0,0)),w=w.concat(["Z"]),F=0<k?Math.PI/2:0,k=0<h?0:Math.PI/2,F=e>-F?e:f>-F?-F:e,D=f<u-k?f:e<u-k?u-k:f,A=2*u-k,h=["M",a+v*n(F),c+g*m(F)],h=h.concat(p(a,c,v,g,F,D,0,0));f>A&&e<A?(h=h.concat(["L",a+v*n(D)+r,c+g*m(D)+z]),h=h.concat(p(a,c,v,g,D,A,r,z)),h=h.concat(["L",a+v*n(A),c+g*m(A)]),h=h.concat(p(a,c,v,g,A,f,0,0)),h=h.concat(["L",a+v*n(f)+r,c+g*m(f)+z]),h=h.concat(p(a,c,v,g,f,A,r,z)),h=h.concat(["L",a+v*n(A),c+g*m(A)]),h=h.concat(p(a,c,v,g,A,D,0,0))):f>u-k&&e<u-k&&(h=h.concat(["L",
a+v*Math.cos(D)+r,c+g*Math.sin(D)+z]),h=h.concat(p(a,c,v,g,D,f,r,z)),h=h.concat(["L",a+v*Math.cos(f),c+g*Math.sin(f)]),h=h.concat(p(a,c,v,g,f,D,0,0)));h=h.concat(["L",a+v*Math.cos(D)+r,c+g*Math.sin(D)+z]);h=h.concat(p(a,c,v,g,D,F,r,z));h=h.concat(["Z"]);k=["M",a+t*x,c+B*q];k=k.concat(p(a,c,t,B,e,f,0,0));k=k.concat(["L",a+t*Math.cos(f)+r,c+B*Math.sin(f)+z]);k=k.concat(p(a,c,t,B,f,e,r,z));k=k.concat(["Z"]);x=["M",a+v*x,c+g*q,"L",a+v*x+r,c+g*q+z,"L",a+t*x+r,c+B*q+z,"L",a+t*x,c+B*q,"Z"];a=["M",a+v*b,
c+g*y,"L",a+v*b+r,c+g*y+z,"L",a+t*b+r,c+B*y+z,"L",a+t*b,c+B*y,"Z"];y=Math.atan2(z,-r);c=Math.abs(f+y);b=Math.abs(e+y);e=Math.abs((e+f)/2+y);c=d(c);b=d(b);e=d(e);e*=1E5;f=1E5*b;c*=1E5;return{top:w,zTop:1E5*Math.PI+1,out:h,zOut:Math.max(e,f,c),inn:k,zInn:Math.max(e,f,c),side1:x,zSide1:.99*c,side2:a,zSide2:.99*f}}})(E);(function(a){function q(a,e){var f=a.plotLeft,d=a.plotWidth+f,b=a.plotTop,c=a.plotHeight+b,g=f+a.plotWidth/2,h=b+a.plotHeight/2,r=Number.MAX_VALUE,m=-Number.MAX_VALUE,k=Number.MAX_VALUE,
n=-Number.MAX_VALUE,q,t=1;q=[{x:f,y:b,z:0},{x:f,y:b,z:e}];p([0,1],function(b){q.push({x:d,y:q[b].y,z:q[b].z})});p([0,1,2,3],function(b){q.push({x:q[b].x,y:c,z:q[b].z})});q=u(q,a,!1);p(q,function(b){r=Math.min(r,b.x);m=Math.max(m,b.x);k=Math.min(k,b.y);n=Math.max(n,b.y)});f>r&&(t=Math.min(t,1-Math.abs((f+g)/(r+g))%1));d<m&&(t=Math.min(t,(d-g)/(m-g)));b>k&&(t=0>k?Math.min(t,(b+h)/(-k+b+h)):Math.min(t,1-(b+h)/(k+h)%1));c<n&&(t=Math.min(t,Math.abs((c-h)/(n-h))));return t}var k=a.Chart,p=a.each,n=a.merge,
u=a.perspective,m=a.pick,g=a.wrap;k.prototype.is3d=function(){return this.options.chart.options3d&&this.options.chart.options3d.enabled};k.prototype.propsRequireDirtyBox.push("chart.options3d");k.prototype.propsRequireUpdateSeries.push("chart.options3d");a.wrap(a.Chart.prototype,"isInsidePlot",function(a){return this.is3d()||a.apply(this,[].slice.call(arguments,1))});var h=a.getOptions();n(!0,h,{chart:{options3d:{enabled:!1,alpha:0,beta:0,depth:100,fitToPlot:!0,viewDistance:25,frame:{bottom:{size:1},
side:{size:1},back:{size:1}}}}});g(k.prototype,"setClassName",function(a){a.apply(this,[].slice.call(arguments,1));this.is3d()&&(this.container.className+=" highcharts-3d-chart")});a.wrap(a.Chart.prototype,"setChartSize",function(a){var e=this.options.chart.options3d;a.apply(this,[].slice.call(arguments,1));if(this.is3d()){var f=this.inverted,d=this.clipBox,b=this.margin;d[f?"y":"x"]=-(b[3]||0);d[f?"x":"y"]=-(b[0]||0);d[f?"height":"width"]=this.chartWidth+(b[3]||0)+(b[1]||0);d[f?"width":"height"]=
this.chartHeight+(b[0]||0)+(b[2]||0);this.scale3d=1;!0===e.fitToPlot&&(this.scale3d=q(this,e.depth))}});g(k.prototype,"redraw",function(a){this.is3d()&&(this.isDirtyBox=!0);a.apply(this,[].slice.call(arguments,1))});g(k.prototype,"renderSeries",function(a){var e=this.series.length;if(this.is3d())for(;e--;)a=this.series[e],a.translate(),a.render();else a.call(this)});k.prototype.retrieveStacks=function(a){var e=this.series,f={},d,b=1;p(this.series,function(c){d=m(c.options.stack,a?0:e.length-1-c.index);
f[d]?f[d].series.push(c):(f[d]={series:[c],position:b},b++)});f.totalStacks=b+1;return f}})(E);(function(a){var q,k=a.Axis,p=a.Chart,n=a.each,u=a.extend,m=a.merge,g=a.perspective,h=a.pick,r=a.splat,e=a.Tick,f=a.wrap;f(k.prototype,"setOptions",function(a,b){a.call(this,b);this.chart.is3d()&&"colorAxis"!==this.coll&&(a=this.options,a.tickWidth=h(a.tickWidth,0),a.gridLineWidth=h(a.gridLineWidth,1))});f(k.prototype,"render",function(a){a.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()&&"colorAxis"!==
this.coll){var b=this.chart,c=b.renderer,d=b.options.chart.options3d,e=d.frame,f=e.bottom,g=e.back,e=e.side,h=d.depth,k=this.height,m=this.width,r=this.left,n=this.top;this.isZAxis||(this.horiz?(g={x:r,y:n+(b.xAxis[0].opposite?-f.size:k),z:0,width:m,height:f.size,depth:h,insidePlotArea:!1},this.bottomFrame?this.bottomFrame.animate(g):(this.bottomFrame=c.cuboid(g).attr({"class":"highcharts-3d-frame highcharts-3d-frame-bottom",zIndex:b.yAxis[0].reversed&&0<d.alpha?4:-1}).add(),this.bottomFrame.attr({fill:f.color||
"none",stroke:f.color||"none"}))):(d={x:r+(b.yAxis[0].opposite?0:-e.size),y:n+(b.xAxis[0].opposite?-f.size:0),z:h,width:m+e.size,height:k+f.size,depth:g.size,insidePlotArea:!1},this.backFrame?this.backFrame.animate(d):(this.backFrame=c.cuboid(d).attr({"class":"highcharts-3d-frame highcharts-3d-frame-back",zIndex:-3}).add(),this.backFrame.attr({fill:g.color||"none",stroke:g.color||"none"})),b={x:r+(b.yAxis[0].opposite?m:-e.size),y:n+(b.xAxis[0].opposite?-f.size:0),z:0,width:e.size,height:k+f.size,
depth:h,insidePlotArea:!1},this.sideFrame?this.sideFrame.animate(b):(this.sideFrame=c.cuboid(b).attr({"class":"highcharts-3d-frame highcharts-3d-frame-side",zIndex:-2}).add(),this.sideFrame.attr({fill:e.color||"none",stroke:e.color||"none"}))))}});f(k.prototype,"getPlotLinePath",function(a){var b=a.apply(this,[].slice.call(arguments,1));if(!this.chart.is3d()||"colorAxis"===this.coll||null===b)return b;var c=this.chart,d=c.options.chart.options3d,c=this.isZAxis?c.plotWidth:d.depth,d=this.opposite;
this.horiz&&(d=!d);b=[this.swapZ({x:b[1],y:b[2],z:d?c:0}),this.swapZ({x:b[1],y:b[2],z:c}),this.swapZ({x:b[4],y:b[5],z:c}),this.swapZ({x:b[4],y:b[5],z:d?0:c})];b=g(b,this.chart,!1);return b=this.chart.renderer.toLinePath(b,!1)});f(k.prototype,"getLinePath",function(a){return this.chart.is3d()?[]:a.apply(this,[].slice.call(arguments,1))});f(k.prototype,"getPlotBandPath",function(a){if(!this.chart.is3d()||"colorAxis"===this.coll)return a.apply(this,[].slice.call(arguments,1));var b=arguments,c=b[1],
b=this.getPlotLinePath(b[2]);(c=this.getPlotLinePath(c))&&b?c.push("L",b[10],b[11],"L",b[7],b[8],"L",b[4],b[5],"L",b[1],b[2]):c=null;return c});f(e.prototype,"getMarkPath",function(a){var b=a.apply(this,[].slice.call(arguments,1));if(!this.axis.chart.is3d()||"colorAxis"===this.coll)return b;b=[this.axis.swapZ({x:b[1],y:b[2],z:0}),this.axis.swapZ({x:b[4],y:b[5],z:0})];b=g(b,this.axis.chart,!1);return b=["M",b[0].x,b[0].y,"L",b[1].x,b[1].y]});f(e.prototype,"getLabelPosition",function(a){var b=a.apply(this,
[].slice.call(arguments,1));this.axis.chart.is3d()&&"colorAxis"!==this.coll&&(b=g([this.axis.swapZ({x:b.x,y:b.y,z:0})],this.axis.chart,!1)[0]);return b});a.wrap(k.prototype,"getTitlePosition",function(a){var b=this.chart.is3d()&&"colorAxis"!==this.coll,c,d;b&&(d=this.axisTitleMargin,this.axisTitleMargin=0);c=a.apply(this,[].slice.call(arguments,1));b&&(c=g([this.swapZ({x:c.x,y:c.y,z:0})],this.chart,!1)[0],c[this.horiz?"y":"x"]+=(this.horiz?1:-1)*(this.opposite?-1:1)*d,this.axisTitleMargin=d);return c});
f(k.prototype,"drawCrosshair",function(a){var b=arguments;this.chart.is3d()&&b[2]&&(b[2]={plotX:b[2].plotXold||b[2].plotX,plotY:b[2].plotYold||b[2].plotY});a.apply(this,[].slice.call(b,1))});f(k.prototype,"destroy",function(a){n(["backFrame","bottomFrame","sideFrame"],function(b){this[b]&&(this[b]=this[b].destroy())},this);a.apply(this,[].slice.call(arguments,1))});k.prototype.swapZ=function(a,b){if(this.isZAxis){b=b?0:this.chart.plotLeft;var c=this.chart;return{x:b+(c.yAxis[0].opposite?a.z:c.xAxis[0].width-
a.z),y:a.y,z:a.x-b}}return a};q=a.ZAxis=function(){this.init.apply(this,arguments)};u(q.prototype,k.prototype);u(q.prototype,{isZAxis:!0,setOptions:function(a){a=m({offset:0,lineWidth:0},a);k.prototype.setOptions.call(this,a);this.coll="zAxis"},setAxisSize:function(){k.prototype.setAxisSize.call(this);this.width=this.len=this.chart.options.chart.options3d.depth;this.right=this.chart.chartWidth-this.width-this.left},getSeriesExtremes:function(){var a=this,b=a.chart;a.hasVisibleSeries=!1;a.dataMin=
a.dataMax=a.ignoreMinPadding=a.ignoreMaxPadding=null;a.buildStacks&&a.buildStacks();n(a.series,function(c){if(c.visible||!b.options.chart.ignoreHiddenSeries)a.hasVisibleSeries=!0,c=c.zData,c.length&&(a.dataMin=Math.min(h(a.dataMin,c[0]),Math.min.apply(null,c)),a.dataMax=Math.max(h(a.dataMax,c[0]),Math.max.apply(null,c)))})}});f(p.prototype,"getAxes",function(a){var b=this,c=this.options,c=c.zAxis=r(c.zAxis||{});a.call(this);b.is3d()&&(this.zAxis=[],n(c,function(a,c){a.index=c;a.isX=!0;(new q(b,a)).setScale()}))})})(E);
(function(a){function q(a){var e=a.apply(this,[].slice.call(arguments,1));this.chart.is3d()&&(e.stroke=this.options.edgeColor||e.fill,e["stroke-width"]=u(this.options.edgeWidth,1));return e}function k(a){if(this.chart.is3d()){var e=this.chart.options.plotOptions.column.grouping;void 0===e||e||void 0===this.group.zIndex||this.zIndexSet||(this.group.attr({zIndex:10*this.group.zIndex}),this.zIndexSet=!0)}a.apply(this,[].slice.call(arguments,1))}var p=a.each,n=a.perspective,u=a.pick,m=a.Series,g=a.seriesTypes,
h=a.svg;a=a.wrap;a(g.column.prototype,"translate",function(a){a.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var e=this.chart,f=this.options,d=f.depth||25,b=(f.stacking?f.stack||0:this._i)*(d+(f.groupZPadding||1));!1!==f.grouping&&(b=0);b+=f.groupZPadding||1;p(this.data,function(a){if(null!==a.y){var c=a.shapeArgs,f=a.tooltipPos;a.shapeType="cuboid";c.z=b;c.depth=d;c.insidePlotArea=!0;f=n([{x:f[0],y:f[1],z:b}],e,!0)[0];a.tooltipPos=[f.x,f.y]}});this.z=b}});a(g.column.prototype,"animate",
function(a){if(this.chart.is3d()){var e=arguments[1],f=this.yAxis,d=this,b=this.yAxis.reversed;h&&(e?p(d.data,function(a){null!==a.y&&(a.height=a.shapeArgs.height,a.shapey=a.shapeArgs.y,a.shapeArgs.height=1,b||(a.shapeArgs.y=a.stackY?a.plotY+f.translate(a.stackY):a.plotY+(a.negative?-a.height:a.height)))}):(p(d.data,function(a){null!==a.y&&(a.shapeArgs.height=a.height,a.shapeArgs.y=a.shapey,a.graphic&&a.graphic.animate(a.shapeArgs,d.options.animation))}),this.drawDataLabels(),d.animate=null))}else a.apply(this,
[].slice.call(arguments,1))});a(g.column.prototype,"init",function(a){a.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var e=this.options,f=e.grouping,d=e.stacking,b=u(this.yAxis.options.reversedStacks,!0),c=0;if(void 0===f||f){f=this.chart.retrieveStacks(d);c=e.stack||0;for(d=0;d<f[c].series.length&&f[c].series[d]!==this;d++);c=10*(f.totalStacks-f[c].position)+(b?d:-d);this.xAxis.reversed||(c=10*f.totalStacks-c)}e.zIndex=c}});a(g.column.prototype,"pointAttribs",q);g.columnrange&&a(g.columnrange.prototype,
"pointAttribs",q);a(m.prototype,"alignDataLabel",function(a){if(this.chart.is3d()&&("column"===this.type||"columnrange"===this.type)){var e=arguments[4],f={x:e.x,y:e.y,z:this.z},f=n([f],this.chart,!0)[0];e.x=f.x;e.y=f.y}a.apply(this,[].slice.call(arguments,1))});g.columnrange&&a(g.columnrange.prototype,"drawPoints",k);a(g.column.prototype,"drawPoints",k)})(E);(function(a){var q=a.deg2rad,k=a.each,p=a.pick,n=a.seriesTypes,u=a.svg;a=a.wrap;a(n.pie.prototype,"translate",function(a){a.apply(this,[].slice.call(arguments,
1));if(this.chart.is3d()){var g=this,h=g.options,m=h.depth||0,e=g.chart.options.chart.options3d,f=e.alpha,d=e.beta,b=h.stacking?(h.stack||0)*m:g._i*m,b=b+m/2;!1!==h.grouping&&(b=0);k(g.data,function(a){var c=a.shapeArgs;a.shapeType="arc3d";c.z=b;c.depth=.75*m;c.alpha=f;c.beta=d;c.center=g.center;c=(c.end+c.start)/2;a.slicedTranslation={translateX:Math.round(Math.cos(c)*h.slicedOffset*Math.cos(f*q)),translateY:Math.round(Math.sin(c)*h.slicedOffset*Math.cos(f*q))}})}});a(n.pie.prototype.pointClass.prototype,
"haloPath",function(a){var g=arguments;return this.series.chart.is3d()?[]:a.call(this,g[1])});a(n.pie.prototype,"pointAttribs",function(a,g,h){a=a.call(this,g,h);h=this.options;this.chart.is3d()&&(a.stroke=h.edgeColor||g.color||this.color,a["stroke-width"]=p(h.edgeWidth,1));return a});a(n.pie.prototype,"drawPoints",function(a){a.apply(this,[].slice.call(arguments,1));this.chart.is3d()&&k(this.points,function(a){var g=a.graphic;if(g)g[a.y&&a.visible?"show":"hide"]()})});a(n.pie.prototype,"drawDataLabels",
function(a){if(this.chart.is3d()){var g=this.chart.options.chart.options3d;k(this.data,function(a){var h=a.shapeArgs,e=h.r,f=(h.start+h.end)/2,d=a.labelPos,b=-e*(1-Math.cos((h.alpha||g.alpha)*q))*Math.sin(f),c=e*(Math.cos((h.beta||g.beta)*q)-1)*Math.cos(f);k([0,2,4],function(a){d[a]+=c;d[a+1]+=b})})}a.apply(this,[].slice.call(arguments,1))});a(n.pie.prototype,"addPoint",function(a){a.apply(this,[].slice.call(arguments,1));this.chart.is3d()&&this.update(this.userOptions,!0)});a(n.pie.prototype,"animate",
function(a){if(this.chart.is3d()){var g=arguments[1],h=this.options.animation,k=this.center,e=this.group,f=this.markerGroup;u&&(!0===h&&(h={}),g?(e.oldtranslateX=e.translateX,e.oldtranslateY=e.translateY,g={translateX:k[0],translateY:k[1],scaleX:.001,scaleY:.001},e.attr(g),f&&(f.attrSetters=e.attrSetters,f.attr(g))):(g={translateX:e.oldtranslateX,translateY:e.oldtranslateY,scaleX:1,scaleY:1},e.animate(g,h),f&&f.animate(g,h),this.animate=null))}else a.apply(this,[].slice.call(arguments,1))})})(E);
(function(a){var q=a.perspective,k=a.pick,p=a.Point,n=a.seriesTypes,u=a.wrap;u(n.scatter.prototype,"translate",function(a){a.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var g=this.chart,h=k(this.zAxis,g.options.zAxis[0]),m=[],e,f,d;for(d=0;d<this.data.length;d++)e=this.data[d],f=h.isLog&&h.val2lin?h.val2lin(e.z):e.z,e.plotZ=h.translate(f),e.isInside=e.isInside?f>=h.min&&f<=h.max:!1,m.push({x:e.plotX,y:e.plotY,z:e.plotZ});g=q(m,g,!0);for(d=0;d<this.data.length;d++)e=this.data[d],h=
g[d],e.plotXold=e.plotX,e.plotYold=e.plotY,e.plotZold=e.plotZ,e.plotX=h.x,e.plotY=h.y,e.plotZ=h.z}});u(n.scatter.prototype,"init",function(a,g,h){g.is3d()&&(this.axisTypes=["xAxis","yAxis","zAxis"],this.pointArrayMap=["x","y","z"],this.parallelArrays=["x","y","z"],this.directTouch=!0);a=a.apply(this,[g,h]);this.chart.is3d()&&(this.tooltipOptions.pointFormat=this.userOptions.tooltip?this.userOptions.tooltip.pointFormat||"x: \x3cb\x3e{point.x}\x3c/b\x3e\x3cbr/\x3ey: \x3cb\x3e{point.y}\x3c/b\x3e\x3cbr/\x3ez: \x3cb\x3e{point.z}\x3c/b\x3e\x3cbr/\x3e":
"x: \x3cb\x3e{point.x}\x3c/b\x3e\x3cbr/\x3ey: \x3cb\x3e{point.y}\x3c/b\x3e\x3cbr/\x3ez: \x3cb\x3e{point.z}\x3c/b\x3e\x3cbr/\x3e");return a});u(n.scatter.prototype,"pointAttribs",function(k,g){var h=k.apply(this,[].slice.call(arguments,1));this.chart.is3d()&&g&&(h.zIndex=a.pointCameraDistance(g,this.chart));return h});u(p.prototype,"applyOptions",function(a){var g=a.apply(this,[].slice.call(arguments,1));this.series.chart.is3d()&&void 0===g.z&&(g.z=0);return g})})(E);(function(a){var q=a.Axis,k=a.SVGRenderer,
p=a.VMLRenderer;p&&(a.setOptions({animate:!1}),p.prototype.cuboid=k.prototype.cuboid,p.prototype.cuboidPath=k.prototype.cuboidPath,p.prototype.toLinePath=k.prototype.toLinePath,p.prototype.createElement3D=k.prototype.createElement3D,p.prototype.arc3d=function(a){a=k.prototype.arc3d.call(this,a);a.css({zIndex:a.zIndex});return a},a.VMLRenderer.prototype.arc3dPath=a.SVGRenderer.prototype.arc3dPath,a.wrap(q.prototype,"render",function(a){a.apply(this,[].slice.call(arguments,1));this.sideFrame&&(this.sideFrame.css({zIndex:0}),
this.sideFrame.front.attr({fill:this.sideFrame.color}));this.bottomFrame&&(this.bottomFrame.css({zIndex:1}),this.bottomFrame.front.attr({fill:this.bottomFrame.color}));this.backFrame&&(this.backFrame.css({zIndex:0}),this.backFrame.front.attr({fill:this.backFrame.color}))}))})(E)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* 3D features for Highcharts JS
*
* @license: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/**
* Mathematical Functionility
*/
var deg2rad = H.deg2rad,
pick = H.pick;
/**
* Apply 3-D rotation
* Euler Angles (XYZ): cosA = cos(Alfa|Roll), cosB = cos(Beta|Pitch), cosG = cos(Gamma|Yaw)
*
* Composite rotation:
* | cosB * cosG | cosB * sinG | -sinB |
* | sinA * sinB * cosG - cosA * sinG | sinA * sinB * sinG + cosA * cosG | sinA * cosB |
* | cosA * sinB * cosG + sinA * sinG | cosA * sinB * sinG - sinA * cosG | cosA * cosB |
*
* Now, Gamma/Yaw is not used (angle=0), so we assume cosG = 1 and sinG = 0, so we get:
* | cosB | 0 | - sinB |
* | sinA * sinB | cosA | sinA * cosB |
* | cosA * sinB | - sinA | cosA * cosB |
*
* But in browsers, y is reversed, so we get sinA => -sinA. The general result is:
* | cosB | 0 | - sinB | | x | | px |
* | - sinA * sinB | cosA | - sinA * cosB | x | y | = | py |
* | cosA * sinB | sinA | cosA * cosB | | z | | pz |
*/
function rotate3D(x, y, z, angles) {
return {
x: angles.cosB * x - angles.sinB * z,
y: -angles.sinA * angles.sinB * x + angles.cosA * y - angles.cosB * angles.sinA * z,
z: angles.cosA * angles.sinB * x + angles.sinA * y + angles.cosA * angles.cosB * z
};
}
function perspective3D(coordinate, origin, distance) {
var projection = ((distance > 0) && (distance < Number.POSITIVE_INFINITY)) ? distance / (coordinate.z + origin.z + distance) : 1;
return {
x: coordinate.x * projection,
y: coordinate.y * projection
};
}
/**
* Transforms a given array of points according to the angles in chart.options.
* Parameters:
* - points: the array of points
* - chart: the chart
* - insidePlotArea: wether to verifiy the points are inside the plotArea
* Returns:
* - an array of transformed points
*/
H.perspective = function(points, chart, insidePlotArea) {
var options3d = chart.options.chart.options3d,
inverted = insidePlotArea ? chart.inverted : false,
origin = {
x: chart.plotWidth / 2,
y: chart.plotHeight / 2,
z: options3d.depth / 2,
vd: pick(options3d.depth, 1) * pick(options3d.viewDistance, 0)
},
scale = chart.scale3d || 1,
beta = deg2rad * options3d.beta * (inverted ? -1 : 1),
alpha = deg2rad * options3d.alpha * (inverted ? -1 : 1),
angles = {
cosA: Math.cos(alpha),
cosB: Math.cos(-beta),
sinA: Math.sin(alpha),
sinB: Math.sin(-beta)
};
if (!insidePlotArea) {
origin.x += chart.plotLeft;
origin.y += chart.plotTop;
}
// Transform each point
return H.map(points, function(point) {
var rotated = rotate3D(
(inverted ? point.y : point.x) - origin.x,
(inverted ? point.x : point.y) - origin.y,
(point.z || 0) - origin.z,
angles
),
coordinate = perspective3D(rotated, origin, origin.vd); // Apply perspective
// Apply translation
coordinate.x = coordinate.x * scale + origin.x;
coordinate.y = coordinate.y * scale + origin.y;
coordinate.z = rotated.z * scale + origin.z;
return {
x: (inverted ? coordinate.y : coordinate.x),
y: (inverted ? coordinate.x : coordinate.y),
z: coordinate.z
};
});
};
/**
* Calculate a distance from camera to points - made for calculating zIndex of scatter points.
* Parameters:
* - coordinates: The coordinates of the specific point
* - chart: the chart
* Returns:
* - a distance from camera to point
*/
H.pointCameraDistance = function(coordinates, chart) {
var options3d = chart.options.chart.options3d,
cameraPosition = {
x: chart.plotWidth / 2,
y: chart.plotHeight / 2,
z: pick(options3d.depth, 1) * pick(options3d.viewDistance, 0) + options3d.depth
},
distance = Math.sqrt(Math.pow(cameraPosition.x - coordinates.plotX, 2) + Math.pow(cameraPosition.y - coordinates.plotY, 2) + Math.pow(cameraPosition.z - coordinates.plotZ, 2));
return distance;
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var cos = Math.cos,
PI = Math.PI,
sin = Math.sin;
var animObject = H.animObject,
charts = H.charts,
color = H.color,
defined = H.defined,
deg2rad = H.deg2rad,
each = H.each,
extend = H.extend,
inArray = H.inArray,
map = H.map,
merge = H.merge,
perspective = H.perspective,
pick = H.pick,
SVGElement = H.SVGElement,
SVGRenderer = H.SVGRenderer,
wrap = H.wrap;
/***
EXTENSION TO THE SVG-RENDERER TO ENABLE 3D SHAPES
***/
////// HELPER METHODS //////
var dFactor = (4 * (Math.sqrt(2) - 1) / 3) / (PI / 2);
//Shoelace algorithm -- http://en.wikipedia.org/wiki/Shoelace_formula
function shapeArea(vertexes) {
var area = 0,
i,
j;
for (i = 0; i < vertexes.length; i++) {
j = (i + 1) % vertexes.length;
area += vertexes[i].x * vertexes[j].y - vertexes[j].x * vertexes[i].y;
}
return area / 2;
}
function averageZ(vertexes) {
var z = 0,
i;
for (i = 0; i < vertexes.length; i++) {
z += vertexes[i].z;
}
return vertexes.length ? z / vertexes.length : 0;
}
/** Method to construct a curved path
* Can 'wrap' around more then 180 degrees
*/
function curveTo(cx, cy, rx, ry, start, end, dx, dy) {
var result = [],
arcAngle = end - start;
if ((end > start) && (end - start > Math.PI / 2 + 0.0001)) {
result = result.concat(curveTo(cx, cy, rx, ry, start, start + (Math.PI / 2), dx, dy));
result = result.concat(curveTo(cx, cy, rx, ry, start + (Math.PI / 2), end, dx, dy));
return result;
}
if ((end < start) && (start - end > Math.PI / 2 + 0.0001)) {
result = result.concat(curveTo(cx, cy, rx, ry, start, start - (Math.PI / 2), dx, dy));
result = result.concat(curveTo(cx, cy, rx, ry, start - (Math.PI / 2), end, dx, dy));
return result;
}
return [
'C',
cx + (rx * Math.cos(start)) - ((rx * dFactor * arcAngle) * Math.sin(start)) + dx,
cy + (ry * Math.sin(start)) + ((ry * dFactor * arcAngle) * Math.cos(start)) + dy,
cx + (rx * Math.cos(end)) + ((rx * dFactor * arcAngle) * Math.sin(end)) + dx,
cy + (ry * Math.sin(end)) - ((ry * dFactor * arcAngle) * Math.cos(end)) + dy,
cx + (rx * Math.cos(end)) + dx,
cy + (ry * Math.sin(end)) + dy
];
}
SVGRenderer.prototype.toLinePath = function(points, closed) {
var result = [];
// Put "L x y" for each point
each(points, function(point) {
result.push('L', point.x, point.y);
});
if (points.length) {
// Set the first element to M
result[0] = 'M';
// If it is a closed line, add Z
if (closed) {
result.push('Z');
}
}
return result;
};
////// CUBOIDS //////
SVGRenderer.prototype.cuboid = function(shapeArgs) {
var result = this.g(),
destroy = result.destroy,
paths = this.cuboidPath(shapeArgs);
result.attr({
'stroke-linejoin': 'round'
});
// create the 3 sides
result.front = this.path(paths[0]).attr({
'class': 'highcharts-3d-front',
zIndex: paths[3]
}).add(result);
result.top = this.path(paths[1]).attr({
'class': 'highcharts-3d-top',
zIndex: paths[4]
}).add(result);
result.side = this.path(paths[2]).attr({
'class': 'highcharts-3d-side',
zIndex: paths[5]
}).add(result);
// apply the fill everywhere, the top a bit brighter, the side a bit darker
result.fillSetter = function(fill) {
this.front.attr({
fill: fill
});
this.top.attr({
fill: color(fill).brighten(0.1).get()
});
this.side.attr({
fill: color(fill).brighten(-0.1).get()
});
this.color = fill;
return this;
};
// apply opacaity everywhere
result.opacitySetter = function(opacity) {
this.front.attr({
opacity: opacity
});
this.top.attr({
opacity: opacity
});
this.side.attr({
opacity: opacity
});
return this;
};
result.attr = function(args, val) {
// Resolve setting attributes by string name
if (typeof args === 'string' && typeof val !== 'undefined') {
var key = args;
args = {};
args[key] = val;
}
if (args.shapeArgs || defined(args.x)) {
var shapeArgs = args.shapeArgs || args;
var paths = this.renderer.cuboidPath(shapeArgs);
this.front.attr({
d: paths[0],
zIndex: paths[3]
});
this.top.attr({
d: paths[1],
zIndex: paths[4]
});
this.side.attr({
d: paths[2],
zIndex: paths[5]
});
} else {
return H.SVGElement.prototype.attr.call(this, args); // getter returns value
}
return this;
};
result.animate = function(args, duration, complete) {
if (defined(args.x) && defined(args.y)) {
var paths = this.renderer.cuboidPath(args);
this.front.attr({
zIndex: paths[3]
}).animate({
d: paths[0]
}, duration, complete);
this.top.attr({
zIndex: paths[4]
}).animate({
d: paths[1]
}, duration, complete);
this.side.attr({
zIndex: paths[5]
}).animate({
d: paths[2]
}, duration, complete);
this.attr({
zIndex: -paths[6] // #4774
});
} else if (args.opacity) {
this.front.animate(args, duration, complete);
this.top.animate(args, duration, complete);
this.side.animate(args, duration, complete);
} else {
SVGElement.prototype.animate.call(this, args, duration, complete);
}
return this;
};
// destroy all children
result.destroy = function() {
this.front.destroy();
this.top.destroy();
this.side.destroy();
return destroy.call(this);
};
// Apply the Z index to the cuboid group
result.attr({
zIndex: -paths[6]
});
return result;
};
/**
* Generates a cuboid
*/
SVGRenderer.prototype.cuboidPath = function(shapeArgs) {
var x = shapeArgs.x,
y = shapeArgs.y,
z = shapeArgs.z,
h = shapeArgs.height,
w = shapeArgs.width,
d = shapeArgs.depth,
chart = charts[this.chartIndex];
// The 8 corners of the cube
var pArr = [{
x: x,
y: y,
z: z
},
{
x: x + w,
y: y,
z: z
},
{
x: x + w,
y: y + h,
z: z
},
{
x: x,
y: y + h,
z: z
},
{
x: x,
y: y + h,
z: z + d
},
{
x: x + w,
y: y + h,
z: z + d
},
{
x: x + w,
y: y,
z: z + d
},
{
x: x,
y: y,
z: z + d
}
];
// apply perspective
pArr = perspective(pArr, chart, shapeArgs.insidePlotArea);
// helper method to decide which side is visible
function mapPath(i) {
return pArr[i];
}
var pickShape = function(path1, path2) {
var ret = [];
path1 = map(path1, mapPath);
path2 = map(path2, mapPath);
if (shapeArea(path1) < 0) {
ret = path1;
} else if (shapeArea(path2) < 0) {
ret = path2;
}
return ret;
};
// front or back
var front = [3, 2, 1, 0];
var back = [7, 6, 5, 4];
var path1 = pickShape(front, back);
// top or bottom
var top = [1, 6, 7, 0];
var bottom = [4, 5, 2, 3];
var path2 = pickShape(top, bottom);
// side
var right = [1, 2, 5, 6];
var left = [0, 7, 4, 3];
var path3 = pickShape(right, left);
return [this.toLinePath(path1, true), this.toLinePath(path2, true), this.toLinePath(path3, true), averageZ(path1), averageZ(path2), averageZ(path3), averageZ(map(bottom, mapPath)) * 9e9]; // #4774
};
////// SECTORS //////
H.SVGRenderer.prototype.arc3d = function(attribs) {
var wrapper = this.g(),
renderer = wrapper.renderer,
customAttribs = ['x', 'y', 'r', 'innerR', 'start', 'end'];
/**
* Get custom attributes. Don't mutate the original object and return an object with only custom attr.
*/
function suckOutCustom(params) {
var hasCA = false,
ca = {};
params = merge(params); // Don't mutate the original object
for (var key in params) {
if (inArray(key, customAttribs) !== -1) {
ca[key] = params[key];
delete params[key];
hasCA = true;
}
}
return hasCA ? ca : false;
}
attribs = merge(attribs);
attribs.alpha *= deg2rad;
attribs.beta *= deg2rad;
// Create the different sub sections of the shape
wrapper.top = renderer.path();
wrapper.side1 = renderer.path();
wrapper.side2 = renderer.path();
wrapper.inn = renderer.path();
wrapper.out = renderer.path();
/**
* Add all faces
*/
wrapper.onAdd = function() {
var parent = wrapper.parentGroup,
className = wrapper.attr('class');
wrapper.top.add(wrapper);
// These faces are added outside the wrapper group because the z index
// relates to neighbour elements as well
each(['out', 'inn', 'side1', 'side2'], function(face) {
wrapper[face]
.addClass(className + ' highcharts-3d-side')
.add(parent);
});
};
/**
* Compute the transformed paths and set them to the composite shapes
*/
wrapper.setPaths = function(attribs) {
var paths = wrapper.renderer.arc3dPath(attribs),
zIndex = paths.zTop * 100;
wrapper.attribs = attribs;
wrapper.top.attr({
d: paths.top,
zIndex: paths.zTop
});
wrapper.inn.attr({
d: paths.inn,
zIndex: paths.zInn
});
wrapper.out.attr({
d: paths.out,
zIndex: paths.zOut
});
wrapper.side1.attr({
d: paths.side1,
zIndex: paths.zSide1
});
wrapper.side2.attr({
d: paths.side2,
zIndex: paths.zSide2
});
// show all children
wrapper.zIndex = zIndex;
wrapper.attr({
zIndex: zIndex
});
// Set the radial gradient center the first time
if (attribs.center) {
wrapper.top.setRadialReference(attribs.center);
delete attribs.center;
}
};
wrapper.setPaths(attribs);
// Apply the fill to the top and a darker shade to the sides
wrapper.fillSetter = function(value) {
var darker = color(value).brighten(-0.1).get();
this.fill = value;
this.side1.attr({
fill: darker
});
this.side2.attr({
fill: darker
});
this.inn.attr({
fill: darker
});
this.out.attr({
fill: darker
});
this.top.attr({
fill: value
});
return this;
};
// Apply the same value to all. These properties cascade down to the children
// when set to the composite arc3d.
each(['opacity', 'translateX', 'translateY', 'visibility'], function(setter) {
wrapper[setter + 'Setter'] = function(value, key) {
wrapper[key] = value;
each(['out', 'inn', 'side1', 'side2', 'top'], function(el) {
wrapper[el].attr(key, value);
});
};
});
/**
* Override attr to remove shape attributes and use those to set child paths
*/
wrap(wrapper, 'attr', function(proceed, params) {
var ca;
if (typeof params === 'object') {
ca = suckOutCustom(params);
if (ca) {
extend(wrapper.attribs, ca);
wrapper.setPaths(wrapper.attribs);
}
}
return proceed.apply(this, [].slice.call(arguments, 1));
});
/**
* Override the animate function by sucking out custom parameters related to the shapes directly,
* and update the shapes from the animation step.
*/
wrap(wrapper, 'animate', function(proceed, params, animation, complete) {
var ca,
from = this.attribs,
to,
anim;
// Attribute-line properties connected to 3D. These shouldn't have been in the
// attribs collection in the first place.
delete params.center;
delete params.z;
delete params.depth;
delete params.alpha;
delete params.beta;
anim = animObject(pick(animation, this.renderer.globalAnimation));
if (anim.duration) {
ca = suckOutCustom(params);
params.dummy = 1; // Params need to have a property in order for the step to run (#5765)
if (ca) {
to = ca;
anim.step = function(a, fx) {
function interpolate(key) {
return from[key] + (pick(to[key], from[key]) - from[key]) * fx.pos;
}
if (fx.prop === 'dummy') {
fx.elem.setPaths(merge(from, {
x: interpolate('x'),
y: interpolate('y'),
r: interpolate('r'),
innerR: interpolate('innerR'),
start: interpolate('start'),
end: interpolate('end')
}));
}
};
}
animation = anim; // Only when duration (#5572)
}
return proceed.call(this, params, animation, complete);
});
// destroy all children
wrapper.destroy = function() {
this.top.destroy();
this.out.destroy();
this.inn.destroy();
this.side1.destroy();
this.side2.destroy();
SVGElement.prototype.destroy.call(this);
};
// hide all children
wrapper.hide = function() {
this.top.hide();
this.out.hide();
this.inn.hide();
this.side1.hide();
this.side2.hide();
};
wrapper.show = function() {
this.top.show();
this.out.show();
this.inn.show();
this.side1.show();
this.side2.show();
};
return wrapper;
};
/**
* Generate the paths required to draw a 3D arc
*/
SVGRenderer.prototype.arc3dPath = function(shapeArgs) {
var cx = shapeArgs.x, // x coordinate of the center
cy = shapeArgs.y, // y coordinate of the center
start = shapeArgs.start, // start angle
end = shapeArgs.end - 0.00001, // end angle
r = shapeArgs.r, // radius
ir = shapeArgs.innerR, // inner radius
d = shapeArgs.depth, // depth
alpha = shapeArgs.alpha, // alpha rotation of the chart
beta = shapeArgs.beta; // beta rotation of the chart
// Derived Variables
var cs = Math.cos(start), // cosinus of the start angle
ss = Math.sin(start), // sinus of the start angle
ce = Math.cos(end), // cosinus of the end angle
se = Math.sin(end), // sinus of the end angle
rx = r * Math.cos(beta), // x-radius
ry = r * Math.cos(alpha), // y-radius
irx = ir * Math.cos(beta), // x-radius (inner)
iry = ir * Math.cos(alpha), // y-radius (inner)
dx = d * Math.sin(beta), // distance between top and bottom in x
dy = d * Math.sin(alpha); // distance between top and bottom in y
// TOP
var top = ['M', cx + (rx * cs), cy + (ry * ss)];
top = top.concat(curveTo(cx, cy, rx, ry, start, end, 0, 0));
top = top.concat([
'L', cx + (irx * ce), cy + (iry * se)
]);
top = top.concat(curveTo(cx, cy, irx, iry, end, start, 0, 0));
top = top.concat(['Z']);
// OUTSIDE
var b = (beta > 0 ? Math.PI / 2 : 0),
a = (alpha > 0 ? 0 : Math.PI / 2);
var start2 = start > -b ? start : (end > -b ? -b : start),
end2 = end < PI - a ? end : (start < PI - a ? PI - a : end),
midEnd = 2 * PI - a;
// When slice goes over bottom middle, need to add both, left and right outer side.
// Additionally, when we cross right hand edge, create sharp edge. Outer shape/wall:
//
// -------
// / ^ \
// 4) / / \ \ 1)
// / / \ \
// / / \ \
// (c)=> ==== ==== <=(d)
// \ \ / /
// \ \<=(a)/ /
// \ \ / / <=(b)
// 3) \ v / 2)
// -------
//
// (a) - inner side
// (b) - outer side
// (c) - left edge (sharp)
// (d) - right edge (sharp)
// 1..n - rendering order for startAngle = 0, when set to e.g 90, order changes clockwise (1->2, 2->3, n->1) and counterclockwise for negative startAngle
var out = ['M', cx + (rx * cos(start2)), cy + (ry * sin(start2))];
out = out.concat(curveTo(cx, cy, rx, ry, start2, end2, 0, 0));
if (end > midEnd && start < midEnd) { // When shape is wide, it can cross both, (c) and (d) edges, when using startAngle
// Go to outer side
out = out.concat([
'L', cx + (rx * cos(end2)) + dx, cy + (ry * sin(end2)) + dy
]);
// Curve to the right edge of the slice (d)
out = out.concat(curveTo(cx, cy, rx, ry, end2, midEnd, dx, dy));
// Go to the inner side
out = out.concat([
'L', cx + (rx * cos(midEnd)), cy + (ry * sin(midEnd))
]);
// Curve to the true end of the slice
out = out.concat(curveTo(cx, cy, rx, ry, midEnd, end, 0, 0));
// Go to the outer side
out = out.concat([
'L', cx + (rx * cos(end)) + dx, cy + (ry * sin(end)) + dy
]);
// Go back to middle (d)
out = out.concat(curveTo(cx, cy, rx, ry, end, midEnd, dx, dy));
out = out.concat([
'L', cx + (rx * cos(midEnd)), cy + (ry * sin(midEnd))
]);
// Go back to the left edge
out = out.concat(curveTo(cx, cy, rx, ry, midEnd, end2, 0, 0));
} else if (end > PI - a && start < PI - a) { // But shape can cross also only (c) edge:
// Go to outer side
out = out.concat([
'L', cx + (rx * Math.cos(end2)) + dx, cy + (ry * Math.sin(end2)) + dy
]);
// Curve to the true end of the slice
out = out.concat(curveTo(cx, cy, rx, ry, end2, end, dx, dy));
// Go to the inner side
out = out.concat([
'L', cx + (rx * Math.cos(end)), cy + (ry * Math.sin(end))
]);
// Go back to the artifical end2
out = out.concat(curveTo(cx, cy, rx, ry, end, end2, 0, 0));
}
out = out.concat([
'L', cx + (rx * Math.cos(end2)) + dx, cy + (ry * Math.sin(end2)) + dy
]);
out = out.concat(curveTo(cx, cy, rx, ry, end2, start2, dx, dy));
out = out.concat(['Z']);
// INSIDE
var inn = ['M', cx + (irx * cs), cy + (iry * ss)];
inn = inn.concat(curveTo(cx, cy, irx, iry, start, end, 0, 0));
inn = inn.concat([
'L', cx + (irx * Math.cos(end)) + dx, cy + (iry * Math.sin(end)) + dy
]);
inn = inn.concat(curveTo(cx, cy, irx, iry, end, start, dx, dy));
inn = inn.concat(['Z']);
// SIDES
var side1 = [
'M', cx + (rx * cs), cy + (ry * ss),
'L', cx + (rx * cs) + dx, cy + (ry * ss) + dy,
'L', cx + (irx * cs) + dx, cy + (iry * ss) + dy,
'L', cx + (irx * cs), cy + (iry * ss),
'Z'
];
var side2 = [
'M', cx + (rx * ce), cy + (ry * se),
'L', cx + (rx * ce) + dx, cy + (ry * se) + dy,
'L', cx + (irx * ce) + dx, cy + (iry * se) + dy,
'L', cx + (irx * ce), cy + (iry * se),
'Z'
];
// correction for changed position of vanishing point caused by alpha and beta rotations
var angleCorr = Math.atan2(dy, -dx),
angleEnd = Math.abs(end + angleCorr),
angleStart = Math.abs(start + angleCorr),
angleMid = Math.abs((start + end) / 2 + angleCorr);
// set to 0-PI range
function toZeroPIRange(angle) {
angle = angle % (2 * Math.PI);
if (angle > Math.PI) {
angle = 2 * Math.PI - angle;
}
return angle;
}
angleEnd = toZeroPIRange(angleEnd);
angleStart = toZeroPIRange(angleStart);
angleMid = toZeroPIRange(angleMid);
// *1e5 is to compensate pInt in zIndexSetter
var incPrecision = 1e5,
a1 = angleMid * incPrecision,
a2 = angleStart * incPrecision,
a3 = angleEnd * incPrecision;
return {
top: top,
zTop: Math.PI * incPrecision + 1, // max angle is PI, so this is allways higher
out: out,
zOut: Math.max(a1, a2, a3),
inn: inn,
zInn: Math.max(a1, a2, a3),
side1: side1,
zSide1: a3 * 0.99, // to keep below zOut and zInn in case of same values
side2: side2,
zSide2: a2 * 0.99
};
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Chart = H.Chart,
each = H.each,
merge = H.merge,
perspective = H.perspective,
pick = H.pick,
wrap = H.wrap;
/***
EXTENSION FOR 3D CHARTS
***/
// Shorthand to check the is3d flag
Chart.prototype.is3d = function() {
return this.options.chart.options3d && this.options.chart.options3d.enabled; // #4280
};
Chart.prototype.propsRequireDirtyBox.push('chart.options3d');
Chart.prototype.propsRequireUpdateSeries.push('chart.options3d');
/**
* Calculate scale of the 3D view. That is required to
* fit chart's 3D projection into the actual plotting area. Reported as #4933.
* @notice This function should ideally take the plot values instead of a chart object,
* but since the chart object is needed for perspective it is not practical.
* Possible to make both getScale and perspective more logical and also immutable.
* @param {Object} chart Chart object
* @param {Number} chart.plotLeft
* @param {Number} chart.plotWidth
* @param {Number} chart.plotTop
* @param {Number} chart.plotHeight
* @param {Number} depth The depth of the chart
* @return {Number} The scale to fit the 3D chart into the plotting area.
*/
function getScale(chart, depth) {
var plotLeft = chart.plotLeft,
plotRight = chart.plotWidth + plotLeft,
plotTop = chart.plotTop,
plotBottom = chart.plotHeight + plotTop,
originX = plotLeft + chart.plotWidth / 2,
originY = plotTop + chart.plotHeight / 2,
bbox3d = {
minX: Number.MAX_VALUE,
maxX: -Number.MAX_VALUE,
minY: Number.MAX_VALUE,
maxY: -Number.MAX_VALUE
},
corners,
scale = 1;
// Top left corners:
corners = [{
x: plotLeft,
y: plotTop,
z: 0
}, {
x: plotLeft,
y: plotTop,
z: depth
}];
// Top right corners:
each([0, 1], function(i) {
corners.push({
x: plotRight,
y: corners[i].y,
z: corners[i].z
});
});
// All bottom corners:
each([0, 1, 2, 3], function(i) {
corners.push({
x: corners[i].x,
y: plotBottom,
z: corners[i].z
});
});
// Calculate 3D corners:
corners = perspective(corners, chart, false);
// Get bounding box of 3D element:
each(corners, function(corner) {
bbox3d.minX = Math.min(bbox3d.minX, corner.x);
bbox3d.maxX = Math.max(bbox3d.maxX, corner.x);
bbox3d.minY = Math.min(bbox3d.minY, corner.y);
bbox3d.maxY = Math.max(bbox3d.maxY, corner.y);
});
// Left edge:
if (plotLeft > bbox3d.minX) {
scale = Math.min(scale, 1 - Math.abs((plotLeft + originX) / (bbox3d.minX + originX)) % 1);
}
// Right edge:
if (plotRight < bbox3d.maxX) {
scale = Math.min(scale, (plotRight - originX) / (bbox3d.maxX - originX));
}
// Top edge:
if (plotTop > bbox3d.minY) {
if (bbox3d.minY < 0) {
scale = Math.min(scale, (plotTop + originY) / (-bbox3d.minY + plotTop + originY));
} else {
scale = Math.min(scale, 1 - (plotTop + originY) / (bbox3d.minY + originY) % 1);
}
}
// Bottom edge:
if (plotBottom < bbox3d.maxY) {
scale = Math.min(scale, Math.abs((plotBottom - originY) / (bbox3d.maxY - originY)));
}
return scale;
}
H.wrap(H.Chart.prototype, 'isInsidePlot', function(proceed) {
return this.is3d() || proceed.apply(this, [].slice.call(arguments, 1));
});
var defaultOptions = H.getOptions();
merge(true, defaultOptions, {
chart: {
options3d: {
enabled: false,
alpha: 0,
beta: 0,
depth: 100,
fitToPlot: true,
viewDistance: 25,
frame: {
bottom: {
size: 1
},
side: {
size: 1
},
back: {
size: 1
}
}
}
}
});
wrap(Chart.prototype, 'setClassName', function(proceed) {
proceed.apply(this, [].slice.call(arguments, 1));
if (this.is3d()) {
this.container.className += ' highcharts-3d-chart';
}
});
H.wrap(H.Chart.prototype, 'setChartSize', function(proceed) {
var chart = this,
options3d = chart.options.chart.options3d;
proceed.apply(chart, [].slice.call(arguments, 1));
if (chart.is3d()) {
var inverted = chart.inverted,
clipBox = chart.clipBox,
margin = chart.margin,
x = inverted ? 'y' : 'x',
y = inverted ? 'x' : 'y',
w = inverted ? 'height' : 'width',
h = inverted ? 'width' : 'height';
clipBox[x] = -(margin[3] || 0);
clipBox[y] = -(margin[0] || 0);
clipBox[w] = chart.chartWidth + (margin[3] || 0) + (margin[1] || 0);
clipBox[h] = chart.chartHeight + (margin[0] || 0) + (margin[2] || 0);
// Set scale, used later in perspective method():
chart.scale3d = 1; // @notice getScale uses perspective, so scale3d has to be reset.
if (options3d.fitToPlot === true) {
chart.scale3d = getScale(chart, options3d.depth);
}
}
});
wrap(Chart.prototype, 'redraw', function(proceed) {
if (this.is3d()) {
// Set to force a redraw of all elements
this.isDirtyBox = true;
}
proceed.apply(this, [].slice.call(arguments, 1));
});
// Draw the series in the reverse order (#3803, #3917)
wrap(Chart.prototype, 'renderSeries', function(proceed) {
var series,
i = this.series.length;
if (this.is3d()) {
while (i--) {
series = this.series[i];
series.translate();
series.render();
}
} else {
proceed.call(this);
}
});
Chart.prototype.retrieveStacks = function(stacking) {
var series = this.series,
stacks = {},
stackNumber,
i = 1;
each(this.series, function(s) {
stackNumber = pick(s.options.stack, (stacking ? 0 : series.length - 1 - s.index)); // #3841, #4532
if (!stacks[stackNumber]) {
stacks[stackNumber] = {
series: [s],
position: i
};
i++;
} else {
stacks[stackNumber].series.push(s);
}
});
stacks.totalStacks = i + 1;
return stacks;
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var ZAxis,
Axis = H.Axis,
Chart = H.Chart,
each = H.each,
extend = H.extend,
merge = H.merge,
perspective = H.perspective,
pick = H.pick,
splat = H.splat,
Tick = H.Tick,
wrap = H.wrap;
/***
EXTENSION TO THE AXIS
***/
wrap(Axis.prototype, 'setOptions', function(proceed, userOptions) {
var options;
proceed.call(this, userOptions);
if (this.chart.is3d() && this.coll !== 'colorAxis') {
options = this.options;
options.tickWidth = pick(options.tickWidth, 0);
options.gridLineWidth = pick(options.gridLineWidth, 1);
}
});
wrap(Axis.prototype, 'render', function(proceed) {
proceed.apply(this, [].slice.call(arguments, 1));
// Do not do this if the chart is not 3D
if (!this.chart.is3d() || this.coll === 'colorAxis') {
return;
}
var chart = this.chart,
renderer = chart.renderer,
options3d = chart.options.chart.options3d,
frame = options3d.frame,
fbottom = frame.bottom,
fback = frame.back,
fside = frame.side,
depth = options3d.depth,
height = this.height,
width = this.width,
left = this.left,
top = this.top;
if (this.isZAxis) {
return;
}
if (this.horiz) {
var bottomShape = {
x: left,
y: top + (chart.xAxis[0].opposite ? -fbottom.size : height),
z: 0,
width: width,
height: fbottom.size,
depth: depth,
insidePlotArea: false
};
if (!this.bottomFrame) {
this.bottomFrame = renderer.cuboid(bottomShape).attr({
'class': 'highcharts-3d-frame highcharts-3d-frame-bottom',
'zIndex': (chart.yAxis[0].reversed && options3d.alpha > 0 ? 4 : -1)
}).add();
this.bottomFrame.attr({
fill: fbottom.color || 'none',
stroke: fbottom.color || 'none'
});
} else {
this.bottomFrame.animate(bottomShape);
}
} else {
// BACK
var backShape = {
x: left + (chart.yAxis[0].opposite ? 0 : -fside.size),
y: top + (chart.xAxis[0].opposite ? -fbottom.size : 0),
z: depth,
width: width + fside.size,
height: height + fbottom.size,
depth: fback.size,
insidePlotArea: false
};
if (!this.backFrame) {
this.backFrame = renderer.cuboid(backShape).attr({
'class': 'highcharts-3d-frame highcharts-3d-frame-back',
zIndex: -3
}).add();
this.backFrame.attr({
fill: fback.color || 'none',
stroke: fback.color || 'none'
});
} else {
this.backFrame.animate(backShape);
}
var sideShape = {
x: left + (chart.yAxis[0].opposite ? width : -fside.size),
y: top + (chart.xAxis[0].opposite ? -fbottom.size : 0),
z: 0,
width: fside.size,
height: height + fbottom.size,
depth: depth,
insidePlotArea: false
};
if (!this.sideFrame) {
this.sideFrame = renderer.cuboid(sideShape).attr({
'class': 'highcharts-3d-frame highcharts-3d-frame-side',
zIndex: -2
}).add();
this.sideFrame.attr({
fill: fside.color || 'none',
stroke: fside.color || 'none'
});
} else {
this.sideFrame.animate(sideShape);
}
}
});
wrap(Axis.prototype, 'getPlotLinePath', function(proceed) {
var path = proceed.apply(this, [].slice.call(arguments, 1));
// Do not do this if the chart is not 3D
if (!this.chart.is3d() || this.coll === 'colorAxis') {
return path;
}
if (path === null) {
return path;
}
var chart = this.chart,
options3d = chart.options.chart.options3d,
d = this.isZAxis ? chart.plotWidth : options3d.depth,
opposite = this.opposite;
if (this.horiz) {
opposite = !opposite;
}
var pArr = [
this.swapZ({
x: path[1],
y: path[2],
z: (opposite ? d : 0)
}),
this.swapZ({
x: path[1],
y: path[2],
z: d
}),
this.swapZ({
x: path[4],
y: path[5],
z: d
}),
this.swapZ({
x: path[4],
y: path[5],
z: (opposite ? 0 : d)
})
];
pArr = perspective(pArr, this.chart, false);
path = this.chart.renderer.toLinePath(pArr, false);
return path;
});
// Do not draw axislines in 3D
wrap(Axis.prototype, 'getLinePath', function(proceed) {
return this.chart.is3d() ? [] : proceed.apply(this, [].slice.call(arguments, 1));
});
wrap(Axis.prototype, 'getPlotBandPath', function(proceed) {
// Do not do this if the chart is not 3D
if (!this.chart.is3d() || this.coll === 'colorAxis') {
return proceed.apply(this, [].slice.call(arguments, 1));
}
var args = arguments,
from = args[1],
to = args[2],
toPath = this.getPlotLinePath(to),
path = this.getPlotLinePath(from);
if (path && toPath) {
path.push(
'L',
toPath[10], // These two do not exist in the regular getPlotLine
toPath[11], // ---- # 3005
'L',
toPath[7],
toPath[8],
'L',
toPath[4],
toPath[5],
'L',
toPath[1],
toPath[2]
);
} else { // outside the axis area
path = null;
}
return path;
});
/***
EXTENSION TO THE TICKS
***/
wrap(Tick.prototype, 'getMarkPath', function(proceed) {
var path = proceed.apply(this, [].slice.call(arguments, 1));
// Do not do this if the chart is not 3D
if (!this.axis.chart.is3d() || this.coll === 'colorAxis') {
return path;
}
var pArr = [
this.axis.swapZ({
x: path[1],
y: path[2],
z: 0
}),
this.axis.swapZ({
x: path[4],
y: path[5],
z: 0
})
];
pArr = perspective(pArr, this.axis.chart, false);
path = [
'M', pArr[0].x, pArr[0].y,
'L', pArr[1].x, pArr[1].y
];
return path;
});
wrap(Tick.prototype, 'getLabelPosition', function(proceed) {
var pos = proceed.apply(this, [].slice.call(arguments, 1));
// Do not do this if the chart is not 3D
if (this.axis.chart.is3d() && this.coll !== 'colorAxis') {
pos = perspective([this.axis.swapZ({
x: pos.x,
y: pos.y,
z: 0
})], this.axis.chart, false)[0];
}
return pos;
});
H.wrap(Axis.prototype, 'getTitlePosition', function(proceed) {
var is3d = this.chart.is3d() && this.coll !== 'colorAxis',
pos,
axisTitleMargin;
// Pull out the axis title margin, that is not subject to the perspective
if (is3d) {
axisTitleMargin = this.axisTitleMargin;
this.axisTitleMargin = 0;
}
pos = proceed.apply(this, [].slice.call(arguments, 1));
if (is3d) {
pos = perspective([this.swapZ({
x: pos.x,
y: pos.y,
z: 0
})], this.chart, false)[0];
// Re-apply the axis title margin outside the perspective
pos[this.horiz ? 'y' : 'x'] += (this.horiz ? 1 : -1) * // horizontal axis reverses the margin ...
(this.opposite ? -1 : 1) * // ... so does opposite axes
axisTitleMargin;
this.axisTitleMargin = axisTitleMargin;
}
return pos;
});
wrap(Axis.prototype, 'drawCrosshair', function(proceed) {
var args = arguments;
if (this.chart.is3d()) {
if (args[2]) {
args[2] = {
plotX: args[2].plotXold || args[2].plotX,
plotY: args[2].plotYold || args[2].plotY
};
}
}
proceed.apply(this, [].slice.call(args, 1));
});
wrap(Axis.prototype, 'destroy', function(proceed) {
each(['backFrame', 'bottomFrame', 'sideFrame'], function(prop) {
if (this[prop]) {
this[prop] = this[prop].destroy();
}
}, this);
proceed.apply(this, [].slice.call(arguments, 1));
});
/***
Z-AXIS
***/
Axis.prototype.swapZ = function(p, insidePlotArea) {
if (this.isZAxis) {
var plotLeft = insidePlotArea ? 0 : this.chart.plotLeft;
var chart = this.chart;
return {
x: plotLeft + (chart.yAxis[0].opposite ? p.z : chart.xAxis[0].width - p.z),
y: p.y,
z: p.x - plotLeft
};
}
return p;
};
ZAxis = H.ZAxis = function() {
this.init.apply(this, arguments);
};
extend(ZAxis.prototype, Axis.prototype);
extend(ZAxis.prototype, {
isZAxis: true,
setOptions: function(userOptions) {
userOptions = merge({
offset: 0,
lineWidth: 0
}, userOptions);
Axis.prototype.setOptions.call(this, userOptions);
this.coll = 'zAxis';
},
setAxisSize: function() {
Axis.prototype.setAxisSize.call(this);
this.width = this.len = this.chart.options.chart.options3d.depth;
this.right = this.chart.chartWidth - this.width - this.left;
},
getSeriesExtremes: function() {
var axis = this,
chart = axis.chart;
axis.hasVisibleSeries = false;
// Reset properties in case we're redrawing (#3353)
axis.dataMin = axis.dataMax = axis.ignoreMinPadding = axis.ignoreMaxPadding = null;
if (axis.buildStacks) {
axis.buildStacks();
}
// loop through this axis' series
each(axis.series, function(series) {
if (series.visible || !chart.options.chart.ignoreHiddenSeries) {
var seriesOptions = series.options,
zData,
threshold = seriesOptions.threshold;
axis.hasVisibleSeries = true;
// Validate threshold in logarithmic axes
if (axis.positiveValuesOnly && threshold <= 0) {
threshold = null;
}
zData = series.zData;
if (zData.length) {
axis.dataMin = Math.min(pick(axis.dataMin, zData[0]), Math.min.apply(null, zData));
axis.dataMax = Math.max(pick(axis.dataMax, zData[0]), Math.max.apply(null, zData));
}
}
});
}
});
/**
* Extend the chart getAxes method to also get the color axis
*/
wrap(Chart.prototype, 'getAxes', function(proceed) {
var chart = this,
options = this.options,
zAxisOptions = options.zAxis = splat(options.zAxis || {});
proceed.call(this);
if (!chart.is3d()) {
return;
}
this.zAxis = [];
each(zAxisOptions, function(axisOptions, i) {
axisOptions.index = i;
axisOptions.isX = true; //Z-Axis is shown horizontally, so it's kind of a X-Axis
var zAxis = new ZAxis(chart, axisOptions);
zAxis.setScale();
});
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var each = H.each,
perspective = H.perspective,
pick = H.pick,
Series = H.Series,
seriesTypes = H.seriesTypes,
svg = H.svg,
wrap = H.wrap;
/***
EXTENSION FOR 3D COLUMNS
***/
wrap(seriesTypes.column.prototype, 'translate', function(proceed) {
proceed.apply(this, [].slice.call(arguments, 1));
// Do not do this if the chart is not 3D
if (!this.chart.is3d()) {
return;
}
var series = this,
chart = series.chart,
seriesOptions = series.options,
depth = seriesOptions.depth || 25;
var stack = seriesOptions.stacking ? (seriesOptions.stack || 0) : series._i;
var z = stack * (depth + (seriesOptions.groupZPadding || 1));
if (seriesOptions.grouping !== false) {
z = 0;
}
z += (seriesOptions.groupZPadding || 1);
each(series.data, function(point) {
if (point.y !== null) {
var shapeArgs = point.shapeArgs,
tooltipPos = point.tooltipPos;
point.shapeType = 'cuboid';
shapeArgs.z = z;
shapeArgs.depth = depth;
shapeArgs.insidePlotArea = true;
// Translate the tooltip position in 3d space
tooltipPos = perspective([{
x: tooltipPos[0],
y: tooltipPos[1],
z: z
}], chart, true)[0];
point.tooltipPos = [tooltipPos.x, tooltipPos.y];
}
});
// store for later use #4067
series.z = z;
});
wrap(seriesTypes.column.prototype, 'animate', function(proceed) {
if (!this.chart.is3d()) {
proceed.apply(this, [].slice.call(arguments, 1));
} else {
var args = arguments,
init = args[1],
yAxis = this.yAxis,
series = this,
reversed = this.yAxis.reversed;
if (svg) { // VML is too slow anyway
if (init) {
each(series.data, function(point) {
if (point.y !== null) {
point.height = point.shapeArgs.height;
point.shapey = point.shapeArgs.y; //#2968
point.shapeArgs.height = 1;
if (!reversed) {
if (point.stackY) {
point.shapeArgs.y = point.plotY + yAxis.translate(point.stackY);
} else {
point.shapeArgs.y = point.plotY + (point.negative ? -point.height : point.height);
}
}
}
});
} else { // run the animation
each(series.data, function(point) {
if (point.y !== null) {
point.shapeArgs.height = point.height;
point.shapeArgs.y = point.shapey; //#2968
// null value do not have a graphic
if (point.graphic) {
point.graphic.animate(point.shapeArgs, series.options.animation);
}
}
});
// redraw datalabels to the correct position
this.drawDataLabels();
// delete this function to allow it only once
series.animate = null;
}
}
}
});
wrap(seriesTypes.column.prototype, 'init', function(proceed) {
proceed.apply(this, [].slice.call(arguments, 1));
if (this.chart.is3d()) {
var seriesOptions = this.options,
grouping = seriesOptions.grouping,
stacking = seriesOptions.stacking,
reversedStacks = pick(this.yAxis.options.reversedStacks, true),
z = 0;
if (!(grouping !== undefined && !grouping)) {
var stacks = this.chart.retrieveStacks(stacking),
stack = seriesOptions.stack || 0,
i; // position within the stack
for (i = 0; i < stacks[stack].series.length; i++) {
if (stacks[stack].series[i] === this) {
break;
}
}
z = (10 * (stacks.totalStacks - stacks[stack].position)) + (reversedStacks ? i : -i); // #4369
// In case when axis is reversed, columns are also reversed inside the group (#3737)
if (!this.xAxis.reversed) {
z = (stacks.totalStacks * 10) - z;
}
}
seriesOptions.zIndex = z;
}
});
function pointAttribs(proceed) {
var attr = proceed.apply(this, [].slice.call(arguments, 1));
if (this.chart.is3d()) {
// Set the fill color to the fill color to provide a smooth edge
attr.stroke = this.options.edgeColor || attr.fill;
attr['stroke-width'] = pick(this.options.edgeWidth, 1); // #4055
}
return attr;
}
wrap(seriesTypes.column.prototype, 'pointAttribs', pointAttribs);
if (seriesTypes.columnrange) {
wrap(seriesTypes.columnrange.prototype, 'pointAttribs', pointAttribs);
}
function draw3DPoints(proceed) {
// Do not do this if the chart is not 3D
if (this.chart.is3d()) {
var grouping = this.chart.options.plotOptions.column.grouping;
if (grouping !== undefined && !grouping && this.group.zIndex !== undefined && !this.zIndexSet) {
this.group.attr({
zIndex: this.group.zIndex * 10
});
this.zIndexSet = true; // #4062 set zindex only once
}
}
proceed.apply(this, [].slice.call(arguments, 1));
}
wrap(Series.prototype, 'alignDataLabel', function(proceed) {
// Only do this for 3D columns and columnranges
if (this.chart.is3d() && (this.type === 'column' || this.type === 'columnrange')) {
var series = this,
chart = series.chart;
var args = arguments,
alignTo = args[4];
var pos = ({
x: alignTo.x,
y: alignTo.y,
z: series.z
});
pos = perspective([pos], chart, true)[0];
alignTo.x = pos.x;
alignTo.y = pos.y;
}
proceed.apply(this, [].slice.call(arguments, 1));
});
if (seriesTypes.columnrange) {
wrap(seriesTypes.columnrange.prototype, 'drawPoints', draw3DPoints);
}
wrap(seriesTypes.column.prototype, 'drawPoints', draw3DPoints);
/***
EXTENSION FOR 3D CYLINDRICAL COLUMNS
Not supported
***/
/*
var defaultOptions = H.getOptions();
defaultOptions.plotOptions.cylinder = H.merge(defaultOptions.plotOptions.column);
var CylinderSeries = H.extendClass(seriesTypes.column, {
type: 'cylinder'
});
seriesTypes.cylinder = CylinderSeries;
wrap(seriesTypes.cylinder.prototype, 'translate', function (proceed) {
proceed.apply(this, [].slice.call(arguments, 1));
// Do not do this if the chart is not 3D
if (!this.chart.is3d()) {
return;
}
var series = this,
chart = series.chart,
options = chart.options,
cylOptions = options.plotOptions.cylinder,
options3d = options.chart.options3d,
depth = cylOptions.depth || 0,
alpha = chart.alpha3d;
var z = cylOptions.stacking ? (this.options.stack || 0) * depth : series._i * depth;
z += depth / 2;
if (cylOptions.grouping !== false) { z = 0; }
each(series.data, function (point) {
var shapeArgs = point.shapeArgs,
deg2rad = H.deg2rad;
point.shapeType = 'arc3d';
shapeArgs.x += depth / 2;
shapeArgs.z = z;
shapeArgs.start = 0;
shapeArgs.end = 2 * PI;
shapeArgs.r = depth * 0.95;
shapeArgs.innerR = 0;
shapeArgs.depth = shapeArgs.height * (1 / sin((90 - alpha) * deg2rad)) - z;
shapeArgs.alpha = 90 - alpha;
shapeArgs.beta = 0;
});
});
*/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var deg2rad = H.deg2rad,
each = H.each,
pick = H.pick,
seriesTypes = H.seriesTypes,
svg = H.svg,
wrap = H.wrap;
/***
EXTENSION FOR 3D PIES
***/
wrap(seriesTypes.pie.prototype, 'translate', function(proceed) {
proceed.apply(this, [].slice.call(arguments, 1));
// Do not do this if the chart is not 3D
if (!this.chart.is3d()) {
return;
}
var series = this,
seriesOptions = series.options,
depth = seriesOptions.depth || 0,
options3d = series.chart.options.chart.options3d,
alpha = options3d.alpha,
beta = options3d.beta,
z = seriesOptions.stacking ? (seriesOptions.stack || 0) * depth : series._i * depth;
z += depth / 2;
if (seriesOptions.grouping !== false) {
z = 0;
}
each(series.data, function(point) {
var shapeArgs = point.shapeArgs,
angle;
point.shapeType = 'arc3d';
shapeArgs.z = z;
shapeArgs.depth = depth * 0.75;
shapeArgs.alpha = alpha;
shapeArgs.beta = beta;
shapeArgs.center = series.center;
angle = (shapeArgs.end + shapeArgs.start) / 2;
point.slicedTranslation = {
translateX: Math.round(Math.cos(angle) * seriesOptions.slicedOffset * Math.cos(alpha * deg2rad)),
translateY: Math.round(Math.sin(angle) * seriesOptions.slicedOffset * Math.cos(alpha * deg2rad))
};
});
});
wrap(seriesTypes.pie.prototype.pointClass.prototype, 'haloPath', function(proceed) {
var args = arguments;
return this.series.chart.is3d() ? [] : proceed.call(this, args[1]);
});
wrap(seriesTypes.pie.prototype, 'pointAttribs', function(proceed, point, state) {
var attr = proceed.call(this, point, state),
options = this.options;
if (this.chart.is3d()) {
attr.stroke = options.edgeColor || point.color || this.color;
attr['stroke-width'] = pick(options.edgeWidth, 1);
}
return attr;
});
wrap(seriesTypes.pie.prototype, 'drawPoints', function(proceed) {
proceed.apply(this, [].slice.call(arguments, 1));
if (this.chart.is3d()) {
each(this.points, function(point) {
var graphic = point.graphic;
// #4584 Check if has graphic - null points don't have it
if (graphic) {
// Hide null or 0 points (#3006, 3650)
graphic[point.y && point.visible ? 'show' : 'hide']();
}
});
}
});
wrap(seriesTypes.pie.prototype, 'drawDataLabels', function(proceed) {
if (this.chart.is3d()) {
var series = this,
chart = series.chart,
options3d = chart.options.chart.options3d;
each(series.data, function(point) {
var shapeArgs = point.shapeArgs,
r = shapeArgs.r,
a1 = (shapeArgs.alpha || options3d.alpha) * deg2rad, //#3240 issue with datalabels for 0 and null values
b1 = (shapeArgs.beta || options3d.beta) * deg2rad,
a2 = (shapeArgs.start + shapeArgs.end) / 2,
labelPos = point.labelPos,
labelIndexes = [0, 2, 4], // [x1, y1, x2, y2, x3, y3]
yOffset = (-r * (1 - Math.cos(a1)) * Math.sin(a2)), // + (sin(a2) > 0 ? sin(a1) * d : 0)
xOffset = r * (Math.cos(b1) - 1) * Math.cos(a2);
// Apply perspective on label positions
each(labelIndexes, function(index) {
labelPos[index] += xOffset;
labelPos[index + 1] += yOffset;
});
});
}
proceed.apply(this, [].slice.call(arguments, 1));
});
wrap(seriesTypes.pie.prototype, 'addPoint', function(proceed) {
proceed.apply(this, [].slice.call(arguments, 1));
if (this.chart.is3d()) {
// destroy (and rebuild) everything!!!
this.update(this.userOptions, true); // #3845 pass the old options
}
});
wrap(seriesTypes.pie.prototype, 'animate', function(proceed) {
if (!this.chart.is3d()) {
proceed.apply(this, [].slice.call(arguments, 1));
} else {
var args = arguments,
init = args[1],
animation = this.options.animation,
attribs,
center = this.center,
group = this.group,
markerGroup = this.markerGroup;
if (svg) { // VML is too slow anyway
if (animation === true) {
animation = {};
}
// Initialize the animation
if (init) {
// Scale down the group and place it in the center
group.oldtranslateX = group.translateX;
group.oldtranslateY = group.translateY;
attribs = {
translateX: center[0],
translateY: center[1],
scaleX: 0.001, // #1499
scaleY: 0.001
};
group.attr(attribs);
if (markerGroup) {
markerGroup.attrSetters = group.attrSetters;
markerGroup.attr(attribs);
}
// Run the animation
} else {
attribs = {
translateX: group.oldtranslateX,
translateY: group.oldtranslateY,
scaleX: 1,
scaleY: 1
};
group.animate(attribs, animation);
if (markerGroup) {
markerGroup.animate(attribs, animation);
}
// Delete this function to allow it only once
this.animate = null;
}
}
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var perspective = H.perspective,
pick = H.pick,
Point = H.Point,
seriesTypes = H.seriesTypes,
wrap = H.wrap;
/***
EXTENSION FOR 3D SCATTER CHART
***/
wrap(seriesTypes.scatter.prototype, 'translate', function(proceed) {
//function translate3d(proceed) {
proceed.apply(this, [].slice.call(arguments, 1));
if (!this.chart.is3d()) {
return;
}
var series = this,
chart = series.chart,
zAxis = pick(series.zAxis, chart.options.zAxis[0]),
rawPoints = [],
rawPoint,
projectedPoints,
projectedPoint,
zValue,
i;
for (i = 0; i < series.data.length; i++) {
rawPoint = series.data[i];
zValue = zAxis.isLog && zAxis.val2lin ? zAxis.val2lin(rawPoint.z) : rawPoint.z; // #4562
rawPoint.plotZ = zAxis.translate(zValue);
rawPoint.isInside = rawPoint.isInside ? (zValue >= zAxis.min && zValue <= zAxis.max) : false;
rawPoints.push({
x: rawPoint.plotX,
y: rawPoint.plotY,
z: rawPoint.plotZ
});
}
projectedPoints = perspective(rawPoints, chart, true);
for (i = 0; i < series.data.length; i++) {
rawPoint = series.data[i];
projectedPoint = projectedPoints[i];
rawPoint.plotXold = rawPoint.plotX;
rawPoint.plotYold = rawPoint.plotY;
rawPoint.plotZold = rawPoint.plotZ;
rawPoint.plotX = projectedPoint.x;
rawPoint.plotY = projectedPoint.y;
rawPoint.plotZ = projectedPoint.z;
}
});
wrap(seriesTypes.scatter.prototype, 'init', function(proceed, chart, options) {
if (chart.is3d()) {
// add a third coordinate
this.axisTypes = ['xAxis', 'yAxis', 'zAxis'];
this.pointArrayMap = ['x', 'y', 'z'];
this.parallelArrays = ['x', 'y', 'z'];
// Require direct touch rather than using the k-d-tree, because the k-d-tree currently doesn't
// take the xyz coordinate system into account (#4552)
this.directTouch = true;
}
var result = proceed.apply(this, [chart, options]);
if (this.chart.is3d()) {
// Set a new default tooltip formatter
var default3dScatterTooltip = 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>z: <b>{point.z}</b><br/>';
if (this.userOptions.tooltip) {
this.tooltipOptions.pointFormat = this.userOptions.tooltip.pointFormat || default3dScatterTooltip;
} else {
this.tooltipOptions.pointFormat = default3dScatterTooltip;
}
}
return result;
});
/**
* Updating zIndex for every point - based on the distance from point to camera
*/
wrap(seriesTypes.scatter.prototype, 'pointAttribs', function(proceed, point) {
var pointOptions = proceed.apply(this, [].slice.call(arguments, 1));
if (this.chart.is3d() && point) {
pointOptions.zIndex = H.pointCameraDistance(point, this.chart);
}
return pointOptions;
});
wrap(Point.prototype, 'applyOptions', function(proceed) {
var point = proceed.apply(this, [].slice.call(arguments, 1));
if (this.series.chart.is3d() && point.z === undefined) {
point.z = 0;
}
return point;
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
SVGRenderer = H.SVGRenderer,
VMLRenderer = H.VMLRenderer;
/**
* Extension to the VML Renderer
*/
if (VMLRenderer) {
H.setOptions({
animate: false
});
VMLRenderer.prototype.cuboid = SVGRenderer.prototype.cuboid;
VMLRenderer.prototype.cuboidPath = SVGRenderer.prototype.cuboidPath;
VMLRenderer.prototype.toLinePath = SVGRenderer.prototype.toLinePath;
VMLRenderer.prototype.createElement3D = SVGRenderer.prototype.createElement3D;
VMLRenderer.prototype.arc3d = function(shapeArgs) {
var result = SVGRenderer.prototype.arc3d.call(this, shapeArgs);
result.css({
zIndex: result.zIndex
});
return result;
};
H.VMLRenderer.prototype.arc3dPath = H.SVGRenderer.prototype.arc3dPath;
H.wrap(Axis.prototype, 'render', function(proceed) {
proceed.apply(this, [].slice.call(arguments, 1));
// VML doesn't support a negative z-index
if (this.sideFrame) {
this.sideFrame.css({
zIndex: 0
});
this.sideFrame.front.attr({
fill: this.sideFrame.color
});
}
if (this.bottomFrame) {
this.bottomFrame.css({
zIndex: 1
});
this.bottomFrame.front.attr({
fill: this.bottomFrame.color
});
}
if (this.backFrame) {
this.backFrame.css({
zIndex: 0
});
this.backFrame.front.attr({
fill: this.backFrame.color
});
}
});
}
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 1 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
(c) 2009-2016 Torstein Honsi
License: www.highcharts.com/license
*/
(function(y){"object"===typeof module&&module.exports?module.exports=y:y(Highcharts)})(function(y){(function(a){function p(a,b){this.init(a,b)}var r=a.CenteredSeriesMixin,v=a.each,m=a.extend,k=a.merge,h=a.splat;m(p.prototype,{coll:"pane",init:function(a,b){this.chart=b;this.background=[];b.pane.push(this);this.setOptions(a)},setOptions:function(a){this.options=k(this.defaultOptions,this.chart.angular?{background:{}}:void 0,a)},render:function(){var a=this.options,b=this.options.background,d=this.chart.renderer;
this.group||(this.group=d.g("pane-group").attr({zIndex:a.zIndex||0}).add());this.updateCenter();if(b)for(b=h(b),a=Math.max(b.length,this.background.length||0),d=0;d<a;d++)b[d]?this.renderBackground(k(this.defaultBackgroundOptions,b[d]),d):this.background[d]&&(this.background[d]=this.background[d].destroy(),this.background.splice(d,1))},renderBackground:function(a,b){var d="animate";this.background[b]||(this.background[b]=this.chart.renderer.path().add(this.group),d="attr");this.background[b][d]({d:this.axis.getPlotBandPath(a.from,
a.to,a)}).attr({fill:a.backgroundColor,stroke:a.borderColor,"stroke-width":a.borderWidth,"class":"highcharts-pane "+(a.className||"")})},defaultOptions:{center:["50%","50%"],size:"85%",startAngle:0},defaultBackgroundOptions:{shape:"circle",borderWidth:1,borderColor:"#cccccc",backgroundColor:{linearGradient:{x1:0,y1:0,x2:0,y2:1},stops:[[0,"#ffffff"],[1,"#e6e6e6"]]},from:-Number.MAX_VALUE,innerRadius:0,to:Number.MAX_VALUE,outerRadius:"105%"},updateCenter:function(a){this.center=(a||this.axis||{}).center=
r.getCenter.call(this)},update:function(a,b){k(!0,this.options,a);this.setOptions(this.options);this.render();v(this.chart.axes,function(d){d.pane===this&&(d.pane=null,d.update({},b))},this)}});a.Pane=p})(y);(function(a){var p=a.each,r=a.extend,v=a.map,m=a.merge,k=a.noop,h=a.pick,t=a.pInt,b=a.wrap,d,e,g=a.Axis.prototype;a=a.Tick.prototype;d={getOffset:k,redraw:function(){this.isDirty=!1},render:function(){this.isDirty=!1},setScale:k,setCategories:k,setTitle:k};e={defaultRadialGaugeOptions:{labels:{align:"center",
x:0,y:null},minorGridLineWidth:0,minorTickInterval:"auto",minorTickLength:10,minorTickPosition:"inside",minorTickWidth:1,tickLength:10,tickPosition:"inside",tickWidth:2,title:{rotation:0},zIndex:2},defaultRadialXOptions:{gridLineWidth:1,labels:{align:null,distance:15,x:0,y:null},maxPadding:0,minPadding:0,showLastLabel:!1,tickLength:0},defaultRadialYOptions:{gridLineInterpolation:"circle",labels:{align:"right",x:-3,y:-2},showLastLabel:!1,title:{x:4,text:null,rotation:90}},setOptions:function(c){c=
this.options=m(this.defaultOptions,this.defaultRadialOptions,c);c.plotBands||(c.plotBands=[])},getOffset:function(){g.getOffset.call(this);this.chart.axisOffset[this.side]=0},getLinePath:function(c,b){c=this.center;var d=this.chart,f=h(b,c[2]/2-this.offset);this.isCircular||void 0!==b?b=this.chart.renderer.symbols.arc(this.left+c[0],this.top+c[1],f,f,{start:this.startAngleRad,end:this.endAngleRad,open:!0,innerR:0}):(b=this.postTranslate(this.angleRad,f),b=["M",c[0]+d.plotLeft,c[1]+d.plotTop,"L",b.x,
b.y]);return b},setAxisTranslation:function(){g.setAxisTranslation.call(this);this.center&&(this.transA=this.isCircular?(this.endAngleRad-this.startAngleRad)/(this.max-this.min||1):this.center[2]/2/(this.max-this.min||1),this.minPixelPadding=this.isXAxis?this.transA*this.minPointOffset:0)},beforeSetTickPositions:function(){if(this.autoConnect=this.isCircular&&void 0===h(this.userMax,this.options.max)&&this.endAngleRad-this.startAngleRad===2*Math.PI)this.max+=this.categories&&1||this.pointRange||this.closestPointRange||
0},setAxisSize:function(){g.setAxisSize.call(this);this.isRadial&&(this.pane.updateCenter(this),this.isCircular&&(this.sector=this.endAngleRad-this.startAngleRad),this.len=this.width=this.height=this.center[2]*h(this.sector,1)/2)},getPosition:function(c,b){return this.postTranslate(this.isCircular?this.translate(c):this.angleRad,h(this.isCircular?b:this.translate(c),this.center[2]/2)-this.offset)},postTranslate:function(c,b){var d=this.chart,f=this.center;c=this.startAngleRad+c;return{x:d.plotLeft+
f[0]+Math.cos(c)*b,y:d.plotTop+f[1]+Math.sin(c)*b}},getPlotBandPath:function(c,b,d){var f=this.center,n=this.startAngleRad,a=f[2]/2,e=[h(d.outerRadius,"100%"),d.innerRadius,h(d.thickness,10)],g=Math.min(this.offset,0),u=/%$/,k,m=this.isCircular;"polygon"===this.options.gridLineInterpolation?f=this.getPlotLinePath(c).concat(this.getPlotLinePath(b,!0)):(c=Math.max(c,this.min),b=Math.min(b,this.max),m||(e[0]=this.translate(c),e[1]=this.translate(b)),e=v(e,function(c){u.test(c)&&(c=t(c,10)*a/100);return c}),
"circle"!==d.shape&&m?(c=n+this.translate(c),b=n+this.translate(b)):(c=-Math.PI/2,b=1.5*Math.PI,k=!0),e[0]-=g,e[2]-=g,f=this.chart.renderer.symbols.arc(this.left+f[0],this.top+f[1],e[0],e[0],{start:Math.min(c,b),end:Math.max(c,b),innerR:h(e[1],e[0]-e[2]),open:k}));return f},getPlotLinePath:function(c,b){var d=this,f=d.center,e=d.chart,a=d.getPosition(c),g,t,h;d.isCircular?h=["M",f[0]+e.plotLeft,f[1]+e.plotTop,"L",a.x,a.y]:"circle"===d.options.gridLineInterpolation?(c=d.translate(c))&&(h=d.getLinePath(0,
c)):(p(e.xAxis,function(c){c.pane===d.pane&&(g=c)}),h=[],c=d.translate(c),f=g.tickPositions,g.autoConnect&&(f=f.concat([f[0]])),b&&(f=[].concat(f).reverse()),p(f,function(b,d){t=g.getPosition(b,c);h.push(d?"L":"M",t.x,t.y)}));return h},getTitlePosition:function(){var c=this.center,b=this.chart,d=this.options.title;return{x:b.plotLeft+c[0]+(d.x||0),y:b.plotTop+c[1]-{high:.5,middle:.25,low:0}[d.align]*c[2]+(d.y||0)}}};b(g,"init",function(c,b,a){var f=b.angular,n=b.polar,g=a.isX,t=f&&g,x,k=b.options,
p=this.pane=b.pane[a.pane||0],z=p.options;if(f){if(r(this,t?d:e),x=!g)this.defaultRadialOptions=this.defaultRadialGaugeOptions}else n&&(r(this,e),this.defaultRadialOptions=(x=g)?this.defaultRadialXOptions:m(this.defaultYAxisOptions,this.defaultRadialYOptions));f||n?(this.isRadial=!0,b.inverted=!1,k.chart.zoomType=null):this.isRadial=!1;x&&(p.axis=this);c.call(this,b,a);t||!f&&!n||(c=this.options,this.angleRad=(c.angle||0)*Math.PI/180,this.startAngleRad=(z.startAngle-90)*Math.PI/180,this.endAngleRad=
(h(z.endAngle,z.startAngle+360)-90)*Math.PI/180,this.offset=c.offset||0,this.isCircular=x)});b(g,"autoLabelAlign",function(b){if(!this.isRadial)return b.apply(this,[].slice.call(arguments,1))});b(a,"getPosition",function(b,d,e,a,l){var c=this.axis;return c.getPosition?c.getPosition(e):b.call(this,d,e,a,l)});b(a,"getLabelPosition",function(b,d,e,a,l,g,t,k,u){var c=this.axis,f=g.y,n=20,q=g.align,w=(c.translate(this.pos)+c.startAngleRad+Math.PI/2)/Math.PI*180%360;c.isRadial?(b=c.getPosition(this.pos,
c.center[2]/2+h(g.distance,-25)),"auto"===g.rotation?a.attr({rotation:w}):null===f&&(f=c.chart.renderer.fontMetrics(a.styles.fontSize).b-a.getBBox().height/2),null===q&&(c.isCircular?(this.label.getBBox().width>c.len*c.tickInterval/(c.max-c.min)&&(n=0),q=w>n&&w<180-n?"left":w>180+n&&w<360-n?"right":"center"):q="center",a.attr({align:q})),b.x+=g.x,b.y+=f):b=b.call(this,d,e,a,l,g,t,k,u);return b});b(a,"getMarkPath",function(b,d,e,a,l,g,t){var c=this.axis;c.isRadial?(b=c.getPosition(this.pos,c.center[2]/
2+a),d=["M",d,e,"L",b.x,b.y]):d=b.call(this,d,e,a,l,g,t);return d})})(y);(function(a){var p=a.each,r=a.noop,v=a.pick,m=a.Series,k=a.seriesType,h=a.seriesTypes;k("arearange","area",{lineWidth:1,marker:null,threshold:null,tooltip:{pointFormat:'\x3cspan style\x3d"color:{series.color}"\x3e\u25cf\x3c/span\x3e {series.name}: \x3cb\x3e{point.low}\x3c/b\x3e - \x3cb\x3e{point.high}\x3c/b\x3e\x3cbr/\x3e'},trackByArea:!0,dataLabels:{align:null,verticalAlign:null,xLow:0,xHigh:0,yLow:0,yHigh:0},states:{hover:{halo:!1}}},
{pointArrayMap:["low","high"],dataLabelCollections:["dataLabel","dataLabelUpper"],toYData:function(a){return[a.low,a.high]},pointValKey:"low",deferTranslatePolar:!0,highToXY:function(a){var b=this.chart,d=this.xAxis.postTranslate(a.rectPlotX,this.yAxis.len-a.plotHigh);a.plotHighX=d.x-b.plotLeft;a.plotHigh=d.y-b.plotTop},translate:function(){var a=this,b=a.yAxis,d=!!a.modifyValue;h.area.prototype.translate.apply(a);p(a.points,function(e){var g=e.low,c=e.high,f=e.plotY;null===c||null===g?e.isNull=!0:
(e.plotLow=f,e.plotHigh=b.translate(d?a.modifyValue(c,e):c,0,1,0,1),d&&(e.yBottom=e.plotHigh))});this.chart.polar&&p(this.points,function(b){a.highToXY(b)})},getGraphPath:function(a){var b=[],d=[],e,g=h.area.prototype.getGraphPath,c,f,n;n=this.options;var w=this.chart.polar&&!1!==n.connectEnds,l=n.step;a=a||this.points;for(e=a.length;e--;)c=a[e],c.isNull||w||a[e+1]&&!a[e+1].isNull||d.push({plotX:c.plotX,plotY:c.plotY,doCurve:!1}),f={polarPlotY:c.polarPlotY,rectPlotX:c.rectPlotX,yBottom:c.yBottom,
plotX:v(c.plotHighX,c.plotX),plotY:c.plotHigh,isNull:c.isNull},d.push(f),b.push(f),c.isNull||w||a[e-1]&&!a[e-1].isNull||d.push({plotX:c.plotX,plotY:c.plotY,doCurve:!1});a=g.call(this,a);l&&(!0===l&&(l="left"),n.step={left:"right",center:"center",right:"left"}[l]);b=g.call(this,b);d=g.call(this,d);n.step=l;n=[].concat(a,b);this.chart.polar||"M"!==d[0]||(d[0]="L");this.graphPath=n;this.areaPath=this.areaPath.concat(a,d);n.isArea=!0;n.xMap=a.xMap;this.areaPath.xMap=a.xMap;return n},drawDataLabels:function(){var a=
this.data,b=a.length,d,e=[],g=m.prototype,c=this.options.dataLabels,f=c.align,n=c.verticalAlign,w=c.inside,l,q,h=this.chart.inverted;if(c.enabled||this._hasPointLabels){for(d=b;d--;)if(l=a[d])q=w?l.plotHigh<l.plotLow:l.plotHigh>l.plotLow,l.y=l.high,l._plotY=l.plotY,l.plotY=l.plotHigh,e[d]=l.dataLabel,l.dataLabel=l.dataLabelUpper,l.below=q,h?f||(c.align=q?"right":"left"):n||(c.verticalAlign=q?"top":"bottom"),c.x=c.xHigh,c.y=c.yHigh;g.drawDataLabels&&g.drawDataLabels.apply(this,arguments);for(d=b;d--;)if(l=
a[d])q=w?l.plotHigh<l.plotLow:l.plotHigh>l.plotLow,l.dataLabelUpper=l.dataLabel,l.dataLabel=e[d],l.y=l.low,l.plotY=l._plotY,l.below=!q,h?f||(c.align=q?"left":"right"):n||(c.verticalAlign=q?"bottom":"top"),c.x=c.xLow,c.y=c.yLow;g.drawDataLabels&&g.drawDataLabels.apply(this,arguments)}c.align=f;c.verticalAlign=n},alignDataLabel:function(){h.column.prototype.alignDataLabel.apply(this,arguments)},setStackedPoints:r,getSymbol:r,drawPoints:r})})(y);(function(a){var p=a.seriesType;p("areasplinerange","arearange",
null,{getPointSpline:a.seriesTypes.spline.prototype.getPointSpline})})(y);(function(a){var p=a.defaultPlotOptions,r=a.each,v=a.merge,m=a.noop,k=a.pick,h=a.seriesType,t=a.seriesTypes.column.prototype;h("columnrange","arearange",v(p.column,p.arearange,{lineWidth:1,pointRange:null}),{translate:function(){var b=this,d=b.yAxis,a=b.xAxis,g=a.startAngleRad,c,f=b.chart,n=b.xAxis.isRadial,w;t.translate.apply(b);r(b.points,function(e){var l=e.shapeArgs,h=b.options.minPointLength,x,u;e.plotHigh=w=d.translate(e.high,
0,1,0,1);e.plotLow=e.plotY;u=w;x=k(e.rectPlotY,e.plotY)-w;Math.abs(x)<h?(h-=x,x+=h,u-=h/2):0>x&&(x*=-1,u-=x);n?(c=e.barX+g,e.shapeType="path",e.shapeArgs={d:b.polarArc(u+x,u,c,c+e.pointWidth)}):(l.height=x,l.y=u,e.tooltipPos=f.inverted?[d.len+d.pos-f.plotLeft-u-x/2,a.len+a.pos-f.plotTop-l.x-l.width/2,x]:[a.left-f.plotLeft+l.x+l.width/2,d.pos-f.plotTop+u+x/2,x])})},directTouch:!0,trackerGroups:["group","dataLabelsGroup"],drawGraph:m,crispCol:t.crispCol,drawPoints:t.drawPoints,drawTracker:t.drawTracker,
getColumnMetrics:t.getColumnMetrics,animate:function(){return t.animate.apply(this,arguments)},polarArc:function(){return t.polarArc.apply(this,arguments)},pointAttribs:t.pointAttribs})})(y);(function(a){var p=a.each,r=a.isNumber,v=a.merge,m=a.pick,k=a.pInt,h=a.Series,t=a.seriesType,b=a.TrackerMixin;t("gauge","line",{dataLabels:{enabled:!0,defer:!1,y:15,borderRadius:3,crop:!1,verticalAlign:"top",zIndex:2,borderWidth:1,borderColor:"#cccccc"},dial:{},pivot:{},tooltip:{headerFormat:""},showInLegend:!1},
{angular:!0,directTouch:!0,drawGraph:a.noop,fixedBox:!0,forceDL:!0,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],translate:function(){var b=this.yAxis,a=this.options,g=b.center;this.generatePoints();p(this.points,function(c){var d=v(a.dial,c.dial),e=k(m(d.radius,80))*g[2]/200,w=k(m(d.baseLength,70))*e/100,l=k(m(d.rearLength,10))*e/100,q=d.baseWidth||3,h=d.topWidth||1,x=a.overshoot,u=b.startAngleRad+b.translate(c.y,null,null,null,!0);r(x)?(x=x/180*Math.PI,u=Math.max(b.startAngleRad-
x,Math.min(b.endAngleRad+x,u))):!1===a.wrap&&(u=Math.max(b.startAngleRad,Math.min(b.endAngleRad,u)));u=180*u/Math.PI;c.shapeType="path";c.shapeArgs={d:d.path||["M",-l,-q/2,"L",w,-q/2,e,-h/2,e,h/2,w,q/2,-l,q/2,"z"],translateX:g[0],translateY:g[1],rotation:u};c.plotX=g[0];c.plotY=g[1]})},drawPoints:function(){var b=this,a=b.yAxis.center,g=b.pivot,c=b.options,f=c.pivot,n=b.chart.renderer;p(b.points,function(d){var a=d.graphic,f=d.shapeArgs,e=f.d,g=v(c.dial,d.dial);a?(a.animate(f),f.d=e):(d.graphic=n[d.shapeType](f).attr({rotation:f.rotation,
zIndex:1}).addClass("highcharts-dial").add(b.group),d.graphic.attr({stroke:g.borderColor||"none","stroke-width":g.borderWidth||0,fill:g.backgroundColor||"#000000"}))});g?g.animate({translateX:a[0],translateY:a[1]}):(b.pivot=n.circle(0,0,m(f.radius,5)).attr({zIndex:2}).addClass("highcharts-pivot").translate(a[0],a[1]).add(b.group),b.pivot.attr({"stroke-width":f.borderWidth||0,stroke:f.borderColor||"#cccccc",fill:f.backgroundColor||"#000000"}))},animate:function(b){var d=this;b||(p(d.points,function(b){var c=
b.graphic;c&&(c.attr({rotation:180*d.yAxis.startAngleRad/Math.PI}),c.animate({rotation:b.shapeArgs.rotation},d.options.animation))}),d.animate=null)},render:function(){this.group=this.plotGroup("group","series",this.visible?"visible":"hidden",this.options.zIndex,this.chart.seriesGroup);h.prototype.render.call(this);this.group.clip(this.chart.clipRect)},setData:function(b,a){h.prototype.setData.call(this,b,!1);this.processData();this.generatePoints();m(a,!0)&&this.chart.redraw()},drawTracker:b&&b.drawTrackerPoint},
{setState:function(b){this.state=b}})})(y);(function(a){var p=a.each,r=a.noop,v=a.pick,m=a.seriesType,k=a.seriesTypes;m("boxplot","column",{threshold:null,tooltip:{pointFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e \x3cb\x3e {series.name}\x3c/b\x3e\x3cbr/\x3eMaximum: {point.high}\x3cbr/\x3eUpper quartile: {point.q3}\x3cbr/\x3eMedian: {point.median}\x3cbr/\x3eLower quartile: {point.q1}\x3cbr/\x3eMinimum: {point.low}\x3cbr/\x3e'},whiskerLength:"50%",fillColor:"#ffffff",lineWidth:1,
medianWidth:2,states:{hover:{brightness:-.3}},whiskerWidth:2},{pointArrayMap:["low","q1","median","q3","high"],toYData:function(a){return[a.low,a.q1,a.median,a.q3,a.high]},pointValKey:"high",pointAttribs:function(a){var h=this.options,b=a&&a.color||this.color;return{fill:a.fillColor||h.fillColor||b,stroke:h.lineColor||b,"stroke-width":h.lineWidth||0}},drawDataLabels:r,translate:function(){var a=this.yAxis,m=this.pointArrayMap;k.column.prototype.translate.apply(this);p(this.points,function(b){p(m,
function(d){null!==b[d]&&(b[d+"Plot"]=a.translate(b[d],0,1,0,1))})})},drawPoints:function(){var a=this,k=a.options,b=a.chart.renderer,d,e,g,c,f,n,w=0,l,q,m,x,u=!1!==a.doQuartiles,r,z=a.options.whiskerLength;p(a.points,function(h){var A=h.graphic,p=A?"animate":"attr",t=h.shapeArgs,y={},D={},H={},I=h.color||a.color;void 0!==h.plotY&&(l=t.width,q=Math.floor(t.x),m=q+l,x=Math.round(l/2),d=Math.floor(u?h.q1Plot:h.lowPlot),e=Math.floor(u?h.q3Plot:h.lowPlot),g=Math.floor(h.highPlot),c=Math.floor(h.lowPlot),
A||(h.graphic=A=b.g("point").add(a.group),h.stem=b.path().addClass("highcharts-boxplot-stem").add(A),z&&(h.whiskers=b.path().addClass("highcharts-boxplot-whisker").add(A)),u&&(h.box=b.path(void 0).addClass("highcharts-boxplot-box").add(A)),h.medianShape=b.path(void 0).addClass("highcharts-boxplot-median").add(A)),y.stroke=h.stemColor||k.stemColor||I,y["stroke-width"]=v(h.stemWidth,k.stemWidth,k.lineWidth),y.dashstyle=h.stemDashStyle||k.stemDashStyle,h.stem.attr(y),z&&(D.stroke=h.whiskerColor||k.whiskerColor||
I,D["stroke-width"]=v(h.whiskerWidth,k.whiskerWidth,k.lineWidth),h.whiskers.attr(D)),u&&(A=a.pointAttribs(h),h.box.attr(A)),H.stroke=h.medianColor||k.medianColor||I,H["stroke-width"]=v(h.medianWidth,k.medianWidth,k.lineWidth),h.medianShape.attr(H),n=h.stem.strokeWidth()%2/2,w=q+x+n,h.stem[p]({d:["M",w,e,"L",w,g,"M",w,d,"L",w,c]}),u&&(n=h.box.strokeWidth()%2/2,d=Math.floor(d)+n,e=Math.floor(e)+n,q+=n,m+=n,h.box[p]({d:["M",q,e,"L",q,d,"L",m,d,"L",m,e,"L",q,e,"z"]})),z&&(n=h.whiskers.strokeWidth()%2/
2,g+=n,c+=n,r=/%$/.test(z)?x*parseFloat(z)/100:z/2,h.whiskers[p]({d:["M",w-r,g,"L",w+r,g,"M",w-r,c,"L",w+r,c]})),f=Math.round(h.medianPlot),n=h.medianShape.strokeWidth()%2/2,f+=n,h.medianShape[p]({d:["M",q,f,"L",m,f]}))})},setStackedPoints:r})})(y);(function(a){var p=a.each,r=a.noop,v=a.seriesType,m=a.seriesTypes;v("errorbar","boxplot",{color:"#000000",grouping:!1,linkedTo:":previous",tooltip:{pointFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e {series.name}: \x3cb\x3e{point.low}\x3c/b\x3e - \x3cb\x3e{point.high}\x3c/b\x3e\x3cbr/\x3e'},
whiskerWidth:null},{type:"errorbar",pointArrayMap:["low","high"],toYData:function(a){return[a.low,a.high]},pointValKey:"high",doQuartiles:!1,drawDataLabels:m.arearange?function(){var a=this.pointValKey;m.arearange.prototype.drawDataLabels.call(this);p(this.data,function(h){h.y=h[a]})}:r,getColumnMetrics:function(){return this.linkedParent&&this.linkedParent.columnMetrics||m.column.prototype.getColumnMetrics.call(this)}})})(y);(function(a){var p=a.correctFloat,r=a.isNumber,v=a.pick,m=a.Point,k=a.Series,
h=a.seriesType,t=a.seriesTypes;h("waterfall","column",{dataLabels:{inside:!0},lineWidth:1,lineColor:"#333333",dashStyle:"dot",borderColor:"#333333",states:{hover:{lineWidthPlus:0}}},{pointValKey:"y",translate:function(){var b=this.options,a=this.yAxis,e,g,c,f,n,h,l,q,k,m,u=v(b.minPointLength,5),r=u/2,z=b.threshold,y=b.stacking,B;t.column.prototype.translate.apply(this);q=k=z;g=this.points;e=0;for(b=g.length;e<b;e++)c=g[e],l=this.processedYData[e],f=c.shapeArgs,n=y&&a.stacks[(this.negStacks&&l<z?"-":
"")+this.stackKey],B=this.getStackIndicator(B,c.x,this.index),m=n?n[c.x].points[B.key]:[0,l],c.isSum?c.y=p(l):c.isIntermediateSum&&(c.y=p(l-k)),h=Math.max(q,q+c.y)+m[0],f.y=a.toPixels(h,!0),c.isSum?(f.y=a.toPixels(m[1],!0),f.height=Math.min(a.toPixels(m[0],!0),a.len)-f.y):c.isIntermediateSum?(f.y=a.toPixels(m[1],!0),f.height=Math.min(a.toPixels(k,!0),a.len)-f.y,k=m[1]):(f.height=0<l?a.toPixels(q,!0)-f.y:a.toPixels(q,!0)-a.toPixels(q-l,!0),q+=n&&n[c.x]?n[c.x].total:l),0>f.height&&(f.y+=f.height,f.height*=
-1),c.plotY=f.y=Math.round(f.y)-this.borderWidth%2/2,f.height=Math.max(Math.round(f.height),.001),c.yBottom=f.y+f.height,f.height<=u&&!c.isNull?(f.height=u,f.y-=r,c.plotY=f.y,c.minPointLengthOffset=0>c.y?-r:r):c.minPointLengthOffset=0,f=c.plotY+(c.negative?f.height:0),this.chart.inverted?c.tooltipPos[0]=a.len-f:c.tooltipPos[1]=f},processData:function(b){var a=this.yData,e=this.options.data,g,c=a.length,f,n,h,l,q,m;n=f=h=l=this.options.threshold||0;for(m=0;m<c;m++)q=a[m],g=e&&e[m]?e[m]:{},"sum"===
q||g.isSum?a[m]=p(n):"intermediateSum"===q||g.isIntermediateSum?a[m]=p(f):(n+=q,f+=q),h=Math.min(n,h),l=Math.max(n,l);k.prototype.processData.call(this,b);this.options.stacking||(this.dataMin=h,this.dataMax=l)},toYData:function(b){return b.isSum?0===b.x?null:"sum":b.isIntermediateSum?0===b.x?null:"intermediateSum":b.y},pointAttribs:function(b,a){var d=this.options.upColor;d&&!b.options.color&&(b.color=0<b.y?d:null);b=t.column.prototype.pointAttribs.call(this,b,a);delete b.dashstyle;return b},getGraphPath:function(){return["M",
0,0]},getCrispPath:function(){var b=this.data,a=b.length,e=this.graph.strokeWidth()+this.borderWidth,e=Math.round(e)%2/2,g=[],c,f,n;for(n=1;n<a;n++)f=b[n].shapeArgs,c=b[n-1].shapeArgs,f=["M",c.x+c.width,c.y+b[n-1].minPointLengthOffset+e,"L",f.x,c.y+b[n-1].minPointLengthOffset+e],0>b[n-1].y&&(f[2]+=c.height,f[5]+=c.height),g=g.concat(f);return g},drawGraph:function(){k.prototype.drawGraph.call(this);this.graph.attr({d:this.getCrispPath()})},setStackedPoints:function(){var b=this.options,a,e;k.prototype.setStackedPoints.apply(this,
arguments);a=this.stackedYData?this.stackedYData.length:0;for(e=1;e<a;e++)b.data[e].isSum||b.data[e].isIntermediateSum||(this.stackedYData[e]+=this.stackedYData[e-1])},getExtremes:function(){if(this.options.stacking)return k.prototype.getExtremes.apply(this,arguments)}},{getClassName:function(){var b=m.prototype.getClassName.call(this);this.isSum?b+=" highcharts-sum":this.isIntermediateSum&&(b+=" highcharts-intermediate-sum");return b},isValid:function(){return r(this.y,!0)||this.isSum||this.isIntermediateSum}})})(y);
(function(a){var p=a.Series,r=a.seriesType,v=a.seriesTypes;r("polygon","scatter",{marker:{enabled:!1,states:{hover:{enabled:!1}}},stickyTracking:!1,tooltip:{followPointer:!0,pointFormat:""},trackByArea:!0},{type:"polygon",getGraphPath:function(){for(var a=p.prototype.getGraphPath.call(this),k=a.length+1;k--;)(k===a.length||"M"===a[k])&&0<k&&a.splice(k,0,"z");return this.areaPath=a},drawGraph:function(){this.options.fillColor=this.color;v.area.prototype.drawGraph.call(this)},drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,
drawTracker:p.prototype.drawTracker,setStackedPoints:a.noop})})(y);(function(a){var p=a.arrayMax,r=a.arrayMin,v=a.Axis,m=a.color,k=a.each,h=a.isNumber,t=a.noop,b=a.pick,d=a.pInt,e=a.Point,g=a.Series,c=a.seriesType,f=a.seriesTypes;c("bubble","scatter",{dataLabels:{formatter:function(){return this.point.z},inside:!0,verticalAlign:"middle"},marker:{lineColor:null,lineWidth:1,radius:null,states:{hover:{radiusPlus:0}},symbol:"circle"},minSize:8,maxSize:"20%",softThreshold:!1,states:{hover:{halo:{size:5}}},
tooltip:{pointFormat:"({point.x}, {point.y}), Size: {point.z}"},turboThreshold:0,zThreshold:0,zoneAxis:"z"},{pointArrayMap:["y","z"],parallelArrays:["x","y","z"],trackerGroups:["markerGroup","dataLabelsGroup"],bubblePadding:!0,zoneAxis:"z",directTouch:!0,pointAttribs:function(a,c){var d=b(this.options.marker.fillOpacity,.5);a=g.prototype.pointAttribs.call(this,a,c);1!==d&&(a.fill=m(a.fill).setOpacity(d).get("rgba"));return a},getRadii:function(b,a,c,d){var f,e,g,n=this.zData,h=[],l=this.options,q=
"width"!==l.sizeBy,k=l.zThreshold,m=a-b;e=0;for(f=n.length;e<f;e++)g=n[e],l.sizeByAbsoluteValue&&null!==g&&(g=Math.abs(g-k),a=Math.max(a-k,Math.abs(b-k)),b=0),null===g?g=null:g<b?g=c/2-1:(g=0<m?(g-b)/m:.5,q&&0<=g&&(g=Math.sqrt(g)),g=Math.ceil(c+g*(d-c))/2),h.push(g);this.radii=h},animate:function(b){var a=this.options.animation;b||(k(this.points,function(b){var c=b.graphic,d;c&&c.width&&(d={x:c.x,y:c.y,width:c.width,height:c.height},c.attr({x:b.plotX,y:b.plotY,width:1,height:1}),c.animate(d,a))}),
this.animate=null)},translate:function(){var b,c=this.data,d,e,g=this.radii;f.scatter.prototype.translate.call(this);for(b=c.length;b--;)d=c[b],e=g?g[b]:0,h(e)&&e>=this.minPxSize/2?(d.marker=a.extend(d.marker,{radius:e,width:2*e,height:2*e}),d.dlBox={x:d.plotX-e,y:d.plotY-e,width:2*e,height:2*e}):d.shapeArgs=d.plotY=d.dlBox=void 0},alignDataLabel:f.column.prototype.alignDataLabel,buildKDTree:t,applyZones:t},{haloPath:function(b){return e.prototype.haloPath.call(this,0===b?0:(this.marker?this.marker.radius||
0:0)+b)},ttBelow:!1});v.prototype.beforePadding=function(){var a=this,c=this.len,f=this.chart,e=0,g=c,m=this.isXAxis,t=m?"xData":"yData",v=this.min,y={},J=Math.min(f.plotWidth,f.plotHeight),B=Number.MAX_VALUE,E=-Number.MAX_VALUE,F=this.max-v,C=c/F,G=[];k(this.series,function(c){var e=c.options;!c.bubblePadding||!c.visible&&f.options.chart.ignoreHiddenSeries||(a.allowZoomOutside=!0,G.push(c),m&&(k(["minSize","maxSize"],function(b){var a=e[b],c=/%$/.test(a),a=d(a);y[b]=c?J*a/100:a}),c.minPxSize=y.minSize,
c.maxPxSize=Math.max(y.maxSize,y.minSize),c=c.zData,c.length&&(B=b(e.zMin,Math.min(B,Math.max(r(c),!1===e.displayNegative?e.zThreshold:-Number.MAX_VALUE))),E=b(e.zMax,Math.max(E,p(c))))))});k(G,function(b){var c=b[t],d=c.length,f;m&&b.getRadii(B,E,b.minPxSize,b.maxPxSize);if(0<F)for(;d--;)h(c[d])&&a.dataMin<=c[d]&&c[d]<=a.dataMax&&(f=b.radii[d],e=Math.min((c[d]-v)*C-f,e),g=Math.max((c[d]-v)*C+f,g))});G.length&&0<F&&!this.isLog&&(g-=c,C*=(c+e-g)/c,k([["min","userMin",e],["max","userMax",g]],function(c){void 0===
b(a.options[c[0]],a[c[1]])&&(a[c[0]]+=c[2]/C)}))}})(y);(function(a){function p(b,a){var d=this.chart,g=this.options.animation,c=this.group,f=this.markerGroup,h=this.xAxis.center,k=d.plotLeft,l=d.plotTop;d.polar?d.renderer.isSVG&&(!0===g&&(g={}),a?(b={translateX:h[0]+k,translateY:h[1]+l,scaleX:.001,scaleY:.001},c.attr(b),f&&f.attr(b)):(b={translateX:k,translateY:l,scaleX:1,scaleY:1},c.animate(b,g),f&&f.animate(b,g),this.animate=null)):b.call(this,a)}var r=a.each,v=a.pick,m=a.seriesTypes,k=a.wrap,h=
a.Series.prototype,t=a.Pointer.prototype;h.searchPointByAngle=function(b){var a=this.chart,e=this.xAxis.pane.center;return this.searchKDTree({clientX:180+-180/Math.PI*Math.atan2(b.chartX-e[0]-a.plotLeft,b.chartY-e[1]-a.plotTop)})};h.getConnectors=function(b,a,e,g){var c,d,h,k,l,m,p,r;d=g?1:0;c=0<=a&&a<=b.length-1?a:0>a?b.length-1+a:0;a=0>c-1?b.length-(1+d):c-1;d=c+1>b.length-1?d:c+1;h=b[a];d=b[d];k=h.plotX;h=h.plotY;l=d.plotX;m=d.plotY;d=b[c].plotX;c=b[c].plotY;k=(1.5*d+k)/2.5;h=(1.5*c+h)/2.5;l=(1.5*
d+l)/2.5;p=(1.5*c+m)/2.5;m=Math.sqrt(Math.pow(k-d,2)+Math.pow(h-c,2));r=Math.sqrt(Math.pow(l-d,2)+Math.pow(p-c,2));k=Math.atan2(h-c,k-d);p=Math.PI/2+(k+Math.atan2(p-c,l-d))/2;Math.abs(k-p)>Math.PI/2&&(p-=Math.PI);k=d+Math.cos(p)*m;h=c+Math.sin(p)*m;l=d+Math.cos(Math.PI+p)*r;p=c+Math.sin(Math.PI+p)*r;d={rightContX:l,rightContY:p,leftContX:k,leftContY:h,plotX:d,plotY:c};e&&(d.prevPointCont=this.getConnectors(b,a,!1,g));return d};k(h,"buildKDTree",function(b){this.chart.polar&&(this.kdByAngle?this.searchPoint=
this.searchPointByAngle:this.options.findNearestPointBy="xy");b.apply(this)});h.toXY=function(b){var a,e=this.chart,g=b.plotX;a=b.plotY;b.rectPlotX=g;b.rectPlotY=a;a=this.xAxis.postTranslate(b.plotX,this.yAxis.len-a);b.plotX=b.polarPlotX=a.x-e.plotLeft;b.plotY=b.polarPlotY=a.y-e.plotTop;this.kdByAngle?(e=(g/Math.PI*180+this.xAxis.pane.options.startAngle)%360,0>e&&(e+=360),b.clientX=e):b.clientX=b.plotX};m.spline&&(k(m.spline.prototype,"getPointSpline",function(a,d,e,g){this.chart.polar?g?(a=this.getConnectors(d,
g,!0,this.connectEnds),a=["C",a.prevPointCont.rightContX,a.prevPointCont.rightContY,a.leftContX,a.leftContY,a.plotX,a.plotY]):a=["M",e.plotX,e.plotY]:a=a.call(this,d,e,g);return a}),m.areasplinerange&&(m.areasplinerange.prototype.getPointSpline=m.spline.prototype.getPointSpline));k(h,"translate",function(a){var b=this.chart;a.call(this);if(b.polar&&(this.kdByAngle=b.tooltip&&b.tooltip.shared,!this.preventPostTranslate))for(a=this.points,b=a.length;b--;)this.toXY(a[b])});k(h,"getGraphPath",function(a,
d){var b=this,g,c,f;if(this.chart.polar){d=d||this.points;for(g=0;g<d.length;g++)if(!d[g].isNull){c=g;break}!1!==this.options.connectEnds&&void 0!==c&&(this.connectEnds=!0,d.splice(d.length,0,d[c]),f=!0);r(d,function(a){void 0===a.polarPlotY&&b.toXY(a)})}g=a.apply(this,[].slice.call(arguments,1));f&&d.pop();return g});k(h,"animate",p);m.column&&(m=m.column.prototype,m.polarArc=function(a,d,e,g){var b=this.xAxis.center,f=this.yAxis.len;return this.chart.renderer.symbols.arc(b[0],b[1],f-d,null,{start:e,
end:g,innerR:f-v(a,f)})},k(m,"animate",p),k(m,"translate",function(a){var b=this.xAxis,e=b.startAngleRad,g,c,f;this.preventPostTranslate=!0;a.call(this);if(b.isRadial)for(g=this.points,f=g.length;f--;)c=g[f],a=c.barX+e,c.shapeType="path",c.shapeArgs={d:this.polarArc(c.yBottom,c.plotY,a,a+c.pointWidth)},this.toXY(c),c.tooltipPos=[c.plotX,c.plotY],c.ttBelow=c.plotY>b.center[1]}),k(m,"alignDataLabel",function(a,d,e,g,c,f){this.chart.polar?(a=d.rectPlotX/Math.PI*180,null===g.align&&(g.align=20<a&&160>
a?"left":200<a&&340>a?"right":"center"),null===g.verticalAlign&&(g.verticalAlign=45>a||315<a?"bottom":135<a&&225>a?"top":"middle"),h.alignDataLabel.call(this,d,e,g,c,f)):a.call(this,d,e,g,c,f)}));k(t,"getCoordinates",function(a,d){var b=this.chart,g={xAxis:[],yAxis:[]};b.polar?r(b.axes,function(a){var c=a.isXAxis,e=a.center,h=d.chartX-e[0]-b.plotLeft,e=d.chartY-e[1]-b.plotTop;g[c?"xAxis":"yAxis"].push({axis:a,value:a.translate(c?Math.PI-Math.atan2(h,e):Math.sqrt(Math.pow(h,2)+Math.pow(e,2)),!0)})}):
g=a.call(this,d);return g});k(a.Chart.prototype,"getAxes",function(b){this.pane||(this.pane=[]);r(a.splat(this.options.pane),function(b){new a.Pane(b,this)},this);b.call(this)});k(a.Chart.prototype,"drawChartBox",function(a){a.call(this);r(this.pane,function(a){a.render()})});k(a.Chart.prototype,"get",function(b,d){return a.find(this.pane,function(a){return a.options.id===d})||b.call(this,d)})})(y)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 | 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var CenteredSeriesMixin = H.CenteredSeriesMixin,
each = H.each,
extend = H.extend,
merge = H.merge,
splat = H.splat;
/**
* The Pane object allows options that are common to a set of X and Y axes.
*
* In the future, this can be extended to basic Highcharts and Highstock.
*
*/
function Pane(options, chart) {
this.init(options, chart);
}
// Extend the Pane prototype
extend(Pane.prototype, {
coll: 'pane', // Member of chart.pane
/**
* Initiate the Pane object
*/
init: function(options, chart) {
this.chart = chart;
this.background = [];
chart.pane.push(this);
this.setOptions(options);
},
setOptions: function(options) {
// Set options. Angular charts have a default background (#3318)
this.options = options = merge(
this.defaultOptions,
this.chart.angular ? {
background: {}
} : undefined,
options
);
},
/**
* Render the pane with its backgrounds.
*/
render: function() {
var options = this.options,
backgroundOption = this.options.background,
renderer = this.chart.renderer,
len,
i;
if (!this.group) {
this.group = renderer.g('pane-group')
.attr({
zIndex: options.zIndex || 0
})
.add();
}
this.updateCenter();
// Render the backgrounds
if (backgroundOption) {
backgroundOption = splat(backgroundOption);
len = Math.max(
backgroundOption.length,
this.background.length || 0
);
for (i = 0; i < len; i++) {
if (backgroundOption[i]) {
this.renderBackground(
merge(
this.defaultBackgroundOptions,
backgroundOption[i]
),
i
);
} else if (this.background[i]) {
this.background[i] = this.background[i].destroy();
this.background.splice(i, 1);
}
}
}
},
/**
* Render an individual pane background.
* @param {Object} backgroundOptions Background options
* @param {number} i The index of the background in this.backgrounds
*/
renderBackground: function(backgroundOptions, i) {
var method = 'animate';
if (!this.background[i]) {
this.background[i] = this.chart.renderer.path()
.add(this.group);
method = 'attr';
}
this.background[i][method]({
'd': this.axis.getPlotBandPath(
backgroundOptions.from,
backgroundOptions.to,
backgroundOptions
)
}).attr({
'fill': backgroundOptions.backgroundColor,
'stroke': backgroundOptions.borderColor,
'stroke-width': backgroundOptions.borderWidth,
'class': 'highcharts-pane ' + (backgroundOptions.className || '')
});
},
/**
* The default options object
*/
defaultOptions: {
// background: {conditional},
center: ['50%', '50%'],
size: '85%',
startAngle: 0
//endAngle: startAngle + 360
},
/**
* The default background options
*/
defaultBackgroundOptions: {
//className: 'highcharts-pane',
shape: 'circle',
borderWidth: 1,
borderColor: '#cccccc',
backgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, '#ffffff'],
[1, '#e6e6e6']
]
},
from: -Number.MAX_VALUE, // corrected to axis min
innerRadius: 0,
to: Number.MAX_VALUE, // corrected to axis max
outerRadius: '105%'
},
/**
* Gets the center for the pane and its axis.
*/
updateCenter: function(axis) {
this.center = (axis || this.axis || {}).center =
CenteredSeriesMixin.getCenter.call(this);
},
/**
* Destroy the pane item
* /
destroy: function () {
H.erase(this.chart.pane, this);
each(this.background, function (background) {
background.destroy();
});
this.background.length = 0;
this.group = this.group.destroy();
},
*/
/**
* Update the pane item with new options
* @param {Object} options New pane options
*/
update: function(options, redraw) {
merge(true, this.options, options);
this.setOptions(this.options);
this.render();
each(this.chart.axes, function(axis) {
if (axis.pane === this) {
axis.pane = null;
axis.update({}, redraw);
}
}, this);
}
});
H.Pane = Pane;
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
each = H.each,
extend = H.extend,
map = H.map,
merge = H.merge,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
Tick = H.Tick,
wrap = H.wrap,
hiddenAxisMixin, // @todo Extract this to a new file
radialAxisMixin, // @todo Extract this to a new file
axisProto = Axis.prototype,
tickProto = Tick.prototype;
/**
* Augmented methods for the x axis in order to hide it completely, used for the X axis in gauges
*/
hiddenAxisMixin = {
getOffset: noop,
redraw: function() {
this.isDirty = false; // prevent setting Y axis dirty
},
render: function() {
this.isDirty = false; // prevent setting Y axis dirty
},
setScale: noop,
setCategories: noop,
setTitle: noop
};
/**
* Augmented methods for the value axis
*/
radialAxisMixin = {
/**
* The default options extend defaultYAxisOptions
*/
defaultRadialGaugeOptions: {
labels: {
align: 'center',
x: 0,
y: null // auto
},
minorGridLineWidth: 0,
minorTickInterval: 'auto',
minorTickLength: 10,
minorTickPosition: 'inside',
minorTickWidth: 1,
tickLength: 10,
tickPosition: 'inside',
tickWidth: 2,
title: {
rotation: 0
},
zIndex: 2 // behind dials, points in the series group
},
// Circular axis around the perimeter of a polar chart
defaultRadialXOptions: {
gridLineWidth: 1, // spokes
labels: {
align: null, // auto
distance: 15,
x: 0,
y: null // auto
},
maxPadding: 0,
minPadding: 0,
showLastLabel: false,
tickLength: 0
},
// Radial axis, like a spoke in a polar chart
defaultRadialYOptions: {
gridLineInterpolation: 'circle',
labels: {
align: 'right',
x: -3,
y: -2
},
showLastLabel: false,
title: {
x: 4,
text: null,
rotation: 90
}
},
/**
* Merge and set options
*/
setOptions: function(userOptions) {
var options = this.options = merge(
this.defaultOptions,
this.defaultRadialOptions,
userOptions
);
// Make sure the plotBands array is instanciated for each Axis (#2649)
if (!options.plotBands) {
options.plotBands = [];
}
},
/**
* Wrap the getOffset method to return zero offset for title or labels in a radial
* axis
*/
getOffset: function() {
// Call the Axis prototype method (the method we're in now is on the instance)
axisProto.getOffset.call(this);
// Title or label offsets are not counted
this.chart.axisOffset[this.side] = 0;
},
/**
* Get the path for the axis line. This method is also referenced in the getPlotLinePath
* method.
*/
getLinePath: function(lineWidth, radius) {
var center = this.center,
end,
chart = this.chart,
r = pick(radius, center[2] / 2 - this.offset),
path;
if (this.isCircular || radius !== undefined) {
path = this.chart.renderer.symbols.arc(
this.left + center[0],
this.top + center[1],
r,
r, {
start: this.startAngleRad,
end: this.endAngleRad,
open: true,
innerR: 0
}
);
} else {
end = this.postTranslate(this.angleRad, r);
path = ['M', center[0] + chart.plotLeft, center[1] + chart.plotTop, 'L', end.x, end.y];
}
return path;
},
/**
* Override setAxisTranslation by setting the translation to the difference
* in rotation. This allows the translate method to return angle for
* any given value.
*/
setAxisTranslation: function() {
// Call uber method
axisProto.setAxisTranslation.call(this);
// Set transA and minPixelPadding
if (this.center) { // it's not defined the first time
if (this.isCircular) {
this.transA = (this.endAngleRad - this.startAngleRad) /
((this.max - this.min) || 1);
} else {
this.transA = (this.center[2] / 2) / ((this.max - this.min) || 1);
}
if (this.isXAxis) {
this.minPixelPadding = this.transA * this.minPointOffset;
} else {
// This is a workaround for regression #2593, but categories still don't position correctly.
this.minPixelPadding = 0;
}
}
},
/**
* In case of auto connect, add one closestPointRange to the max value right before
* tickPositions are computed, so that ticks will extend passed the real max.
*/
beforeSetTickPositions: function() {
// If autoConnect is true, polygonal grid lines are connected, and one closestPointRange
// is added to the X axis to prevent the last point from overlapping the first.
this.autoConnect = this.isCircular && pick(this.userMax, this.options.max) === undefined &&
this.endAngleRad - this.startAngleRad === 2 * Math.PI;
if (this.autoConnect) {
this.max += (this.categories && 1) || this.pointRange || this.closestPointRange || 0; // #1197, #2260
}
},
/**
* Override the setAxisSize method to use the arc's circumference as length. This
* allows tickPixelInterval to apply to pixel lengths along the perimeter
*/
setAxisSize: function() {
axisProto.setAxisSize.call(this);
if (this.isRadial) {
// Set the center array
this.pane.updateCenter(this);
// The sector is used in Axis.translate to compute the translation of reversed axis points (#2570)
if (this.isCircular) {
this.sector = this.endAngleRad - this.startAngleRad;
}
// Axis len is used to lay out the ticks
this.len = this.width = this.height = this.center[2] * pick(this.sector, 1) / 2;
}
},
/**
* Returns the x, y coordinate of a point given by a value and a pixel distance
* from center
*/
getPosition: function(value, length) {
return this.postTranslate(
this.isCircular ? this.translate(value) : this.angleRad, // #2848
pick(this.isCircular ? length : this.translate(value), this.center[2] / 2) - this.offset
);
},
/**
* Translate from intermediate plotX (angle), plotY (axis.len - radius) to final chart coordinates.
*/
postTranslate: function(angle, radius) {
var chart = this.chart,
center = this.center;
angle = this.startAngleRad + angle;
return {
x: chart.plotLeft + center[0] + Math.cos(angle) * radius,
y: chart.plotTop + center[1] + Math.sin(angle) * radius
};
},
/**
* Find the path for plot bands along the radial axis
*/
getPlotBandPath: function(from, to, options) {
var center = this.center,
startAngleRad = this.startAngleRad,
fullRadius = center[2] / 2,
radii = [
pick(options.outerRadius, '100%'),
options.innerRadius,
pick(options.thickness, 10)
],
offset = Math.min(this.offset, 0),
percentRegex = /%$/,
start,
end,
open,
isCircular = this.isCircular, // X axis in a polar chart
ret;
// Polygonal plot bands
if (this.options.gridLineInterpolation === 'polygon') {
ret = this.getPlotLinePath(from).concat(this.getPlotLinePath(to, true));
// Circular grid bands
} else {
// Keep within bounds
from = Math.max(from, this.min);
to = Math.min(to, this.max);
// Plot bands on Y axis (radial axis) - inner and outer radius depend on to and from
if (!isCircular) {
radii[0] = this.translate(from);
radii[1] = this.translate(to);
}
// Convert percentages to pixel values
radii = map(radii, function(radius) {
if (percentRegex.test(radius)) {
radius = (pInt(radius, 10) * fullRadius) / 100;
}
return radius;
});
// Handle full circle
if (options.shape === 'circle' || !isCircular) {
start = -Math.PI / 2;
end = Math.PI * 1.5;
open = true;
} else {
start = startAngleRad + this.translate(from);
end = startAngleRad + this.translate(to);
}
radii[0] -= offset; // #5283
radii[2] -= offset; // #5283
ret = this.chart.renderer.symbols.arc(
this.left + center[0],
this.top + center[1],
radii[0],
radii[0], {
start: Math.min(start, end), // Math is for reversed yAxis (#3606)
end: Math.max(start, end),
innerR: pick(radii[1], radii[0] - radii[2]),
open: open
}
);
}
return ret;
},
/**
* Find the path for plot lines perpendicular to the radial axis.
*/
getPlotLinePath: function(value, reverse) {
var axis = this,
center = axis.center,
chart = axis.chart,
end = axis.getPosition(value),
xAxis,
xy,
tickPositions,
ret;
// Spokes
if (axis.isCircular) {
ret = ['M', center[0] + chart.plotLeft, center[1] + chart.plotTop, 'L', end.x, end.y];
// Concentric circles
} else if (axis.options.gridLineInterpolation === 'circle') {
value = axis.translate(value);
if (value) { // a value of 0 is in the center
ret = axis.getLinePath(0, value);
}
// Concentric polygons
} else {
// Find the X axis in the same pane
each(chart.xAxis, function(a) {
if (a.pane === axis.pane) {
xAxis = a;
}
});
ret = [];
value = axis.translate(value);
tickPositions = xAxis.tickPositions;
if (xAxis.autoConnect) {
tickPositions = tickPositions.concat([tickPositions[0]]);
}
// Reverse the positions for concatenation of polygonal plot bands
if (reverse) {
tickPositions = [].concat(tickPositions).reverse();
}
each(tickPositions, function(pos, i) {
xy = xAxis.getPosition(pos, value);
ret.push(i ? 'L' : 'M', xy.x, xy.y);
});
}
return ret;
},
/**
* Find the position for the axis title, by default inside the gauge
*/
getTitlePosition: function() {
var center = this.center,
chart = this.chart,
titleOptions = this.options.title;
return {
x: chart.plotLeft + center[0] + (titleOptions.x || 0),
y: chart.plotTop + center[1] - ({
high: 0.5,
middle: 0.25,
low: 0
}[titleOptions.align] *
center[2]) + (titleOptions.y || 0)
};
}
};
/**
* Override axisProto.init to mix in special axis instance functions and function overrides
*/
wrap(axisProto, 'init', function(proceed, chart, userOptions) {
var angular = chart.angular,
polar = chart.polar,
isX = userOptions.isX,
isHidden = angular && isX,
isCircular,
options,
chartOptions = chart.options,
paneIndex = userOptions.pane || 0,
pane = this.pane = chart.pane[paneIndex],
paneOptions = pane.options;
// Before prototype.init
if (angular) {
extend(this, isHidden ? hiddenAxisMixin : radialAxisMixin);
isCircular = !isX;
if (isCircular) {
this.defaultRadialOptions = this.defaultRadialGaugeOptions;
}
} else if (polar) {
extend(this, radialAxisMixin);
isCircular = isX;
this.defaultRadialOptions = isX ? this.defaultRadialXOptions : merge(this.defaultYAxisOptions, this.defaultRadialYOptions);
}
// Disable certain features on angular and polar axes
if (angular || polar) {
this.isRadial = true;
chart.inverted = false;
chartOptions.chart.zoomType = null;
} else {
this.isRadial = false;
}
// A pointer back to this axis to borrow geometry
if (isCircular) {
pane.axis = this;
}
// Run prototype.init
proceed.call(this, chart, userOptions);
if (!isHidden && (angular || polar)) {
options = this.options;
// Start and end angle options are
// given in degrees relative to top, while internal computations are
// in radians relative to right (like SVG).
this.angleRad = (options.angle || 0) * Math.PI / 180; // Y axis in polar charts
this.startAngleRad = (paneOptions.startAngle - 90) * Math.PI / 180; // Gauges
this.endAngleRad = (pick(paneOptions.endAngle, paneOptions.startAngle + 360) - 90) * Math.PI / 180; // Gauges
this.offset = options.offset || 0;
this.isCircular = isCircular;
}
});
/**
* Wrap auto label align to avoid setting axis-wide rotation on radial axes (#4920)
* @param {Function} proceed
* @returns {String} Alignment
*/
wrap(axisProto, 'autoLabelAlign', function(proceed) {
if (!this.isRadial) {
return proceed.apply(this, [].slice.call(arguments, 1));
} // else return undefined
});
/**
* Add special cases within the Tick class' methods for radial axes.
*/
wrap(tickProto, 'getPosition', function(proceed, horiz, pos, tickmarkOffset, old) {
var axis = this.axis;
return axis.getPosition ?
axis.getPosition(pos) :
proceed.call(this, horiz, pos, tickmarkOffset, old);
});
/**
* Wrap the getLabelPosition function to find the center position of the label
* based on the distance option
*/
wrap(tickProto, 'getLabelPosition', function(proceed, x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
var axis = this.axis,
optionsY = labelOptions.y,
ret,
centerSlot = 20, // 20 degrees to each side at the top and bottom
align = labelOptions.align,
angle = ((axis.translate(this.pos) + axis.startAngleRad + Math.PI / 2) / Math.PI * 180) % 360;
if (axis.isRadial) { // Both X and Y axes in a polar chart
ret = axis.getPosition(this.pos, (axis.center[2] / 2) + pick(labelOptions.distance, -25));
// Automatically rotated
if (labelOptions.rotation === 'auto') {
label.attr({
rotation: angle
});
// Vertically centered
} else if (optionsY === null) {
optionsY = axis.chart.renderer.fontMetrics(label.styles.fontSize).b - label.getBBox().height / 2;
}
// Automatic alignment
if (align === null) {
if (axis.isCircular) { // Y axis
if (this.label.getBBox().width > axis.len * axis.tickInterval / (axis.max - axis.min)) { // #3506
centerSlot = 0;
}
if (angle > centerSlot && angle < 180 - centerSlot) {
align = 'left'; // right hemisphere
} else if (angle > 180 + centerSlot && angle < 360 - centerSlot) {
align = 'right'; // left hemisphere
} else {
align = 'center'; // top or bottom
}
} else {
align = 'center';
}
label.attr({
align: align
});
}
ret.x += labelOptions.x;
ret.y += optionsY;
} else {
ret = proceed.call(this, x, y, label, horiz, labelOptions, tickmarkOffset, index, step);
}
return ret;
});
/**
* Wrap the getMarkPath function to return the path of the radial marker
*/
wrap(tickProto, 'getMarkPath', function(proceed, x, y, tickLength, tickWidth, horiz, renderer) {
var axis = this.axis,
endPoint,
ret;
if (axis.isRadial) {
endPoint = axis.getPosition(this.pos, axis.center[2] / 2 + tickLength);
ret = [
'M',
x,
y,
'L',
endPoint.x,
endPoint.y
];
} else {
ret = proceed.call(this, x, y, tickLength, tickWidth, horiz, renderer);
}
return ret;
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var each = H.each,
noop = H.noop,
pick = H.pick,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/*
* The arearangeseries series type
*/
seriesType('arearange', 'area', {
lineWidth: 1,
marker: null,
threshold: null,
tooltip: {
pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>' // eslint-disable-line no-dupe-keys
},
trackByArea: true,
dataLabels: {
align: null,
verticalAlign: null,
xLow: 0,
xHigh: 0,
yLow: 0,
yHigh: 0
},
states: {
hover: {
halo: false
}
}
// Prototype members
}, {
pointArrayMap: ['low', 'high'],
dataLabelCollections: ['dataLabel', 'dataLabelUpper'],
toYData: function(point) {
return [point.low, point.high];
},
pointValKey: 'low',
deferTranslatePolar: true,
/**
* Translate a point's plotHigh from the internal angle and radius measures to
* true plotHigh coordinates. This is an addition of the toXY method found in
* Polar.js, because it runs too early for arearanges to be considered (#3419).
*/
highToXY: function(point) {
// Find the polar plotX and plotY
var chart = this.chart,
xy = this.xAxis.postTranslate(point.rectPlotX, this.yAxis.len - point.plotHigh);
point.plotHighX = xy.x - chart.plotLeft;
point.plotHigh = xy.y - chart.plotTop;
},
/**
* Translate data points from raw values x and y to plotX and plotY
*/
translate: function() {
var series = this,
yAxis = series.yAxis,
hasModifyValue = !!series.modifyValue;
seriesTypes.area.prototype.translate.apply(series);
// Set plotLow and plotHigh
each(series.points, function(point) {
var low = point.low,
high = point.high,
plotY = point.plotY;
if (high === null || low === null) {
point.isNull = true;
} else {
point.plotLow = plotY;
point.plotHigh = yAxis.translate(
hasModifyValue ? series.modifyValue(high, point) : high,
0,
1,
0,
1
);
if (hasModifyValue) {
point.yBottom = point.plotHigh;
}
}
});
// Postprocess plotHigh
if (this.chart.polar) {
each(this.points, function(point) {
series.highToXY(point);
});
}
},
/**
* Extend the line series' getSegmentPath method by applying the segment
* path to both lower and higher values of the range
*/
getGraphPath: function(points) {
var highPoints = [],
highAreaPoints = [],
i,
getGraphPath = seriesTypes.area.prototype.getGraphPath,
point,
pointShim,
linePath,
lowerPath,
options = this.options,
connectEnds = this.chart.polar && options.connectEnds !== false,
step = options.step,
higherPath,
higherAreaPath;
points = points || this.points;
i = points.length;
// Create the top line and the top part of the area fill. The area fill compensates for
// null points by drawing down to the lower graph, moving across the null gap and
// starting again at the lower graph.
i = points.length;
while (i--) {
point = points[i];
if (!point.isNull &&
!connectEnds &&
(!points[i + 1] || points[i + 1].isNull)
) {
highAreaPoints.push({
plotX: point.plotX,
plotY: point.plotY,
doCurve: false // #5186, gaps in areasplinerange fill
});
}
pointShim = {
polarPlotY: point.polarPlotY,
rectPlotX: point.rectPlotX,
yBottom: point.yBottom,
plotX: pick(point.plotHighX, point.plotX), // plotHighX is for polar charts
plotY: point.plotHigh,
isNull: point.isNull
};
highAreaPoints.push(pointShim);
highPoints.push(pointShim);
if (!point.isNull &&
!connectEnds &&
(!points[i - 1] || points[i - 1].isNull)
) {
highAreaPoints.push({
plotX: point.plotX,
plotY: point.plotY,
doCurve: false // #5186, gaps in areasplinerange fill
});
}
}
// Get the paths
lowerPath = getGraphPath.call(this, points);
if (step) {
if (step === true) {
step = 'left';
}
options.step = {
left: 'right',
center: 'center',
right: 'left'
}[step]; // swap for reading in getGraphPath
}
higherPath = getGraphPath.call(this, highPoints);
higherAreaPath = getGraphPath.call(this, highAreaPoints);
options.step = step;
// Create a line on both top and bottom of the range
linePath = [].concat(lowerPath, higherPath);
// For the area path, we need to change the 'move' statement into 'lineTo' or 'curveTo'
if (!this.chart.polar && higherAreaPath[0] === 'M') {
higherAreaPath[0] = 'L'; // this probably doesn't work for spline
}
this.graphPath = linePath;
this.areaPath = this.areaPath.concat(lowerPath, higherAreaPath);
// Prepare for sideways animation
linePath.isArea = true;
linePath.xMap = lowerPath.xMap;
this.areaPath.xMap = lowerPath.xMap;
return linePath;
},
/**
* Extend the basic drawDataLabels method by running it for both lower and higher
* values.
*/
drawDataLabels: function() {
var data = this.data,
length = data.length,
i,
originalDataLabels = [],
seriesProto = Series.prototype,
dataLabelOptions = this.options.dataLabels,
align = dataLabelOptions.align,
verticalAlign = dataLabelOptions.verticalAlign,
inside = dataLabelOptions.inside,
point,
up,
inverted = this.chart.inverted;
if (dataLabelOptions.enabled || this._hasPointLabels) {
// Step 1: set preliminary values for plotY and dataLabel and draw the upper labels
i = length;
while (i--) {
point = data[i];
if (point) {
up = inside ? point.plotHigh < point.plotLow : point.plotHigh > point.plotLow;
// Set preliminary values
point.y = point.high;
point._plotY = point.plotY;
point.plotY = point.plotHigh;
// Store original data labels and set preliminary label objects to be picked up
// in the uber method
originalDataLabels[i] = point.dataLabel;
point.dataLabel = point.dataLabelUpper;
// Set the default offset
point.below = up;
if (inverted) {
if (!align) {
dataLabelOptions.align = up ? 'right' : 'left';
}
} else {
if (!verticalAlign) {
dataLabelOptions.verticalAlign = up ? 'top' : 'bottom';
}
}
dataLabelOptions.x = dataLabelOptions.xHigh;
dataLabelOptions.y = dataLabelOptions.yHigh;
}
}
if (seriesProto.drawDataLabels) {
seriesProto.drawDataLabels.apply(this, arguments); // #1209
}
// Step 2: reorganize and handle data labels for the lower values
i = length;
while (i--) {
point = data[i];
if (point) {
up = inside ? point.plotHigh < point.plotLow : point.plotHigh > point.plotLow;
// Move the generated labels from step 1, and reassign the original data labels
point.dataLabelUpper = point.dataLabel;
point.dataLabel = originalDataLabels[i];
// Reset values
point.y = point.low;
point.plotY = point._plotY;
// Set the default offset
point.below = !up;
if (inverted) {
if (!align) {
dataLabelOptions.align = up ? 'left' : 'right';
}
} else {
if (!verticalAlign) {
dataLabelOptions.verticalAlign = up ? 'bottom' : 'top';
}
}
dataLabelOptions.x = dataLabelOptions.xLow;
dataLabelOptions.y = dataLabelOptions.yLow;
}
}
if (seriesProto.drawDataLabels) {
seriesProto.drawDataLabels.apply(this, arguments);
}
}
dataLabelOptions.align = align;
dataLabelOptions.verticalAlign = verticalAlign;
},
alignDataLabel: function() {
seriesTypes.column.prototype.alignDataLabel.apply(this, arguments);
},
setStackedPoints: noop,
getSymbol: noop,
drawPoints: noop
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/**
* The areasplinerange series type
*/
seriesType('areasplinerange', 'arearange', null, {
getPointSpline: seriesTypes.spline.prototype.getPointSpline
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var defaultPlotOptions = H.defaultPlotOptions,
each = H.each,
merge = H.merge,
noop = H.noop,
pick = H.pick,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
var colProto = seriesTypes.column.prototype;
/**
* The ColumnRangeSeries class
*/
seriesType('columnrange', 'arearange', merge(defaultPlotOptions.column, defaultPlotOptions.arearange, {
lineWidth: 1,
pointRange: null
// Prototype members
}), {
/**
* Translate data points from raw values x and y to plotX and plotY
*/
translate: function() {
var series = this,
yAxis = series.yAxis,
xAxis = series.xAxis,
startAngleRad = xAxis.startAngleRad,
start,
chart = series.chart,
isRadial = series.xAxis.isRadial,
plotHigh;
colProto.translate.apply(series);
// Set plotLow and plotHigh
each(series.points, function(point) {
var shapeArgs = point.shapeArgs,
minPointLength = series.options.minPointLength,
heightDifference,
height,
y;
point.plotHigh = plotHigh = yAxis.translate(point.high, 0, 1, 0, 1);
point.plotLow = point.plotY;
// adjust shape
y = plotHigh;
height = pick(point.rectPlotY, point.plotY) - plotHigh;
// Adjust for minPointLength
if (Math.abs(height) < minPointLength) {
heightDifference = (minPointLength - height);
height += heightDifference;
y -= heightDifference / 2;
// Adjust for negative ranges or reversed Y axis (#1457)
} else if (height < 0) {
height *= -1;
y -= height;
}
if (isRadial) {
start = point.barX + startAngleRad;
point.shapeType = 'path';
point.shapeArgs = {
d: series.polarArc(y + height, y, start, start + point.pointWidth)
};
} else {
shapeArgs.height = height;
shapeArgs.y = y;
point.tooltipPos = chart.inverted ? [
yAxis.len + yAxis.pos - chart.plotLeft - y - height / 2,
xAxis.len + xAxis.pos - chart.plotTop - shapeArgs.x -
shapeArgs.width / 2,
height
] : [
xAxis.left - chart.plotLeft + shapeArgs.x +
shapeArgs.width / 2,
yAxis.pos - chart.plotTop + y + height / 2,
height
]; // don't inherit from column tooltip position - #3372
}
});
},
directTouch: true,
trackerGroups: ['group', 'dataLabelsGroup'],
drawGraph: noop,
crispCol: colProto.crispCol,
drawPoints: colProto.drawPoints,
drawTracker: colProto.drawTracker,
getColumnMetrics: colProto.getColumnMetrics,
animate: function() {
return colProto.animate.apply(this, arguments);
},
polarArc: function() {
return colProto.polarArc.apply(this, arguments);
},
pointAttribs: colProto.pointAttribs
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var each = H.each,
isNumber = H.isNumber,
merge = H.merge,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
Series = H.Series,
seriesType = H.seriesType,
TrackerMixin = H.TrackerMixin;
/*
* The GaugeSeries class
*/
seriesType('gauge', 'line', {
dataLabels: {
enabled: true,
defer: false,
y: 15,
borderRadius: 3,
crop: false,
verticalAlign: 'top',
zIndex: 2,
// Presentational
borderWidth: 1,
borderColor: '#cccccc'
},
dial: {
// radius: '80%',
// baseWidth: 3,
// topWidth: 1,
// baseLength: '70%' // of radius
// rearLength: '10%'
// backgroundColor: '#000000',
// borderColor: '#cccccc',
// borderWidth: 0
},
pivot: {
//radius: 5,
//borderWidth: 0
//borderColor: '#cccccc',
//backgroundColor: '#000000'
},
tooltip: {
headerFormat: ''
},
showInLegend: false
// Prototype members
}, {
// chart.angular will be set to true when a gauge series is present, and this will
// be used on the axes
angular: true,
directTouch: true, // #5063
drawGraph: noop,
fixedBox: true,
forceDL: true,
noSharedTooltip: true,
trackerGroups: ['group', 'dataLabelsGroup'],
/**
* Calculate paths etc
*/
translate: function() {
var series = this,
yAxis = series.yAxis,
options = series.options,
center = yAxis.center;
series.generatePoints();
each(series.points, function(point) {
var dialOptions = merge(options.dial, point.dial),
radius = (pInt(pick(dialOptions.radius, 80)) * center[2]) / 200,
baseLength = (pInt(pick(dialOptions.baseLength, 70)) * radius) / 100,
rearLength = (pInt(pick(dialOptions.rearLength, 10)) * radius) / 100,
baseWidth = dialOptions.baseWidth || 3,
topWidth = dialOptions.topWidth || 1,
overshoot = options.overshoot,
rotation = yAxis.startAngleRad + yAxis.translate(point.y, null, null, null, true);
// Handle the wrap and overshoot options
if (isNumber(overshoot)) {
overshoot = overshoot / 180 * Math.PI;
rotation = Math.max(yAxis.startAngleRad - overshoot, Math.min(yAxis.endAngleRad + overshoot, rotation));
} else if (options.wrap === false) {
rotation = Math.max(yAxis.startAngleRad, Math.min(yAxis.endAngleRad, rotation));
}
rotation = rotation * 180 / Math.PI;
point.shapeType = 'path';
point.shapeArgs = {
d: dialOptions.path || [
'M', -rearLength, -baseWidth / 2,
'L',
baseLength, -baseWidth / 2,
radius, -topWidth / 2,
radius, topWidth / 2,
baseLength, baseWidth / 2, -rearLength, baseWidth / 2,
'z'
],
translateX: center[0],
translateY: center[1],
rotation: rotation
};
// Positions for data label
point.plotX = center[0];
point.plotY = center[1];
});
},
/**
* Draw the points where each point is one needle
*/
drawPoints: function() {
var series = this,
center = series.yAxis.center,
pivot = series.pivot,
options = series.options,
pivotOptions = options.pivot,
renderer = series.chart.renderer;
each(series.points, function(point) {
var graphic = point.graphic,
shapeArgs = point.shapeArgs,
d = shapeArgs.d,
dialOptions = merge(options.dial, point.dial); // #1233
if (graphic) {
graphic.animate(shapeArgs);
shapeArgs.d = d; // animate alters it
} else {
point.graphic = renderer[point.shapeType](shapeArgs)
.attr({
rotation: shapeArgs.rotation, // required by VML when animation is false
zIndex: 1
})
.addClass('highcharts-dial')
.add(series.group);
// Presentational attributes
point.graphic.attr({
stroke: dialOptions.borderColor || 'none',
'stroke-width': dialOptions.borderWidth || 0,
fill: dialOptions.backgroundColor || '#000000'
});
}
});
// Add or move the pivot
if (pivot) {
pivot.animate({ // #1235
translateX: center[0],
translateY: center[1]
});
} else {
series.pivot = renderer.circle(0, 0, pick(pivotOptions.radius, 5))
.attr({
zIndex: 2
})
.addClass('highcharts-pivot')
.translate(center[0], center[1])
.add(series.group);
// Presentational attributes
series.pivot.attr({
'stroke-width': pivotOptions.borderWidth || 0,
stroke: pivotOptions.borderColor || '#cccccc',
fill: pivotOptions.backgroundColor || '#000000'
});
}
},
/**
* Animate the arrow up from startAngle
*/
animate: function(init) {
var series = this;
if (!init) {
each(series.points, function(point) {
var graphic = point.graphic;
if (graphic) {
// start value
graphic.attr({
rotation: series.yAxis.startAngleRad * 180 / Math.PI
});
// animate
graphic.animate({
rotation: point.shapeArgs.rotation
}, series.options.animation);
}
});
// delete this function to allow it only once
series.animate = null;
}
},
render: function() {
this.group = this.plotGroup(
'group',
'series',
this.visible ? 'visible' : 'hidden',
this.options.zIndex,
this.chart.seriesGroup
);
Series.prototype.render.call(this);
this.group.clip(this.chart.clipRect);
},
/**
* Extend the basic setData method by running processData and generatePoints immediately,
* in order to access the points from the legend.
*/
setData: function(data, redraw) {
Series.prototype.setData.call(this, data, false);
this.processData();
this.generatePoints();
if (pick(redraw, true)) {
this.chart.redraw();
}
},
/**
* If the tracking module is loaded, add the point tracker
*/
drawTracker: TrackerMixin && TrackerMixin.drawTrackerPoint
// Point members
}, {
/**
* Don't do any hover colors or anything
*/
setState: function(state) {
this.state = state;
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var each = H.each,
noop = H.noop,
pick = H.pick,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/**
* The boxplot series type.
*
* @constructor seriesTypes.boxplot
* @augments seriesTypes.column
*/
seriesType('boxplot', 'column', {
threshold: null,
tooltip: {
pointFormat: '<span style="color:{point.color}">\u25CF</span> <b> {series.name}</b><br/>' + // eslint-disable-line no-dupe-keys
'Maximum: {point.high}<br/>' +
'Upper quartile: {point.q3}<br/>' +
'Median: {point.median}<br/>' +
'Lower quartile: {point.q1}<br/>' +
'Minimum: {point.low}<br/>'
},
whiskerLength: '50%',
fillColor: '#ffffff',
lineWidth: 1,
//medianColor: null,
medianWidth: 2,
states: {
hover: {
brightness: -0.3
}
},
//stemColor: null,
//stemDashStyle: 'solid'
//stemWidth: null,
//whiskerColor: null,
whiskerWidth: 2
}, /** @lends seriesTypes.boxplot */ {
pointArrayMap: ['low', 'q1', 'median', 'q3', 'high'], // array point configs are mapped to this
toYData: function(point) { // return a plain array for speedy calculation
return [point.low, point.q1, point.median, point.q3, point.high];
},
pointValKey: 'high', // defines the top of the tracker
/**
* Get presentational attributes
*/
pointAttribs: function(point) {
var options = this.options,
color = (point && point.color) || this.color;
return {
'fill': point.fillColor || options.fillColor || color,
'stroke': options.lineColor || color,
'stroke-width': options.lineWidth || 0
};
},
/**
* Disable data labels for box plot
*/
drawDataLabels: noop,
/**
* Translate data points from raw values x and y to plotX and plotY
*/
translate: function() {
var series = this,
yAxis = series.yAxis,
pointArrayMap = series.pointArrayMap;
seriesTypes.column.prototype.translate.apply(series);
// do the translation on each point dimension
each(series.points, function(point) {
each(pointArrayMap, function(key) {
if (point[key] !== null) {
point[key + 'Plot'] = yAxis.translate(point[key], 0, 1, 0, 1);
}
});
});
},
/**
* Draw the data points
*/
drawPoints: function() {
var series = this, //state = series.state,
points = series.points,
options = series.options,
chart = series.chart,
renderer = chart.renderer,
q1Plot,
q3Plot,
highPlot,
lowPlot,
medianPlot,
medianPath,
crispCorr,
crispX = 0,
boxPath,
width,
left,
right,
halfWidth,
doQuartiles = series.doQuartiles !== false, // error bar inherits this series type but doesn't do quartiles
pointWiskerLength,
whiskerLength = series.options.whiskerLength;
each(points, function(point) {
var graphic = point.graphic,
verb = graphic ? 'animate' : 'attr',
shapeArgs = point.shapeArgs; // the box
var boxAttr,
stemAttr = {},
whiskersAttr = {},
medianAttr = {},
color = point.color || series.color;
if (point.plotY !== undefined) {
// crisp vector coordinates
width = shapeArgs.width;
left = Math.floor(shapeArgs.x);
right = left + width;
halfWidth = Math.round(width / 2);
q1Plot = Math.floor(doQuartiles ? point.q1Plot : point.lowPlot);
q3Plot = Math.floor(doQuartiles ? point.q3Plot : point.lowPlot);
highPlot = Math.floor(point.highPlot);
lowPlot = Math.floor(point.lowPlot);
if (!graphic) {
point.graphic = graphic = renderer.g('point')
.add(series.group);
point.stem = renderer.path()
.addClass('highcharts-boxplot-stem')
.add(graphic);
if (whiskerLength) {
point.whiskers = renderer.path()
.addClass('highcharts-boxplot-whisker')
.add(graphic);
}
if (doQuartiles) {
point.box = renderer.path(boxPath)
.addClass('highcharts-boxplot-box')
.add(graphic);
}
point.medianShape = renderer.path(medianPath)
.addClass('highcharts-boxplot-median')
.add(graphic);
}
// Stem attributes
stemAttr.stroke = point.stemColor || options.stemColor || color;
stemAttr['stroke-width'] = pick(point.stemWidth, options.stemWidth, options.lineWidth);
stemAttr.dashstyle = point.stemDashStyle || options.stemDashStyle;
point.stem.attr(stemAttr);
// Whiskers attributes
if (whiskerLength) {
whiskersAttr.stroke = point.whiskerColor || options.whiskerColor || color;
whiskersAttr['stroke-width'] = pick(point.whiskerWidth, options.whiskerWidth, options.lineWidth);
point.whiskers.attr(whiskersAttr);
}
if (doQuartiles) {
boxAttr = series.pointAttribs(point);
point.box.attr(boxAttr);
}
// Median attributes
medianAttr.stroke = point.medianColor || options.medianColor || color;
medianAttr['stroke-width'] = pick(point.medianWidth, options.medianWidth, options.lineWidth);
point.medianShape.attr(medianAttr);
// The stem
crispCorr = (point.stem.strokeWidth() % 2) / 2;
crispX = left + halfWidth + crispCorr;
point.stem[verb]({
d: [
// stem up
'M',
crispX, q3Plot,
'L',
crispX, highPlot,
// stem down
'M',
crispX, q1Plot,
'L',
crispX, lowPlot
]
});
// The box
if (doQuartiles) {
crispCorr = (point.box.strokeWidth() % 2) / 2;
q1Plot = Math.floor(q1Plot) + crispCorr;
q3Plot = Math.floor(q3Plot) + crispCorr;
left += crispCorr;
right += crispCorr;
point.box[verb]({
d: [
'M',
left, q3Plot,
'L',
left, q1Plot,
'L',
right, q1Plot,
'L',
right, q3Plot,
'L',
left, q3Plot,
'z'
]
});
}
// The whiskers
if (whiskerLength) {
crispCorr = (point.whiskers.strokeWidth() % 2) / 2;
highPlot = highPlot + crispCorr;
lowPlot = lowPlot + crispCorr;
pointWiskerLength = (/%$/).test(whiskerLength) ? halfWidth * parseFloat(whiskerLength) / 100 : whiskerLength / 2;
point.whiskers[verb]({
d: [
// High whisker
'M',
crispX - pointWiskerLength,
highPlot,
'L',
crispX + pointWiskerLength,
highPlot,
// Low whisker
'M',
crispX - pointWiskerLength,
lowPlot,
'L',
crispX + pointWiskerLength,
lowPlot
]
});
}
// The median
medianPlot = Math.round(point.medianPlot);
crispCorr = (point.medianShape.strokeWidth() % 2) / 2;
medianPlot = medianPlot + crispCorr;
point.medianShape[verb]({
d: [
'M',
left,
medianPlot,
'L',
right,
medianPlot
]
});
}
});
},
setStackedPoints: noop // #3890
});
/* ****************************************************************************
* End Box plot series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var each = H.each,
noop = H.noop,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/* ****************************************************************************
* Start error bar series code *
*****************************************************************************/
seriesType('errorbar', 'boxplot', {
color: '#000000',
grouping: false,
linkedTo: ':previous',
tooltip: {
pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'
},
whiskerWidth: null
// Prototype members
}, {
type: 'errorbar',
pointArrayMap: ['low', 'high'], // array point configs are mapped to this
toYData: function(point) { // return a plain array for speedy calculation
return [point.low, point.high];
},
pointValKey: 'high', // defines the top of the tracker
doQuartiles: false,
drawDataLabels: seriesTypes.arearange ? function() {
var valKey = this.pointValKey;
seriesTypes.arearange.prototype.drawDataLabels.call(this);
// Arearange drawDataLabels does not reset point.y to high, but to low after drawing. #4133
each(this.data, function(point) {
point.y = point[valKey];
});
} : noop,
/**
* Get the width and X offset, either on top of the linked series column
* or standalone
*/
getColumnMetrics: function() {
return (this.linkedParent && this.linkedParent.columnMetrics) ||
seriesTypes.column.prototype.getColumnMetrics.call(this);
}
});
/* ****************************************************************************
* End error bar series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var correctFloat = H.correctFloat,
isNumber = H.isNumber,
pick = H.pick,
Point = H.Point,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/* ****************************************************************************
* Start Waterfall series code *
*****************************************************************************/
seriesType('waterfall', 'column', {
dataLabels: {
inside: true
},
lineWidth: 1,
lineColor: '#333333',
dashStyle: 'dot',
borderColor: '#333333',
states: {
hover: {
lineWidthPlus: 0 // #3126
}
}
// Prototype members
}, {
pointValKey: 'y',
/**
* Translate data points from raw values
*/
translate: function() {
var series = this,
options = series.options,
yAxis = series.yAxis,
len,
i,
points,
point,
shapeArgs,
stack,
y,
yValue,
previousY,
previousIntermediate,
range,
minPointLength = pick(options.minPointLength, 5),
halfMinPointLength = minPointLength / 2,
threshold = options.threshold,
stacking = options.stacking,
stackIndicator,
tooltipY;
// run column series translate
seriesTypes.column.prototype.translate.apply(series);
previousY = previousIntermediate = threshold;
points = series.points;
for (i = 0, len = points.length; i < len; i++) {
// cache current point object
point = points[i];
yValue = series.processedYData[i];
shapeArgs = point.shapeArgs;
// get current stack
stack = stacking && yAxis.stacks[(series.negStacks && yValue < threshold ? '-' : '') + series.stackKey];
stackIndicator = series.getStackIndicator(
stackIndicator,
point.x,
series.index
);
range = stack ?
stack[point.x].points[stackIndicator.key] : [0, yValue];
// override point value for sums
// #3710 Update point does not propagate to sum
if (point.isSum) {
point.y = correctFloat(yValue);
} else if (point.isIntermediateSum) {
point.y = correctFloat(yValue - previousIntermediate); // #3840
}
// up points
y = Math.max(previousY, previousY + point.y) + range[0];
shapeArgs.y = yAxis.toPixels(y, true);
// sum points
if (point.isSum) {
shapeArgs.y = yAxis.toPixels(range[1], true);
shapeArgs.height = Math.min(yAxis.toPixels(range[0], true), yAxis.len) -
shapeArgs.y; // #4256
} else if (point.isIntermediateSum) {
shapeArgs.y = yAxis.toPixels(range[1], true);
shapeArgs.height = Math.min(yAxis.toPixels(previousIntermediate, true), yAxis.len) -
shapeArgs.y;
previousIntermediate = range[1];
// If it's not the sum point, update previous stack end position and get
// shape height (#3886)
} else {
shapeArgs.height = yValue > 0 ?
yAxis.toPixels(previousY, true) - shapeArgs.y :
yAxis.toPixels(previousY, true) - yAxis.toPixels(previousY - yValue, true);
previousY += stack && stack[point.x] ? stack[point.x].total : yValue;
}
// #3952 Negative sum or intermediate sum not rendered correctly
if (shapeArgs.height < 0) {
shapeArgs.y += shapeArgs.height;
shapeArgs.height *= -1;
}
point.plotY = shapeArgs.y = Math.round(shapeArgs.y) - (series.borderWidth % 2) / 2;
shapeArgs.height = Math.max(Math.round(shapeArgs.height), 0.001); // #3151
point.yBottom = shapeArgs.y + shapeArgs.height;
if (shapeArgs.height <= minPointLength && !point.isNull) {
shapeArgs.height = minPointLength;
shapeArgs.y -= halfMinPointLength;
point.plotY = shapeArgs.y;
if (point.y < 0) {
point.minPointLengthOffset = -halfMinPointLength;
} else {
point.minPointLengthOffset = halfMinPointLength;
}
} else {
point.minPointLengthOffset = 0;
}
// Correct tooltip placement (#3014)
tooltipY = point.plotY + (point.negative ? shapeArgs.height : 0);
if (series.chart.inverted) {
point.tooltipPos[0] = yAxis.len - tooltipY;
} else {
point.tooltipPos[1] = tooltipY;
}
}
},
/**
* Call default processData then override yData to reflect waterfall's extremes on yAxis
*/
processData: function(force) {
var series = this,
options = series.options,
yData = series.yData,
points = series.options.data, // #3710 Update point does not propagate to sum
point,
dataLength = yData.length,
threshold = options.threshold || 0,
subSum,
sum,
dataMin,
dataMax,
y,
i;
sum = subSum = dataMin = dataMax = threshold;
for (i = 0; i < dataLength; i++) {
y = yData[i];
point = points && points[i] ? points[i] : {};
if (y === 'sum' || point.isSum) {
yData[i] = correctFloat(sum);
} else if (y === 'intermediateSum' || point.isIntermediateSum) {
yData[i] = correctFloat(subSum);
} else {
sum += y;
subSum += y;
}
dataMin = Math.min(sum, dataMin);
dataMax = Math.max(sum, dataMax);
}
Series.prototype.processData.call(this, force);
// Record extremes only if stacking was not set:
if (!series.options.stacking) {
series.dataMin = dataMin;
series.dataMax = dataMax;
}
},
/**
* Return y value or string if point is sum
*/
toYData: function(pt) {
if (pt.isSum) {
return (pt.x === 0 ? null : 'sum'); //#3245 Error when first element is Sum or Intermediate Sum
}
if (pt.isIntermediateSum) {
return (pt.x === 0 ? null : 'intermediateSum'); //#3245
}
return pt.y;
},
/**
* Postprocess mapping between options and SVG attributes
*/
pointAttribs: function(point, state) {
var upColor = this.options.upColor,
attr;
// Set or reset up color (#3710, update to negative)
if (upColor && !point.options.color) {
point.color = point.y > 0 ? upColor : null;
}
attr = seriesTypes.column.prototype.pointAttribs.call(this, point, state);
// The dashStyle option in waterfall applies to the graph, not
// the points
delete attr.dashstyle;
return attr;
},
/**
* Return an empty path initially, because we need to know the stroke-width in order
* to set the final path.
*/
getGraphPath: function() {
return ['M', 0, 0];
},
/**
* Draw columns' connector lines
*/
getCrispPath: function() {
var data = this.data,
length = data.length,
lineWidth = this.graph.strokeWidth() + this.borderWidth,
normalizer = Math.round(lineWidth) % 2 / 2,
path = [],
prevArgs,
pointArgs,
i,
d;
for (i = 1; i < length; i++) {
pointArgs = data[i].shapeArgs;
prevArgs = data[i - 1].shapeArgs;
d = [
'M',
prevArgs.x + prevArgs.width,
prevArgs.y + data[i - 1].minPointLengthOffset + normalizer,
'L',
pointArgs.x,
prevArgs.y + data[i - 1].minPointLengthOffset + normalizer
];
if (data[i - 1].y < 0) {
d[2] += prevArgs.height;
d[5] += prevArgs.height;
}
path = path.concat(d);
}
return path;
},
/**
* The graph is initally drawn with an empty definition, then updated with
* crisp rendering.
*/
drawGraph: function() {
Series.prototype.drawGraph.call(this);
this.graph.attr({
d: this.getCrispPath()
});
},
/**
* Waterfall has stacking along the x-values too.
*/
setStackedPoints: function() {
var series = this,
options = series.options,
stackedYLength,
i;
Series.prototype.setStackedPoints.apply(series, arguments);
stackedYLength = series.stackedYData ? series.stackedYData.length : 0;
// Start from the second point:
for (i = 1; i < stackedYLength; i++) {
if (!options.data[i].isSum &&
!options.data[i].isIntermediateSum
) {
// Sum previous stacked data as waterfall can grow up/down:
series.stackedYData[i] += series.stackedYData[i - 1];
}
}
},
/**
* Extremes for a non-stacked series are recorded in processData.
* In case of stacking, use Series.stackedYData to calculate extremes.
*/
getExtremes: function() {
if (this.options.stacking) {
return Series.prototype.getExtremes.apply(this, arguments);
}
}
// Point members
}, {
getClassName: function() {
var className = Point.prototype.getClassName.call(this);
if (this.isSum) {
className += ' highcharts-sum';
} else if (this.isIntermediateSum) {
className += ' highcharts-intermediate-sum';
}
return className;
},
/**
* Pass the null test in ColumnSeries.translate.
*/
isValid: function() {
return isNumber(this.y, true) || this.isSum || this.isIntermediateSum;
}
});
/* ****************************************************************************
* End Waterfall series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var LegendSymbolMixin = H.LegendSymbolMixin,
noop = H.noop,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/**
* The polygon series prototype
*/
seriesType('polygon', 'scatter', {
marker: {
enabled: false,
states: {
hover: {
enabled: false
}
}
},
stickyTracking: false,
tooltip: {
followPointer: true,
pointFormat: ''
},
trackByArea: true
// Prototype members
}, {
type: 'polygon',
getGraphPath: function() {
var graphPath = Series.prototype.getGraphPath.call(this),
i = graphPath.length + 1;
// Close all segments
while (i--) {
if ((i === graphPath.length || graphPath[i] === 'M') && i > 0) {
graphPath.splice(i, 0, 'z');
}
}
this.areaPath = graphPath;
return graphPath;
},
drawGraph: function() {
this.options.fillColor = this.color; // Hack into the fill logic in area.drawGraph
seriesTypes.area.prototype.drawGraph.call(this);
},
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
drawTracker: Series.prototype.drawTracker,
setStackedPoints: noop // No stacking points on polygons (#5310)
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
Axis = H.Axis,
color = H.color,
each = H.each,
isNumber = H.isNumber,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
Point = H.Point,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/* ****************************************************************************
* Start Bubble series code *
*****************************************************************************/
seriesType('bubble', 'scatter', {
dataLabels: {
formatter: function() { // #2945
return this.point.z;
},
inside: true,
verticalAlign: 'middle'
},
// displayNegative: true,
marker: {
// fillOpacity: 0.5,
lineColor: null, // inherit from series.color
lineWidth: 1,
// Avoid offset in Point.setState
radius: null,
states: {
hover: {
radiusPlus: 0
}
},
symbol: 'circle'
},
minSize: 8,
maxSize: '20%',
// negativeColor: null,
// sizeBy: 'area'
softThreshold: false,
states: {
hover: {
halo: {
size: 5
}
}
},
tooltip: {
pointFormat: '({point.x}, {point.y}), Size: {point.z}'
},
turboThreshold: 0,
zThreshold: 0,
zoneAxis: 'z'
// Prototype members
}, {
pointArrayMap: ['y', 'z'],
parallelArrays: ['x', 'y', 'z'],
trackerGroups: ['markerGroup', 'dataLabelsGroup'],
bubblePadding: true,
zoneAxis: 'z',
directTouch: true,
pointAttribs: function(point, state) {
var markerOptions = this.options.marker,
fillOpacity = pick(markerOptions.fillOpacity, 0.5),
attr = Series.prototype.pointAttribs.call(this, point, state);
if (fillOpacity !== 1) {
attr.fill = color(attr.fill).setOpacity(fillOpacity).get('rgba');
}
return attr;
},
/**
* Get the radius for each point based on the minSize, maxSize and each point's Z value. This
* must be done prior to Series.translate because the axis needs to add padding in
* accordance with the point sizes.
*/
getRadii: function(zMin, zMax, minSize, maxSize) {
var len,
i,
pos,
zData = this.zData,
radii = [],
options = this.options,
sizeByArea = options.sizeBy !== 'width',
zThreshold = options.zThreshold,
zRange = zMax - zMin,
value,
radius;
// Set the shape type and arguments to be picked up in drawPoints
for (i = 0, len = zData.length; i < len; i++) {
value = zData[i];
// When sizing by threshold, the absolute value of z determines the size
// of the bubble.
if (options.sizeByAbsoluteValue && value !== null) {
value = Math.abs(value - zThreshold);
zMax = Math.max(zMax - zThreshold, Math.abs(zMin - zThreshold));
zMin = 0;
}
if (value === null) {
radius = null;
// Issue #4419 - if value is less than zMin, push a radius that's always smaller than the minimum size
} else if (value < zMin) {
radius = minSize / 2 - 1;
} else {
// Relative size, a number between 0 and 1
pos = zRange > 0 ? (value - zMin) / zRange : 0.5;
if (sizeByArea && pos >= 0) {
pos = Math.sqrt(pos);
}
radius = Math.ceil(minSize + pos * (maxSize - minSize)) / 2;
}
radii.push(radius);
}
this.radii = radii;
},
/**
* Perform animation on the bubbles
*/
animate: function(init) {
var animation = this.options.animation;
if (!init) { // run the animation
each(this.points, function(point) {
var graphic = point.graphic,
animationTarget;
if (graphic && graphic.width) { // URL symbols don't have width
animationTarget = {
x: graphic.x,
y: graphic.y,
width: graphic.width,
height: graphic.height
};
// Start values
graphic.attr({
x: point.plotX,
y: point.plotY,
width: 1,
height: 1
});
// Run animation
graphic.animate(animationTarget, animation);
}
});
// delete this function to allow it only once
this.animate = null;
}
},
/**
* Extend the base translate method to handle bubble size
*/
translate: function() {
var i,
data = this.data,
point,
radius,
radii = this.radii;
// Run the parent method
seriesTypes.scatter.prototype.translate.call(this);
// Set the shape type and arguments to be picked up in drawPoints
i = data.length;
while (i--) {
point = data[i];
radius = radii ? radii[i] : 0; // #1737
if (isNumber(radius) && radius >= this.minPxSize / 2) {
// Shape arguments
point.marker = H.extend(point.marker, {
radius: radius,
width: 2 * radius,
height: 2 * radius
});
// Alignment box for the data label
point.dlBox = {
x: point.plotX - radius,
y: point.plotY - radius,
width: 2 * radius,
height: 2 * radius
};
} else { // below zThreshold
point.shapeArgs = point.plotY = point.dlBox = undefined; // #1691
}
}
},
alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
buildKDTree: noop,
applyZones: noop
// Point class
}, {
haloPath: function(size) {
return Point.prototype.haloPath.call(
this,
size === 0 ? 0 : (this.marker ? this.marker.radius || 0 : 0) + size // #6067
);
},
ttBelow: false
});
/**
* Add logic to pad each axis with the amount of pixels
* necessary to avoid the bubbles to overflow.
*/
Axis.prototype.beforePadding = function() {
var axis = this,
axisLength = this.len,
chart = this.chart,
pxMin = 0,
pxMax = axisLength,
isXAxis = this.isXAxis,
dataKey = isXAxis ? 'xData' : 'yData',
min = this.min,
extremes = {},
smallestSize = Math.min(chart.plotWidth, chart.plotHeight),
zMin = Number.MAX_VALUE,
zMax = -Number.MAX_VALUE,
range = this.max - min,
transA = axisLength / range,
activeSeries = [];
// Handle padding on the second pass, or on redraw
each(this.series, function(series) {
var seriesOptions = series.options,
zData;
if (series.bubblePadding && (series.visible || !chart.options.chart.ignoreHiddenSeries)) {
// Correction for #1673
axis.allowZoomOutside = true;
// Cache it
activeSeries.push(series);
if (isXAxis) { // because X axis is evaluated first
// For each series, translate the size extremes to pixel values
each(['minSize', 'maxSize'], function(prop) {
var length = seriesOptions[prop],
isPercent = /%$/.test(length);
length = pInt(length);
extremes[prop] = isPercent ?
smallestSize * length / 100 :
length;
});
series.minPxSize = extremes.minSize;
// Prioritize min size if conflict to make sure bubbles are
// always visible. #5873
series.maxPxSize = Math.max(extremes.maxSize, extremes.minSize);
// Find the min and max Z
zData = series.zData;
if (zData.length) { // #1735
zMin = pick(seriesOptions.zMin, Math.min(
zMin,
Math.max(
arrayMin(zData),
seriesOptions.displayNegative === false ? seriesOptions.zThreshold : -Number.MAX_VALUE
)
));
zMax = pick(seriesOptions.zMax, Math.max(zMax, arrayMax(zData)));
}
}
}
});
each(activeSeries, function(series) {
var data = series[dataKey],
i = data.length,
radius;
if (isXAxis) {
series.getRadii(zMin, zMax, series.minPxSize, series.maxPxSize);
}
if (range > 0) {
while (i--) {
if (isNumber(data[i]) && axis.dataMin <= data[i] && data[i] <= axis.dataMax) {
radius = series.radii[i];
pxMin = Math.min(((data[i] - min) * transA) - radius, pxMin);
pxMax = Math.max(((data[i] - min) * transA) + radius, pxMax);
}
}
}
});
if (activeSeries.length && range > 0 && !this.isLog) {
pxMax -= axisLength;
transA *= (axisLength + pxMin - pxMax) / axisLength;
each([
['min', 'userMin', pxMin],
['max', 'userMax', pxMax]
], function(keys) {
if (pick(axis.options[keys[0]], axis[keys[1]]) === undefined) {
axis[keys[0]] += keys[2] / transA;
}
});
}
};
/* ****************************************************************************
* End Bubble series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/**
* Extensions for polar charts. Additionally, much of the geometry required for polar charts is
* gathered in RadialAxes.js.
*
*/
var each = H.each,
pick = H.pick,
Pointer = H.Pointer,
Series = H.Series,
seriesTypes = H.seriesTypes,
wrap = H.wrap,
seriesProto = Series.prototype,
pointerProto = Pointer.prototype,
colProto;
/**
* Search a k-d tree by the point angle, used for shared tooltips in polar charts
*/
seriesProto.searchPointByAngle = function(e) {
var series = this,
chart = series.chart,
xAxis = series.xAxis,
center = xAxis.pane.center,
plotX = e.chartX - center[0] - chart.plotLeft,
plotY = e.chartY - center[1] - chart.plotTop;
return this.searchKDTree({
clientX: 180 + (Math.atan2(plotX, plotY) * (-180 / Math.PI))
});
};
/**
* #6212 Calculate connectors for spline series in polar chart.
* @param {Boolean} calculateNeighbours - Check if connectors should be calculated for neighbour points as well
* allows short recurence
*/
seriesProto.getConnectors = function(segment, index, calculateNeighbours, connectEnds) {
var i,
prevPointInd,
nextPointInd,
previousPoint,
nextPoint,
previousX,
previousY,
nextX,
nextY,
plotX,
plotY,
ret,
smoothing = 1.5, // 1 means control points midway between points, 2 means 1/3 from the point, 3 is 1/4 etc;
denom = smoothing + 1,
leftContX,
leftContY,
rightContX,
rightContY,
dLControlPoint, //distance left control point
dRControlPoint,
leftContAngle,
rightContAngle,
jointAngle,
addedNumber = connectEnds ? 1 : 0;
/** calculate final index of points depending on the initial index value.
* Because of calculating neighbours, index may be outisde segment array.
*/
if (index >= 0 && index <= segment.length - 1) {
i = index;
} else if (index < 0) {
i = segment.length - 1 + index;
} else {
i = 0;
}
prevPointInd = (i - 1 < 0) ? segment.length - (1 + addedNumber) : i - 1;
nextPointInd = (i + 1 > segment.length - 1) ? addedNumber : i + 1;
previousPoint = segment[prevPointInd];
nextPoint = segment[nextPointInd];
previousX = previousPoint.plotX;
previousY = previousPoint.plotY;
nextX = nextPoint.plotX;
nextY = nextPoint.plotY;
plotX = segment[i].plotX; // actual point
plotY = segment[i].plotY;
leftContX = (smoothing * plotX + previousX) / denom;
leftContY = (smoothing * plotY + previousY) / denom;
rightContX = (smoothing * plotX + nextX) / denom;
rightContY = (smoothing * plotY + nextY) / denom;
dLControlPoint = Math.sqrt(Math.pow(leftContX - plotX, 2) + Math.pow(leftContY - plotY, 2));
dRControlPoint = Math.sqrt(Math.pow(rightContX - plotX, 2) + Math.pow(rightContY - plotY, 2));
leftContAngle = Math.atan2(leftContY - plotY, leftContX - plotX);
rightContAngle = Math.atan2(rightContY - plotY, rightContX - plotX);
jointAngle = (Math.PI / 2) + ((leftContAngle + rightContAngle) / 2);
// Ensure the right direction, jointAngle should be in the same quadrant as leftContAngle
if (Math.abs(leftContAngle - jointAngle) > Math.PI / 2) {
jointAngle -= Math.PI;
}
// Find the corrected control points for a spline straight through the point
leftContX = plotX + Math.cos(jointAngle) * dLControlPoint;
leftContY = plotY + Math.sin(jointAngle) * dLControlPoint;
rightContX = plotX + Math.cos(Math.PI + jointAngle) * dRControlPoint;
rightContY = plotY + Math.sin(Math.PI + jointAngle) * dRControlPoint;
// push current point's connectors into returned object
ret = {
rightContX: rightContX,
rightContY: rightContY,
leftContX: leftContX,
leftContY: leftContY,
plotX: plotX,
plotY: plotY
};
// calculate connectors for previous and next point and push them inside returned object
if (calculateNeighbours) {
ret.prevPointCont = this.getConnectors(segment, prevPointInd, false, connectEnds);
}
return ret;
};
/**
* Wrap the buildKDTree function so that it searches by angle (clientX) in case of shared tooltip,
* and by two dimensional distance in case of non-shared.
*/
wrap(seriesProto, 'buildKDTree', function(proceed) {
if (this.chart.polar) {
if (this.kdByAngle) {
this.searchPoint = this.searchPointByAngle;
} else {
this.options.findNearestPointBy = 'xy';
}
}
proceed.apply(this);
});
/**
* Translate a point's plotX and plotY from the internal angle and radius measures to
* true plotX, plotY coordinates
*/
seriesProto.toXY = function(point) {
var xy,
chart = this.chart,
plotX = point.plotX,
plotY = point.plotY,
clientX;
// Save rectangular plotX, plotY for later computation
point.rectPlotX = plotX;
point.rectPlotY = plotY;
// Find the polar plotX and plotY
xy = this.xAxis.postTranslate(point.plotX, this.yAxis.len - plotY);
point.plotX = point.polarPlotX = xy.x - chart.plotLeft;
point.plotY = point.polarPlotY = xy.y - chart.plotTop;
// If shared tooltip, record the angle in degrees in order to align X points. Otherwise,
// use a standard k-d tree to get the nearest point in two dimensions.
if (this.kdByAngle) {
clientX = ((plotX / Math.PI * 180) + this.xAxis.pane.options.startAngle) % 360;
if (clientX < 0) { // #2665
clientX += 360;
}
point.clientX = clientX;
} else {
point.clientX = point.plotX;
}
};
if (seriesTypes.spline) {
/**
* Overridden method for calculating a spline from one point to the next
*/
wrap(seriesTypes.spline.prototype, 'getPointSpline', function(proceed, segment, point, i) {
var ret,
connectors;
if (this.chart.polar) {
// moveTo or lineTo
if (!i) {
ret = ['M', point.plotX, point.plotY];
} else { // curve from last point to this
connectors = this.getConnectors(segment, i, true, this.connectEnds);
ret = [
'C',
connectors.prevPointCont.rightContX,
connectors.prevPointCont.rightContY,
connectors.leftContX,
connectors.leftContY,
connectors.plotX,
connectors.plotY
];
}
} else {
ret = proceed.call(this, segment, point, i);
}
return ret;
});
// #6430 Areasplinerange series use unwrapped getPointSpline method, so we need to set this method again.
if (seriesTypes.areasplinerange) {
seriesTypes.areasplinerange.prototype.getPointSpline = seriesTypes.spline.prototype.getPointSpline;
}
}
/**
* Extend translate. The plotX and plotY values are computed as if the polar chart were a
* cartesian plane, where plotX denotes the angle in radians and (yAxis.len - plotY) is the pixel distance from
* center.
*/
wrap(seriesProto, 'translate', function(proceed) {
var chart = this.chart,
points,
i;
// Run uber method
proceed.call(this);
// Postprocess plot coordinates
if (chart.polar) {
this.kdByAngle = chart.tooltip && chart.tooltip.shared;
if (!this.preventPostTranslate) {
points = this.points;
i = points.length;
while (i--) {
// Translate plotX, plotY from angle and radius to true plot coordinates
this.toXY(points[i]);
}
}
}
});
/**
* Extend getSegmentPath to allow connecting ends across 0 to provide a closed circle in
* line-like series.
*/
wrap(seriesProto, 'getGraphPath', function(proceed, points) {
var series = this,
i,
firstValid,
popLastPoint;
// Connect the path
if (this.chart.polar) {
points = points || this.points;
// Append first valid point in order to connect the ends
for (i = 0; i < points.length; i++) {
if (!points[i].isNull) {
firstValid = i;
break;
}
}
if (this.options.connectEnds !== false && firstValid !== undefined) {
this.connectEnds = true; // re-used in splines
points.splice(points.length, 0, points[firstValid]);
popLastPoint = true;
}
// For area charts, pseudo points are added to the graph, now we need to translate these
each(points, function(point) {
if (point.polarPlotY === undefined) {
series.toXY(point);
}
});
}
// Run uber method
var ret = proceed.apply(this, [].slice.call(arguments, 1));
/** #6212 points.splice method is adding points to an array. In case of areaspline getGraphPath method is used two times
* and in both times points are added to an array. That is why points.pop is used, to get unmodified points.
*/
if (popLastPoint) {
points.pop();
}
return ret;
});
function polarAnimate(proceed, init) {
var chart = this.chart,
animation = this.options.animation,
group = this.group,
markerGroup = this.markerGroup,
center = this.xAxis.center,
plotLeft = chart.plotLeft,
plotTop = chart.plotTop,
attribs;
// Specific animation for polar charts
if (chart.polar) {
// Enable animation on polar charts only in SVG. In VML, the scaling is different, plus animation
// would be so slow it would't matter.
if (chart.renderer.isSVG) {
if (animation === true) {
animation = {};
}
// Initialize the animation
if (init) {
// Scale down the group and place it in the center
attribs = {
translateX: center[0] + plotLeft,
translateY: center[1] + plotTop,
scaleX: 0.001, // #1499
scaleY: 0.001
};
group.attr(attribs);
if (markerGroup) {
//markerGroup.attrSetters = group.attrSetters;
markerGroup.attr(attribs);
}
// Run the animation
} else {
attribs = {
translateX: plotLeft,
translateY: plotTop,
scaleX: 1,
scaleY: 1
};
group.animate(attribs, animation);
if (markerGroup) {
markerGroup.animate(attribs, animation);
}
// Delete this function to allow it only once
this.animate = null;
}
}
// For non-polar charts, revert to the basic animation
} else {
proceed.call(this, init);
}
}
// Define the animate method for regular series
wrap(seriesProto, 'animate', polarAnimate);
if (seriesTypes.column) {
colProto = seriesTypes.column.prototype;
colProto.polarArc = function(low, high, start, end) {
var center = this.xAxis.center,
len = this.yAxis.len;
return this.chart.renderer.symbols.arc(
center[0],
center[1],
len - high,
null, {
start: start,
end: end,
innerR: len - pick(low, len)
}
);
};
/**
* Define the animate method for columnseries
*/
wrap(colProto, 'animate', polarAnimate);
/**
* Extend the column prototype's translate method
*/
wrap(colProto, 'translate', function(proceed) {
var xAxis = this.xAxis,
startAngleRad = xAxis.startAngleRad,
start,
points,
point,
i;
this.preventPostTranslate = true;
// Run uber method
proceed.call(this);
// Postprocess plot coordinates
if (xAxis.isRadial) {
points = this.points;
i = points.length;
while (i--) {
point = points[i];
start = point.barX + startAngleRad;
point.shapeType = 'path';
point.shapeArgs = {
d: this.polarArc(point.yBottom, point.plotY, start, start + point.pointWidth)
};
// Provide correct plotX, plotY for tooltip
this.toXY(point);
point.tooltipPos = [point.plotX, point.plotY];
point.ttBelow = point.plotY > xAxis.center[1];
}
}
});
/**
* Align column data labels outside the columns. #1199.
*/
wrap(colProto, 'alignDataLabel', function(proceed, point, dataLabel, options, alignTo, isNew) {
if (this.chart.polar) {
var angle = point.rectPlotX / Math.PI * 180,
align,
verticalAlign;
// Align nicely outside the perimeter of the columns
if (options.align === null) {
if (angle > 20 && angle < 160) {
align = 'left'; // right hemisphere
} else if (angle > 200 && angle < 340) {
align = 'right'; // left hemisphere
} else {
align = 'center'; // top or bottom
}
options.align = align;
}
if (options.verticalAlign === null) {
if (angle < 45 || angle > 315) {
verticalAlign = 'bottom'; // top part
} else if (angle > 135 && angle < 225) {
verticalAlign = 'top'; // bottom part
} else {
verticalAlign = 'middle'; // left or right
}
options.verticalAlign = verticalAlign;
}
seriesProto.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
} else {
proceed.call(this, point, dataLabel, options, alignTo, isNew);
}
});
}
/**
* Extend getCoordinates to prepare for polar axis values
*/
wrap(pointerProto, 'getCoordinates', function(proceed, e) {
var chart = this.chart,
ret = {
xAxis: [],
yAxis: []
};
if (chart.polar) {
each(chart.axes, function(axis) {
var isXAxis = axis.isXAxis,
center = axis.center,
x = e.chartX - center[0] - chart.plotLeft,
y = e.chartY - center[1] - chart.plotTop;
ret[isXAxis ? 'xAxis' : 'yAxis'].push({
axis: axis,
value: axis.translate(
isXAxis ?
Math.PI - Math.atan2(x, y) : // angle
Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)), // distance from center
true
)
});
});
} else {
ret = proceed.call(this, e);
}
return ret;
});
wrap(H.Chart.prototype, 'getAxes', function(proceed) {
if (!this.pane) {
this.pane = [];
}
each(H.splat(this.options.pane), function(paneOptions) {
new H.Pane( // eslint-disable-line no-new
paneOptions,
this
);
}, this);
proceed.call(this);
});
wrap(H.Chart.prototype, 'drawChartBox', function(proceed) {
proceed.call(this);
each(this.pane, function(pane) {
pane.render();
});
});
/**
* Extend chart.get to also search in panes. Used internally in responsiveness
* and chart.update.
*/
wrap(H.Chart.prototype, 'get', function(proceed, id) {
return H.find(this.pane, function(pane) {
return pane.options.id === id;
}) || proceed.call(this, id);
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
(c) 2009-2016 Torstein Honsi
License: www.highcharts.com/license
*/
(function(L,a){"object"===typeof module&&module.exports?module.exports=L.document?a(L):a:L.Highcharts=a(L)})("undefined"!==typeof window?window:this,function(L){L=function(){var a=window,B=a.document,A=a.navigator&&a.navigator.userAgent||"",H=B&&B.createElementNS&&!!B.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,G=/(edge|msie|trident)/i.test(A)&&!window.opera,r=!H,f=/Firefox/.test(A),l=f&&4>parseInt(A.split("Firefox/")[1],10);return a.Highcharts?a.Highcharts.error(16,!0):{product:"Highcharts",
version:"5.0.10",deg2rad:2*Math.PI/360,doc:B,hasBidiBug:l,hasTouch:B&&void 0!==B.documentElement.ontouchstart,isMS:G,isWebKit:/AppleWebKit/.test(A),isFirefox:f,isTouchDevice:/(Mobile|Android|Windows Phone)/.test(A),SVG_NS:"http://www.w3.org/2000/svg",chartCount:0,seriesTypes:{},symbolSizes:{},svg:H,vml:r,win:a,charts:[],marginNames:["plotTop","marginRight","marginBottom","plotLeft"],noop:function(){}}}();(function(a){var B=[],A=a.charts,H=a.doc,G=a.win;a.error=function(r,f){r=a.isNumber(r)?"Highcharts error #"+
r+": www.highcharts.com/errors/"+r:r;if(f)throw Error(r);G.console&&console.log(r)};a.Fx=function(a,f,l){this.options=f;this.elem=a;this.prop=l};a.Fx.prototype={dSetter:function(){var a=this.paths[0],f=this.paths[1],l=[],q=this.now,k=a.length,u;if(1===q)l=this.toD;else if(k===f.length&&1>q)for(;k--;)u=parseFloat(a[k]),l[k]=isNaN(u)?a[k]:q*parseFloat(f[k]-u)+u;else l=f;this.elem.attr("d",l,null,!0)},update:function(){var a=this.elem,f=this.prop,l=this.now,q=this.options.step;if(this[f+"Setter"])this[f+
"Setter"]();else a.attr?a.element&&a.attr(f,l,null,!0):a.style[f]=l+this.unit;q&&q.call(a,l,this)},run:function(a,f,l){var r=this,k=function(a){return k.stopped?!1:r.step(a)},u;this.startTime=+new Date;this.start=a;this.end=f;this.unit=l;this.now=this.start;this.pos=0;k.elem=this.elem;k.prop=this.prop;k()&&1===B.push(k)&&(k.timerId=setInterval(function(){for(u=0;u<B.length;u++)B[u]()||B.splice(u--,1);B.length||clearInterval(k.timerId)},13))},step:function(a){var f=+new Date,r,q=this.options;r=this.elem;
var k=q.complete,u=q.duration,d=q.curAnim,c;if(r.attr&&!r.element)r=!1;else if(a||f>=u+this.startTime){this.now=this.end;this.pos=1;this.update();a=d[this.prop]=!0;for(c in d)!0!==d[c]&&(a=!1);a&&k&&k.call(r);r=!1}else this.pos=q.easing((f-this.startTime)/u),this.now=this.start+(this.end-this.start)*this.pos,this.update(),r=!0;return r},initPath:function(r,f,l){function q(a){var b,e;for(t=a.length;t--;)b="M"===a[t]||"L"===a[t],e=/[a-zA-Z]/.test(a[t+3]),b&&e&&a.splice(t+1,0,a[t+1],a[t+2],a[t+1],a[t+
2])}function k(a,e){for(;a.length<p;){a[0]=e[p-a.length];var h=a.slice(0,b);[].splice.apply(a,[0,0].concat(h));D&&(h=a.slice(a.length-b),[].splice.apply(a,[a.length,0].concat(h)),t--)}a[0]="M"}function u(a,e){for(var c=(p-a.length)/b;0<c&&c--;)h=a.slice().splice(a.length/w-b,b*w),h[0]=e[p-b-c*b],z&&(h[b-6]=h[b-2],h[b-5]=h[b-1]),[].splice.apply(a,[a.length/w,0].concat(h)),D&&c--}f=f||"";var d,c=r.startX,n=r.endX,z=-1<f.indexOf("C"),b=z?7:3,p,h,t;f=f.split(" ");l=l.slice();var D=r.isArea,w=D?2:1,e;
z&&(q(f),q(l));if(c&&n){for(t=0;t<c.length;t++)if(c[t]===n[0]){d=t;break}else if(c[0]===n[n.length-c.length+t]){d=t;e=!0;break}void 0===d&&(f=[])}f.length&&a.isNumber(d)&&(p=l.length+d*w*b,e?(k(f,l),u(l,f)):(k(l,f),u(f,l)));return[f,l]}};a.extend=function(a,f){var r;a||(a={});for(r in f)a[r]=f[r];return a};a.merge=function(){var r,f=arguments,l,q={},k=function(u,d){var c,n;"object"!==typeof u&&(u={});for(n in d)d.hasOwnProperty(n)&&(c=d[n],a.isObject(c,!0)&&"renderTo"!==n&&"number"!==typeof c.nodeType?
u[n]=k(u[n]||{},c):u[n]=d[n]);return u};!0===f[0]&&(q=f[1],f=Array.prototype.slice.call(f,2));l=f.length;for(r=0;r<l;r++)q=k(q,f[r]);return q};a.pInt=function(a,f){return parseInt(a,f||10)};a.isString=function(a){return"string"===typeof a};a.isArray=function(a){a=Object.prototype.toString.call(a);return"[object Array]"===a||"[object Array Iterator]"===a};a.isObject=function(r,f){return r&&"object"===typeof r&&(!f||!a.isArray(r))};a.isNumber=function(a){return"number"===typeof a&&!isNaN(a)};a.erase=
function(a,f){for(var r=a.length;r--;)if(a[r]===f){a.splice(r,1);break}};a.defined=function(a){return void 0!==a&&null!==a};a.attr=function(r,f,l){var q,k;if(a.isString(f))a.defined(l)?r.setAttribute(f,l):r&&r.getAttribute&&(k=r.getAttribute(f));else if(a.defined(f)&&a.isObject(f))for(q in f)r.setAttribute(q,f[q]);return k};a.splat=function(r){return a.isArray(r)?r:[r]};a.syncTimeout=function(a,f,l){if(f)return setTimeout(a,f,l);a.call(0,l)};a.pick=function(){var a=arguments,f,l,q=a.length;for(f=
0;f<q;f++)if(l=a[f],void 0!==l&&null!==l)return l};a.css=function(r,f){a.isMS&&!a.svg&&f&&void 0!==f.opacity&&(f.filter="alpha(opacity\x3d"+100*f.opacity+")");a.extend(r.style,f)};a.createElement=function(r,f,l,q,k){r=H.createElement(r);var u=a.css;f&&a.extend(r,f);k&&u(r,{padding:0,border:"none",margin:0});l&&u(r,l);q&&q.appendChild(r);return r};a.extendClass=function(r,f){var l=function(){};l.prototype=new r;a.extend(l.prototype,f);return l};a.pad=function(a,f,l){return Array((f||2)+1-String(a).length).join(l||
0)+a};a.relativeLength=function(a,f){return/%$/.test(a)?f*parseFloat(a)/100:parseFloat(a)};a.wrap=function(a,f,l){var q=a[f];a[f]=function(){var a=Array.prototype.slice.call(arguments),u=arguments,d=this;d.proceed=function(){q.apply(d,arguments.length?arguments:u)};a.unshift(q);a=l.apply(this,a);d.proceed=null;return a}};a.getTZOffset=function(r){var f=a.Date;return 6E4*(f.hcGetTimezoneOffset&&f.hcGetTimezoneOffset(r)||f.hcTimezoneOffset||0)};a.dateFormat=function(r,f,l){if(!a.defined(f)||isNaN(f))return a.defaultOptions.lang.invalidDate||
"";r=a.pick(r,"%Y-%m-%d %H:%M:%S");var q=a.Date,k=new q(f-a.getTZOffset(f)),u,d=k[q.hcGetHours](),c=k[q.hcGetDay](),n=k[q.hcGetDate](),z=k[q.hcGetMonth](),b=k[q.hcGetFullYear](),p=a.defaultOptions.lang,h=p.weekdays,t=p.shortWeekdays,D=a.pad,q=a.extend({a:t?t[c]:h[c].substr(0,3),A:h[c],d:D(n),e:D(n,2," "),w:c,b:p.shortMonths[z],B:p.months[z],m:D(z+1),y:b.toString().substr(2,2),Y:b,H:D(d),k:d,I:D(d%12||12),l:d%12||12,M:D(k[q.hcGetMinutes]()),p:12>d?"AM":"PM",P:12>d?"am":"pm",S:D(k.getSeconds()),L:D(Math.round(f%
1E3),3)},a.dateFormats);for(u in q)for(;-1!==r.indexOf("%"+u);)r=r.replace("%"+u,"function"===typeof q[u]?q[u](f):q[u]);return l?r.substr(0,1).toUpperCase()+r.substr(1):r};a.formatSingle=function(r,f){var l=/\.([0-9])/,q=a.defaultOptions.lang;/f$/.test(r)?(l=(l=r.match(l))?l[1]:-1,null!==f&&(f=a.numberFormat(f,l,q.decimalPoint,-1<r.indexOf(",")?q.thousandsSep:""))):f=a.dateFormat(r,f);return f};a.format=function(r,f){for(var l="{",q=!1,k,u,d,c,n=[],z;r;){l=r.indexOf(l);if(-1===l)break;k=r.slice(0,
l);if(q){k=k.split(":");u=k.shift().split(".");c=u.length;z=f;for(d=0;d<c;d++)z=z[u[d]];k.length&&(z=a.formatSingle(k.join(":"),z));n.push(z)}else n.push(k);r=r.slice(l+1);l=(q=!q)?"}":"{"}n.push(r);return n.join("")};a.getMagnitude=function(a){return Math.pow(10,Math.floor(Math.log(a)/Math.LN10))};a.normalizeTickInterval=function(r,f,l,q,k){var u,d=r;l=a.pick(l,1);u=r/l;f||(f=k?[1,1.2,1.5,2,2.5,3,4,5,6,8,10]:[1,2,2.5,5,10],!1===q&&(1===l?f=a.grep(f,function(a){return 0===a%1}):.1>=l&&(f=[1/l])));
for(q=0;q<f.length&&!(d=f[q],k&&d*l>=r||!k&&u<=(f[q]+(f[q+1]||f[q]))/2);q++);return d=a.correctFloat(d*l,-Math.round(Math.log(.001)/Math.LN10))};a.stableSort=function(a,f){var l=a.length,q,k;for(k=0;k<l;k++)a[k].safeI=k;a.sort(function(a,d){q=f(a,d);return 0===q?a.safeI-d.safeI:q});for(k=0;k<l;k++)delete a[k].safeI};a.arrayMin=function(a){for(var f=a.length,l=a[0];f--;)a[f]<l&&(l=a[f]);return l};a.arrayMax=function(a){for(var f=a.length,l=a[0];f--;)a[f]>l&&(l=a[f]);return l};a.destroyObjectProperties=
function(a,f){for(var l in a)a[l]&&a[l]!==f&&a[l].destroy&&a[l].destroy(),delete a[l]};a.discardElement=function(r){var f=a.garbageBin;f||(f=a.createElement("div"));r&&f.appendChild(r);f.innerHTML=""};a.correctFloat=function(a,f){return parseFloat(a.toPrecision(f||14))};a.setAnimation=function(r,f){f.renderer.globalAnimation=a.pick(r,f.options.chart.animation,!0)};a.animObject=function(r){return a.isObject(r)?a.merge(r):{duration:r?500:0}};a.timeUnits={millisecond:1,second:1E3,minute:6E4,hour:36E5,
day:864E5,week:6048E5,month:24192E5,year:314496E5};a.numberFormat=function(r,f,l,q){r=+r||0;f=+f;var k=a.defaultOptions.lang,u=(r.toString().split(".")[1]||"").length,d,c;-1===f?f=Math.min(u,20):a.isNumber(f)||(f=2);c=(Math.abs(r)+Math.pow(10,-Math.max(f,u)-1)).toFixed(f);u=String(a.pInt(c));d=3<u.length?u.length%3:0;l=a.pick(l,k.decimalPoint);q=a.pick(q,k.thousandsSep);r=(0>r?"-":"")+(d?u.substr(0,d)+q:"");r+=u.substr(d).replace(/(\d{3})(?=\d)/g,"$1"+q);f&&(r+=l+c.slice(-f));return r};Math.easeInOutSine=
function(a){return-.5*(Math.cos(Math.PI*a)-1)};a.getStyle=function(r,f){return"width"===f?Math.min(r.offsetWidth,r.scrollWidth)-a.getStyle(r,"padding-left")-a.getStyle(r,"padding-right"):"height"===f?Math.min(r.offsetHeight,r.scrollHeight)-a.getStyle(r,"padding-top")-a.getStyle(r,"padding-bottom"):(r=G.getComputedStyle(r,void 0))&&a.pInt(r.getPropertyValue(f))};a.inArray=function(a,f){return f.indexOf?f.indexOf(a):[].indexOf.call(f,a)};a.grep=function(a,f){return[].filter.call(a,f)};a.find=function(a,
f){return[].find.call(a,f)};a.map=function(a,f){for(var l=[],q=0,k=a.length;q<k;q++)l[q]=f.call(a[q],a[q],q,a);return l};a.offset=function(a){var f=H.documentElement;a=a.getBoundingClientRect();return{top:a.top+(G.pageYOffset||f.scrollTop)-(f.clientTop||0),left:a.left+(G.pageXOffset||f.scrollLeft)-(f.clientLeft||0)}};a.stop=function(a,f){for(var l=B.length;l--;)B[l].elem!==a||f&&f!==B[l].prop||(B[l].stopped=!0)};a.each=function(a,f,l){return Array.prototype.forEach.call(a,f,l)};a.addEvent=function(r,
f,l){function q(a){a.target=a.srcElement||G;l.call(r,a)}var k=r.hcEvents=r.hcEvents||{};r.addEventListener?r.addEventListener(f,l,!1):r.attachEvent&&(r.hcEventsIE||(r.hcEventsIE={}),r.hcEventsIE[l.toString()]=q,r.attachEvent("on"+f,q));k[f]||(k[f]=[]);k[f].push(l);return function(){a.removeEvent(r,f,l)}};a.removeEvent=function(r,f,l){function q(a,c){r.removeEventListener?r.removeEventListener(a,c,!1):r.attachEvent&&(c=r.hcEventsIE[c.toString()],r.detachEvent("on"+a,c))}function k(){var a,c;if(r.nodeName)for(c in f?
(a={},a[f]=!0):a=d,a)if(d[c])for(a=d[c].length;a--;)q(c,d[c][a])}var u,d=r.hcEvents,c;d&&(f?(u=d[f]||[],l?(c=a.inArray(l,u),-1<c&&(u.splice(c,1),d[f]=u),q(f,l)):(k(),d[f]=[])):(k(),r.hcEvents={}))};a.fireEvent=function(r,f,l,q){var k;k=r.hcEvents;var u,d;l=l||{};if(H.createEvent&&(r.dispatchEvent||r.fireEvent))k=H.createEvent("Events"),k.initEvent(f,!0,!0),a.extend(k,l),r.dispatchEvent?r.dispatchEvent(k):r.fireEvent(f,k);else if(k)for(k=k[f]||[],u=k.length,l.target||a.extend(l,{preventDefault:function(){l.defaultPrevented=
!0},target:r,type:f}),f=0;f<u;f++)(d=k[f])&&!1===d.call(r,l)&&l.preventDefault();q&&!l.defaultPrevented&&q(l)};a.animate=function(r,f,l){var q,k="",u,d,c;a.isObject(l)||(q=arguments,l={duration:q[2],easing:q[3],complete:q[4]});a.isNumber(l.duration)||(l.duration=400);l.easing="function"===typeof l.easing?l.easing:Math[l.easing]||Math.easeInOutSine;l.curAnim=a.merge(f);for(c in f)a.stop(r,c),d=new a.Fx(r,l,c),u=null,"d"===c?(d.paths=d.initPath(r,r.d,f.d),d.toD=f.d,q=0,u=1):r.attr?q=r.attr(c):(q=parseFloat(a.getStyle(r,
c))||0,"opacity"!==c&&(k="px")),u||(u=f[c]),u&&u.match&&u.match("px")&&(u=u.replace(/px/g,"")),d.run(q,u,k)};a.seriesType=function(r,f,l,q,k){var u=a.getOptions(),d=a.seriesTypes;u.plotOptions[r]=a.merge(u.plotOptions[f],l);d[r]=a.extendClass(d[f]||function(){},q);d[r].prototype.type=r;k&&(d[r].prototype.pointClass=a.extendClass(a.Point,k));return d[r]};a.uniqueKey=function(){var a=Math.random().toString(36).substring(2,9),f=0;return function(){return"highcharts-"+a+"-"+f++}}();G.jQuery&&(G.jQuery.fn.highcharts=
function(){var r=[].slice.call(arguments);if(this[0])return r[0]?(new (a[a.isString(r[0])?r.shift():"Chart"])(this[0],r[0],r[1]),this):A[a.attr(this[0],"data-highcharts-chart")]});H&&!H.defaultView&&(a.getStyle=function(r,f){var l={width:"clientWidth",height:"clientHeight"}[f];if(r.style[f])return a.pInt(r.style[f]);"opacity"===f&&(f="filter");if(l)return r.style.zoom=1,Math.max(r[l]-2*a.getStyle(r,"padding"),0);r=r.currentStyle[f.replace(/\-(\w)/g,function(a,k){return k.toUpperCase()})];"filter"===
f&&(r=r.replace(/alpha\(opacity=([0-9]+)\)/,function(a,k){return k/100}));return""===r?1:a.pInt(r)});Array.prototype.forEach||(a.each=function(a,f,l){for(var q=0,k=a.length;q<k;q++)if(!1===f.call(l,a[q],q,a))return q});Array.prototype.indexOf||(a.inArray=function(a,f){var l,q=0;if(f)for(l=f.length;q<l;q++)if(f[q]===a)return q;return-1});Array.prototype.filter||(a.grep=function(a,f){for(var l=[],q=0,k=a.length;q<k;q++)f(a[q],q)&&l.push(a[q]);return l});Array.prototype.find||(a.find=function(a,f){var l,
q=a.length;for(l=0;l<q;l++)if(f(a[l],l))return a[l]})})(L);(function(a){var B=a.each,A=a.isNumber,H=a.map,G=a.merge,r=a.pInt;a.Color=function(f){if(!(this instanceof a.Color))return new a.Color(f);this.init(f)};a.Color.prototype={parsers:[{regex:/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,parse:function(a){return[r(a[1]),r(a[2]),r(a[3]),parseFloat(a[4],10)]}},{regex:/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,parse:function(a){return[r(a[1]),
r(a[2]),r(a[3]),1]}}],names:{white:"#ffffff",black:"#000000"},init:function(f){var l,q,k,u;if((this.input=f=this.names[f&&f.toLowerCase?f.toLowerCase():""]||f)&&f.stops)this.stops=H(f.stops,function(d){return new a.Color(d[1])});else if(f&&"#"===f[0]&&(l=f.length,f=parseInt(f.substr(1),16),7===l?q=[(f&16711680)>>16,(f&65280)>>8,f&255,1]:4===l&&(q=[(f&3840)>>4|(f&3840)>>8,(f&240)>>4|f&240,(f&15)<<4|f&15,1])),!q)for(k=this.parsers.length;k--&&!q;)u=this.parsers[k],(l=u.regex.exec(f))&&(q=u.parse(l));
this.rgba=q||[]},get:function(a){var f=this.input,q=this.rgba,k;this.stops?(k=G(f),k.stops=[].concat(k.stops),B(this.stops,function(u,d){k.stops[d]=[k.stops[d][0],u.get(a)]})):k=q&&A(q[0])?"rgb"===a||!a&&1===q[3]?"rgb("+q[0]+","+q[1]+","+q[2]+")":"a"===a?q[3]:"rgba("+q.join(",")+")":f;return k},brighten:function(a){var f,q=this.rgba;if(this.stops)B(this.stops,function(k){k.brighten(a)});else if(A(a)&&0!==a)for(f=0;3>f;f++)q[f]+=r(255*a),0>q[f]&&(q[f]=0),255<q[f]&&(q[f]=255);return this},setOpacity:function(a){this.rgba[3]=
a;return this}};a.color=function(f){return new a.Color(f)}})(L);(function(a){var B,A,H=a.addEvent,G=a.animate,r=a.attr,f=a.charts,l=a.color,q=a.css,k=a.createElement,u=a.defined,d=a.deg2rad,c=a.destroyObjectProperties,n=a.doc,z=a.each,b=a.extend,p=a.erase,h=a.grep,t=a.hasTouch,D=a.inArray,w=a.isArray,e=a.isFirefox,x=a.isMS,C=a.isObject,E=a.isString,m=a.isWebKit,y=a.merge,I=a.noop,K=a.pick,J=a.pInt,g=a.removeEvent,F=a.stop,Q=a.svg,N=a.SVG_NS,P=a.symbolSizes,O=a.win;B=a.SVGElement=function(){return this};
B.prototype={opacity:1,SVG_NS:N,textProps:"direction fontSize fontWeight fontFamily fontStyle color lineHeight width textAlign textDecoration textOverflow textOutline".split(" "),init:function(a,g){this.element="span"===g?k(g):n.createElementNS(this.SVG_NS,g);this.renderer=a},animate:function(v,g,b){g=a.animObject(K(g,this.renderer.globalAnimation,!0));0!==g.duration?(b&&(g.complete=b),G(this,v,g)):(this.attr(v,null,b),g.step&&g.step.call(this));return this},colorGradient:function(v,g,b){var e=this.renderer,
h,c,m,M,F,x,d,C,t,p,n,k=[],R;v.radialGradient?c="radialGradient":v.linearGradient&&(c="linearGradient");if(c){m=v[c];F=e.gradients;d=v.stops;p=b.radialReference;w(m)&&(v[c]=m={x1:m[0],y1:m[1],x2:m[2],y2:m[3],gradientUnits:"userSpaceOnUse"});"radialGradient"===c&&p&&!u(m.gradientUnits)&&(M=m,m=y(m,e.getRadialAttr(p,M),{gradientUnits:"userSpaceOnUse"}));for(n in m)"id"!==n&&k.push(n,m[n]);for(n in d)k.push(d[n]);k=k.join(",");F[k]?p=F[k].attr("id"):(m.id=p=a.uniqueKey(),F[k]=x=e.createElement(c).attr(m).add(e.defs),
x.radAttr=M,x.stops=[],z(d,function(v){0===v[1].indexOf("rgba")?(h=a.color(v[1]),C=h.get("rgb"),t=h.get("a")):(C=v[1],t=1);v=e.createElement("stop").attr({offset:v[0],"stop-color":C,"stop-opacity":t}).add(x);x.stops.push(v)}));R="url("+e.url+"#"+p+")";b.setAttribute(g,R);b.gradient=k;v.toString=function(){return R}}},applyTextOutline:function(v){var g=this.element,b,e,c,h,m;-1!==v.indexOf("contrast")&&(v=v.replace(/contrast/g,this.renderer.getContrast(g.style.fill)));v=v.split(" ");e=v[v.length-1];
if((c=v[0])&&"none"!==c&&a.svg){this.fakeTS=!0;v=[].slice.call(g.getElementsByTagName("tspan"));this.ySetter=this.xSetter;c=c.replace(/(^[\d\.]+)(.*?)$/g,function(a,v,g){return 2*v+g});for(m=v.length;m--;)b=v[m],"highcharts-text-outline"===b.getAttribute("class")&&p(v,g.removeChild(b));h=g.firstChild;z(v,function(a,v){0===v&&(a.setAttribute("x",g.getAttribute("x")),v=g.getAttribute("y"),a.setAttribute("y",v||0),null===v&&g.setAttribute("y",0));a=a.cloneNode(1);r(a,{"class":"highcharts-text-outline",
fill:e,stroke:e,"stroke-width":c,"stroke-linejoin":"round"});g.insertBefore(a,h)})}},attr:function(a,g,b,e){var v,c=this.element,h,m=this,M;"string"===typeof a&&void 0!==g&&(v=a,a={},a[v]=g);if("string"===typeof a)m=(this[a+"Getter"]||this._defaultGetter).call(this,a,c);else{for(v in a)g=a[v],M=!1,e||F(this,v),this.symbolName&&/^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)$/.test(v)&&(h||(this.symbolAttr(a),h=!0),M=!0),!this.rotation||"x"!==v&&"y"!==v||(this.doTransform=!0),M||(M=this[v+
"Setter"]||this._defaultSetter,M.call(this,g,v,c),this.shadows&&/^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(v)&&this.updateShadows(v,g,M));this.doTransform&&(this.updateTransform(),this.doTransform=!1)}b&&b();return m},updateShadows:function(a,g,b){for(var v=this.shadows,e=v.length;e--;)b.call(v[e],"height"===a?Math.max(g-(v[e].cutHeight||0),0):"d"===a?this.d:g,a,v[e])},addClass:function(a,g){var v=this.attr("class")||"";-1===v.indexOf(a)&&(g||(a=(v+(v?" ":"")+a).replace(" "," ")),
this.attr("class",a));return this},hasClass:function(a){return-1!==r(this.element,"class").indexOf(a)},removeClass:function(a){r(this.element,"class",(r(this.element,"class")||"").replace(a,""));return this},symbolAttr:function(a){var v=this;z("x y r start end width height innerR anchorX anchorY".split(" "),function(g){v[g]=K(a[g],v[g])});v.attr({d:v.renderer.symbols[v.symbolName](v.x,v.y,v.width,v.height,v)})},clip:function(a){return this.attr("clip-path",a?"url("+this.renderer.url+"#"+a.id+")":
"none")},crisp:function(a,g){var v,b={},e;g=g||a.strokeWidth||0;e=Math.round(g)%2/2;a.x=Math.floor(a.x||this.x||0)+e;a.y=Math.floor(a.y||this.y||0)+e;a.width=Math.floor((a.width||this.width||0)-2*e);a.height=Math.floor((a.height||this.height||0)-2*e);u(a.strokeWidth)&&(a.strokeWidth=g);for(v in a)this[v]!==a[v]&&(this[v]=b[v]=a[v]);return b},css:function(a){var v=this.styles,g={},e=this.element,c,h="",m=!v,F=["textOutline","textOverflow","width"];a&&a.color&&(a.fill=a.color);if(v)for(c in a)a[c]!==
v[c]&&(g[c]=a[c],m=!0);if(m){v&&(a=b(v,g));v=this.textWidth=a&&a.width&&"auto"!==a.width&&"text"===e.nodeName.toLowerCase()&&J(a.width);this.styles=a;v&&!Q&&this.renderer.forExport&&delete a.width;if(x&&!Q)q(this.element,a);else{v=function(a,v){return"-"+v.toLowerCase()};for(c in a)-1===D(c,F)&&(h+=c.replace(/([A-Z])/g,v)+":"+a[c]+";");h&&r(e,"style",h)}this.added&&("text"===this.element.nodeName&&this.renderer.buildText(this),a&&a.textOutline&&this.applyTextOutline(a.textOutline))}return this},strokeWidth:function(){return this["stroke-width"]||
0},on:function(a,g){var v=this,e=v.element;t&&"click"===a?(e.ontouchstart=function(a){v.touchEventFired=Date.now();a.preventDefault();g.call(e,a)},e.onclick=function(a){(-1===O.navigator.userAgent.indexOf("Android")||1100<Date.now()-(v.touchEventFired||0))&&g.call(e,a)}):e["on"+a]=g;return this},setRadialReference:function(a){var v=this.renderer.gradients[this.element.gradient];this.element.radialReference=a;v&&v.radAttr&&v.animate(this.renderer.getRadialAttr(a,v.radAttr));return this},translate:function(a,
g){return this.attr({translateX:a,translateY:g})},invert:function(a){this.inverted=a;this.updateTransform();return this},updateTransform:function(){var a=this.translateX||0,g=this.translateY||0,e=this.scaleX,b=this.scaleY,c=this.inverted,h=this.rotation,m=this.element;c&&(a+=this.width,g+=this.height);a=["translate("+a+","+g+")"];c?a.push("rotate(90) scale(-1,1)"):h&&a.push("rotate("+h+" "+(m.getAttribute("x")||0)+" "+(m.getAttribute("y")||0)+")");(u(e)||u(b))&&a.push("scale("+K(e,1)+" "+K(b,1)+")");
a.length&&m.setAttribute("transform",a.join(" "))},toFront:function(){var a=this.element;a.parentNode.appendChild(a);return this},align:function(a,g,e){var v,b,c,h,m={};b=this.renderer;c=b.alignedObjects;var F,x;if(a){if(this.alignOptions=a,this.alignByTranslate=g,!e||E(e))this.alignTo=v=e||"renderer",p(c,this),c.push(this),e=null}else a=this.alignOptions,g=this.alignByTranslate,v=this.alignTo;e=K(e,b[v],b);v=a.align;b=a.verticalAlign;c=(e.x||0)+(a.x||0);h=(e.y||0)+(a.y||0);"right"===v?F=1:"center"===
v&&(F=2);F&&(c+=(e.width-(a.width||0))/F);m[g?"translateX":"x"]=Math.round(c);"bottom"===b?x=1:"middle"===b&&(x=2);x&&(h+=(e.height-(a.height||0))/x);m[g?"translateY":"y"]=Math.round(h);this[this.placed?"animate":"attr"](m);this.placed=!0;this.alignAttr=m;return this},getBBox:function(a,g){var v,e=this.renderer,c,h=this.element,m=this.styles,F,x=this.textStr,y,M=e.cache,C=e.cacheKeys,t;g=K(g,this.rotation);c=g*d;F=m&&m.fontSize;void 0!==x&&(t=x.toString(),-1===t.indexOf("\x3c")&&(t=t.replace(/[0-9]/g,
"0")),t+=["",g||0,F,m&&m.width,m&&m.textOverflow].join());t&&!a&&(v=M[t]);if(!v){if(h.namespaceURI===this.SVG_NS||e.forExport){try{(y=this.fakeTS&&function(a){z(h.querySelectorAll(".highcharts-text-outline"),function(v){v.style.display=a})})&&y("none"),v=h.getBBox?b({},h.getBBox()):{width:h.offsetWidth,height:h.offsetHeight},y&&y("")}catch(X){}if(!v||0>v.width)v={width:0,height:0}}else v=this.htmlGetBBox();e.isSVG&&(a=v.width,e=v.height,m&&"11px"===m.fontSize&&17===Math.round(e)&&(v.height=e=14),
g&&(v.width=Math.abs(e*Math.sin(c))+Math.abs(a*Math.cos(c)),v.height=Math.abs(e*Math.cos(c))+Math.abs(a*Math.sin(c))));if(t&&0<v.height){for(;250<C.length;)delete M[C.shift()];M[t]||C.push(t);M[t]=v}}return v},show:function(a){return this.attr({visibility:a?"inherit":"visible"})},hide:function(){return this.attr({visibility:"hidden"})},fadeOut:function(a){var v=this;v.animate({opacity:0},{duration:a||150,complete:function(){v.attr({y:-9999})}})},add:function(a){var v=this.renderer,g=this.element,
e;a&&(this.parentGroup=a);this.parentInverted=a&&a.inverted;void 0!==this.textStr&&v.buildText(this);this.added=!0;if(!a||a.handleZ||this.zIndex)e=this.zIndexSetter();e||(a?a.element:v.box).appendChild(g);if(this.onAdd)this.onAdd();return this},safeRemoveChild:function(a){var v=a.parentNode;v&&v.removeChild(a)},destroy:function(){var a=this,g=a.element||{},e=a.renderer.isSVG&&"SPAN"===g.nodeName&&a.parentGroup,b,c;g.onclick=g.onmouseout=g.onmouseover=g.onmousemove=g.point=null;F(a);a.clipPath&&(z(a.element.ownerSVGElement.querySelectorAll("[clip-path]"),
function(v){-1<v.getAttribute("clip-path").indexOf(a.clipPath.element.id)&&v.removeAttribute("clip-path")}),a.clipPath=a.clipPath.destroy());if(a.stops){for(c=0;c<a.stops.length;c++)a.stops[c]=a.stops[c].destroy();a.stops=null}a.safeRemoveChild(g);for(a.destroyShadows();e&&e.div&&0===e.div.childNodes.length;)g=e.parentGroup,a.safeRemoveChild(e.div),delete e.div,e=g;a.alignTo&&p(a.renderer.alignedObjects,a);for(b in a)delete a[b];return null},shadow:function(a,g,e){var v=[],b,c,h=this.element,m,F,
x,y;if(!a)this.destroyShadows();else if(!this.shadows){F=K(a.width,3);x=(a.opacity||.15)/F;y=this.parentInverted?"(-1,-1)":"("+K(a.offsetX,1)+", "+K(a.offsetY,1)+")";for(b=1;b<=F;b++)c=h.cloneNode(0),m=2*F+1-2*b,r(c,{isShadow:"true",stroke:a.color||"#000000","stroke-opacity":x*b,"stroke-width":m,transform:"translate"+y,fill:"none"}),e&&(r(c,"height",Math.max(r(c,"height")-m,0)),c.cutHeight=m),g?g.element.appendChild(c):h.parentNode.insertBefore(c,h),v.push(c);this.shadows=v}return this},destroyShadows:function(){z(this.shadows||
[],function(a){this.safeRemoveChild(a)},this);this.shadows=void 0},xGetter:function(a){"circle"===this.element.nodeName&&("x"===a?a="cx":"y"===a&&(a="cy"));return this._defaultGetter(a)},_defaultGetter:function(a){a=K(this[a],this.element?this.element.getAttribute(a):null,0);/^[\-0-9\.]+$/.test(a)&&(a=parseFloat(a));return a},dSetter:function(a,g,e){a&&a.join&&(a=a.join(" "));/(NaN| {2}|^$)/.test(a)&&(a="M 0 0");e.setAttribute(g,a);this[g]=a},dashstyleSetter:function(a){var v,g=this["stroke-width"];
"inherit"===g&&(g=1);if(a=a&&a.toLowerCase()){a=a.replace("shortdashdotdot","3,1,1,1,1,1,").replace("shortdashdot","3,1,1,1").replace("shortdot","1,1,").replace("shortdash","3,1,").replace("longdash","8,3,").replace(/dot/g,"1,3,").replace("dash","4,3,").replace(/,$/,"").split(",");for(v=a.length;v--;)a[v]=J(a[v])*g;a=a.join(",").replace(/NaN/g,"none");this.element.setAttribute("stroke-dasharray",a)}},alignSetter:function(a){this.element.setAttribute("text-anchor",{left:"start",center:"middle",right:"end"}[a])},
opacitySetter:function(a,g,e){this[g]=a;e.setAttribute(g,a)},titleSetter:function(a){var v=this.element.getElementsByTagName("title")[0];v||(v=n.createElementNS(this.SVG_NS,"title"),this.element.appendChild(v));v.firstChild&&v.removeChild(v.firstChild);v.appendChild(n.createTextNode(String(K(a),"").replace(/<[^>]*>/g,"")))},textSetter:function(a){a!==this.textStr&&(delete this.bBox,this.textStr=a,this.added&&this.renderer.buildText(this))},fillSetter:function(a,g,e){"string"===typeof a?e.setAttribute(g,
a):a&&this.colorGradient(a,g,e)},visibilitySetter:function(a,g,e){"inherit"===a?e.removeAttribute(g):e.setAttribute(g,a)},zIndexSetter:function(a,g){var v=this.renderer,e=this.parentGroup,b=(e||v).element||v.box,c,h=this.element,m;c=this.added;var F;u(a)&&(h.zIndex=a,a=+a,this[g]===a&&(c=!1),this[g]=a);if(c){(a=this.zIndex)&&e&&(e.handleZ=!0);g=b.childNodes;for(F=0;F<g.length&&!m;F++)e=g[F],c=e.zIndex,e!==h&&(J(c)>a||!u(a)&&u(c)||0>a&&!u(c)&&b!==v.box)&&(b.insertBefore(h,e),m=!0);m||b.appendChild(h)}return m},
_defaultSetter:function(a,g,e){e.setAttribute(g,a)}};B.prototype.yGetter=B.prototype.xGetter;B.prototype.translateXSetter=B.prototype.translateYSetter=B.prototype.rotationSetter=B.prototype.verticalAlignSetter=B.prototype.scaleXSetter=B.prototype.scaleYSetter=function(a,g){this[g]=a;this.doTransform=!0};B.prototype["stroke-widthSetter"]=B.prototype.strokeSetter=function(a,g,e){this[g]=a;this.stroke&&this["stroke-width"]?(B.prototype.fillSetter.call(this,this.stroke,"stroke",e),e.setAttribute("stroke-width",
this["stroke-width"]),this.hasStroke=!0):"stroke-width"===g&&0===a&&this.hasStroke&&(e.removeAttribute("stroke"),this.hasStroke=!1)};A=a.SVGRenderer=function(){this.init.apply(this,arguments)};A.prototype={Element:B,SVG_NS:N,init:function(a,g,b,c,h,F){var v;c=this.createElement("svg").attr({version:"1.1","class":"highcharts-root"}).css(this.getStyle(c));v=c.element;a.appendChild(v);-1===a.innerHTML.indexOf("xmlns")&&r(v,"xmlns",this.SVG_NS);this.isSVG=!0;this.box=v;this.boxWrapper=c;this.alignedObjects=
[];this.url=(e||m)&&n.getElementsByTagName("base").length?O.location.href.replace(/#.*?$/,"").replace(/<[^>]*>/g,"").replace(/([\('\)])/g,"\\$1").replace(/ /g,"%20"):"";this.createElement("desc").add().element.appendChild(n.createTextNode("Created with Highcharts 5.0.10"));this.defs=this.createElement("defs").add();this.allowHTML=F;this.forExport=h;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(g,b,!1);var x;e&&a.getBoundingClientRect&&(g=function(){q(a,{left:0,top:0});
x=a.getBoundingClientRect();q(a,{left:Math.ceil(x.left)-x.left+"px",top:Math.ceil(x.top)-x.top+"px"})},g(),this.unSubPixelFix=H(O,"resize",g))},getStyle:function(a){return this.style=b({fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif',fontSize:"12px"},a)},setStyle:function(a){this.boxWrapper.css(this.getStyle(a))},isHidden:function(){return!this.boxWrapper.getBBox().width},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=this.boxWrapper.destroy();c(this.gradients||
{});this.gradients=null;a&&(this.defs=a.destroy());this.unSubPixelFix&&this.unSubPixelFix();return this.alignedObjects=null},createElement:function(a){var g=new this.Element;g.init(this,a);return g},draw:I,getRadialAttr:function(a,g){return{cx:a[0]-a[2]/2+g.cx*a[2],cy:a[1]-a[2]/2+g.cy*a[2],r:g.r*a[2]}},getSpanWidth:function(a,g){var v=a.getBBox(!0).width;!Q&&this.forExport&&(v=this.measureSpanWidth(g.firstChild.data,a.styles));return v},applyEllipsis:function(a,g,e,b){var v=this.getSpanWidth(a,g),
c=v>b,v=e,h,m=0,F=e.length,x=function(a){g.removeChild(g.firstChild);a&&g.appendChild(n.createTextNode(a))};if(c){for(;m<=F;)h=Math.ceil((m+F)/2),v=e.substring(0,h)+"\u2026",x(v),v=this.getSpanWidth(a,g),m===F?m=F+1:v>b?F=h-1:m=h;0===F&&x("")}return c},buildText:function(a){var g=a.element,e=this,v=e.forExport,b=K(a.textStr,"").toString(),c=-1!==b.indexOf("\x3c"),m=g.childNodes,F,x,y,t,d=r(g,"x"),C=a.styles,p=a.textWidth,k=C&&C.lineHeight,w=C&&C.textOutline,u=C&&"ellipsis"===C.textOverflow,f=C&&"nowrap"===
C.whiteSpace,E=C&&C.fontSize,D,I,l=m.length,C=p&&!a.added&&this.box,P=function(a){var v;v=/(px|em)$/.test(a&&a.style.fontSize)?a.style.fontSize:E||e.style.fontSize||12;return k?J(k):e.fontMetrics(v,a.getAttribute("style")?a:g).h};D=[b,u,f,k,w,E,p].join();if(D!==a.textCache){for(a.textCache=D;l--;)g.removeChild(m[l]);c||w||u||p||-1!==b.indexOf(" ")?(F=/<.*class="([^"]+)".*>/,x=/<.*style="([^"]+)".*>/,y=/<.*href="(http[^"]+)".*>/,C&&C.appendChild(g),b=c?b.replace(/<(b|strong)>/g,'\x3cspan style\x3d"font-weight:bold"\x3e').replace(/<(i|em)>/g,
'\x3cspan style\x3d"font-style:italic"\x3e').replace(/<a/g,"\x3cspan").replace(/<\/(b|strong|i|em|a)>/g,"\x3c/span\x3e").split(/<br.*?>/g):[b],b=h(b,function(a){return""!==a}),z(b,function(b,c){var m,h=0;b=b.replace(/^\s+|\s+$/g,"").replace(/<span/g,"|||\x3cspan").replace(/<\/span>/g,"\x3c/span\x3e|||");m=b.split("|||");z(m,function(b){if(""!==b||1===m.length){var C={},k=n.createElementNS(e.SVG_NS,"tspan"),w,E;F.test(b)&&(w=b.match(F)[1],r(k,"class",w));x.test(b)&&(E=b.match(x)[1].replace(/(;| |^)color([ :])/,
"$1fill$2"),r(k,"style",E));y.test(b)&&!v&&(r(k,"onclick",'location.href\x3d"'+b.match(y)[1]+'"'),q(k,{cursor:"pointer"}));b=(b.replace(/<(.|\n)*?>/g,"")||" ").replace(/</g,"\x3c").replace(/>/g,"\x3e");if(" "!==b){k.appendChild(n.createTextNode(b));h?C.dx=0:c&&null!==d&&(C.x=d);r(k,C);g.appendChild(k);!h&&I&&(!Q&&v&&q(k,{display:"block"}),r(k,"dy",P(k)));if(p){C=b.replace(/([^\^])-/g,"$1- ").split(" ");w=1<m.length||c||1<C.length&&!f;var D=[],M,z=P(k),l=a.rotation;for(u&&(t=e.applyEllipsis(a,
k,b,p));!u&&w&&(C.length||D.length);)a.rotation=0,M=e.getSpanWidth(a,k),b=M>p,void 0===t&&(t=b),b&&1!==C.length?(k.removeChild(k.firstChild),D.unshift(C.pop())):(C=D,D=[],C.length&&!f&&(k=n.createElementNS(N,"tspan"),r(k,{dy:z,x:d}),E&&r(k,"style",E),g.appendChild(k)),M>p&&(p=M)),C.length&&k.appendChild(n.createTextNode(C.join(" ").replace(/- /g,"-")));a.rotation=l}h++}}});I=I||g.childNodes.length}),t&&a.attr("title",a.textStr),C&&C.removeChild(g),w&&a.applyTextOutline&&a.applyTextOutline(w)):g.appendChild(n.createTextNode(b.replace(/</g,
"\x3c").replace(/>/g,"\x3e")))}},getContrast:function(a){a=l(a).rgba;return 510<a[0]+a[1]+a[2]?"#000000":"#FFFFFF"},button:function(a,g,e,c,m,h,F,C,t){var v=this.label(a,g,e,t,null,null,null,null,"button"),d=0;v.attr(y({padding:8,r:2},m));var p,n,k,w;m=y({fill:"#f7f7f7",stroke:"#cccccc","stroke-width":1,style:{color:"#333333",cursor:"pointer",fontWeight:"normal"}},m);p=m.style;delete m.style;h=y(m,{fill:"#e6e6e6"},h);n=h.style;delete h.style;F=y(m,{fill:"#e6ebf5",style:{color:"#000000",fontWeight:"bold"}},
F);k=F.style;delete F.style;C=y(m,{style:{color:"#cccccc"}},C);w=C.style;delete C.style;H(v.element,x?"mouseover":"mouseenter",function(){3!==d&&v.setState(1)});H(v.element,x?"mouseout":"mouseleave",function(){3!==d&&v.setState(d)});v.setState=function(a){1!==a&&(v.state=d=a);v.removeClass(/highcharts-button-(normal|hover|pressed|disabled)/).addClass("highcharts-button-"+["normal","hover","pressed","disabled"][a||0]);v.attr([m,h,F,C][a||0]).css([p,n,k,w][a||0])};v.attr(m).css(b({cursor:"default"},
p));return v.on("click",function(a){3!==d&&c.call(v,a)})},crispLine:function(a,g){a[1]===a[4]&&(a[1]=a[4]=Math.round(a[1])-g%2/2);a[2]===a[5]&&(a[2]=a[5]=Math.round(a[2])+g%2/2);return a},path:function(a){var g={fill:"none"};w(a)?g.d=a:C(a)&&b(g,a);return this.createElement("path").attr(g)},circle:function(a,g,e){a=C(a)?a:{x:a,y:g,r:e};g=this.createElement("circle");g.xSetter=g.ySetter=function(a,g,e){e.setAttribute("c"+g,a)};return g.attr(a)},arc:function(a,g,e,b,c,m){C(a)?(b=a,g=b.y,e=b.r,a=b.x):
b={innerR:b,start:c,end:m};a=this.symbol("arc",a,g,e,e,b);a.r=e;return a},rect:function(a,g,e,b,c,m){c=C(a)?a.r:c;var v=this.createElement("rect");a=C(a)?a:void 0===a?{}:{x:a,y:g,width:Math.max(e,0),height:Math.max(b,0)};void 0!==m&&(a.strokeWidth=m,a=v.crisp(a));a.fill="none";c&&(a.r=c);v.rSetter=function(a,g,e){r(e,{rx:a,ry:a})};return v.attr(a)},setSize:function(a,g,e){var b=this.alignedObjects,v=b.length;this.width=a;this.height=g;for(this.boxWrapper.animate({width:a,height:g},{step:function(){this.attr({viewBox:"0 0 "+
this.attr("width")+" "+this.attr("height")})},duration:K(e,!0)?void 0:0});v--;)b[v].align()},g:function(a){var g=this.createElement("g");return a?g.attr({"class":"highcharts-"+a}):g},image:function(a,g,e,c,m){var v={preserveAspectRatio:"none"};1<arguments.length&&b(v,{x:g,y:e,width:c,height:m});v=this.createElement("image").attr(v);v.element.setAttributeNS?v.element.setAttributeNS("http://www.w3.org/1999/xlink","href",a):v.element.setAttribute("hc-svg-href",a);return v},symbol:function(a,g,e,c,m,
h){var v=this,F,x=this.symbols[a],y=u(g)&&x&&this.symbols[a](Math.round(g),Math.round(e),c,m,h),C=/^url\((.*?)\)$/,d,t;x?(F=this.path(y),F.attr("fill","none"),b(F,{symbolName:a,x:g,y:e,width:c,height:m}),h&&b(F,h)):C.test(a)&&(d=a.match(C)[1],F=this.image(d),F.imgwidth=K(P[d]&&P[d].width,h&&h.width),F.imgheight=K(P[d]&&P[d].height,h&&h.height),t=function(){F.attr({width:F.width,height:F.height})},z(["width","height"],function(a){F[a+"Setter"]=function(a,g){var e={},b=this["img"+g],v="width"===g?"translateX":
"translateY";this[g]=a;u(b)&&(this.element&&this.element.setAttribute(g,b),this.alignByTranslate||(e[v]=((this[g]||0)-b)/2,this.attr(e)))}}),u(g)&&F.attr({x:g,y:e}),F.isImg=!0,u(F.imgwidth)&&u(F.imgheight)?t():(F.attr({width:0,height:0}),k("img",{onload:function(){var a=f[v.chartIndex];0===this.width&&(q(this,{position:"absolute",top:"-999em"}),n.body.appendChild(this));P[d]={width:this.width,height:this.height};F.imgwidth=this.width;F.imgheight=this.height;F.element&&t();this.parentNode&&this.parentNode.removeChild(this);
v.imgCount--;if(!v.imgCount&&a&&a.onload)a.onload()},src:d}),this.imgCount++));return F},symbols:{circle:function(a,g,e,b){return this.arc(a+e/2,g+b/2,e/2,b/2,{start:0,end:2*Math.PI,open:!1})},square:function(a,g,e,b){return["M",a,g,"L",a+e,g,a+e,g+b,a,g+b,"Z"]},triangle:function(a,g,e,b){return["M",a+e/2,g,"L",a+e,g+b,a,g+b,"Z"]},"triangle-down":function(a,g,e,b){return["M",a,g,"L",a+e,g,a+e/2,g+b,"Z"]},diamond:function(a,g,e,b){return["M",a+e/2,g,"L",a+e,g+b/2,a+e/2,g+b,a,g+b/2,"Z"]},arc:function(a,
g,e,b,c){var v=c.start,m=c.r||e,h=c.r||b||e,F=c.end-.001;e=c.innerR;b=c.open;var x=Math.cos(v),y=Math.sin(v),C=Math.cos(F),F=Math.sin(F);c=c.end-v<Math.PI?0:1;m=["M",a+m*x,g+h*y,"A",m,h,0,c,1,a+m*C,g+h*F];u(e)&&m.push(b?"M":"L",a+e*C,g+e*F,"A",e,e,0,c,0,a+e*x,g+e*y);m.push(b?"":"Z");return m},callout:function(a,g,e,b,c){var m=Math.min(c&&c.r||0,e,b),h=m+6,v=c&&c.anchorX;c=c&&c.anchorY;var F;F=["M",a+m,g,"L",a+e-m,g,"C",a+e,g,a+e,g,a+e,g+m,"L",a+e,g+b-m,"C",a+e,g+b,a+e,g+b,a+e-m,g+b,"L",a+m,g+b,"C",
a,g+b,a,g+b,a,g+b-m,"L",a,g+m,"C",a,g,a,g,a+m,g];v&&v>e?c>g+h&&c<g+b-h?F.splice(13,3,"L",a+e,c-6,a+e+6,c,a+e,c+6,a+e,g+b-m):F.splice(13,3,"L",a+e,b/2,v,c,a+e,b/2,a+e,g+b-m):v&&0>v?c>g+h&&c<g+b-h?F.splice(33,3,"L",a,c+6,a-6,c,a,c-6,a,g+m):F.splice(33,3,"L",a,b/2,v,c,a,b/2,a,g+m):c&&c>b&&v>a+h&&v<a+e-h?F.splice(23,3,"L",v+6,g+b,v,g+b+6,v-6,g+b,a+m,g+b):c&&0>c&&v>a+h&&v<a+e-h&&F.splice(3,3,"L",v-6,g,v,g-6,v+6,g,e-m,g);return F}},clipRect:function(g,e,b,c){var m=a.uniqueKey(),h=this.createElement("clipPath").attr({id:m}).add(this.defs);
g=this.rect(g,e,b,c,0).add(h);g.id=m;g.clipPath=h;g.count=0;return g},text:function(a,g,e,b){var c=!Q&&this.forExport,m={};if(b&&(this.allowHTML||!this.forExport))return this.html(a,g,e);m.x=Math.round(g||0);e&&(m.y=Math.round(e));if(a||0===a)m.text=a;a=this.createElement("text").attr(m);c&&a.css({position:"absolute"});b||(a.xSetter=function(a,g,e){var b=e.getElementsByTagName("tspan"),c,m=e.getAttribute(g),h;for(h=0;h<b.length;h++)c=b[h],c.getAttribute(g)===m&&c.setAttribute(g,a);e.setAttribute(g,
a)});return a},fontMetrics:function(a,g){a=a||g&&g.style&&g.style.fontSize||this.style&&this.style.fontSize;a=/px/.test(a)?J(a):/em/.test(a)?parseFloat(a)*(g?this.fontMetrics(null,g.parentNode).f:16):12;g=24>a?a+3:Math.round(1.2*a);return{h:g,b:Math.round(.8*g),f:a}},rotCorr:function(a,g,e){var b=a;g&&e&&(b=Math.max(b*Math.cos(g*d),4));return{x:-a/3*Math.sin(g*d),y:b}},label:function(e,c,m,h,F,x,C,d,t){var v=this,p=v.g("button"!==t&&"label"),n=p.text=v.text("",0,0,C).attr({zIndex:1}),k,w,E=0,f=3,
D=0,I,q,l,Q,N,K={},J,r,M=/^url\((.*?)\)$/.test(h),P=M,R,S,O,U;t&&p.addClass("highcharts-"+t);P=M;R=function(){return(J||0)%2/2};S=function(){var a=n.element.style,g={};w=(void 0===I||void 0===q||N)&&u(n.textStr)&&n.getBBox();p.width=(I||w.width||0)+2*f+D;p.height=(q||w.height||0)+2*f;r=f+v.fontMetrics(a&&a.fontSize,n).b;P&&(k||(p.box=k=v.symbols[h]||M?v.symbol(h):v.rect(),k.addClass(("button"===t?"":"highcharts-label-box")+(t?" highcharts-"+t+"-box":"")),k.add(p),a=R(),g.x=a,g.y=(d?-r:0)+a),g.width=
Math.round(p.width),g.height=Math.round(p.height),k.attr(b(g,K)),K={})};O=function(){var a=D+f,g;g=d?0:r;u(I)&&w&&("center"===N||"right"===N)&&(a+={center:.5,right:1}[N]*(I-w.width));if(a!==n.x||g!==n.y)n.attr("x",a),void 0!==g&&n.attr("y",g);n.x=a;n.y=g};U=function(a,g){k?k.attr(a,g):K[a]=g};p.onAdd=function(){n.add(p);p.attr({text:e||0===e?e:"",x:c,y:m});k&&u(F)&&p.attr({anchorX:F,anchorY:x})};p.widthSetter=function(g){I=a.isNumber(g)?g:null};p.heightSetter=function(a){q=a};p["text-alignSetter"]=
function(a){N=a};p.paddingSetter=function(a){u(a)&&a!==f&&(f=p.padding=a,O())};p.paddingLeftSetter=function(a){u(a)&&a!==D&&(D=a,O())};p.alignSetter=function(a){a={left:0,center:.5,right:1}[a];a!==E&&(E=a,w&&p.attr({x:l}))};p.textSetter=function(a){void 0!==a&&n.textSetter(a);S();O()};p["stroke-widthSetter"]=function(a,g){a&&(P=!0);J=this["stroke-width"]=a;U(g,a)};p.strokeSetter=p.fillSetter=p.rSetter=function(a,g){"fill"===g&&a&&(P=!0);U(g,a)};p.anchorXSetter=function(a,g){F=a;U(g,Math.round(a)-
R()-l)};p.anchorYSetter=function(a,g){x=a;U(g,a-Q)};p.xSetter=function(a){p.x=a;E&&(a-=E*((I||w.width)+2*f));l=Math.round(a);p.attr("translateX",l)};p.ySetter=function(a){Q=p.y=Math.round(a);p.attr("translateY",Q)};var W=p.css;return b(p,{css:function(a){if(a){var g={};a=y(a);z(p.textProps,function(e){void 0!==a[e]&&(g[e]=a[e],delete a[e])});n.css(g)}return W.call(p,a)},getBBox:function(){return{width:w.width+2*f,height:w.height+2*f,x:w.x-f,y:w.y-f}},shadow:function(a){a&&(S(),k&&k.shadow(a));return p},
destroy:function(){g(p.element,"mouseenter");g(p.element,"mouseleave");n&&(n=n.destroy());k&&(k=k.destroy());B.prototype.destroy.call(p);p=v=S=O=U=null}})}};a.Renderer=A})(L);(function(a){var B=a.attr,A=a.createElement,H=a.css,G=a.defined,r=a.each,f=a.extend,l=a.isFirefox,q=a.isMS,k=a.isWebKit,u=a.pInt,d=a.SVGRenderer,c=a.win,n=a.wrap;f(a.SVGElement.prototype,{htmlCss:function(a){var b=this.element;if(b=a&&"SPAN"===b.tagName&&a.width)delete a.width,this.textWidth=b,this.updateTransform();a&&"ellipsis"===
a.textOverflow&&(a.whiteSpace="nowrap",a.overflow="hidden");this.styles=f(this.styles,a);H(this.element,a);return this},htmlGetBBox:function(){var a=this.element;"text"===a.nodeName&&(a.style.position="absolute");return{x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight}},htmlUpdateTransform:function(){if(this.added){var a=this.renderer,b=this.element,c=this.translateX||0,h=this.translateY||0,d=this.x||0,n=this.y||0,w=this.textAlign||"left",e={left:0,center:.5,right:1}[w],x=this.styles;
H(b,{marginLeft:c,marginTop:h});this.shadows&&r(this.shadows,function(a){H(a,{marginLeft:c+1,marginTop:h+1})});this.inverted&&r(b.childNodes,function(e){a.invertChild(e,b)});if("SPAN"===b.tagName){var C=this.rotation,f=u(this.textWidth),m=x&&x.whiteSpace,y=[C,w,b.innerHTML,this.textWidth,this.textAlign].join();y!==this.cTT&&(x=a.fontMetrics(b.style.fontSize).b,G(C)&&this.setSpanRotation(C,e,x),H(b,{width:"",whiteSpace:m||"nowrap"}),b.offsetWidth>f&&/[ \-]/.test(b.textContent||b.innerText)&&H(b,{width:f+
"px",display:"block",whiteSpace:m||"normal"}),this.getSpanCorrection(b.offsetWidth,x,e,C,w));H(b,{left:d+(this.xCorr||0)+"px",top:n+(this.yCorr||0)+"px"});k&&(x=b.offsetHeight);this.cTT=y}}else this.alignOnAdd=!0},setSpanRotation:function(a,b,p){var h={},d=q?"-ms-transform":k?"-webkit-transform":l?"MozTransform":c.opera?"-o-transform":"";h[d]=h.transform="rotate("+a+"deg)";h[d+(l?"Origin":"-origin")]=h.transformOrigin=100*b+"% "+p+"px";H(this.element,h)},getSpanCorrection:function(a,b,c){this.xCorr=
-a*c;this.yCorr=-b}});f(d.prototype,{html:function(a,b,c){var h=this.createElement("span"),d=h.element,p=h.renderer,k=p.isSVG,e=function(a,e){r(["opacity","visibility"],function(b){n(a,b+"Setter",function(a,b,c,h){a.call(this,b,c,h);e[c]=b})})};h.textSetter=function(a){a!==d.innerHTML&&delete this.bBox;d.innerHTML=this.textStr=a;h.htmlUpdateTransform()};k&&e(h,h.element.style);h.xSetter=h.ySetter=h.alignSetter=h.rotationSetter=function(a,e){"align"===e&&(e="textAlign");h[e]=a;h.htmlUpdateTransform()};
h.attr({text:a,x:Math.round(b),y:Math.round(c)}).css({fontFamily:this.style.fontFamily,fontSize:this.style.fontSize,position:"absolute"});d.style.whiteSpace="nowrap";h.css=h.htmlCss;k&&(h.add=function(a){var b,c=p.box.parentNode,m=[];if(this.parentGroup=a){if(b=a.div,!b){for(;a;)m.push(a),a=a.parentGroup;r(m.reverse(),function(a){var x,d=B(a.element,"class");d&&(d={className:d});b=a.div=a.div||A("div",d,{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px",display:a.display,
opacity:a.opacity,pointerEvents:a.styles&&a.styles.pointerEvents},b||c);x=b.style;f(a,{on:function(){h.on.apply({element:m[0].div},arguments);return a},translateXSetter:function(e,g){x.left=e+"px";a[g]=e;a.doTransform=!0},translateYSetter:function(e,g){x.top=e+"px";a[g]=e;a.doTransform=!0}});e(a,x)})}}else b=c;b.appendChild(d);h.added=!0;h.alignOnAdd&&h.htmlUpdateTransform();return h});return h}})})(L);(function(a){var B,A,H=a.createElement,G=a.css,r=a.defined,f=a.deg2rad,l=a.discardElement,q=a.doc,
k=a.each,u=a.erase,d=a.extend;B=a.extendClass;var c=a.isArray,n=a.isNumber,z=a.isObject,b=a.merge;A=a.noop;var p=a.pick,h=a.pInt,t=a.SVGElement,D=a.SVGRenderer,w=a.win;a.svg||(A={docMode8:q&&8===q.documentMode,init:function(a,b){var e=["\x3c",b,' filled\x3d"f" stroked\x3d"f"'],c=["position: ","absolute",";"],m="div"===b;("shape"===b||m)&&c.push("left:0;top:0;width:1px;height:1px;");c.push("visibility: ",m?"hidden":"visible");e.push(' style\x3d"',c.join(""),'"/\x3e');b&&(e=m||"span"===b||"img"===b?
e.join(""):a.prepVML(e),this.element=H(e));this.renderer=a},add:function(a){var e=this.renderer,b=this.element,c=e.box,m=a&&a.inverted,c=a?a.element||a:c;a&&(this.parentGroup=a);m&&e.invertChild(b,c);c.appendChild(b);this.added=!0;this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform();if(this.onAdd)this.onAdd();this.className&&this.attr("class",this.className);return this},updateTransform:t.prototype.htmlUpdateTransform,setSpanRotation:function(){var a=this.rotation,b=Math.cos(a*f),c=
Math.sin(a*f);G(this.element,{filter:a?["progid:DXImageTransform.Microsoft.Matrix(M11\x3d",b,", M12\x3d",-c,", M21\x3d",c,", M22\x3d",b,", sizingMethod\x3d'auto expand')"].join(""):"none"})},getSpanCorrection:function(a,b,c,h,m){var e=h?Math.cos(h*f):1,x=h?Math.sin(h*f):0,d=p(this.elemHeight,this.element.offsetHeight),t;this.xCorr=0>e&&-a;this.yCorr=0>x&&-d;t=0>e*x;this.xCorr+=x*b*(t?1-c:c);this.yCorr-=e*b*(h?t?c:1-c:1);m&&"left"!==m&&(this.xCorr-=a*c*(0>e?-1:1),h&&(this.yCorr-=d*c*(0>x?-1:1)),G(this.element,
{textAlign:m}))},pathToVML:function(a){for(var e=a.length,b=[];e--;)n(a[e])?b[e]=Math.round(10*a[e])-5:"Z"===a[e]?b[e]="x":(b[e]=a[e],!a.isArc||"wa"!==a[e]&&"at"!==a[e]||(b[e+5]===b[e+7]&&(b[e+7]+=a[e+7]>a[e+5]?1:-1),b[e+6]===b[e+8]&&(b[e+8]+=a[e+8]>a[e+6]?1:-1)));return b.join(" ")||"x"},clip:function(a){var e=this,b;a?(b=a.members,u(b,e),b.push(e),e.destroyClip=function(){u(b,e)},a=a.getCSS(e)):(e.destroyClip&&e.destroyClip(),a={clip:e.docMode8?"inherit":"rect(auto)"});return e.css(a)},css:t.prototype.htmlCss,
safeRemoveChild:function(a){a.parentNode&&l(a)},destroy:function(){this.destroyClip&&this.destroyClip();return t.prototype.destroy.apply(this)},on:function(a,b){this.element["on"+a]=function(){var a=w.event;a.target=a.srcElement;b(a)};return this},cutOffPath:function(a,b){var e;a=a.split(/[ ,]/);e=a.length;if(9===e||11===e)a[e-4]=a[e-2]=h(a[e-2])-10*b;return a.join(" ")},shadow:function(a,b,c){var e=[],m,d=this.element,t=this.renderer,x,n=d.style,g,F=d.path,k,C,w,f;F&&"string"!==typeof F.value&&(F=
"x");C=F;if(a){w=p(a.width,3);f=(a.opacity||.15)/w;for(m=1;3>=m;m++)k=2*w+1-2*m,c&&(C=this.cutOffPath(F.value,k+.5)),g=['\x3cshape isShadow\x3d"true" strokeweight\x3d"',k,'" filled\x3d"false" path\x3d"',C,'" coordsize\x3d"10 10" style\x3d"',d.style.cssText,'" /\x3e'],x=H(t.prepVML(g),null,{left:h(n.left)+p(a.offsetX,1),top:h(n.top)+p(a.offsetY,1)}),c&&(x.cutOff=k+1),g=['\x3cstroke color\x3d"',a.color||"#000000",'" opacity\x3d"',f*m,'"/\x3e'],H(t.prepVML(g),null,null,x),b?b.element.appendChild(x):
d.parentNode.insertBefore(x,d),e.push(x);this.shadows=e}return this},updateShadows:A,setAttr:function(a,b){this.docMode8?this.element[a]=b:this.element.setAttribute(a,b)},classSetter:function(a){(this.added?this.element:this).className=a},dashstyleSetter:function(a,b,c){(c.getElementsByTagName("stroke")[0]||H(this.renderer.prepVML(["\x3cstroke/\x3e"]),null,null,c))[b]=a||"solid";this[b]=a},dSetter:function(a,b,c){var e=this.shadows;a=a||[];this.d=a.join&&a.join(" ");c.path=a=this.pathToVML(a);if(e)for(c=
e.length;c--;)e[c].path=e[c].cutOff?this.cutOffPath(a,e[c].cutOff):a;this.setAttr(b,a)},fillSetter:function(a,b,c){var e=c.nodeName;"SPAN"===e?c.style.color=a:"IMG"!==e&&(c.filled="none"!==a,this.setAttr("fillcolor",this.renderer.color(a,c,b,this)))},"fill-opacitySetter":function(a,b,c){H(this.renderer.prepVML(["\x3c",b.split("-")[0],' opacity\x3d"',a,'"/\x3e']),null,null,c)},opacitySetter:A,rotationSetter:function(a,b,c){c=c.style;this[b]=c[b]=a;c.left=-Math.round(Math.sin(a*f)+1)+"px";c.top=Math.round(Math.cos(a*
f))+"px"},strokeSetter:function(a,b,c){this.setAttr("strokecolor",this.renderer.color(a,c,b,this))},"stroke-widthSetter":function(a,b,c){c.stroked=!!a;this[b]=a;n(a)&&(a+="px");this.setAttr("strokeweight",a)},titleSetter:function(a,b){this.setAttr(b,a)},visibilitySetter:function(a,b,c){"inherit"===a&&(a="visible");this.shadows&&k(this.shadows,function(e){e.style[b]=a});"DIV"===c.nodeName&&(a="hidden"===a?"-999em":0,this.docMode8||(c.style[b]=a?"visible":"hidden"),b="top");c.style[b]=a},xSetter:function(a,
b,c){this[b]=a;"x"===b?b="left":"y"===b&&(b="top");this.updateClipping?(this[b]=a,this.updateClipping()):c.style[b]=a},zIndexSetter:function(a,b,c){c.style[b]=a}},A["stroke-opacitySetter"]=A["fill-opacitySetter"],a.VMLElement=A=B(t,A),A.prototype.ySetter=A.prototype.widthSetter=A.prototype.heightSetter=A.prototype.xSetter,A={Element:A,isIE8:-1<w.navigator.userAgent.indexOf("MSIE 8.0"),init:function(a,b,c){var e,m;this.alignedObjects=[];e=this.createElement("div").css({position:"relative"});m=e.element;
a.appendChild(e.element);this.isVML=!0;this.box=m;this.boxWrapper=e;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(b,c,!1);if(!q.namespaces.hcv){q.namespaces.add("hcv","urn:schemas-microsoft-com:vml");try{q.createStyleSheet().cssText="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}catch(y){q.styleSheets[0].cssText+="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}}},
isHidden:function(){return!this.box.offsetWidth},clipRect:function(a,b,c,h){var e=this.createElement(),p=z(a);return d(e,{members:[],count:0,left:(p?a.x:a)+1,top:(p?a.y:b)+1,width:(p?a.width:c)-1,height:(p?a.height:h)-1,getCSS:function(a){var b=a.element,c=b.nodeName,g=a.inverted,e=this.top-("shape"===c?b.offsetTop:0),m=this.left,b=m+this.width,h=e+this.height,e={clip:"rect("+Math.round(g?m:e)+"px,"+Math.round(g?h:b)+"px,"+Math.round(g?b:h)+"px,"+Math.round(g?e:m)+"px)"};!g&&a.docMode8&&"DIV"===c&&
d(e,{width:b+"px",height:h+"px"});return e},updateClipping:function(){k(e.members,function(a){a.element&&a.css(e.getCSS(a))})}})},color:function(b,c,h,d){var e=this,p,t=/^rgba/,n,x,g="none";b&&b.linearGradient?x="gradient":b&&b.radialGradient&&(x="pattern");if(x){var F,w,f=b.linearGradient||b.radialGradient,C,u,v,D,q,l="";b=b.stops;var z,E=[],r=function(){n=['\x3cfill colors\x3d"'+E.join(",")+'" opacity\x3d"',v,'" o:opacity2\x3d"',u,'" type\x3d"',x,'" ',l,'focus\x3d"100%" method\x3d"any" /\x3e'];
H(e.prepVML(n),null,null,c)};C=b[0];z=b[b.length-1];0<C[0]&&b.unshift([0,C[1]]);1>z[0]&&b.push([1,z[1]]);k(b,function(g,b){t.test(g[1])?(p=a.color(g[1]),F=p.get("rgb"),w=p.get("a")):(F=g[1],w=1);E.push(100*g[0]+"% "+F);b?(v=w,D=F):(u=w,q=F)});if("fill"===h)if("gradient"===x)h=f.x1||f[0]||0,b=f.y1||f[1]||0,C=f.x2||f[2]||0,f=f.y2||f[3]||0,l='angle\x3d"'+(90-180*Math.atan((f-b)/(C-h))/Math.PI)+'"',r();else{var g=f.r,A=2*g,B=2*g,G=f.cx,V=f.cy,L=c.radialReference,T,g=function(){L&&(T=d.getBBox(),G+=(L[0]-
T.x)/T.width-.5,V+=(L[1]-T.y)/T.height-.5,A*=L[2]/T.width,B*=L[2]/T.height);l='src\x3d"'+a.getOptions().global.VMLRadialGradientURL+'" size\x3d"'+A+","+B+'" origin\x3d"0.5,0.5" position\x3d"'+G+","+V+'" color2\x3d"'+q+'" ';r()};d.added?g():d.onAdd=g;g=D}else g=F}else t.test(b)&&"IMG"!==c.tagName?(p=a.color(b),d[h+"-opacitySetter"](p.get("a"),h,c),g=p.get("rgb")):(g=c.getElementsByTagName(h),g.length&&(g[0].opacity=1,g[0].type="solid"),g=b);return g},prepVML:function(a){var b=this.isIE8;a=a.join("");
b?(a=a.replace("/\x3e",' xmlns\x3d"urn:schemas-microsoft-com:vml" /\x3e'),a=-1===a.indexOf('style\x3d"')?a.replace("/\x3e",' style\x3d"display:inline-block;behavior:url(#default#VML);" /\x3e'):a.replace('style\x3d"','style\x3d"display:inline-block;behavior:url(#default#VML);')):a=a.replace("\x3c","\x3chcv:");return a},text:D.prototype.html,path:function(a){var b={coordsize:"10 10"};c(a)?b.d=a:z(a)&&d(b,a);return this.createElement("shape").attr(b)},circle:function(a,b,c){var e=this.symbol("circle");
z(a)&&(c=a.r,b=a.y,a=a.x);e.isCircle=!0;e.r=c;return e.attr({x:a,y:b})},g:function(a){var b;a&&(b={className:"highcharts-"+a,"class":"highcharts-"+a});return this.createElement("div").attr(b)},image:function(a,b,c,h,m){var e=this.createElement("img").attr({src:a});1<arguments.length&&e.attr({x:b,y:c,width:h,height:m});return e},createElement:function(a){return"rect"===a?this.symbol(a):D.prototype.createElement.call(this,a)},invertChild:function(a,b){var c=this;b=b.style;var e="IMG"===a.tagName&&a.style;
G(a,{flip:"x",left:h(b.width)-(e?h(e.top):1),top:h(b.height)-(e?h(e.left):1),rotation:-90});k(a.childNodes,function(b){c.invertChild(b,a)})},symbols:{arc:function(a,b,c,h,m){var e=m.start,d=m.end,p=m.r||c||h;c=m.innerR;h=Math.cos(e);var t=Math.sin(e),g=Math.cos(d),F=Math.sin(d);if(0===d-e)return["x"];e=["wa",a-p,b-p,a+p,b+p,a+p*h,b+p*t,a+p*g,b+p*F];m.open&&!c&&e.push("e","M",a,b);e.push("at",a-c,b-c,a+c,b+c,a+c*g,b+c*F,a+c*h,b+c*t,"x","e");e.isArc=!0;return e},circle:function(a,b,c,h,m){m&&r(m.r)&&
(c=h=2*m.r);m&&m.isCircle&&(a-=c/2,b-=h/2);return["wa",a,b,a+c,b+h,a+c,b+h/2,a+c,b+h/2,"e"]},rect:function(a,b,c,h,m){return D.prototype.symbols[r(m)&&m.r?"callout":"square"].call(0,a,b,c,h,m)}}},a.VMLRenderer=B=function(){this.init.apply(this,arguments)},B.prototype=b(D.prototype,A),a.Renderer=B);D.prototype.measureSpanWidth=function(a,b){var c=q.createElement("span");a=q.createTextNode(a);c.appendChild(a);G(c,b);this.box.appendChild(c);b=c.offsetWidth;l(c);return b}})(L);(function(a){function B(){var k=
a.defaultOptions.global,f=q.moment;if(k.timezone){if(f)return function(a){return-f.tz(a,k.timezone).utcOffset()};a.error(25)}return k.useUTC&&k.getTimezoneOffset}function A(){var k=a.defaultOptions.global,f,d=k.useUTC,c=d?"getUTC":"get",n=d?"setUTC":"set";a.Date=f=k.Date||q.Date;f.hcTimezoneOffset=d&&k.timezoneOffset;f.hcGetTimezoneOffset=B();f.hcMakeTime=function(a,b,c,h,t,n){var p;d?(p=f.UTC.apply(0,arguments),p+=r(p)):p=(new f(a,b,l(c,1),l(h,0),l(t,0),l(n,0))).getTime();return p};G("Minutes Hours Day Date Month FullYear".split(" "),
function(a){f["hcGet"+a]=c+a});G("Milliseconds Seconds Minutes Hours Date Month FullYear".split(" "),function(a){f["hcSet"+a]=n+a})}var H=a.color,G=a.each,r=a.getTZOffset,f=a.merge,l=a.pick,q=a.win;a.defaultOptions={colors:"#7cb5ec #434348 #90ed7d #f7a35c #8085e9 #f15c80 #e4d354 #2b908f #f45b5b #91e8e1".split(" "),symbols:["circle","diamond","square","triangle","triangle-down"],lang:{loading:"Loading...",months:"January February March April May June July August September October November December".split(" "),
shortMonths:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),weekdays:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),decimalPoint:".",numericSymbols:"kMGTPE".split(""),resetZoom:"Reset zoom",resetZoomTitle:"Reset zoom level 1:1",thousandsSep:" "},global:{useUTC:!0,VMLRadialGradientURL:"http://code.highcharts.com/5.0.10/gfx/vml-radial-gradient.png"},chart:{borderRadius:0,defaultSeriesType:"line",ignoreHiddenSeries:!0,spacing:[10,10,15,10],resetZoomButton:{theme:{zIndex:20},
position:{align:"right",x:-10,y:10}},width:null,height:null,borderColor:"#335cad",backgroundColor:"#ffffff",plotBorderColor:"#cccccc"},title:{text:"Chart title",align:"center",margin:15,widthAdjust:-44},subtitle:{text:"",align:"center",widthAdjust:-44},plotOptions:{},labels:{style:{position:"absolute",color:"#333333"}},legend:{enabled:!0,align:"center",layout:"horizontal",labelFormatter:function(){return this.name},borderColor:"#999999",borderRadius:0,navigation:{activeColor:"#003399",inactiveColor:"#cccccc"},
itemStyle:{color:"#333333",fontSize:"12px",fontWeight:"bold"},itemHoverStyle:{color:"#000000"},itemHiddenStyle:{color:"#cccccc"},shadow:!1,itemCheckboxStyle:{position:"absolute",width:"13px",height:"13px"},squareSymbol:!0,symbolPadding:5,verticalAlign:"bottom",x:0,y:0,title:{style:{fontWeight:"bold"}}},loading:{labelStyle:{fontWeight:"bold",position:"relative",top:"45%"},style:{position:"absolute",backgroundColor:"#ffffff",opacity:.5,textAlign:"center"}},tooltip:{enabled:!0,animation:a.svg,borderRadius:3,
dateTimeLabelFormats:{millisecond:"%A, %b %e, %H:%M:%S.%L",second:"%A, %b %e, %H:%M:%S",minute:"%A, %b %e, %H:%M",hour:"%A, %b %e, %H:%M",day:"%A, %b %e, %Y",week:"Week from %A, %b %e, %Y",month:"%B %Y",year:"%Y"},footerFormat:"",padding:8,snap:a.isTouchDevice?25:10,backgroundColor:H("#f7f7f7").setOpacity(.85).get(),borderWidth:1,headerFormat:'\x3cspan style\x3d"font-size: 10px"\x3e{point.key}\x3c/span\x3e\x3cbr/\x3e',pointFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e {series.name}: \x3cb\x3e{point.y}\x3c/b\x3e\x3cbr/\x3e',
shadow:!0,style:{color:"#333333",cursor:"default",fontSize:"12px",pointerEvents:"none",whiteSpace:"nowrap"}},credits:{enabled:!0,href:"http://www.highcharts.com",position:{align:"right",x:-10,verticalAlign:"bottom",y:-5},style:{cursor:"pointer",color:"#999999",fontSize:"9px"},text:"Highcharts.com"}};a.setOptions=function(k){a.defaultOptions=f(!0,a.defaultOptions,k);A();return a.defaultOptions};a.getOptions=function(){return a.defaultOptions};a.defaultPlotOptions=a.defaultOptions.plotOptions;A()})(L);
(function(a){var B=a.arrayMax,A=a.arrayMin,H=a.defined,G=a.destroyObjectProperties,r=a.each,f=a.erase,l=a.merge,q=a.pick;a.PlotLineOrBand=function(a,f){this.axis=a;f&&(this.options=f,this.id=f.id)};a.PlotLineOrBand.prototype={render:function(){var a=this,f=a.axis,d=f.horiz,c=a.options,n=c.label,z=a.label,b=c.to,p=c.from,h=c.value,t=H(p)&&H(b),D=H(h),w=a.svgElem,e=!w,x=[],C,E=c.color,m=q(c.zIndex,0),y=c.events,x={"class":"highcharts-plot-"+(t?"band ":"line ")+(c.className||"")},I={},r=f.chart.renderer,
J=t?"bands":"lines",g=f.log2lin;f.isLog&&(p=g(p),b=g(b),h=g(h));D?(x={stroke:E,"stroke-width":c.width},c.dashStyle&&(x.dashstyle=c.dashStyle)):t&&(E&&(x.fill=E),c.borderWidth&&(x.stroke=c.borderColor,x["stroke-width"]=c.borderWidth));I.zIndex=m;J+="-"+m;(E=f.plotLinesAndBandsGroups[J])||(f.plotLinesAndBandsGroups[J]=E=r.g("plot-"+J).attr(I).add());e&&(a.svgElem=w=r.path().attr(x).add(E));if(D)x=f.getPlotLinePath(h,w.strokeWidth());else if(t)x=f.getPlotBandPath(p,b,c);else return;if(e&&x&&x.length){if(w.attr({d:x}),
y)for(C in c=function(g){w.on(g,function(b){y[g].apply(a,[b])})},y)c(C)}else w&&(x?(w.show(),w.animate({d:x})):(w.hide(),z&&(a.label=z=z.destroy())));n&&H(n.text)&&x&&x.length&&0<f.width&&0<f.height&&!x.flat?(n=l({align:d&&t&&"center",x:d?!t&&4:10,verticalAlign:!d&&t&&"middle",y:d?t?16:10:t?6:-4,rotation:d&&!t&&90},n),this.renderLabel(n,x,t,m)):z&&z.hide();return a},renderLabel:function(a,f,d,c){var n=this.label,k=this.axis.chart.renderer;n||(n={align:a.textAlign||a.align,rotation:a.rotation,"class":"highcharts-plot-"+
(d?"band":"line")+"-label "+(a.className||"")},n.zIndex=c,this.label=n=k.text(a.text,0,0,a.useHTML).attr(n).add(),n.css(a.style));c=[f[1],f[4],d?f[6]:f[1]];f=[f[2],f[5],d?f[7]:f[2]];d=A(c);k=A(f);n.align(a,!1,{x:d,y:k,width:B(c)-d,height:B(f)-k});n.show()},destroy:function(){f(this.axis.plotLinesAndBands,this);delete this.axis;G(this)}};a.AxisPlotLineOrBandExtension={getPlotBandPath:function(a,f){var d=this.getPlotLinePath(f,null,null,!0),c=this.getPlotLinePath(a,null,null,!0),n=this.horiz,k=1;a=
a<this.min&&f<this.min||a>this.max&&f>this.max;c&&d?(a&&(c.flat=c.toString()===d.toString(),k=0),c.push(n&&d[4]===c[4]?d[4]+k:d[4],n||d[5]!==c[5]?d[5]:d[5]+k,n&&d[1]===c[1]?d[1]+k:d[1],n||d[2]!==c[2]?d[2]:d[2]+k)):c=null;return c},addPlotBand:function(a){return this.addPlotBandOrLine(a,"plotBands")},addPlotLine:function(a){return this.addPlotBandOrLine(a,"plotLines")},addPlotBandOrLine:function(f,q){var d=(new a.PlotLineOrBand(this,f)).render(),c=this.userOptions;d&&(q&&(c[q]=c[q]||[],c[q].push(f)),
this.plotLinesAndBands.push(d));return d},removePlotBandOrLine:function(a){for(var k=this.plotLinesAndBands,d=this.options,c=this.userOptions,n=k.length;n--;)k[n].id===a&&k[n].destroy();r([d.plotLines||[],c.plotLines||[],d.plotBands||[],c.plotBands||[]],function(c){for(n=c.length;n--;)c[n].id===a&&f(c,c[n])})}}})(L);(function(a){var B=a.correctFloat,A=a.defined,H=a.destroyObjectProperties,G=a.isNumber,r=a.merge,f=a.pick,l=a.deg2rad;a.Tick=function(a,f,l,d){this.axis=a;this.pos=f;this.type=l||"";this.isNew=
!0;l||d||this.addLabel()};a.Tick.prototype={addLabel:function(){var a=this.axis,k=a.options,l=a.chart,d=a.categories,c=a.names,n=this.pos,z=k.labels,b=a.tickPositions,p=n===b[0],h=n===b[b.length-1],c=d?f(d[n],c[n],n):n,d=this.label,b=b.info,t;a.isDatetimeAxis&&b&&(t=k.dateTimeLabelFormats[b.higherRanks[n]||b.unitName]);this.isFirst=p;this.isLast=h;k=a.labelFormatter.call({axis:a,chart:l,isFirst:p,isLast:h,dateTimeLabelFormat:t,value:a.isLog?B(a.lin2log(c)):c});A(d)?d&&d.attr({text:k}):(this.labelLength=
(this.label=d=A(k)&&z.enabled?l.renderer.text(k,0,0,z.useHTML).css(r(z.style)).add(a.labelGroup):null)&&d.getBBox().width,this.rotation=0)},getLabelSize:function(){return this.label?this.label.getBBox()[this.axis.horiz?"height":"width"]:0},handleOverflow:function(a){var k=this.axis,q=a.x,d=k.chart.chartWidth,c=k.chart.spacing,n=f(k.labelLeft,Math.min(k.pos,c[3])),c=f(k.labelRight,Math.max(k.pos+k.len,d-c[1])),z=this.label,b=this.rotation,p={left:0,center:.5,right:1}[k.labelAlign],h=z.getBBox().width,
t=k.getSlotWidth(),D=t,w=1,e,x={};if(b)0>b&&q-p*h<n?e=Math.round(q/Math.cos(b*l)-n):0<b&&q+p*h>c&&(e=Math.round((d-q)/Math.cos(b*l)));else if(d=q+(1-p)*h,q-p*h<n?D=a.x+D*(1-p)-n:d>c&&(D=c-a.x+D*p,w=-1),D=Math.min(t,D),D<t&&"center"===k.labelAlign&&(a.x+=w*(t-D-p*(t-Math.min(h,D)))),h>D||k.autoRotation&&(z.styles||{}).width)e=D;e&&(x.width=e,(k.options.labels.style||{}).textOverflow||(x.textOverflow="ellipsis"),z.css(x))},getPosition:function(a,f,l,d){var c=this.axis,n=c.chart,k=d&&n.oldChartHeight||
n.chartHeight;return{x:a?c.translate(f+l,null,null,d)+c.transB:c.left+c.offset+(c.opposite?(d&&n.oldChartWidth||n.chartWidth)-c.right-c.left:0),y:a?k-c.bottom+c.offset-(c.opposite?c.height:0):k-c.translate(f+l,null,null,d)-c.transB}},getLabelPosition:function(a,f,u,d,c,n,z,b){var p=this.axis,h=p.transA,t=p.reversed,k=p.staggerLines,w=p.tickRotCorr||{x:0,y:0},e=c.y;A(e)||(e=0===p.side?u.rotation?-8:-u.getBBox().height:2===p.side?w.y+8:Math.cos(u.rotation*l)*(w.y-u.getBBox(!1,0).height/2));a=a+c.x+
w.x-(n&&d?n*h*(t?-1:1):0);f=f+e-(n&&!d?n*h*(t?1:-1):0);k&&(u=z/(b||1)%k,p.opposite&&(u=k-u-1),f+=p.labelOffset/k*u);return{x:a,y:Math.round(f)}},getMarkPath:function(a,f,l,d,c,n){return n.crispLine(["M",a,f,"L",a+(c?0:-l),f+(c?l:0)],d)},renderGridLine:function(a,f,l){var d=this.axis,c=d.options,n=this.gridLine,k={},b=this.pos,p=this.type,h=d.tickmarkOffset,t=d.chart.renderer,D=p?p+"Grid":"grid",w=c[D+"LineWidth"],e=c[D+"LineColor"],c=c[D+"LineDashStyle"];n||(k.stroke=e,k["stroke-width"]=w,c&&(k.dashstyle=
c),p||(k.zIndex=1),a&&(k.opacity=0),this.gridLine=n=t.path().attr(k).addClass("highcharts-"+(p?p+"-":"")+"grid-line").add(d.gridGroup));if(!a&&n&&(a=d.getPlotLinePath(b+h,n.strokeWidth()*l,a,!0)))n[this.isNew?"attr":"animate"]({d:a,opacity:f})},renderMark:function(a,k,l){var d=this.axis,c=d.options,n=d.chart.renderer,q=this.type,b=q?q+"Tick":"tick",p=d.tickSize(b),h=this.mark,t=!h,D=a.x;a=a.y;var w=f(c[b+"Width"],!q&&d.isXAxis?1:0),c=c[b+"Color"];p&&(d.opposite&&(p[0]=-p[0]),t&&(this.mark=h=n.path().addClass("highcharts-"+
(q?q+"-":"")+"tick").add(d.axisGroup),h.attr({stroke:c,"stroke-width":w})),h[t?"attr":"animate"]({d:this.getMarkPath(D,a,p[0],h.strokeWidth()*l,d.horiz,n),opacity:k}))},renderLabel:function(a,k,l,d){var c=this.axis,n=c.horiz,q=c.options,b=this.label,p=q.labels,h=p.step,t=c.tickmarkOffset,D=!0,w=a.x;a=a.y;b&&G(w)&&(b.xy=a=this.getLabelPosition(w,a,b,n,p,t,d,h),this.isFirst&&!this.isLast&&!f(q.showFirstLabel,1)||this.isLast&&!this.isFirst&&!f(q.showLastLabel,1)?D=!1:!n||c.isRadial||p.step||p.rotation||
k||0===l||this.handleOverflow(a),h&&d%h&&(D=!1),D&&G(a.y)?(a.opacity=l,b[this.isNew?"attr":"animate"](a)):b.attr("y",-9999),this.isNew=!1)},render:function(a,k,l){var d=this.axis,c=d.horiz,n=this.getPosition(c,this.pos,d.tickmarkOffset,k),q=n.x,b=n.y,d=c&&q===d.pos+d.len||!c&&b===d.pos?-1:1;l=f(l,1);this.isActive=!0;this.renderGridLine(k,l,d);this.renderMark(n,l,d);this.renderLabel(n,k,l,a)},destroy:function(){H(this,this.axis)}}})(L);(function(a){var B=a.addEvent,A=a.animObject,H=a.arrayMax,G=a.arrayMin,
r=a.AxisPlotLineOrBandExtension,f=a.color,l=a.correctFloat,q=a.defaultOptions,k=a.defined,u=a.deg2rad,d=a.destroyObjectProperties,c=a.each,n=a.extend,z=a.fireEvent,b=a.format,p=a.getMagnitude,h=a.grep,t=a.inArray,D=a.isArray,w=a.isNumber,e=a.isString,x=a.merge,C=a.normalizeTickInterval,E=a.pick,m=a.PlotLineOrBand,y=a.removeEvent,I=a.splat,K=a.syncTimeout,J=a.Tick;a.Axis=function(){this.init.apply(this,arguments)};a.Axis.prototype={defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",
minute:"%H:%M",hour:"%H:%M",day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,labels:{enabled:!0,style:{color:"#666666",cursor:"default",fontSize:"11px"},x:0},minPadding:.01,maxPadding:.01,minorTickLength:2,minorTickPosition:"outside",startOfWeek:1,startOnTick:!1,tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",title:{align:"middle",style:{color:"#666666"}},type:"linear",minorGridLineColor:"#f2f2f2",minorGridLineWidth:1,minorTickColor:"#999999",
lineColor:"#ccd6eb",lineWidth:1,gridLineColor:"#e6e6e6",tickColor:"#ccd6eb"},defaultYAxisOptions:{endOnTick:!0,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8},maxPadding:.05,minPadding:.05,startOnTick:!0,title:{rotation:270,text:"Values"},stackLabels:{enabled:!1,formatter:function(){return a.numberFormat(this.total,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"#000000",textOutline:"1px contrast"}},gridLineWidth:1,lineWidth:0},defaultLeftAxisOptions:{labels:{x:-15},title:{rotation:270}},
defaultRightAxisOptions:{labels:{x:15},title:{rotation:90}},defaultBottomAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},defaultTopAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},init:function(a,b){var g=b.isX;this.chart=a;this.horiz=a.inverted?!g:g;this.isXAxis=g;this.coll=this.coll||(g?"xAxis":"yAxis");this.opposite=b.opposite;this.side=b.side||(this.horiz?this.opposite?0:2:this.opposite?1:3);this.setOptions(b);var c=this.options,e=c.type;this.labelFormatter=c.labels.formatter||
this.defaultLabelFormatter;this.userOptions=b;this.minPixelPadding=0;this.reversed=c.reversed;this.visible=!1!==c.visible;this.zoomEnabled=!1!==c.zoomEnabled;this.hasNames="category"===e||!0===c.categories;this.categories=c.categories||this.hasNames;this.names=this.names||[];this.plotLinesAndBandsGroups={};this.isLog="logarithmic"===e;this.isDatetimeAxis="datetime"===e;this.positiveValuesOnly=this.isLog&&!this.allowNegativeLog;this.isLinked=k(c.linkedTo);this.ticks={};this.labelEdge=[];this.minorTicks=
{};this.plotLinesAndBands=[];this.alternateBands={};this.len=0;this.minRange=this.userMinRange=c.minRange||c.maxZoom;this.range=c.range;this.offset=c.offset||0;this.stacks={};this.oldStacks={};this.stacksTouched=0;this.min=this.max=null;this.crosshair=E(c.crosshair,I(a.options.tooltip.crosshairs)[g?0:1],!1);var h;b=this.options.events;-1===t(this,a.axes)&&(g?a.axes.splice(a.xAxis.length,0,this):a.axes.push(this),a[this.coll].push(this));this.series=this.series||[];a.inverted&&g&&void 0===this.reversed&&
(this.reversed=!0);this.removePlotLine=this.removePlotBand=this.removePlotBandOrLine;for(h in b)B(this,h,b[h]);this.lin2log=c.linearToLogConverter||this.lin2log;this.isLog&&(this.val2lin=this.log2lin,this.lin2val=this.lin2log)},setOptions:function(a){this.options=x(this.defaultOptions,"yAxis"===this.coll&&this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions,this.defaultLeftAxisOptions][this.side],x(q[this.coll],a))},defaultLabelFormatter:function(){var g=
this.axis,c=this.value,e=g.categories,h=this.dateTimeLabelFormat,m=q.lang,d=m.numericSymbols,m=m.numericSymbolMagnitude||1E3,v=d&&d.length,p,t=g.options.labels.format,g=g.isLog?Math.abs(c):g.tickInterval;if(t)p=b(t,this);else if(e)p=c;else if(h)p=a.dateFormat(h,c);else if(v&&1E3<=g)for(;v--&&void 0===p;)e=Math.pow(m,v+1),g>=e&&0===10*c%e&&null!==d[v]&&0!==c&&(p=a.numberFormat(c/e,-1)+d[v]);void 0===p&&(p=1E4<=Math.abs(c)?a.numberFormat(c,-1):a.numberFormat(c,-1,void 0,""));return p},getSeriesExtremes:function(){var a=
this,b=a.chart;a.hasVisibleSeries=!1;a.dataMin=a.dataMax=a.threshold=null;a.softThreshold=!a.isXAxis;a.buildStacks&&a.buildStacks();c(a.series,function(g){if(g.visible||!b.options.chart.ignoreHiddenSeries){var c=g.options,e=c.threshold,m;a.hasVisibleSeries=!0;a.positiveValuesOnly&&0>=e&&(e=null);if(a.isXAxis)c=g.xData,c.length&&(g=G(c),w(g)||g instanceof Date||(c=h(c,function(a){return w(a)}),g=G(c)),a.dataMin=Math.min(E(a.dataMin,c[0]),g),a.dataMax=Math.max(E(a.dataMax,c[0]),H(c)));else if(g.getExtremes(),
m=g.dataMax,g=g.dataMin,k(g)&&k(m)&&(a.dataMin=Math.min(E(a.dataMin,g),g),a.dataMax=Math.max(E(a.dataMax,m),m)),k(e)&&(a.threshold=e),!c.softThreshold||a.positiveValuesOnly)a.softThreshold=!1}})},translate:function(a,b,c,e,h,m){var g=this.linkedParent||this,F=1,p=0,d=e?g.oldTransA:g.transA;e=e?g.oldMin:g.min;var t=g.minPixelPadding;h=(g.isOrdinal||g.isBroken||g.isLog&&h)&&g.lin2val;d||(d=g.transA);c&&(F*=-1,p=g.len);g.reversed&&(F*=-1,p-=F*(g.sector||g.len));b?(a=(a*F+p-t)/d+e,h&&(a=g.lin2val(a))):
(h&&(a=g.val2lin(a)),a=F*(a-e)*d+p+F*t+(w(m)?d*m:0));return a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a-(b?0:this.pos),!0,!this.horiz,null,!0)},getPlotLinePath:function(a,b,c,e,h){var g=this.chart,m=this.left,F=this.top,p,d,t=c&&g.oldChartHeight||g.chartHeight,f=c&&g.oldChartWidth||g.chartWidth,n;p=this.transB;var y=function(a,b,g){if(a<b||a>g)e?a=Math.min(Math.max(b,a),g):n=!0;return a};h=E(h,this.translate(a,
null,null,c));a=c=Math.round(h+p);p=d=Math.round(t-h-p);w(h)?this.horiz?(p=F,d=t-this.bottom,a=c=y(a,m,m+this.width)):(a=m,c=f-this.right,p=d=y(p,F,F+this.height)):n=!0;return n&&!e?null:g.renderer.crispLine(["M",a,p,"L",c,d],b||1)},getLinearTickPositions:function(a,b,c){var g,e=l(Math.floor(b/a)*a);c=l(Math.ceil(c/a)*a);var h=[];if(this.single)return[b];for(b=e;b<=c;){h.push(b);b=l(b+a);if(b===g)break;g=b}return h},getMinorTickPositions:function(){var a=this,b=a.options,e=a.tickPositions,h=a.minorTickInterval,
m=[],p=a.pointRangePadding||0,v=a.min-p,p=a.max+p,d=p-v;if(d&&d/h<a.len/3)if(a.isLog)c(this.paddedTicks,function(b,g,c){g&&m.push.apply(m,a.getLogTickPositions(h,c[g-1],c[g],!0))});else if(a.isDatetimeAxis&&"auto"===b.minorTickInterval)m=m.concat(a.getTimeTicks(a.normalizeTimeTickInterval(h),v,p,b.startOfWeek));else for(b=v+(e[0]-v)%h;b<=p&&b!==m[0];b+=h)m.push(b);0!==m.length&&a.trimTicks(m);return m},adjustForMinRange:function(){var a=this.options,b=this.min,e=this.max,h,m=this.dataMax-this.dataMin>=
this.minRange,p,v,d,t,f,n;this.isXAxis&&void 0===this.minRange&&!this.isLog&&(k(a.min)||k(a.max)?this.minRange=null:(c(this.series,function(a){t=a.xData;for(v=f=a.xIncrement?1:t.length-1;0<v;v--)if(d=t[v]-t[v-1],void 0===p||d<p)p=d}),this.minRange=Math.min(5*p,this.dataMax-this.dataMin)));e-b<this.minRange&&(n=this.minRange,h=(n-e+b)/2,h=[b-h,E(a.min,b-h)],m&&(h[2]=this.isLog?this.log2lin(this.dataMin):this.dataMin),b=H(h),e=[b+n,E(a.max,b+n)],m&&(e[2]=this.isLog?this.log2lin(this.dataMax):this.dataMax),
e=G(e),e-b<n&&(h[0]=e-n,h[1]=E(a.min,e-n),b=H(h)));this.min=b;this.max=e},getClosest:function(){var a;this.categories?a=1:c(this.series,function(b){var g=b.closestPointRange,c=b.visible||!b.chart.options.chart.ignoreHiddenSeries;!b.noSharedTooltip&&k(g)&&c&&(a=k(a)?Math.min(a,g):g)});return a},nameToX:function(a){var b=D(this.categories),g=b?this.categories:this.names,c=a.options.x,e;a.series.requireSorting=!1;k(c)||(c=!1===this.options.uniqueNames?a.series.autoIncrement():t(a.name,g));-1===c?b||
(e=g.length):e=c;void 0!==e&&(this.names[e]=a.name);return e},updateNames:function(){var a=this;0<this.names.length&&(this.names.length=0,this.minRange=void 0,c(this.series||[],function(b){b.xIncrement=null;if(!b.points||b.isDirtyData)b.processData(),b.generatePoints();c(b.points,function(g,c){var e;g.options&&(e=a.nameToX(g),void 0!==e&&e!==g.x&&(g.x=e,b.xData[c]=e))})}))},setAxisTranslation:function(a){var b=this,g=b.max-b.min,h=b.axisPointRange||0,m,p=0,v=0,d=b.linkedParent,t=!!b.categories,f=
b.transA,n=b.isXAxis;if(n||t||h)m=b.getClosest(),d?(p=d.minPointOffset,v=d.pointRangePadding):c(b.series,function(a){var g=t?1:n?E(a.options.pointRange,m,0):b.axisPointRange||0;a=a.options.pointPlacement;h=Math.max(h,g);b.single||(p=Math.max(p,e(a)?0:g/2),v=Math.max(v,"on"===a?0:g))}),d=b.ordinalSlope&&m?b.ordinalSlope/m:1,b.minPointOffset=p*=d,b.pointRangePadding=v*=d,b.pointRange=Math.min(h,g),n&&(b.closestPointRange=m);a&&(b.oldTransA=f);b.translationSlope=b.transA=f=b.options.staticScale||b.len/
(g+v||1);b.transB=b.horiz?b.left:b.bottom;b.minPixelPadding=f*p},minFromRange:function(){return this.max-this.range},setTickInterval:function(b){var g=this,e=g.chart,h=g.options,m=g.isLog,d=g.log2lin,v=g.isDatetimeAxis,t=g.isXAxis,f=g.isLinked,n=h.maxPadding,y=h.minPadding,x=h.tickInterval,D=h.tickPixelInterval,I=g.categories,q=g.threshold,u=g.softThreshold,r,K,J,A;v||I||f||this.getTickAmount();J=E(g.userMin,h.min);A=E(g.userMax,h.max);f?(g.linkedParent=e[g.coll][h.linkedTo],e=g.linkedParent.getExtremes(),
g.min=E(e.min,e.dataMin),g.max=E(e.max,e.dataMax),h.type!==g.linkedParent.options.type&&a.error(11,1)):(!u&&k(q)&&(g.dataMin>=q?(r=q,y=0):g.dataMax<=q&&(K=q,n=0)),g.min=E(J,r,g.dataMin),g.max=E(A,K,g.dataMax));m&&(g.positiveValuesOnly&&!b&&0>=Math.min(g.min,E(g.dataMin,g.min))&&a.error(10,1),g.min=l(d(g.min),15),g.max=l(d(g.max),15));g.range&&k(g.max)&&(g.userMin=g.min=J=Math.max(g.min,g.minFromRange()),g.userMax=A=g.max,g.range=null);z(g,"foundExtremes");g.beforePadding&&g.beforePadding();g.adjustForMinRange();
!(I||g.axisPointRange||g.usePercentage||f)&&k(g.min)&&k(g.max)&&(d=g.max-g.min)&&(!k(J)&&y&&(g.min-=d*y),!k(A)&&n&&(g.max+=d*n));w(h.softMin)&&(g.min=Math.min(g.min,h.softMin));w(h.softMax)&&(g.max=Math.max(g.max,h.softMax));w(h.floor)&&(g.min=Math.max(g.min,h.floor));w(h.ceiling)&&(g.max=Math.min(g.max,h.ceiling));u&&k(g.dataMin)&&(q=q||0,!k(J)&&g.min<q&&g.dataMin>=q?g.min=q:!k(A)&&g.max>q&&g.dataMax<=q&&(g.max=q));g.tickInterval=g.min===g.max||void 0===g.min||void 0===g.max?1:f&&!x&&D===g.linkedParent.options.tickPixelInterval?
x=g.linkedParent.tickInterval:E(x,this.tickAmount?(g.max-g.min)/Math.max(this.tickAmount-1,1):void 0,I?1:(g.max-g.min)*D/Math.max(g.len,D));t&&!b&&c(g.series,function(a){a.processData(g.min!==g.oldMin||g.max!==g.oldMax)});g.setAxisTranslation(!0);g.beforeSetTickPositions&&g.beforeSetTickPositions();g.postProcessTickInterval&&(g.tickInterval=g.postProcessTickInterval(g.tickInterval));g.pointRange&&!x&&(g.tickInterval=Math.max(g.pointRange,g.tickInterval));b=E(h.minTickInterval,g.isDatetimeAxis&&g.closestPointRange);
!x&&g.tickInterval<b&&(g.tickInterval=b);v||m||x||(g.tickInterval=C(g.tickInterval,null,p(g.tickInterval),E(h.allowDecimals,!(.5<g.tickInterval&&5>g.tickInterval&&1E3<g.max&&9999>g.max)),!!this.tickAmount));this.tickAmount||(g.tickInterval=g.unsquish());this.setTickPositions()},setTickPositions:function(){var a=this.options,b,c=a.tickPositions,e=a.tickPositioner,h=a.startOnTick,m=a.endOnTick;this.tickmarkOffset=this.categories&&"between"===a.tickmarkPlacement&&1===this.tickInterval?.5:0;this.minorTickInterval=
"auto"===a.minorTickInterval&&this.tickInterval?this.tickInterval/5:a.minorTickInterval;this.single=this.min===this.max&&k(this.min)&&!this.tickAmount&&!1!==a.allowDecimals;this.tickPositions=b=c&&c.slice();!b&&(b=this.isDatetimeAxis?this.getTimeTicks(this.normalizeTimeTickInterval(this.tickInterval,a.units),this.min,this.max,a.startOfWeek,this.ordinalPositions,this.closestPointRange,!0):this.isLog?this.getLogTickPositions(this.tickInterval,this.min,this.max):this.getLinearTickPositions(this.tickInterval,
this.min,this.max),b.length>this.len&&(b=[b[0],b.pop()]),this.tickPositions=b,e&&(e=e.apply(this,[this.min,this.max])))&&(this.tickPositions=b=e);this.paddedTicks=b.slice(0);this.trimTicks(b,h,m);this.isLinked||(this.single&&(this.min-=.5,this.max+=.5),c||e||this.adjustTickAmount())},trimTicks:function(a,b,c){var g=a[0],e=a[a.length-1],h=this.minPointOffset||0;if(!this.isLinked){if(b&&-Infinity!==g)this.min=g;else for(;this.min-h>a[0];)a.shift();if(c)this.max=e;else for(;this.max+h<a[a.length-1];)a.pop();
0===a.length&&k(g)&&a.push((e+g)/2)}},alignToOthers:function(){var a={},b,e=this.options;!1===this.chart.options.chart.alignTicks||!1===e.alignTicks||this.isLog||c(this.chart[this.coll],function(g){var c=g.options,c=[g.horiz?c.left:c.top,c.width,c.height,c.pane].join();g.series.length&&(a[c]?b=!0:a[c]=1)});return b},getTickAmount:function(){var a=this.options,b=a.tickAmount,c=a.tickPixelInterval;!k(a.tickInterval)&&this.len<c&&!this.isRadial&&!this.isLog&&a.startOnTick&&a.endOnTick&&(b=2);!b&&this.alignToOthers()&&
(b=Math.ceil(this.len/c)+1);4>b&&(this.finalTickAmt=b,b=5);this.tickAmount=b},adjustTickAmount:function(){var a=this.tickInterval,b=this.tickPositions,c=this.tickAmount,e=this.finalTickAmt,h=b&&b.length;if(h<c){for(;b.length<c;)b.push(l(b[b.length-1]+a));this.transA*=(h-1)/(c-1);this.max=b[b.length-1]}else h>c&&(this.tickInterval*=2,this.setTickPositions());if(k(e)){for(a=c=b.length;a--;)(3===e&&1===a%2||2>=e&&0<a&&a<c-1)&&b.splice(a,1);this.finalTickAmt=void 0}},setScale:function(){var a,b;this.oldMin=
this.min;this.oldMax=this.max;this.oldAxisLength=this.len;this.setAxisSize();b=this.len!==this.oldAxisLength;c(this.series,function(b){if(b.isDirtyData||b.isDirty||b.xAxis.isDirty)a=!0});b||a||this.isLinked||this.forceRedraw||this.userMin!==this.oldUserMin||this.userMax!==this.oldUserMax||this.alignToOthers()?(this.resetStacks&&this.resetStacks(),this.forceRedraw=!1,this.getSeriesExtremes(),this.setTickInterval(),this.oldUserMin=this.userMin,this.oldUserMax=this.userMax,this.isDirty||(this.isDirty=
b||this.min!==this.oldMin||this.max!==this.oldMax)):this.cleanStacks&&this.cleanStacks()},setExtremes:function(a,b,e,h,m){var g=this,p=g.chart;e=E(e,!0);c(g.series,function(a){delete a.kdTree});m=n(m,{min:a,max:b});z(g,"setExtremes",m,function(){g.userMin=a;g.userMax=b;g.eventArgs=m;e&&p.redraw(h)})},zoom:function(a,b){var g=this.dataMin,c=this.dataMax,e=this.options,h=Math.min(g,E(e.min,g)),e=Math.max(c,E(e.max,c));if(a!==this.min||b!==this.max)this.allowZoomOutside||(k(g)&&(a<h&&(a=h),a>e&&(a=e)),
k(c)&&(b<h&&(b=h),b>e&&(b=e))),this.displayBtn=void 0!==a||void 0!==b,this.setExtremes(a,b,!1,void 0,{trigger:"zoom"});return!0},setAxisSize:function(){var a=this.chart,b=this.options,c=b.offsets||[0,0,0,0],e=this.horiz,h=E(b.width,a.plotWidth-c[3]+c[1]),m=E(b.height,a.plotHeight-c[0]+c[2]),p=E(b.top,a.plotTop+c[0]),b=E(b.left,a.plotLeft+c[3]),c=/%$/;c.test(m)&&(m=Math.round(parseFloat(m)/100*a.plotHeight));c.test(p)&&(p=Math.round(parseFloat(p)/100*a.plotHeight+a.plotTop));this.left=b;this.top=p;
this.width=h;this.height=m;this.bottom=a.chartHeight-m-p;this.right=a.chartWidth-h-b;this.len=Math.max(e?h:m,0);this.pos=e?b:p},getExtremes:function(){var a=this.isLog,b=this.lin2log;return{min:a?l(b(this.min)):this.min,max:a?l(b(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}},getThreshold:function(a){var b=this.isLog,g=this.lin2log,c=b?g(this.min):this.min,b=b?g(this.max):this.max;null===a?a=c:c>a?a=c:b<a&&(a=b);return this.translate(a,0,
1,0,1)},autoLabelAlign:function(a){a=(E(a,0)-90*this.side+720)%360;return 15<a&&165>a?"right":195<a&&345>a?"left":"center"},tickSize:function(a){var b=this.options,g=b[a+"Length"],c=E(b[a+"Width"],"tick"===a&&this.isXAxis?1:0);if(c&&g)return"inside"===b[a+"Position"]&&(g=-g),[g,c]},labelMetrics:function(){return this.chart.renderer.fontMetrics(this.options.labels.style&&this.options.labels.style.fontSize,this.ticks[0]&&this.ticks[0].label)},unsquish:function(){var a=this.options.labels,b=this.horiz,
e=this.tickInterval,h=e,m=this.len/(((this.categories?1:0)+this.max-this.min)/e),p,d=a.rotation,t=this.labelMetrics(),f,n=Number.MAX_VALUE,y,w=function(a){a/=m||1;a=1<a?Math.ceil(a):1;return a*e};b?(y=!a.staggerLines&&!a.step&&(k(d)?[d]:m<E(a.autoRotationLimit,80)&&a.autoRotation))&&c(y,function(a){var b;if(a===d||a&&-90<=a&&90>=a)f=w(Math.abs(t.h/Math.sin(u*a))),b=f+Math.abs(a/360),b<n&&(n=b,p=a,h=f)}):a.step||(h=w(t.h));this.autoRotation=y;this.labelRotation=E(p,d);return h},getSlotWidth:function(){var a=
this.chart,b=this.horiz,c=this.options.labels,e=Math.max(this.tickPositions.length-(this.categories?0:1),1),h=a.margin[3];return b&&2>(c.step||0)&&!c.rotation&&(this.staggerLines||1)*this.len/e||!b&&(h&&h-a.spacing[3]||.33*a.chartWidth)},renderUnsquish:function(){var a=this.chart,b=a.renderer,h=this.tickPositions,m=this.ticks,p=this.options.labels,d=this.horiz,v=this.getSlotWidth(),t=Math.max(1,Math.round(v-2*(p.padding||5))),f={},n=this.labelMetrics(),y=p.style&&p.style.textOverflow,k,w=0,D,l;e(p.rotation)||
(f.rotation=p.rotation||0);c(h,function(a){(a=m[a])&&a.labelLength>w&&(w=a.labelLength)});this.maxLabelLength=w;if(this.autoRotation)w>t&&w>n.h?f.rotation=this.labelRotation:this.labelRotation=0;else if(v&&(k={width:t+"px"},!y))for(k.textOverflow="clip",D=h.length;!d&&D--;)if(l=h[D],t=m[l].label)t.styles&&"ellipsis"===t.styles.textOverflow?t.css({textOverflow:"clip"}):m[l].labelLength>v&&t.css({width:v+"px"}),t.getBBox().height>this.len/h.length-(n.h-n.f)&&(t.specCss={textOverflow:"ellipsis"});f.rotation&&
(k={width:(w>.5*a.chartHeight?.33*a.chartHeight:a.chartHeight)+"px"},y||(k.textOverflow="ellipsis"));if(this.labelAlign=p.align||this.autoLabelAlign(this.labelRotation))f.align=this.labelAlign;c(h,function(a){var b=(a=m[a])&&a.label;b&&(b.attr(f),k&&b.css(x(k,b.specCss)),delete b.specCss,a.rotation=f.rotation)});this.tickRotCorr=b.rotCorr(n.b,this.labelRotation||0,0!==this.side)},hasData:function(){return this.hasVisibleSeries||k(this.min)&&k(this.max)&&!!this.tickPositions},addTitle:function(a){var b=
this.chart.renderer,c=this.horiz,g=this.opposite,e=this.options.title,h;this.axisTitle||((h=e.textAlign)||(h=(c?{low:"left",middle:"center",high:"right"}:{low:g?"right":"left",middle:"center",high:g?"left":"right"})[e.align]),this.axisTitle=b.text(e.text,0,0,e.useHTML).attr({zIndex:7,rotation:e.rotation||0,align:h}).addClass("highcharts-axis-title").css(e.style).add(this.axisGroup),this.axisTitle.isNew=!0);this.axisTitle[a?"show":"hide"](!0)},generateTick:function(a){var b=this.ticks;b[a]?b[a].addLabel():
b[a]=new J(this,a)},getOffset:function(){var a=this,b=a.chart,e=b.renderer,h=a.options,m=a.tickPositions,p=a.ticks,d=a.horiz,t=a.side,f=b.inverted?[1,0,3,2][t]:t,n,y,w=0,x,D=0,l=h.title,C=h.labels,q=0,I=b.axisOffset,b=b.clipOffset,u=[-1,1,1,-1][t],z,r=h.className,K=a.axisParent,J=this.tickSize("tick");n=a.hasData();a.showAxis=y=n||E(h.showEmpty,!0);a.staggerLines=a.horiz&&C.staggerLines;a.axisGroup||(a.gridGroup=e.g("grid").attr({zIndex:h.gridZIndex||1}).addClass("highcharts-"+this.coll.toLowerCase()+
"-grid "+(r||"")).add(K),a.axisGroup=e.g("axis").attr({zIndex:h.zIndex||2}).addClass("highcharts-"+this.coll.toLowerCase()+" "+(r||"")).add(K),a.labelGroup=e.g("axis-labels").attr({zIndex:C.zIndex||7}).addClass("highcharts-"+a.coll.toLowerCase()+"-labels "+(r||"")).add(K));if(n||a.isLinked)c(m,function(b,c){a.generateTick(b,c)}),a.renderUnsquish(),!1===C.reserveSpace||0!==t&&2!==t&&{1:"left",3:"right"}[t]!==a.labelAlign&&"center"!==a.labelAlign||c(m,function(a){q=Math.max(p[a].getLabelSize(),q)}),
a.staggerLines&&(q*=a.staggerLines,a.labelOffset=q*(a.opposite?-1:1));else for(z in p)p[z].destroy(),delete p[z];l&&l.text&&!1!==l.enabled&&(a.addTitle(y),y&&(w=a.axisTitle.getBBox()[d?"height":"width"],x=l.offset,D=k(x)?0:E(l.margin,d?5:10)));a.renderLine();a.offset=u*E(h.offset,I[t]);a.tickRotCorr=a.tickRotCorr||{x:0,y:0};e=0===t?-a.labelMetrics().h:2===t?a.tickRotCorr.y:0;D=Math.abs(q)+D;q&&(D=D-e+u*(d?E(C.y,a.tickRotCorr.y+8*u):C.x));a.axisTitleMargin=E(x,D);I[t]=Math.max(I[t],a.axisTitleMargin+
w+u*a.offset,D,n&&m.length&&J?J[0]+u*a.offset:0);h=h.offset?0:2*Math.floor(a.axisLine.strokeWidth()/2);b[f]=Math.max(b[f],h)},getLinePath:function(a){var b=this.chart,c=this.opposite,g=this.offset,e=this.horiz,h=this.left+(c?this.width:0)+g,g=b.chartHeight-this.bottom-(c?this.height:0)+g;c&&(a*=-1);return b.renderer.crispLine(["M",e?this.left:h,e?g:this.top,"L",e?b.chartWidth-this.right:h,e?g:b.chartHeight-this.bottom],a)},renderLine:function(){this.axisLine||(this.axisLine=this.chart.renderer.path().addClass("highcharts-axis-line").add(this.axisGroup),
this.axisLine.attr({stroke:this.options.lineColor,"stroke-width":this.options.lineWidth,zIndex:7}))},getTitlePosition:function(){var a=this.horiz,b=this.left,c=this.top,e=this.len,h=this.options.title,m=a?b:c,p=this.opposite,d=this.offset,t=h.x||0,f=h.y||0,n=this.chart.renderer.fontMetrics(h.style&&h.style.fontSize,this.axisTitle).f,e={low:m+(a?0:e),middle:m+e/2,high:m+(a?e:0)}[h.align],b=(a?c+this.height:b)+(a?1:-1)*(p?-1:1)*this.axisTitleMargin+(2===this.side?n:0);return{x:a?e+t:b+(p?this.width:
0)+d+t,y:a?b+f-(p?this.height:0)+d:e+f}},renderMinorTick:function(a){var b=this.chart.hasRendered&&w(this.oldMin),c=this.minorTicks;c[a]||(c[a]=new J(this,a,"minor"));b&&c[a].isNew&&c[a].render(null,!0);c[a].render(null,!1,1)},renderTick:function(a,b){var c=this.isLinked,g=this.ticks,e=this.chart.hasRendered&&w(this.oldMin);if(!c||a>=this.min&&a<=this.max)g[a]||(g[a]=new J(this,a)),e&&g[a].isNew&&g[a].render(b,!0,.1),g[a].render(b)},render:function(){var a=this,b=a.chart,e=a.options,h=a.isLog,p=a.lin2log,
d=a.isLinked,t=a.tickPositions,f=a.axisTitle,n=a.ticks,y=a.minorTicks,k=a.alternateBands,w=e.stackLabels,x=e.alternateGridColor,D=a.tickmarkOffset,l=a.axisLine,C=a.showAxis,q=A(b.renderer.globalAnimation),I,E;a.labelEdge.length=0;a.overlap=!1;c([n,y,k],function(a){for(var b in a)a[b].isActive=!1});if(a.hasData()||d)a.minorTickInterval&&!a.categories&&c(a.getMinorTickPositions(),function(b){a.renderMinorTick(b)}),t.length&&(c(t,function(b,c){a.renderTick(b,c)}),D&&(0===a.min||a.single)&&(n[-1]||(n[-1]=
new J(a,-1,null,!0)),n[-1].render(-1))),x&&c(t,function(c,e){E=void 0!==t[e+1]?t[e+1]+D:a.max-D;0===e%2&&c<a.max&&E<=a.max+(b.polar?-D:D)&&(k[c]||(k[c]=new m(a)),I=c+D,k[c].options={from:h?p(I):I,to:h?p(E):E,color:x},k[c].render(),k[c].isActive=!0)}),a._addedPlotLB||(c((e.plotLines||[]).concat(e.plotBands||[]),function(b){a.addPlotBandOrLine(b)}),a._addedPlotLB=!0);c([n,y,k],function(a){var c,e,g=[],h=q.duration;for(c in a)a[c].isActive||(a[c].render(c,!1,0),a[c].isActive=!1,g.push(c));K(function(){for(e=
g.length;e--;)a[g[e]]&&!a[g[e]].isActive&&(a[g[e]].destroy(),delete a[g[e]])},a!==k&&b.hasRendered&&h?h:0)});l&&(l[l.isPlaced?"animate":"attr"]({d:this.getLinePath(l.strokeWidth())}),l.isPlaced=!0,l[C?"show":"hide"](!0));f&&C&&(f[f.isNew?"attr":"animate"](a.getTitlePosition()),f.isNew=!1);w&&w.enabled&&a.renderStackTotals();a.isDirty=!1},redraw:function(){this.visible&&(this.render(),c(this.plotLinesAndBands,function(a){a.render()}));c(this.series,function(a){a.isDirty=!0})},keepProps:"extKey hcEvents names series userMax userMin".split(" "),
destroy:function(a){var b=this,e=b.stacks,g,h=b.plotLinesAndBands,m,p;a||y(b);for(g in e)d(e[g]),e[g]=null;c([b.ticks,b.minorTicks,b.alternateBands],function(a){d(a)});if(h)for(a=h.length;a--;)h[a].destroy();c("stackTotalGroup axisLine axisTitle axisGroup gridGroup labelGroup cross".split(" "),function(a){b[a]&&(b[a]=b[a].destroy())});for(m in b.plotLinesAndBandsGroups)b.plotLinesAndBandsGroups[m]=b.plotLinesAndBandsGroups[m].destroy();for(p in b)b.hasOwnProperty(p)&&-1===t(p,b.keepProps)&&delete b[p]},
drawCrosshair:function(a,b){var c,e=this.crosshair,g=E(e.snap,!0),h,m=this.cross;a||(a=this.cross&&this.cross.e);this.crosshair&&!1!==(k(b)||!g)?(g?k(b)&&(h=this.isXAxis?b.plotX:this.len-b.plotY):h=a&&(this.horiz?a.chartX-this.pos:this.len-a.chartY+this.pos),k(h)&&(c=this.getPlotLinePath(b&&(this.isXAxis?b.x:E(b.stackY,b.y)),null,null,null,h)||null),k(c)?(b=this.categories&&!this.isRadial,m||(this.cross=m=this.chart.renderer.path().addClass("highcharts-crosshair highcharts-crosshair-"+(b?"category ":
"thin ")+e.className).attr({zIndex:E(e.zIndex,2)}).add(),m.attr({stroke:e.color||(b?f("#ccd6eb").setOpacity(.25).get():"#cccccc"),"stroke-width":E(e.width,1)}),e.dashStyle&&m.attr({dashstyle:e.dashStyle})),m.show().attr({d:c}),b&&!e.width&&m.attr({"stroke-width":this.transA}),this.cross.e=a):this.hideCrosshair()):this.hideCrosshair()},hideCrosshair:function(){this.cross&&this.cross.hide()}};n(a.Axis.prototype,r)})(L);(function(a){var B=a.Axis,A=a.Date,H=a.dateFormat,G=a.defaultOptions,r=a.defined,
f=a.each,l=a.extend,q=a.getMagnitude,k=a.getTZOffset,u=a.normalizeTickInterval,d=a.pick,c=a.timeUnits;B.prototype.getTimeTicks=function(a,q,b,p){var h=[],t={},n=G.global.useUTC,w,e=new A(q-Math.abs(k(q))),x=A.hcMakeTime,C=a.unitRange,E=a.count,m;if(r(q)){e[A.hcSetMilliseconds](C>=c.second?0:E*Math.floor(e.getMilliseconds()/E));if(C>=c.second)e[A.hcSetSeconds](C>=c.minute?0:E*Math.floor(e.getSeconds()/E));if(C>=c.minute)e[A.hcSetMinutes](C>=c.hour?0:E*Math.floor(e[A.hcGetMinutes]()/E));if(C>=c.hour)e[A.hcSetHours](C>=
c.day?0:E*Math.floor(e[A.hcGetHours]()/E));if(C>=c.day)e[A.hcSetDate](C>=c.month?1:E*Math.floor(e[A.hcGetDate]()/E));C>=c.month&&(e[A.hcSetMonth](C>=c.year?0:E*Math.floor(e[A.hcGetMonth]()/E)),w=e[A.hcGetFullYear]());if(C>=c.year)e[A.hcSetFullYear](w-w%E);if(C===c.week)e[A.hcSetDate](e[A.hcGetDate]()-e[A.hcGetDay]()+d(p,1));w=e[A.hcGetFullYear]();p=e[A.hcGetMonth]();var y=e[A.hcGetDate](),I=e[A.hcGetHours]();if(A.hcTimezoneOffset||A.hcGetTimezoneOffset)m=(!n||!!A.hcGetTimezoneOffset)&&(b-q>4*c.month||
k(q)!==k(b)),e=e.getTime(),e=new A(e+k(e));n=e.getTime();for(q=1;n<b;)h.push(n),n=C===c.year?x(w+q*E,0):C===c.month?x(w,p+q*E):!m||C!==c.day&&C!==c.week?m&&C===c.hour?x(w,p,y,I+q*E):n+C*E:x(w,p,y+q*E*(C===c.day?1:7)),q++;h.push(n);C<=c.hour&&1E4>h.length&&f(h,function(a){0===a%18E5&&"000000000"===H("%H%M%S%L",a)&&(t[a]="day")})}h.info=l(a,{higherRanks:t,totalRange:C*E});return h};B.prototype.normalizeTimeTickInterval=function(a,d){var b=d||[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",
[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]];d=b[b.length-1];var p=c[d[0]],h=d[1],t;for(t=0;t<b.length&&!(d=b[t],p=c[d[0]],h=d[1],b[t+1]&&a<=(p*h[h.length-1]+c[b[t+1][0]])/2);t++);p===c.year&&a<5*p&&(h=[1,2,5]);a=u(a/p,h,"year"===d[0]?Math.max(q(a/p),1):1);return{unitRange:p,count:a,unitName:d[0]}}})(L);(function(a){var B=a.Axis,A=a.getMagnitude,H=a.map,G=a.normalizeTickInterval,r=a.pick;B.prototype.getLogTickPositions=
function(a,l,q,k){var f=this.options,d=this.len,c=this.lin2log,n=this.log2lin,z=[];k||(this._minorAutoInterval=null);if(.5<=a)a=Math.round(a),z=this.getLinearTickPositions(a,l,q);else if(.08<=a)for(var d=Math.floor(l),b,p,h,t,D,f=.3<a?[1,2,4]:.15<a?[1,2,4,6,8]:[1,2,3,4,5,6,7,8,9];d<q+1&&!D;d++)for(p=f.length,b=0;b<p&&!D;b++)h=n(c(d)*f[b]),h>l&&(!k||t<=q)&&void 0!==t&&z.push(t),t>q&&(D=!0),t=h;else l=c(l),q=c(q),a=f[k?"minorTickInterval":"tickInterval"],a=r("auto"===a?null:a,this._minorAutoInterval,
f.tickPixelInterval/(k?5:1)*(q-l)/((k?d/this.tickPositions.length:d)||1)),a=G(a,null,A(a)),z=H(this.getLinearTickPositions(a,l,q),n),k||(this._minorAutoInterval=a/5);k||(this.tickInterval=a);return z};B.prototype.log2lin=function(a){return Math.log(a)/Math.LN10};B.prototype.lin2log=function(a){return Math.pow(10,a)}})(L);(function(a){var B=a.dateFormat,A=a.each,H=a.extend,G=a.format,r=a.isNumber,f=a.map,l=a.merge,q=a.pick,k=a.splat,u=a.syncTimeout,d=a.timeUnits;a.Tooltip=function(){this.init.apply(this,
arguments)};a.Tooltip.prototype={init:function(a,d){this.chart=a;this.options=d;this.crosshairs=[];this.now={x:0,y:0};this.isHidden=!0;this.split=d.split&&!a.inverted;this.shared=d.shared||this.split},cleanSplit:function(a){A(this.chart.series,function(c){var d=c&&c.tt;d&&(!d.isActive||a?c.tt=d.destroy():d.isActive=!1)})},getLabel:function(){var a=this.chart.renderer,d=this.options;this.label||(this.split?this.label=a.g("tooltip"):(this.label=a.label("",0,0,d.shape||"callout",null,null,d.useHTML,
null,"tooltip").attr({padding:d.padding,r:d.borderRadius}),this.label.attr({fill:d.backgroundColor,"stroke-width":d.borderWidth}).css(d.style).shadow(d.shadow)),this.label.attr({zIndex:8}).add());return this.label},update:function(a){this.destroy();this.init(this.chart,l(!0,this.options,a))},destroy:function(){this.label&&(this.label=this.label.destroy());this.split&&this.tt&&(this.cleanSplit(this.chart,!0),this.tt=this.tt.destroy());clearTimeout(this.hideTimer);clearTimeout(this.tooltipTimeout)},
move:function(a,d,f,b){var c=this,h=c.now,t=!1!==c.options.animation&&!c.isHidden&&(1<Math.abs(a-h.x)||1<Math.abs(d-h.y)),n=c.followPointer||1<c.len;H(h,{x:t?(2*h.x+a)/3:a,y:t?(h.y+d)/2:d,anchorX:n?void 0:t?(2*h.anchorX+f)/3:f,anchorY:n?void 0:t?(h.anchorY+b)/2:b});c.getLabel().attr(h);t&&(clearTimeout(this.tooltipTimeout),this.tooltipTimeout=setTimeout(function(){c&&c.move(a,d,f,b)},32))},hide:function(a){var c=this;clearTimeout(this.hideTimer);a=q(a,this.options.hideDelay,500);this.isHidden||(this.hideTimer=
u(function(){c.getLabel()[a?"fadeOut":"hide"]();c.isHidden=!0},a))},getAnchor:function(a,d){var c,b=this.chart,p=b.inverted,h=b.plotTop,t=b.plotLeft,n=0,w=0,e,x;a=k(a);c=a[0].tooltipPos;this.followPointer&&d&&(void 0===d.chartX&&(d=b.pointer.normalize(d)),c=[d.chartX-b.plotLeft,d.chartY-h]);c||(A(a,function(a){e=a.series.yAxis;x=a.series.xAxis;n+=a.plotX+(!p&&x?x.left-t:0);w+=(a.plotLow?(a.plotLow+a.plotHigh)/2:a.plotY)+(!p&&e?e.top-h:0)}),n/=a.length,w/=a.length,c=[p?b.plotWidth-w:n,this.shared&&
!p&&1<a.length&&d?d.chartY-h:p?b.plotHeight-n:w]);return f(c,Math.round)},getPosition:function(a,d,f){var b=this.chart,c=this.distance,h={},t=f.h||0,n,k=["y",b.chartHeight,d,f.plotY+b.plotTop,b.plotTop,b.plotTop+b.plotHeight],e=["x",b.chartWidth,a,f.plotX+b.plotLeft,b.plotLeft,b.plotLeft+b.plotWidth],x=!this.followPointer&&q(f.ttBelow,!b.inverted===!!f.negative),l=function(a,b,e,g,m,d){var p=e<g-c,f=g+c+e<b,n=g-c-e;g+=c;if(x&&f)h[a]=g;else if(!x&&p)h[a]=n;else if(p)h[a]=Math.min(d-e,0>n-t?n:n-t);
else if(f)h[a]=Math.max(m,g+t+e>b?g:g+t);else return!1},E=function(a,b,e,g){var m;g<c||g>b-c?m=!1:h[a]=g<e/2?1:g>b-e/2?b-e-2:g-e/2;return m},m=function(a){var b=k;k=e;e=b;n=a},y=function(){!1!==l.apply(0,k)?!1!==E.apply(0,e)||n||(m(!0),y()):n?h.x=h.y=0:(m(!0),y())};(b.inverted||1<this.len)&&m();y();return h},defaultFormatter:function(a){var c=this.points||k(this),d;d=[a.tooltipFooterHeaderFormatter(c[0])];d=d.concat(a.bodyFormatter(c));d.push(a.tooltipFooterHeaderFormatter(c[0],!0));return d},refresh:function(a,
d){var c,b=this.options,p,h=a,t,f={},n=[];c=b.formatter||this.defaultFormatter;var f=this.shared,e;clearTimeout(this.hideTimer);this.followPointer=k(h)[0].series.tooltipOptions.followPointer;t=this.getAnchor(h,d);d=t[0];p=t[1];!f||h.series&&h.series.noSharedTooltip?f=h.getLabelConfig():(A(h,function(a){a.setState("hover");n.push(a.getLabelConfig())}),f={x:h[0].category,y:h[0].y},f.points=n,h=h[0]);this.len=n.length;f=c.call(f,this);e=h.series;this.distance=q(e.tooltipOptions.distance,16);!1===f?this.hide():
(c=this.getLabel(),this.isHidden&&c.attr({opacity:1}).show(),this.split?this.renderSplit(f,a):(c.attr({text:f&&f.join?f.join(""):f}),c.removeClass(/highcharts-color-[\d]+/g).addClass("highcharts-color-"+q(h.colorIndex,e.colorIndex)),c.attr({stroke:b.borderColor||h.color||e.color||"#666666"}),this.updatePosition({plotX:d,plotY:p,negative:h.negative,ttBelow:h.ttBelow,h:t[2]||0})),this.isHidden=!1)},renderSplit:function(c,d){var f=this,b=[],p=this.chart,h=p.renderer,t=!0,n=this.options,k,e=this.getLabel();
A(c.slice(0,d.length+1),function(a,c){c=d[c-1]||{isHeader:!0,plotX:d[0].plotX};var w=c.series||f,m=w.tt,y=c.series||{},x="highcharts-color-"+q(c.colorIndex,y.colorIndex,"none");m||(w.tt=m=h.label(null,null,null,"callout").addClass("highcharts-tooltip-box "+x).attr({padding:n.padding,r:n.borderRadius,fill:n.backgroundColor,stroke:c.color||y.color||"#333333","stroke-width":n.borderWidth}).add(e));m.isActive=!0;m.attr({text:a});m.css(n.style);a=m.getBBox();y=a.width+m.strokeWidth();c.isHeader?(k=a.height,
y=Math.max(0,Math.min(c.plotX+p.plotLeft-y/2,p.chartWidth-y))):y=c.plotX+p.plotLeft-q(n.distance,16)-y;0>y&&(t=!1);a=(c.series&&c.series.yAxis&&c.series.yAxis.pos)+(c.plotY||0);a-=p.plotTop;b.push({target:c.isHeader?p.plotHeight+k:a,rank:c.isHeader?1:0,size:w.tt.getBBox().height+1,point:c,x:y,tt:m})});this.cleanSplit();a.distribute(b,p.plotHeight+k);A(b,function(a){var b=a.point,c=b.series;a.tt.attr({visibility:void 0===a.pos?"hidden":"inherit",x:t||b.isHeader?a.x:b.plotX+p.plotLeft+q(n.distance,
16),y:a.pos+p.plotTop,anchorX:b.isHeader?b.plotX+p.plotLeft:b.plotX+c.xAxis.pos,anchorY:b.isHeader?a.pos+p.plotTop-15:b.plotY+c.yAxis.pos})})},updatePosition:function(a){var c=this.chart,d=this.getLabel(),d=(this.options.positioner||this.getPosition).call(this,d.width,d.height,a);this.move(Math.round(d.x),Math.round(d.y||0),a.plotX+c.plotLeft,a.plotY+c.plotTop)},getDateFormat:function(a,f,k,b){var c=B("%m-%d %H:%M:%S.%L",f),h,t,n={millisecond:15,second:12,minute:9,hour:6,day:3},w="millisecond";for(t in d){if(a===
d.week&&+B("%w",f)===k&&"00:00:00.000"===c.substr(6)){t="week";break}if(d[t]>a){t=w;break}if(n[t]&&c.substr(n[t])!=="01-01 00:00:00.000".substr(n[t]))break;"week"!==t&&(w=t)}t&&(h=b[t]);return h},getXDateFormat:function(a,d,f){d=d.dateTimeLabelFormats;var b=f&&f.closestPointRange;return(b?this.getDateFormat(b,a.x,f.options.startOfWeek,d):d.day)||d.year},tooltipFooterHeaderFormatter:function(a,d){var c=d?"footer":"header";d=a.series;var b=d.tooltipOptions,p=b.xDateFormat,h=d.xAxis,t=h&&"datetime"===
h.options.type&&r(a.key),c=b[c+"Format"];t&&!p&&(p=this.getXDateFormat(a,b,h));t&&p&&(c=c.replace("{point.key}","{point.key:"+p+"}"));return G(c,{point:a,series:d})},bodyFormatter:function(a){return f(a,function(a){var c=a.series.tooltipOptions;return(c.pointFormatter||a.point.tooltipFormatter).call(a.point,c.pointFormat)})}}})(L);(function(a){var B=a.addEvent,A=a.attr,H=a.charts,G=a.color,r=a.css,f=a.defined,l=a.doc,q=a.each,k=a.extend,u=a.fireEvent,d=a.offset,c=a.pick,n=a.removeEvent,z=a.splat,
b=a.Tooltip,p=a.win;a.Pointer=function(a,b){this.init(a,b)};a.Pointer.prototype={init:function(a,d){this.options=d;this.chart=a;this.runChartClick=d.chart.events&&!!d.chart.events.click;this.pinchDown=[];this.lastValidTouch={};b&&d.tooltip.enabled&&(a.tooltip=new b(a,d.tooltip),this.followTouchMove=c(d.tooltip.followTouchMove,!0));this.setDOMEvents()},zoomOption:function(a){var b=this.chart,h=b.options.chart,d=h.zoomType||"",b=b.inverted;/touch/.test(a.type)&&(d=c(h.pinchType,d));this.zoomX=a=/x/.test(d);
this.zoomY=d=/y/.test(d);this.zoomHor=a&&!b||d&&b;this.zoomVert=d&&!b||a&&b;this.hasZoom=a||d},normalize:function(a,b){var c,h;a=a||p.event;a.target||(a.target=a.srcElement);h=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a;b||(this.chartPosition=b=d(this.chart.container));void 0===h.pageX?(c=Math.max(a.x,a.clientX-b.left),b=a.y):(c=h.pageX-b.left,b=h.pageY-b.top);return k(a,{chartX:Math.round(c),chartY:Math.round(b)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};q(this.chart.axes,
function(c){b[c.isXAxis?"xAxis":"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})});return b},getKDPoints:function(a,b,d){var h=[],e,p,f;q(a,function(a){e=a.noSharedTooltip&&b;p=!b&&a.directTouch;a.visible&&!p&&c(a.options.enableMouseTracking,!0)&&(f=a.searchPoint(d,!e&&0>a.options.findNearestPointBy.indexOf("y")))&&f.series&&h.push(f)});h.sort(function(a,c){var e=a.distX-c.distX,h=a.dist-c.dist,m=(c.series.group&&c.series.group.zIndex)-(a.series.group&&a.series.group.zIndex);
return 0!==e&&b?e:0!==h?h:0!==m?m:a.series.index>c.series.index?-1:1});if(b&&h[0]&&!h[0].series.noSharedTooltip)for(a=h.length;a--;)(h[a].x!==h[0].x||h[a].series.noSharedTooltip)&&h.splice(a,1);return h},getPointFromEvent:function(a){a=a.target;for(var b;a&&!b;)b=a.point,a=a.parentNode;return b},getHoverData:function(b,d,p,f,e,n){var h=b,t=d,m;f?e?(m=[],q(p,function(a){var b=a.noSharedTooltip&&e,d=!e&&a.directTouch;a.visible&&!b&&!d&&c(a.options.enableMouseTracking,!0)&&(a=a.searchKDTree({clientX:h.clientX,
plotY:h.plotY},!b&&1===a.kdDimensions))&&a.series&&m.push(a)}),0===m.length&&(m=[h])):m=[h]:t&&!t.stickyTracking?(e||(p=[t]),m=this.getKDPoints(p,e,n),h=a.find(m,function(a){return a.series===t})):(b=a.grep(p,function(a){return a.stickyTracking}),m=this.getKDPoints(b,e,n),t=(h=m[0])&&h.series,e&&(m=this.getKDPoints(p,e,n)));m.sort(function(a,b){return a.series.index-b.series.index});return{hoverPoint:h,hoverSeries:t,hoverPoints:m}},runPointActions:function(b,d){var h=this.chart,p=h.tooltip,e=p?p.shared:
!1,f=d||h.hoverPoint,t=f&&f.series||h.hoverSeries;d=this.getHoverData(f,t,h.series,!!d||!e&&t&&t.directTouch,e,b);var n,m,f=d.hoverPoint;n=(t=d.hoverSeries)&&t.tooltipOptions.followPointer;m=(e=e&&f&&!f.series.noSharedTooltip)?d.hoverPoints:f?[f]:[];if(f&&(f!==h.hoverPoint||p&&p.isHidden)){q(h.hoverPoints||[],function(b){-1===a.inArray(b,m)&&b.setState()});q(m||[],function(a){a.setState("hover")});if(h.hoverSeries!==t)t.onMouseOver();t&&!t.directTouch&&(h.hoverPoint&&h.hoverPoint.firePointEvent("mouseOut"),
f.firePointEvent("mouseOver"));h.hoverPoints=m;h.hoverPoint=f;p&&p.refresh(e?m:f,b)}else n&&p&&!p.isHidden&&(f=p.getAnchor([{}],b),p.updatePosition({plotX:f[0],plotY:f[1]}));this.unDocMouseMove||(this.unDocMouseMove=B(l,"mousemove",function(b){var c=H[a.hoverChartIndex];if(c)c.pointer.onDocumentMouseMove(b)}));q(h.axes,function(a){c(a.crosshair.snap,!0)?q(m,function(c){c.series[a.coll]===a&&a.drawCrosshair(b,c)}):a.drawCrosshair(b)})},reset:function(a,b){var c=this.chart,h=c.hoverSeries,e=c.hoverPoint,
d=c.hoverPoints,p=c.tooltip,f=p&&p.shared?d:e;a&&f&&q(z(f),function(b){b.series.isCartesian&&void 0===b.plotX&&(a=!1)});if(a)p&&f&&(p.refresh(f),e&&(e.setState(e.state,!0),q(c.axes,function(a){a.crosshair&&a.drawCrosshair(null,e)})));else{if(e)e.onMouseOut();d&&q(d,function(a){a.setState()});if(h)h.onMouseOut();p&&p.hide(b);this.unDocMouseMove&&(this.unDocMouseMove=this.unDocMouseMove());q(c.axes,function(a){a.hideCrosshair()});this.hoverX=c.hoverPoints=c.hoverPoint=null}},scaleGroups:function(a,
b){var c=this.chart,h;q(c.series,function(e){h=a||e.getPlotBox();e.xAxis&&e.xAxis.zoomEnabled&&e.group&&(e.group.attr(h),e.markerGroup&&(e.markerGroup.attr(h),e.markerGroup.clip(b?c.clipRect:null)),e.dataLabelsGroup&&e.dataLabelsGroup.attr(h))});c.clipRect.attr(b||c.clipBox)},dragStart:function(a){var b=this.chart;b.mouseIsDown=a.type;b.cancelClick=!1;b.mouseDownX=this.mouseDownX=a.chartX;b.mouseDownY=this.mouseDownY=a.chartY},drag:function(a){var b=this.chart,c=b.options.chart,h=a.chartX,e=a.chartY,
d=this.zoomHor,p=this.zoomVert,f=b.plotLeft,m=b.plotTop,n=b.plotWidth,k=b.plotHeight,l,q=this.selectionMarker,g=this.mouseDownX,u=this.mouseDownY,r=c.panKey&&a[c.panKey+"Key"];q&&q.touch||(h<f?h=f:h>f+n&&(h=f+n),e<m?e=m:e>m+k&&(e=m+k),this.hasDragged=Math.sqrt(Math.pow(g-h,2)+Math.pow(u-e,2)),10<this.hasDragged&&(l=b.isInsidePlot(g-f,u-m),b.hasCartesianSeries&&(this.zoomX||this.zoomY)&&l&&!r&&!q&&(this.selectionMarker=q=b.renderer.rect(f,m,d?1:n,p?1:k,0).attr({fill:c.selectionMarkerFill||G("#335cad").setOpacity(.25).get(),
"class":"highcharts-selection-marker",zIndex:7}).add()),q&&d&&(h-=g,q.attr({width:Math.abs(h),x:(0<h?0:h)+g})),q&&p&&(h=e-u,q.attr({height:Math.abs(h),y:(0<h?0:h)+u})),l&&!q&&c.panning&&b.pan(a,c.panning)))},drop:function(a){var b=this,c=this.chart,h=this.hasPinched;if(this.selectionMarker){var e={originalEvent:a,xAxis:[],yAxis:[]},d=this.selectionMarker,p=d.attr?d.attr("x"):d.x,n=d.attr?d.attr("y"):d.y,m=d.attr?d.attr("width"):d.width,y=d.attr?d.attr("height"):d.height,l;if(this.hasDragged||h)q(c.axes,
function(c){if(c.zoomEnabled&&f(c.min)&&(h||b[{xAxis:"zoomX",yAxis:"zoomY"}[c.coll]])){var d=c.horiz,g="touchend"===a.type?c.minPixelPadding:0,t=c.toValue((d?p:n)+g),d=c.toValue((d?p+m:n+y)-g);e[c.coll].push({axis:c,min:Math.min(t,d),max:Math.max(t,d)});l=!0}}),l&&u(c,"selection",e,function(a){c.zoom(k(a,h?{animation:!1}:null))});this.selectionMarker=this.selectionMarker.destroy();h&&this.scaleGroups()}c&&(r(c.container,{cursor:c._cursor}),c.cancelClick=10<this.hasDragged,c.mouseIsDown=this.hasDragged=
this.hasPinched=!1,this.pinchDown=[])},onContainerMouseDown:function(a){a=this.normalize(a);this.zoomOption(a);a.preventDefault&&a.preventDefault();this.dragStart(a)},onDocumentMouseUp:function(b){H[a.hoverChartIndex]&&H[a.hoverChartIndex].pointer.drop(b)},onDocumentMouseMove:function(a){var b=this.chart,c=this.chartPosition;a=this.normalize(a,c);!c||this.inClass(a.target,"highcharts-tracker")||b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)||this.reset()},onContainerMouseLeave:function(b){var c=
H[a.hoverChartIndex];c&&(b.relatedTarget||b.toElement)&&(c.pointer.reset(),c.pointer.chartPosition=null)},onContainerMouseMove:function(b){var c=this.chart;f(a.hoverChartIndex)&&H[a.hoverChartIndex]&&H[a.hoverChartIndex].mouseIsDown||(a.hoverChartIndex=c.index);b=this.normalize(b);b.returnValue=!1;"mousedown"===c.mouseIsDown&&this.drag(b);!this.inClass(b.target,"highcharts-tracker")&&!c.isInsidePlot(b.chartX-c.plotLeft,b.chartY-c.plotTop)||c.openMenu||this.runPointActions(b)},inClass:function(a,b){for(var c;a;){if(c=
A(a,"class")){if(-1!==c.indexOf(b))return!0;if(-1!==c.indexOf("highcharts-container"))return!1}a=a.parentNode}},onTrackerMouseOut:function(a){var b=this.chart.hoverSeries;a=a.relatedTarget||a.toElement;if(!(!b||!a||b.stickyTracking||this.inClass(a,"highcharts-tooltip")||this.inClass(a,"highcharts-series-"+b.index)&&this.inClass(a,"highcharts-tracker")))b.onMouseOut()},onContainerClick:function(a){var b=this.chart,c=b.hoverPoint,h=b.plotLeft,e=b.plotTop;a=this.normalize(a);b.cancelClick||(c&&this.inClass(a.target,
"highcharts-tracker")?(u(c.series,"click",k(a,{point:c})),b.hoverPoint&&c.firePointEvent("click",a)):(k(a,this.getCoordinates(a)),b.isInsidePlot(a.chartX-h,a.chartY-e)&&u(b,"click",a)))},setDOMEvents:function(){var b=this,c=b.chart.container;c.onmousedown=function(a){b.onContainerMouseDown(a)};c.onmousemove=function(a){b.onContainerMouseMove(a)};c.onclick=function(a){b.onContainerClick(a)};B(c,"mouseleave",b.onContainerMouseLeave);1===a.chartCount&&B(l,"mouseup",b.onDocumentMouseUp);a.hasTouch&&(c.ontouchstart=
function(a){b.onContainerTouchStart(a)},c.ontouchmove=function(a){b.onContainerTouchMove(a)},1===a.chartCount&&B(l,"touchend",b.onDocumentTouchEnd))},destroy:function(){var b;this.unDocMouseMove&&this.unDocMouseMove();n(this.chart.container,"mouseleave",this.onContainerMouseLeave);a.chartCount||(n(l,"mouseup",this.onDocumentMouseUp),n(l,"touchend",this.onDocumentTouchEnd));clearInterval(this.tooltipTimeout);for(b in this)this[b]=null}}})(L);(function(a){var B=a.charts,A=a.each,H=a.extend,G=a.map,
r=a.noop,f=a.pick;H(a.Pointer.prototype,{pinchTranslate:function(a,f,k,u,d,c){this.zoomHor&&this.pinchTranslateDirection(!0,a,f,k,u,d,c);this.zoomVert&&this.pinchTranslateDirection(!1,a,f,k,u,d,c)},pinchTranslateDirection:function(a,f,k,u,d,c,n,r){var b=this.chart,p=a?"x":"y",h=a?"X":"Y",t="chart"+h,l=a?"width":"height",w=b["plot"+(a?"Left":"Top")],e,q,C=r||1,E=b.inverted,m=b.bounds[a?"h":"v"],y=1===f.length,I=f[0][t],K=k[0][t],J=!y&&f[1][t],g=!y&&k[1][t],z;k=function(){!y&&20<Math.abs(I-J)&&(C=r||
Math.abs(K-g)/Math.abs(I-J));q=(w-K)/C+I;e=b["plot"+(a?"Width":"Height")]/C};k();f=q;f<m.min?(f=m.min,z=!0):f+e>m.max&&(f=m.max-e,z=!0);z?(K-=.8*(K-n[p][0]),y||(g-=.8*(g-n[p][1])),k()):n[p]=[K,g];E||(c[p]=q-w,c[l]=e);c=E?1/C:C;d[l]=e;d[p]=f;u[E?a?"scaleY":"scaleX":"scale"+h]=C;u["translate"+h]=c*w+(K-c*I)},pinch:function(a){var l=this,k=l.chart,u=l.pinchDown,d=a.touches,c=d.length,n=l.lastValidTouch,z=l.hasZoom,b=l.selectionMarker,p={},h=1===c&&(l.inClass(a.target,"highcharts-tracker")&&k.runTrackerClick||
l.runChartClick),t={};1<c&&(l.initiated=!0);z&&l.initiated&&!h&&a.preventDefault();G(d,function(a){return l.normalize(a)});"touchstart"===a.type?(A(d,function(a,b){u[b]={chartX:a.chartX,chartY:a.chartY}}),n.x=[u[0].chartX,u[1]&&u[1].chartX],n.y=[u[0].chartY,u[1]&&u[1].chartY],A(k.axes,function(a){if(a.zoomEnabled){var b=k.bounds[a.horiz?"h":"v"],c=a.minPixelPadding,h=a.toPixels(f(a.options.min,a.dataMin)),d=a.toPixels(f(a.options.max,a.dataMax)),p=Math.max(h,d);b.min=Math.min(a.pos,Math.min(h,d)-
c);b.max=Math.max(a.pos+a.len,p+c)}}),l.res=!0):l.followTouchMove&&1===c?this.runPointActions(l.normalize(a)):u.length&&(b||(l.selectionMarker=b=H({destroy:r,touch:!0},k.plotBox)),l.pinchTranslate(u,d,p,b,t,n),l.hasPinched=z,l.scaleGroups(p,t),l.res&&(l.res=!1,this.reset(!1,0)))},touch:function(l,q){var k=this.chart,u,d;if(k.index!==a.hoverChartIndex)this.onContainerMouseLeave({relatedTarget:!0});a.hoverChartIndex=k.index;1===l.touches.length?(l=this.normalize(l),(d=k.isInsidePlot(l.chartX-k.plotLeft,
l.chartY-k.plotTop))&&!k.openMenu?(q&&this.runPointActions(l),"touchmove"===l.type&&(q=this.pinchDown,u=q[0]?4<=Math.sqrt(Math.pow(q[0].chartX-l.chartX,2)+Math.pow(q[0].chartY-l.chartY,2)):!1),f(u,!0)&&this.pinch(l)):q&&this.reset()):2===l.touches.length&&this.pinch(l)},onContainerTouchStart:function(a){this.zoomOption(a);this.touch(a,!0)},onContainerTouchMove:function(a){this.touch(a)},onDocumentTouchEnd:function(f){B[a.hoverChartIndex]&&B[a.hoverChartIndex].pointer.drop(f)}})})(L);(function(a){var B=
a.addEvent,A=a.charts,H=a.css,G=a.doc,r=a.extend,f=a.noop,l=a.Pointer,q=a.removeEvent,k=a.win,u=a.wrap;if(k.PointerEvent||k.MSPointerEvent){var d={},c=!!k.PointerEvent,n=function(){var a,c=[];c.item=function(a){return this[a]};for(a in d)d.hasOwnProperty(a)&&c.push({pageX:d[a].pageX,pageY:d[a].pageY,target:d[a].target});return c},z=function(b,c,h,d){"touch"!==b.pointerType&&b.pointerType!==b.MSPOINTER_TYPE_TOUCH||!A[a.hoverChartIndex]||(d(b),d=A[a.hoverChartIndex].pointer,d[c]({type:h,target:b.currentTarget,
preventDefault:f,touches:n()}))};r(l.prototype,{onContainerPointerDown:function(a){z(a,"onContainerTouchStart","touchstart",function(a){d[a.pointerId]={pageX:a.pageX,pageY:a.pageY,target:a.currentTarget}})},onContainerPointerMove:function(a){z(a,"onContainerTouchMove","touchmove",function(a){d[a.pointerId]={pageX:a.pageX,pageY:a.pageY};d[a.pointerId].target||(d[a.pointerId].target=a.currentTarget)})},onDocumentPointerUp:function(a){z(a,"onDocumentTouchEnd","touchend",function(a){delete d[a.pointerId]})},
batchMSEvents:function(a){a(this.chart.container,c?"pointerdown":"MSPointerDown",this.onContainerPointerDown);a(this.chart.container,c?"pointermove":"MSPointerMove",this.onContainerPointerMove);a(G,c?"pointerup":"MSPointerUp",this.onDocumentPointerUp)}});u(l.prototype,"init",function(a,c,h){a.call(this,c,h);this.hasZoom&&H(c.container,{"-ms-touch-action":"none","touch-action":"none"})});u(l.prototype,"setDOMEvents",function(a){a.apply(this);(this.hasZoom||this.followTouchMove)&&this.batchMSEvents(B)});
u(l.prototype,"destroy",function(a){this.batchMSEvents(q);a.call(this)})}})(L);(function(a){var B,A=a.addEvent,H=a.css,G=a.discardElement,r=a.defined,f=a.each,l=a.isFirefox,q=a.marginNames,k=a.merge,u=a.pick,d=a.setAnimation,c=a.stableSort,n=a.win,z=a.wrap;B=a.Legend=function(a,c){this.init(a,c)};B.prototype={init:function(a,c){this.chart=a;this.setOptions(c);c.enabled&&(this.render(),A(this.chart,"endResize",function(){this.legend.positionCheckboxes()}))},setOptions:function(a){var b=u(a.padding,
8);this.options=a;this.itemStyle=a.itemStyle;this.itemHiddenStyle=k(this.itemStyle,a.itemHiddenStyle);this.itemMarginTop=a.itemMarginTop||0;this.padding=b;this.initialItemY=b-5;this.itemHeight=this.maxItemWidth=0;this.symbolWidth=u(a.symbolWidth,16);this.pages=[]},update:function(a,c){var b=this.chart;this.setOptions(k(!0,this.options,a));this.destroy();b.isDirtyLegend=b.isDirtyBox=!0;u(c,!0)&&b.redraw()},colorizeItem:function(a,c){a.legendGroup[c?"removeClass":"addClass"]("highcharts-legend-item-hidden");
var b=this.options,d=a.legendItem,f=a.legendLine,p=a.legendSymbol,e=this.itemHiddenStyle.color,b=c?b.itemStyle.color:e,n=c?a.color||e:e,k=a.options&&a.options.marker,l={fill:n},m;d&&d.css({fill:b,color:b});f&&f.attr({stroke:n});if(p){if(k&&p.isMarker&&(l=a.pointAttribs(),!c))for(m in l)l[m]=e;p.attr(l)}},positionItem:function(a){var b=this.options,c=b.symbolPadding,b=!b.rtl,d=a._legendItemPos,f=d[0],d=d[1],n=a.checkbox;(a=a.legendGroup)&&a.element&&a.translate(b?f:this.legendWidth-f-2*c-4,d);n&&(n.x=
f,n.y=d)},destroyItem:function(a){var b=a.checkbox;f(["legendItem","legendLine","legendSymbol","legendGroup"],function(b){a[b]&&(a[b]=a[b].destroy())});b&&G(a.checkbox)},destroy:function(){function a(a){this[a]&&(this[a]=this[a].destroy())}f(this.getAllItems(),function(b){f(["legendItem","legendGroup"],a,b)});f("clipRect up down pager nav box title group".split(" "),a,this);this.display=null},positionCheckboxes:function(a){var b=this.group&&this.group.alignAttr,c,d=this.clipHeight||this.legendHeight,
n=this.titleHeight;b&&(c=b.translateY,f(this.allItems,function(h){var e=h.checkbox,f;e&&(f=c+n+e.y+(a||0)+3,H(e,{left:b.translateX+h.checkboxOffset+e.x-20+"px",top:f+"px",display:f>c-6&&f<c+d-6?"":"none"}))}))},renderTitle:function(){var a=this.padding,c=this.options.title,h=0;c.text&&(this.title||(this.title=this.chart.renderer.label(c.text,a-3,a-4,null,null,null,null,null,"legend-title").attr({zIndex:1}).css(c.style).add(this.group)),a=this.title.getBBox(),h=a.height,this.offsetWidth=a.width,this.contentGroup.attr({translateY:h}));
this.titleHeight=h},setText:function(b){var c=this.options;b.legendItem.attr({text:c.labelFormat?a.format(c.labelFormat,b):c.labelFormatter.call(b)})},renderItem:function(a){var b=this.chart,c=b.renderer,d=this.options,f="horizontal"===d.layout,n=this.symbolWidth,e=d.symbolPadding,l=this.itemStyle,q=this.itemHiddenStyle,r=this.padding,m=f?u(d.itemDistance,20):0,y=!d.rtl,I=d.width,K=d.itemMarginBottom||0,J=this.itemMarginTop,g=a.legendItem,z=!a.series,Q=!z&&a.series.drawLegendSymbol?a.series:a,A=Q.options,
A=this.createCheckboxForItem&&A&&A.showCheckbox,B=d.useHTML,H=a.options.className;g||(a.legendGroup=c.g("legend-item").addClass("highcharts-"+Q.type+"-series highcharts-color-"+a.colorIndex+(H?" "+H:"")+(z?" highcharts-series-"+a.index:"")).attr({zIndex:1}).add(this.scrollGroup),a.legendItem=g=c.text("",y?n+e:-e,this.baseline||0,B).css(k(a.visible?l:q)).attr({align:y?"left":"right",zIndex:2}).add(a.legendGroup),this.baseline||(l=l.fontSize,this.fontMetrics=c.fontMetrics(l,g),this.baseline=this.fontMetrics.f+
3+J,g.attr("y",this.baseline)),this.symbolHeight=d.symbolHeight||this.fontMetrics.f,Q.drawLegendSymbol(this,a),this.setItemEvents&&this.setItemEvents(a,g,B),A&&this.createCheckboxForItem(a));this.colorizeItem(a,a.visible);this.setText(a);c=g.getBBox();n=a.checkboxOffset=d.itemWidth||a.legendItemWidth||n+e+c.width+m+(A?20:0);this.itemHeight=e=Math.round(a.legendItemHeight||c.height||this.symbolHeight);f&&this.itemX-r+n>(I||b.spacingBox.width-2*r-d.x)&&(this.itemX=r,this.itemY+=J+this.lastLineHeight+
K,this.lastLineHeight=0);this.maxItemWidth=Math.max(this.maxItemWidth,n);this.lastItemY=J+this.itemY+K;this.lastLineHeight=Math.max(e,this.lastLineHeight);a._legendItemPos=[this.itemX,this.itemY];f?this.itemX+=n:(this.itemY+=J+e+K,this.lastLineHeight=e);this.offsetWidth=I||Math.max((f?this.itemX-r-m:n)+r,this.offsetWidth)},getAllItems:function(){var a=[];f(this.chart.series,function(b){var c=b&&b.options;b&&u(c.showInLegend,r(c.linkedTo)?!1:void 0,!0)&&(a=a.concat(b.legendItems||("point"===c.legendType?
b.data:b)))});return a},adjustMargins:function(a,c){var b=this.chart,d=this.options,p=d.align.charAt(0)+d.verticalAlign.charAt(0)+d.layout.charAt(0);d.floating||f([/(lth|ct|rth)/,/(rtv|rm|rbv)/,/(rbh|cb|lbh)/,/(lbv|lm|ltv)/],function(h,e){h.test(p)&&!r(a[e])&&(b[q[e]]=Math.max(b[q[e]],b.legend[(e+1)%2?"legendHeight":"legendWidth"]+[1,-1,-1,1][e]*d[e%2?"x":"y"]+u(d.margin,12)+c[e]))})},render:function(){var a=this,d=a.chart,h=d.renderer,n=a.group,l,q,e,x,u=a.box,r=a.options,m=a.padding;a.itemX=m;a.itemY=
a.initialItemY;a.offsetWidth=0;a.lastItemY=0;n||(a.group=n=h.g("legend").attr({zIndex:7}).add(),a.contentGroup=h.g().attr({zIndex:1}).add(n),a.scrollGroup=h.g().add(a.contentGroup));a.renderTitle();l=a.getAllItems();c(l,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)});r.reversed&&l.reverse();a.allItems=l;a.display=q=!!l.length;a.lastLineHeight=0;f(l,function(b){a.renderItem(b)});e=(r.width||a.offsetWidth)+m;x=a.lastItemY+a.lastLineHeight+a.titleHeight;
x=a.handleOverflow(x);x+=m;u||(a.box=u=h.rect().addClass("highcharts-legend-box").attr({r:r.borderRadius}).add(n),u.isNew=!0);u.attr({stroke:r.borderColor,"stroke-width":r.borderWidth||0,fill:r.backgroundColor||"none"}).shadow(r.shadow);0<e&&0<x&&(u[u.isNew?"attr":"animate"](u.crisp({x:0,y:0,width:e,height:x},u.strokeWidth())),u.isNew=!1);u[q?"show":"hide"]();a.legendWidth=e;a.legendHeight=x;f(l,function(b){a.positionItem(b)});q&&n.align(k(r,{width:e,height:x}),!0,"spacingBox");d.isResizing||this.positionCheckboxes()},
handleOverflow:function(a){var b=this,c=this.chart,d=c.renderer,n=this.options,k=n.y,e=this.padding,c=c.spacingBox.height+("top"===n.verticalAlign?-k:k)-e,k=n.maxHeight,l,q=this.clipRect,r=n.navigation,m=u(r.animation,!0),y=r.arrowSize||12,I=this.nav,K=this.pages,J,g=this.allItems,z=function(a){a?q.attr({height:a}):q&&(b.clipRect=q.destroy(),b.contentGroup.clip());b.contentGroup.div&&(b.contentGroup.div.style.clip=a?"rect("+e+"px,9999px,"+(e+a)+"px,0)":"auto")};"horizontal"!==n.layout||"middle"===
n.verticalAlign||n.floating||(c/=2);k&&(c=Math.min(c,k));K.length=0;a>c&&!1!==r.enabled?(this.clipHeight=l=Math.max(c-20-this.titleHeight-e,0),this.currentPage=u(this.currentPage,1),this.fullHeight=a,f(g,function(a,b){var c=a._legendItemPos[1];a=Math.round(a.legendItem.getBBox().height);var e=K.length;if(!e||c-K[e-1]>l&&(J||c)!==K[e-1])K.push(J||c),e++;b===g.length-1&&c+a-K[e-1]>l&&K.push(c);c!==J&&(J=c)}),q||(q=b.clipRect=d.clipRect(0,e,9999,0),b.contentGroup.clip(q)),z(l),I||(this.nav=I=d.g().attr({zIndex:1}).add(this.group),
this.up=d.symbol("triangle",0,0,y,y).on("click",function(){b.scroll(-1,m)}).add(I),this.pager=d.text("",15,10).addClass("highcharts-legend-navigation").css(r.style).add(I),this.down=d.symbol("triangle-down",0,0,y,y).on("click",function(){b.scroll(1,m)}).add(I)),b.scroll(0),a=c):I&&(z(),this.nav=I.destroy(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0);return a},scroll:function(a,c){var b=this.pages,f=b.length;a=this.currentPage+a;var p=this.clipHeight,n=this.options.navigation,e=this.pager,
k=this.padding;a>f&&(a=f);0<a&&(void 0!==c&&d(c,this.chart),this.nav.attr({translateX:k,translateY:p+this.padding+7+this.titleHeight,visibility:"visible"}),this.up.attr({"class":1===a?"highcharts-legend-nav-inactive":"highcharts-legend-nav-active"}),e.attr({text:a+"/"+f}),this.down.attr({x:18+this.pager.getBBox().width,"class":a===f?"highcharts-legend-nav-inactive":"highcharts-legend-nav-active"}),this.up.attr({fill:1===a?n.inactiveColor:n.activeColor}).css({cursor:1===a?"default":"pointer"}),this.down.attr({fill:a===
f?n.inactiveColor:n.activeColor}).css({cursor:a===f?"default":"pointer"}),c=-b[a-1]+this.initialItemY,this.scrollGroup.animate({translateY:c}),this.currentPage=a,this.positionCheckboxes(c))}};a.LegendSymbolMixin={drawRectangle:function(a,c){var b=a.symbolHeight,d=a.options.squareSymbol;c.legendSymbol=this.chart.renderer.rect(d?(a.symbolWidth-b)/2:0,a.baseline-b+1,d?b:a.symbolWidth,b,u(a.options.symbolRadius,b/2)).addClass("highcharts-point").attr({zIndex:3}).add(c.legendGroup)},drawLineMarker:function(a){var b=
this.options,c=b.marker,d=a.symbolWidth,f=a.symbolHeight,n=f/2,e=this.chart.renderer,l=this.legendGroup;a=a.baseline-Math.round(.3*a.fontMetrics.b);var q;q={"stroke-width":b.lineWidth||0};b.dashStyle&&(q.dashstyle=b.dashStyle);this.legendLine=e.path(["M",0,a,"L",d,a]).addClass("highcharts-graph").attr(q).add(l);c&&!1!==c.enabled&&(b=Math.min(u(c.radius,n),n),0===this.symbol.indexOf("url")&&(c=k(c,{width:f,height:f}),b=0),this.legendSymbol=c=e.symbol(this.symbol,d/2-b,a-b,2*b,2*b,c).addClass("highcharts-point").add(l),
c.isMarker=!0)}};(/Trident\/7\.0/.test(n.navigator.userAgent)||l)&&z(B.prototype,"positionItem",function(a,c){var b=this,d=function(){c._legendItemPos&&a.call(b,c)};d();setTimeout(d)})})(L);(function(a){var B=a.addEvent,A=a.animate,H=a.animObject,G=a.attr,r=a.doc,f=a.Axis,l=a.createElement,q=a.defaultOptions,k=a.discardElement,u=a.charts,d=a.css,c=a.defined,n=a.each,z=a.extend,b=a.find,p=a.fireEvent,h=a.getStyle,t=a.grep,D=a.isNumber,w=a.isObject,e=a.isString,x=a.Legend,C=a.marginNames,E=a.merge,
m=a.Pointer,y=a.pick,I=a.pInt,K=a.removeEvent,J=a.seriesTypes,g=a.splat,F=a.svg,Q=a.syncTimeout,N=a.win,P=a.Renderer,O=a.Chart=function(){this.getArgs.apply(this,arguments)};a.chart=function(a,b,c){return new O(a,b,c)};O.prototype={callbacks:[],getArgs:function(){var a=[].slice.call(arguments);if(e(a[0])||a[0].nodeName)this.renderTo=a.shift();this.init(a[0],a[1])},init:function(b,c){var e,g=b.series;b.series=null;e=E(q,b);e.series=b.series=g;this.userOptions=b;b=e.chart;g=b.events;this.margin=[];
this.spacing=[];this.bounds={h:{},v:{}};this.callback=c;this.isResizing=0;this.options=e;this.axes=[];this.series=[];this.hasCartesianSeries=b.showAxes;var d;this.index=u.length;u.push(this);a.chartCount++;if(g)for(d in g)B(this,d,g[d]);this.xAxis=[];this.yAxis=[];this.pointCount=this.colorCounter=this.symbolCounter=0;this.firstRender()},initSeries:function(b){var c=this.options.chart;(c=J[b.type||c.type||c.defaultSeriesType])||a.error(17,!0);c=new c;c.init(this,b);return c},orderSeries:function(a){var b=
this.series;for(a=a||0;a<b.length;a++)b[a]&&(b[a].index=a,b[a].name=b[a].name||"Series "+(b[a].index+1))},isInsidePlot:function(a,b,c){var e=c?b:a;a=c?a:b;return 0<=e&&e<=this.plotWidth&&0<=a&&a<=this.plotHeight},redraw:function(b){var c=this.axes,e=this.series,g=this.pointer,d=this.legend,m=this.isDirtyLegend,h,f,v=this.hasCartesianSeries,k=this.isDirtyBox,y,l=this.renderer,t=l.isHidden(),q=[];this.setResponsive&&this.setResponsive(!1);a.setAnimation(b,this);t&&this.cloneRenderTo();this.layOutTitles();
for(b=e.length;b--;)if(y=e[b],y.options.stacking&&(h=!0,y.isDirty)){f=!0;break}if(f)for(b=e.length;b--;)y=e[b],y.options.stacking&&(y.isDirty=!0);n(e,function(a){a.isDirty&&"point"===a.options.legendType&&(a.updateTotals&&a.updateTotals(),m=!0);a.isDirtyData&&p(a,"updatedData")});m&&d.options.enabled&&(d.render(),this.isDirtyLegend=!1);h&&this.getStacks();v&&n(c,function(a){a.updateNames();a.setScale()});this.getMargins();v&&(n(c,function(a){a.isDirty&&(k=!0)}),n(c,function(a){var b=a.min+","+a.max;
a.extKey!==b&&(a.extKey=b,q.push(function(){p(a,"afterSetExtremes",z(a.eventArgs,a.getExtremes()));delete a.eventArgs}));(k||h)&&a.redraw()}));k&&this.drawChartBox();p(this,"predraw");n(e,function(a){(k||a.isDirty)&&a.visible&&a.redraw();a.isDirtyData=!1});g&&g.reset(!0);l.draw();p(this,"redraw");p(this,"render");t&&this.cloneRenderTo(!0);n(q,function(a){a.call()})},get:function(a){function c(b){return b.id===a||b.options&&b.options.id===a}var e,g=this.series,d;e=b(this.axes,c)||b(this.series,c);
for(d=0;!e&&d<g.length;d++)e=b(g[d].points||[],c);return e},getAxes:function(){var a=this,b=this.options,c=b.xAxis=g(b.xAxis||{}),b=b.yAxis=g(b.yAxis||{});n(c,function(a,b){a.index=b;a.isX=!0});n(b,function(a,b){a.index=b});c=c.concat(b);n(c,function(b){new f(a,b)})},getSelectedPoints:function(){var a=[];n(this.series,function(b){a=a.concat(t(b.points||[],function(a){return a.selected}))});return a},getSelectedSeries:function(){return t(this.series,function(a){return a.selected})},setTitle:function(a,
b,c){var e=this,g=e.options,d;d=g.title=E({style:{color:"#333333",fontSize:g.isStock?"16px":"18px"}},g.title,a);g=g.subtitle=E({style:{color:"#666666"}},g.subtitle,b);n([["title",a,d],["subtitle",b,g]],function(a,b){var c=a[0],g=e[c],d=a[1];a=a[2];g&&d&&(e[c]=g=g.destroy());a&&a.text&&!g&&(e[c]=e.renderer.text(a.text,0,0,a.useHTML).attr({align:a.align,"class":"highcharts-"+c,zIndex:a.zIndex||4}).add(),e[c].update=function(a){e.setTitle(!b&&a,b&&a)},e[c].css(a.style))});e.layOutTitles(c)},layOutTitles:function(a){var b=
0,c,e=this.renderer,g=this.spacingBox;n(["title","subtitle"],function(a){var c=this[a],d=this.options[a],m;c&&(m=d.style.fontSize,m=e.fontMetrics(m,c).b,c.css({width:(d.width||g.width+d.widthAdjust)+"px"}).align(z({y:b+m+("title"===a?-3:2)},d),!1,"spacingBox"),d.floating||d.verticalAlign||(b=Math.ceil(b+c.getBBox(d.useHTML).height)))},this);c=this.titleOffset!==b;this.titleOffset=b;!this.isDirtyBox&&c&&(this.isDirtyBox=c,this.hasRendered&&y(a,!0)&&this.isDirtyBox&&this.redraw())},getChartSize:function(){var b=
this.options.chart,e=b.width,b=b.height,g=this.renderToClone||this.renderTo;c(e)||(this.containerWidth=h(g,"width"));c(b)||(this.containerHeight=h(g,"height"));this.chartWidth=Math.max(0,e||this.containerWidth||600);this.chartHeight=Math.max(0,a.relativeLength(b,this.chartWidth)||this.containerHeight||400)},cloneRenderTo:function(a){var b=this.renderToClone,c=this.container;if(a){if(b){for(;b.childNodes.length;)this.renderTo.appendChild(b.firstChild);k(b);delete this.renderToClone}}else c&&c.parentNode===
this.renderTo&&this.renderTo.removeChild(c),this.renderToClone=b=this.renderTo.cloneNode(0),d(b,{position:"absolute",top:"-9999px",display:"block"}),b.style.setProperty&&b.style.setProperty("display","block","important"),r.body.appendChild(b),c&&b.appendChild(c)},setClassName:function(a){this.container.className="highcharts-container "+(a||"")},getContainer:function(){var b,c=this.options,g=c.chart,d,m;b=this.renderTo;var h=a.uniqueKey(),f;b||(this.renderTo=b=g.renderTo);e(b)&&(this.renderTo=b=r.getElementById(b));
b||a.error(13,!0);d=I(G(b,"data-highcharts-chart"));D(d)&&u[d]&&u[d].hasRendered&&u[d].destroy();G(b,"data-highcharts-chart",this.index);b.innerHTML="";g.skipClone||b.offsetWidth||this.cloneRenderTo();this.getChartSize();d=this.chartWidth;m=this.chartHeight;f=z({position:"relative",overflow:"hidden",width:d+"px",height:m+"px",textAlign:"left",lineHeight:"normal",zIndex:0,"-webkit-tap-highlight-color":"rgba(0,0,0,0)"},g.style);this.container=b=l("div",{id:h},f,this.renderToClone||b);this._cursor=b.style.cursor;
this.renderer=new (a[g.renderer]||P)(b,d,m,null,g.forExport,c.exporting&&c.exporting.allowHTML);this.setClassName(g.className);this.renderer.setStyle(g.style);this.renderer.chartIndex=this.index},getMargins:function(a){var b=this.spacing,e=this.margin,g=this.titleOffset;this.resetMargins();g&&!c(e[0])&&(this.plotTop=Math.max(this.plotTop,g+this.options.title.margin+b[0]));this.legend.display&&this.legend.adjustMargins(e,b);this.extraMargin&&(this[this.extraMargin.type]=(this[this.extraMargin.type]||
0)+this.extraMargin.value);this.extraTopMargin&&(this.plotTop+=this.extraTopMargin);a||this.getAxisMargins()},getAxisMargins:function(){var a=this,b=a.axisOffset=[0,0,0,0],e=a.margin;a.hasCartesianSeries&&n(a.axes,function(a){a.visible&&a.getOffset()});n(C,function(g,d){c(e[d])||(a[g]+=b[d])});a.setChartSize()},reflow:function(a){var b=this,e=b.options.chart,g=b.renderTo,d=c(e.width),m=e.width||h(g,"width"),e=e.height||h(g,"height"),g=a?a.target:N;if(!d&&!b.isPrinting&&m&&e&&(g===N||g===r)){if(m!==
b.containerWidth||e!==b.containerHeight)clearTimeout(b.reflowTimeout),b.reflowTimeout=Q(function(){b.container&&b.setSize(void 0,void 0,!1)},a?100:0);b.containerWidth=m;b.containerHeight=e}},initReflow:function(){var a=this,b;b=B(N,"resize",function(b){a.reflow(b)});B(a,"destroy",b)},setSize:function(b,c,e){var g=this,m=g.renderer;g.isResizing+=1;a.setAnimation(e,g);g.oldChartHeight=g.chartHeight;g.oldChartWidth=g.chartWidth;void 0!==b&&(g.options.chart.width=b);void 0!==c&&(g.options.chart.height=
c);g.getChartSize();b=m.globalAnimation;(b?A:d)(g.container,{width:g.chartWidth+"px",height:g.chartHeight+"px"},b);g.setChartSize(!0);m.setSize(g.chartWidth,g.chartHeight,e);n(g.axes,function(a){a.isDirty=!0;a.setScale()});g.isDirtyLegend=!0;g.isDirtyBox=!0;g.layOutTitles();g.getMargins();g.redraw(e);g.oldChartHeight=null;p(g,"resize");Q(function(){g&&p(g,"endResize",null,function(){--g.isResizing})},H(b).duration)},setChartSize:function(a){var b=this.inverted,c=this.renderer,e=this.chartWidth,g=
this.chartHeight,d=this.options.chart,m=this.spacing,h=this.clipOffset,f,p,k,y;this.plotLeft=f=Math.round(this.plotLeft);this.plotTop=p=Math.round(this.plotTop);this.plotWidth=k=Math.max(0,Math.round(e-f-this.marginRight));this.plotHeight=y=Math.max(0,Math.round(g-p-this.marginBottom));this.plotSizeX=b?y:k;this.plotSizeY=b?k:y;this.plotBorderWidth=d.plotBorderWidth||0;this.spacingBox=c.spacingBox={x:m[3],y:m[0],width:e-m[3]-m[1],height:g-m[0]-m[2]};this.plotBox=c.plotBox={x:f,y:p,width:k,height:y};
e=2*Math.floor(this.plotBorderWidth/2);b=Math.ceil(Math.max(e,h[3])/2);c=Math.ceil(Math.max(e,h[0])/2);this.clipBox={x:b,y:c,width:Math.floor(this.plotSizeX-Math.max(e,h[1])/2-b),height:Math.max(0,Math.floor(this.plotSizeY-Math.max(e,h[2])/2-c))};a||n(this.axes,function(a){a.setAxisSize();a.setAxisTranslation()})},resetMargins:function(){var a=this,b=a.options.chart;n(["margin","spacing"],function(c){var e=b[c],g=w(e)?e:[e,e,e,e];n(["Top","Right","Bottom","Left"],function(e,d){a[c][d]=y(b[c+e],g[d])})});
n(C,function(b,c){a[b]=y(a.margin[c],a.spacing[c])});a.axisOffset=[0,0,0,0];a.clipOffset=[0,0,0,0]},drawChartBox:function(){var a=this.options.chart,b=this.renderer,c=this.chartWidth,e=this.chartHeight,g=this.chartBackground,d=this.plotBackground,m=this.plotBorder,h,f=this.plotBGImage,n=a.backgroundColor,p=a.plotBackgroundColor,k=a.plotBackgroundImage,y,l=this.plotLeft,t=this.plotTop,q=this.plotWidth,u=this.plotHeight,x=this.plotBox,r=this.clipRect,w=this.clipBox,I="animate";g||(this.chartBackground=
g=b.rect().addClass("highcharts-background").add(),I="attr");h=a.borderWidth||0;y=h+(a.shadow?8:0);n={fill:n||"none"};if(h||g["stroke-width"])n.stroke=a.borderColor,n["stroke-width"]=h;g.attr(n).shadow(a.shadow);g[I]({x:y/2,y:y/2,width:c-y-h%2,height:e-y-h%2,r:a.borderRadius});I="animate";d||(I="attr",this.plotBackground=d=b.rect().addClass("highcharts-plot-background").add());d[I](x);d.attr({fill:p||"none"}).shadow(a.plotShadow);k&&(f?f.animate(x):this.plotBGImage=b.image(k,l,t,q,u).add());r?r.animate({width:w.width,
height:w.height}):this.clipRect=b.clipRect(w);I="animate";m||(I="attr",this.plotBorder=m=b.rect().addClass("highcharts-plot-border").attr({zIndex:1}).add());m.attr({stroke:a.plotBorderColor,"stroke-width":a.plotBorderWidth||0,fill:"none"});m[I](m.crisp({x:l,y:t,width:q,height:u},-m.strokeWidth()));this.isDirtyBox=!1},propFromSeries:function(){var a=this,b=a.options.chart,c,e=a.options.series,g,d;n(["inverted","angular","polar"],function(m){c=J[b.type||b.defaultSeriesType];d=b[m]||c&&c.prototype[m];
for(g=e&&e.length;!d&&g--;)(c=J[e[g].type])&&c.prototype[m]&&(d=!0);a[m]=d})},linkSeries:function(){var a=this,b=a.series;n(b,function(a){a.linkedSeries.length=0});n(b,function(b){var c=b.options.linkedTo;e(c)&&(c=":previous"===c?a.series[b.index-1]:a.get(c))&&c.linkedParent!==b&&(c.linkedSeries.push(b),b.linkedParent=c,b.visible=y(b.options.visible,c.options.visible,b.visible))})},renderSeries:function(){n(this.series,function(a){a.translate();a.render()})},renderLabels:function(){var a=this,b=a.options.labels;
b.items&&n(b.items,function(c){var e=z(b.style,c.style),g=I(e.left)+a.plotLeft,d=I(e.top)+a.plotTop+12;delete e.left;delete e.top;a.renderer.text(c.html,g,d).attr({zIndex:2}).css(e).add()})},render:function(){var a=this.axes,b=this.renderer,c=this.options,e,g,d;this.setTitle();this.legend=new x(this,c.legend);this.getStacks&&this.getStacks();this.getMargins(!0);this.setChartSize();c=this.plotWidth;e=this.plotHeight-=21;n(a,function(a){a.setScale()});this.getAxisMargins();g=1.1<c/this.plotWidth;d=
1.05<e/this.plotHeight;if(g||d)n(a,function(a){(a.horiz&&g||!a.horiz&&d)&&a.setTickInterval(!0)}),this.getMargins();this.drawChartBox();this.hasCartesianSeries&&n(a,function(a){a.visible&&a.render()});this.seriesGroup||(this.seriesGroup=b.g("series-group").attr({zIndex:3}).add());this.renderSeries();this.renderLabels();this.addCredits();this.setResponsive&&this.setResponsive();this.hasRendered=!0},addCredits:function(a){var b=this;a=E(!0,this.options.credits,a);a.enabled&&!this.credits&&(this.credits=
this.renderer.text(a.text+(this.mapCredits||""),0,0).addClass("highcharts-credits").on("click",function(){a.href&&(N.location.href=a.href)}).attr({align:a.position.align,zIndex:8}).css(a.style).add().align(a.position),this.credits.update=function(a){b.credits=b.credits.destroy();b.addCredits(a)})},destroy:function(){var b=this,c=b.axes,e=b.series,g=b.container,d,m=g&&g.parentNode;p(b,"destroy");u[b.index]=void 0;a.chartCount--;b.renderTo.removeAttribute("data-highcharts-chart");K(b);for(d=c.length;d--;)c[d]=
c[d].destroy();this.scroller&&this.scroller.destroy&&this.scroller.destroy();for(d=e.length;d--;)e[d]=e[d].destroy();n("title subtitle chartBackground plotBackground plotBGImage plotBorder seriesGroup clipRect credits pointer rangeSelector legend resetZoomButton tooltip renderer".split(" "),function(a){var c=b[a];c&&c.destroy&&(b[a]=c.destroy())});g&&(g.innerHTML="",K(g),m&&k(g));for(d in b)delete b[d]},isReadyToRender:function(){var a=this;return F||N!=N.top||"complete"===r.readyState?!0:(r.attachEvent("onreadystatechange",
function(){r.detachEvent("onreadystatechange",a.firstRender);"complete"===r.readyState&&a.firstRender()}),!1)},firstRender:function(){var a=this,b=a.options;if(a.isReadyToRender()){a.getContainer();p(a,"init");a.resetMargins();a.setChartSize();a.propFromSeries();a.getAxes();n(b.series||[],function(b){a.initSeries(b)});a.linkSeries();p(a,"beforeRender");m&&(a.pointer=new m(a,b));a.render();if(!a.renderer.imgCount&&a.onload)a.onload();a.cloneRenderTo(!0)}},onload:function(){n([this.callback].concat(this.callbacks),
function(a){a&&void 0!==this.index&&a.apply(this,[this])},this);p(this,"load");p(this,"render");c(this.index)&&!1!==this.options.chart.reflow&&this.initReflow();this.onload=null}}})(L);(function(a){var B,A=a.each,H=a.extend,G=a.erase,r=a.fireEvent,f=a.format,l=a.isArray,q=a.isNumber,k=a.pick,u=a.removeEvent;B=a.Point=function(){};B.prototype={init:function(a,c,f){this.series=a;this.color=a.color;this.applyOptions(c,f);a.options.colorByPoint?(c=a.options.colors||a.chart.options.colors,this.color=this.color||
c[a.colorCounter],c=c.length,f=a.colorCounter,a.colorCounter++,a.colorCounter===c&&(a.colorCounter=0)):f=a.colorIndex;this.colorIndex=k(this.colorIndex,f);a.chart.pointCount++;return this},applyOptions:function(a,c){var d=this.series,f=d.options.pointValKey||d.pointValKey;a=B.prototype.optionsToObject.call(this,a);H(this,a);this.options=this.options?H(this.options,a):a;a.group&&delete this.group;f&&(this.y=this[f]);this.isNull=k(this.isValid&&!this.isValid(),null===this.x||!q(this.y,!0));this.selected&&
(this.state="select");"name"in this&&void 0===c&&d.xAxis&&d.xAxis.hasNames&&(this.x=d.xAxis.nameToX(this));void 0===this.x&&d&&(this.x=void 0===c?d.autoIncrement(this):c);return this},optionsToObject:function(a){var c={},d=this.series,f=d.options.keys,b=f||d.pointArrayMap||["y"],p=b.length,h=0,k=0;if(q(a)||null===a)c[b[0]]=a;else if(l(a))for(!f&&a.length>p&&(d=typeof a[0],"string"===d?c.name=a[0]:"number"===d&&(c.x=a[0]),h++);k<p;)f&&void 0===a[h]||(c[b[k]]=a[h]),h++,k++;else"object"===typeof a&&
(c=a,a.dataLabels&&(d._hasPointLabels=!0),a.marker&&(d._hasPointMarkers=!0));return c},getClassName:function(){return"highcharts-point"+(this.selected?" highcharts-point-select":"")+(this.negative?" highcharts-negative":"")+(this.isNull?" highcharts-null-point":"")+(void 0!==this.colorIndex?" highcharts-color-"+this.colorIndex:"")+(this.options.className?" "+this.options.className:"")+(this.zone&&this.zone.className?" "+this.zone.className.replace("highcharts-negative",""):"")},getZone:function(){var a=
this.series,c=a.zones,a=a.zoneAxis||"y",f=0,k;for(k=c[f];this[a]>=k.value;)k=c[++f];k&&k.color&&!this.options.color&&(this.color=k.color);return k},destroy:function(){var a=this.series.chart,c=a.hoverPoints,f;a.pointCount--;c&&(this.setState(),G(c,this),c.length||(a.hoverPoints=null));if(this===a.hoverPoint)this.onMouseOut();if(this.graphic||this.dataLabel)u(this),this.destroyElements();this.legendItem&&a.legend.destroyItem(this);for(f in this)this[f]=null},destroyElements:function(){for(var a=["graphic",
"dataLabel","dataLabelUpper","connector","shadowGroup"],c,f=6;f--;)c=a[f],this[c]&&(this[c]=this[c].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,color:this.color,colorIndex:this.colorIndex,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},tooltipFormatter:function(a){var c=this.series,d=c.tooltipOptions,l=k(d.valueDecimals,""),b=d.valuePrefix||"",p=d.valueSuffix||"";A(c.pointArrayMap||["y"],function(c){c=
"{point."+c;if(b||p)a=a.replace(c+"}",b+c+"}"+p);a=a.replace(c+"}",c+":,."+l+"f}")});return f(a,{point:this,series:this.series})},firePointEvent:function(a,c,f){var d=this,b=this.series.options;(b.point.events[a]||d.options&&d.options.events&&d.options.events[a])&&this.importEvents();"click"===a&&b.allowPointSelect&&(f=function(a){d.select&&d.select(null,a.ctrlKey||a.metaKey||a.shiftKey)});r(this,a,c,f)},visible:!0}})(L);(function(a){var B=a.addEvent,A=a.animObject,H=a.arrayMax,G=a.arrayMin,r=a.correctFloat,
f=a.Date,l=a.defaultOptions,q=a.defaultPlotOptions,k=a.defined,u=a.each,d=a.erase,c=a.extend,n=a.fireEvent,z=a.grep,b=a.isArray,p=a.isNumber,h=a.isString,t=a.merge,D=a.pick,w=a.removeEvent,e=a.splat,x=a.SVGElement,C=a.syncTimeout,E=a.win;a.Series=a.seriesType("line",null,{lineWidth:2,allowPointSelect:!1,showCheckbox:!1,animation:{duration:1E3},events:{},marker:{lineWidth:0,lineColor:"#ffffff",radius:4,states:{hover:{animation:{duration:50},enabled:!0,radiusPlus:2,lineWidthPlus:1},select:{fillColor:"#cccccc",
lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:{align:"center",formatter:function(){return null===this.y?"":a.numberFormat(this.y,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"contrast",textOutline:"1px contrast"},verticalAlign:"bottom",x:0,y:0,padding:5},cropThreshold:300,pointRange:0,softThreshold:!0,states:{hover:{animation:{duration:50},lineWidthPlus:1,marker:{},halo:{size:10,opacity:.25}},select:{marker:{}}},stickyTracking:!0,turboThreshold:1E3,findNearestPointBy:"x"},
{isCartesian:!0,pointClass:a.Point,sorted:!0,requireSorting:!0,directTouch:!1,axisTypes:["xAxis","yAxis"],colorCounter:0,parallelArrays:["x","y"],coll:"series",init:function(a,b){var e=this,d,m,g=a.series,h;e.chart=a;e.options=b=e.setOptions(b);e.linkedSeries=[];e.bindAxes();c(e,{name:b.name,state:"",visible:!1!==b.visible,selected:!0===b.selected});m=b.events;for(d in m)B(e,d,m[d]);if(m&&m.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)a.runTrackerClick=!0;e.getColor();
e.getSymbol();u(e.parallelArrays,function(a){e[a+"Data"]=[]});e.setData(b.data,!1);e.isCartesian&&(a.hasCartesianSeries=!0);g.length&&(h=g[g.length-1]);e._i=D(h&&h._i,-1)+1;a.orderSeries(this.insert(g))},insert:function(a){var b=this.options.index,c;if(p(b)){for(c=a.length;c--;)if(b>=D(a[c].options.index,a[c]._i)){a.splice(c+1,0,this);break}-1===c&&a.unshift(this);c+=1}else a.push(this);return D(c,a.length-1)},bindAxes:function(){var b=this,c=b.options,e=b.chart,d;u(b.axisTypes||[],function(m){u(e[m],
function(a){d=a.options;if(c[m]===d.index||void 0!==c[m]&&c[m]===d.id||void 0===c[m]&&0===d.index)b.insert(a.series),b[m]=a,a.isDirty=!0});b[m]||b.optionalAxis===m||a.error(18,!0)})},updateParallelArrays:function(a,b){var c=a.series,e=arguments,d=p(b)?function(e){var g="y"===e&&c.toYData?c.toYData(a):a[e];c[e+"Data"][b]=g}:function(a){Array.prototype[b].apply(c[a+"Data"],Array.prototype.slice.call(e,2))};u(c.parallelArrays,d)},autoIncrement:function(){var a=this.options,b=this.xIncrement,c,e=a.pointIntervalUnit,
b=D(b,a.pointStart,0);this.pointInterval=c=D(this.pointInterval,a.pointInterval,1);e&&(a=new f(b),"day"===e?a=+a[f.hcSetDate](a[f.hcGetDate]()+c):"month"===e?a=+a[f.hcSetMonth](a[f.hcGetMonth]()+c):"year"===e&&(a=+a[f.hcSetFullYear](a[f.hcGetFullYear]()+c)),c=a-b);this.xIncrement=b+c;return b},setOptions:function(a){var b=this.chart,c=b.options.plotOptions,b=b.userOptions||{},e=b.plotOptions||{},d=c[this.type];this.userOptions=a;c=t(d,c.series,a);this.tooltipOptions=t(l.tooltip,l.plotOptions[this.type].tooltip,
b.tooltip,e.series&&e.series.tooltip,e[this.type]&&e[this.type].tooltip,a.tooltip);this.stickyTracking=D(a.stickyTracking,e[this.type]&&e[this.type].stickyTracking,e.series&&e.series.stickyTracking,this.tooltipOptions.shared&&!this.noSharedTooltip?!0:c.stickyTracking);null===d.marker&&delete c.marker;this.zoneAxis=c.zoneAxis;a=this.zones=(c.zones||[]).slice();!c.negativeColor&&!c.negativeFillColor||c.zones||a.push({value:c[this.zoneAxis+"Threshold"]||c.threshold||0,className:"highcharts-negative",
color:c.negativeColor,fillColor:c.negativeFillColor});a.length&&k(a[a.length-1].value)&&a.push({color:this.color,fillColor:this.fillColor});return c},getCyclic:function(a,b,c){var e,d=this.chart,g=this.userOptions,m=a+"Index",h=a+"Counter",f=c?c.length:D(d.options.chart[a+"Count"],d[a+"Count"]);b||(e=D(g[m],g["_"+m]),k(e)||(d.series.length||(d[h]=0),g["_"+m]=e=d[h]%f,d[h]+=1),c&&(b=c[e]));void 0!==e&&(this[m]=e);this[a]=b},getColor:function(){this.options.colorByPoint?this.options.color=null:this.getCyclic("color",
this.options.color||q[this.type].color,this.chart.options.colors)},getSymbol:function(){this.getCyclic("symbol",this.options.marker.symbol,this.chart.options.symbols)},drawLegendSymbol:a.LegendSymbolMixin.drawLineMarker,setData:function(c,e,d,f){var m=this,g=m.points,k=g&&g.length||0,n,l=m.options,y=m.chart,t=null,q=m.xAxis,x=l.turboThreshold,r=this.xData,w=this.yData,C=(n=m.pointArrayMap)&&n.length;c=c||[];n=c.length;e=D(e,!0);if(!1!==f&&n&&k===n&&!m.cropped&&!m.hasGroupedData&&m.visible)u(c,function(a,
b){g[b].update&&a!==l.data[b]&&g[b].update(a,!1,null,!1)});else{m.xIncrement=null;m.colorCounter=0;u(this.parallelArrays,function(a){m[a+"Data"].length=0});if(x&&n>x){for(d=0;null===t&&d<n;)t=c[d],d++;if(p(t))for(d=0;d<n;d++)r[d]=this.autoIncrement(),w[d]=c[d];else if(b(t))if(C)for(d=0;d<n;d++)t=c[d],r[d]=t[0],w[d]=t.slice(1,C+1);else for(d=0;d<n;d++)t=c[d],r[d]=t[0],w[d]=t[1];else a.error(12)}else for(d=0;d<n;d++)void 0!==c[d]&&(t={series:m},m.pointClass.prototype.applyOptions.apply(t,[c[d]]),m.updateParallelArrays(t,
d));h(w[0])&&a.error(14,!0);m.data=[];m.options.data=m.userOptions.data=c;for(d=k;d--;)g[d]&&g[d].destroy&&g[d].destroy();q&&(q.minRange=q.userMinRange);m.isDirty=y.isDirtyBox=!0;m.isDirtyData=!!g;d=!1}"point"===l.legendType&&(this.processData(),this.generatePoints());e&&y.redraw(d)},processData:function(b){var c=this.xData,e=this.yData,d=c.length,m;m=0;var g,h,f=this.xAxis,p,k=this.options;p=k.cropThreshold;var n=this.getExtremesFromAll||k.getExtremesFromAll,l=this.isCartesian,k=f&&f.val2lin,t=f&&
f.isLog,q,x;if(l&&!this.isDirty&&!f.isDirty&&!this.yAxis.isDirty&&!b)return!1;f&&(b=f.getExtremes(),q=b.min,x=b.max);if(l&&this.sorted&&!n&&(!p||d>p||this.forceCrop))if(c[d-1]<q||c[0]>x)c=[],e=[];else if(c[0]<q||c[d-1]>x)m=this.cropData(this.xData,this.yData,q,x),c=m.xData,e=m.yData,m=m.start,g=!0;for(p=c.length||1;--p;)d=t?k(c[p])-k(c[p-1]):c[p]-c[p-1],0<d&&(void 0===h||d<h)?h=d:0>d&&this.requireSorting&&a.error(15);this.cropped=g;this.cropStart=m;this.processedXData=c;this.processedYData=e;this.closestPointRange=
h},cropData:function(a,b,c,e){var d=a.length,g=0,m=d,h=D(this.cropShoulder,1),f;for(f=0;f<d;f++)if(a[f]>=c){g=Math.max(0,f-h);break}for(c=f;c<d;c++)if(a[c]>e){m=c+h;break}return{xData:a.slice(g,m),yData:b.slice(g,m),start:g,end:m}},generatePoints:function(){var a=this.options.data,b=this.data,c,d=this.processedXData,h=this.processedYData,g=this.pointClass,f=d.length,p=this.cropStart||0,k,n=this.hasGroupedData,l,t=[],q;b||n||(b=[],b.length=a.length,b=this.data=b);for(q=0;q<f;q++)k=p+q,n?(l=(new g).init(this,
[d[q]].concat(e(h[q]))),l.dataGroup=this.groupMap[q]):(l=b[k])||void 0===a[k]||(b[k]=l=(new g).init(this,a[k],d[q])),l&&(l.index=k,t[q]=l);if(b&&(f!==(c=b.length)||n))for(q=0;q<c;q++)q!==p||n||(q+=f),b[q]&&(b[q].destroyElements(),b[q].plotX=void 0);this.data=b;this.points=t},getExtremes:function(a){var c=this.yAxis,e=this.processedXData,d,m=[],g=0;d=this.xAxis.getExtremes();var h=d.min,f=d.max,k,n,l,t;a=a||this.stackedYData||this.processedYData||[];d=a.length;for(t=0;t<d;t++)if(n=e[t],l=a[t],k=(p(l,
!0)||b(l))&&(!c.positiveValuesOnly||l.length||0<l),n=this.getExtremesFromAll||this.options.getExtremesFromAll||this.cropped||(e[t]||n)>=h&&(e[t]||n)<=f,k&&n)if(k=l.length)for(;k--;)null!==l[k]&&(m[g++]=l[k]);else m[g++]=l;this.dataMin=G(m);this.dataMax=H(m)},translate:function(){this.processedXData||this.processData();this.generatePoints();var a=this.options,b=a.stacking,c=this.xAxis,e=c.categories,d=this.yAxis,g=this.points,h=g.length,f=!!this.modifyValue,n=a.pointPlacement,l="between"===n||p(n),
t=a.threshold,q=a.startFromThreshold?t:0,x,u,w,C,E=Number.MAX_VALUE;"between"===n&&(n=.5);p(n)&&(n*=D(a.pointRange||c.pointRange));for(a=0;a<h;a++){var z=g[a],A=z.x,B=z.y;u=z.low;var H=b&&d.stacks[(this.negStacks&&B<(q?0:t)?"-":"")+this.stackKey],G;d.positiveValuesOnly&&null!==B&&0>=B&&(z.isNull=!0);z.plotX=x=r(Math.min(Math.max(-1E5,c.translate(A,0,0,0,1,n,"flags"===this.type)),1E5));b&&this.visible&&!z.isNull&&H&&H[A]&&(C=this.getStackIndicator(C,A,this.index),G=H[A],B=G.points[C.key],u=B[0],B=
B[1],u===q&&C.key===H[A].base&&(u=D(t,d.min)),d.positiveValuesOnly&&0>=u&&(u=null),z.total=z.stackTotal=G.total,z.percentage=G.total&&z.y/G.total*100,z.stackY=B,G.setOffset(this.pointXOffset||0,this.barW||0));z.yBottom=k(u)?d.translate(u,0,1,0,1):null;f&&(B=this.modifyValue(B,z));z.plotY=u="number"===typeof B&&Infinity!==B?Math.min(Math.max(-1E5,d.translate(B,0,1,0,1)),1E5):void 0;z.isInside=void 0!==u&&0<=u&&u<=d.len&&0<=x&&x<=c.len;z.clientX=l?r(c.translate(A,0,0,0,1,n)):x;z.negative=z.y<(t||0);
z.category=e&&void 0!==e[z.x]?e[z.x]:z.x;z.isNull||(void 0!==w&&(E=Math.min(E,Math.abs(x-w))),w=x);z.zone=this.zones.length&&z.getZone()}this.closestPointRangePx=E},getValidPoints:function(a,b){var c=this.chart;return z(a||this.points||[],function(a){return b&&!c.isInsidePlot(a.plotX,a.plotY,c.inverted)?!1:!a.isNull})},setClip:function(a){var b=this.chart,c=this.options,e=b.renderer,d=b.inverted,g=this.clipBox,h=g||b.clipBox,m=this.sharedClipKey||["_sharedClip",a&&a.duration,a&&a.easing,h.height,
c.xAxis,c.yAxis].join(),f=b[m],p=b[m+"m"];f||(a&&(h.width=0,b[m+"m"]=p=e.clipRect(-99,d?-b.plotLeft:-b.plotTop,99,d?b.chartWidth:b.chartHeight)),b[m]=f=e.clipRect(h),f.count={length:0});a&&!f.count[this.index]&&(f.count[this.index]=!0,f.count.length+=1);!1!==c.clip&&(this.group.clip(a||g?f:b.clipRect),this.markerGroup.clip(p),this.sharedClipKey=m);a||(f.count[this.index]&&(delete f.count[this.index],--f.count.length),0===f.count.length&&m&&b[m]&&(g||(b[m]=b[m].destroy()),b[m+"m"]&&(b[m+"m"]=b[m+"m"].destroy())))},
animate:function(a){var b=this.chart,c=A(this.options.animation),e;a?this.setClip(c):(e=this.sharedClipKey,(a=b[e])&&a.animate({width:b.plotSizeX},c),b[e+"m"]&&b[e+"m"].animate({width:b.plotSizeX+99},c),this.animate=null)},afterAnimate:function(){this.setClip();n(this,"afterAnimate")},drawPoints:function(){var a=this.points,b=this.chart,c,e,d,g,h=this.options.marker,f,n,k,l,t=this.markerGroup,q=D(h.enabled,this.xAxis.isRadial?!0:null,this.closestPointRangePx>=2*h.radius);if(!1!==h.enabled||this._hasPointMarkers)for(e=
0;e<a.length;e++)d=a[e],c=d.plotY,g=d.graphic,f=d.marker||{},n=!!d.marker,k=q&&void 0===f.enabled||f.enabled,l=d.isInside,k&&p(c)&&null!==d.y?(c=D(f.symbol,this.symbol),d.hasImage=0===c.indexOf("url"),k=this.markerAttribs(d,d.selected&&"select"),g?g[l?"show":"hide"](!0).animate(k):l&&(0<k.width||d.hasImage)&&(d.graphic=g=b.renderer.symbol(c,k.x,k.y,k.width,k.height,n?f:h).add(t)),g&&g.attr(this.pointAttribs(d,d.selected&&"select")),g&&g.addClass(d.getClassName(),!0)):g&&(d.graphic=g.destroy())},markerAttribs:function(a,
b){var c=this.options.marker,e=a.marker||{},d=D(e.radius,c.radius);b&&(c=c.states[b],b=e.states&&e.states[b],d=D(b&&b.radius,c&&c.radius,d+(c&&c.radiusPlus||0)));a.hasImage&&(d=0);a={x:Math.floor(a.plotX)-d,y:a.plotY-d};d&&(a.width=a.height=2*d);return a},pointAttribs:function(a,b){var c=this.options.marker,e=a&&a.options,d=e&&e.marker||{},g=this.color,h=e&&e.color,f=a&&a.color,e=D(d.lineWidth,c.lineWidth);a=a&&a.zone&&a.zone.color;g=h||a||f||g;a=d.fillColor||c.fillColor||g;g=d.lineColor||c.lineColor||
g;b&&(c=c.states[b],b=d.states&&d.states[b]||{},e=D(b.lineWidth,c.lineWidth,e+D(b.lineWidthPlus,c.lineWidthPlus,0)),a=b.fillColor||c.fillColor||a,g=b.lineColor||c.lineColor||g);return{stroke:g,"stroke-width":e,fill:a}},destroy:function(){var a=this,b=a.chart,c=/AppleWebKit\/533/.test(E.navigator.userAgent),e,h=a.data||[],g,f,k;n(a,"destroy");w(a);u(a.axisTypes||[],function(b){(k=a[b])&&k.series&&(d(k.series,a),k.isDirty=k.forceRedraw=!0)});a.legendItem&&a.chart.legend.destroyItem(a);for(e=h.length;e--;)(g=
h[e])&&g.destroy&&g.destroy();a.points=null;clearTimeout(a.animationTimeout);for(f in a)a[f]instanceof x&&!a[f].survive&&(e=c&&"group"===f?"hide":"destroy",a[f][e]());b.hoverSeries===a&&(b.hoverSeries=null);d(b.series,a);b.orderSeries();for(f in a)delete a[f]},getGraphPath:function(a,b,c){var e=this,d=e.options,g=d.step,h,f=[],m=[],p;a=a||e.points;(h=a.reversed)&&a.reverse();(g={right:1,center:2}[g]||g&&3)&&h&&(g=4-g);!d.connectNulls||b||c||(a=this.getValidPoints(a));u(a,function(h,n){var l=h.plotX,
t=h.plotY,q=a[n-1];(h.leftCliff||q&&q.rightCliff)&&!c&&(p=!0);h.isNull&&!k(b)&&0<n?p=!d.connectNulls:h.isNull&&!b?p=!0:(0===n||p?n=["M",h.plotX,h.plotY]:e.getPointSpline?n=e.getPointSpline(a,h,n):g?(n=1===g?["L",q.plotX,t]:2===g?["L",(q.plotX+l)/2,q.plotY,"L",(q.plotX+l)/2,t]:["L",l,q.plotY],n.push("L",l,t)):n=["L",l,t],m.push(h.x),g&&m.push(h.x),f.push.apply(f,n),p=!1)});f.xMap=m;return e.graphPath=f},drawGraph:function(){var a=this,b=this.options,c=(this.gappedPath||this.getGraphPath).call(this),
e=[["graph","highcharts-graph",b.lineColor||this.color,b.dashStyle]];u(this.zones,function(c,d){e.push(["zone-graph-"+d,"highcharts-graph highcharts-zone-graph-"+d+" "+(c.className||""),c.color||a.color,c.dashStyle||b.dashStyle])});u(e,function(e,d){var g=e[0],h=a[g];h?(h.endX=c.xMap,h.animate({d:c})):c.length&&(a[g]=a.chart.renderer.path(c).addClass(e[1]).attr({zIndex:1}).add(a.group),h={stroke:e[2],"stroke-width":b.lineWidth,fill:a.fillGraph&&a.color||"none"},e[3]?h.dashstyle=e[3]:"square"!==b.linecap&&
(h["stroke-linecap"]=h["stroke-linejoin"]="round"),h=a[g].attr(h).shadow(2>d&&b.shadow));h&&(h.startX=c.xMap,h.isArea=c.isArea)})},applyZones:function(){var a=this,b=this.chart,c=b.renderer,e=this.zones,d,g,h=this.clips||[],f,k=this.graph,p=this.area,n=Math.max(b.chartWidth,b.chartHeight),l=this[(this.zoneAxis||"y")+"Axis"],t,q,x=b.inverted,w,r,C,E,z=!1;e.length&&(k||p)&&l&&void 0!==l.min&&(q=l.reversed,w=l.horiz,k&&k.hide(),p&&p.hide(),t=l.getExtremes(),u(e,function(e,m){d=q?w?b.plotWidth:0:w?0:
l.toPixels(t.min);d=Math.min(Math.max(D(g,d),0),n);g=Math.min(Math.max(Math.round(l.toPixels(D(e.value,t.max),!0)),0),n);z&&(d=g=l.toPixels(t.max));r=Math.abs(d-g);C=Math.min(d,g);E=Math.max(d,g);l.isXAxis?(f={x:x?E:C,y:0,width:r,height:n},w||(f.x=b.plotHeight-f.x)):(f={x:0,y:x?E:C,width:n,height:r},w&&(f.y=b.plotWidth-f.y));x&&c.isVML&&(f=l.isXAxis?{x:0,y:q?C:E,height:f.width,width:b.chartWidth}:{x:f.y-b.plotLeft-b.spacingBox.x,y:0,width:f.height,height:b.chartHeight});h[m]?h[m].animate(f):(h[m]=
c.clipRect(f),k&&a["zone-graph-"+m].clip(h[m]),p&&a["zone-area-"+m].clip(h[m]));z=e.value>t.max}),this.clips=h)},invertGroups:function(a){function b(){u(["group","markerGroup"],function(b){c[b]&&(e.renderer.isVML&&c[b].attr({width:c.yAxis.len,height:c.xAxis.len}),c[b].width=c.yAxis.len,c[b].height=c.xAxis.len,c[b].invert(a))})}var c=this,e=c.chart,d;c.xAxis&&(d=B(e,"resize",b),B(c,"destroy",d),b(a),c.invertGroups=b)},plotGroup:function(a,b,c,e,d){var g=this[a],h=!g;h&&(this[a]=g=this.chart.renderer.g(b).attr({zIndex:e||
.1}).add(d),g.addClass("highcharts-series-"+this.index+" highcharts-"+this.type+"-series highcharts-color-"+this.colorIndex+" "+(this.options.className||"")));g.attr({visibility:c})[h?"attr":"animate"](this.getPlotBox());return g},getPlotBox:function(){var a=this.chart,b=this.xAxis,c=this.yAxis;a.inverted&&(b=c,c=this.xAxis);return{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var a=this,b=a.chart,c,e=a.options,d=!!a.animate&&b.renderer.isSVG&&A(e.animation).duration,
g=a.visible?"inherit":"hidden",h=e.zIndex,f=a.hasRendered,k=b.seriesGroup,p=b.inverted;c=a.plotGroup("group","series",g,h,k);a.markerGroup=a.plotGroup("markerGroup","markers",g,h,k);d&&a.animate(!0);c.inverted=a.isCartesian?p:!1;a.drawGraph&&(a.drawGraph(),a.applyZones());a.drawDataLabels&&a.drawDataLabels();a.visible&&a.drawPoints();a.drawTracker&&!1!==a.options.enableMouseTracking&&a.drawTracker();a.invertGroups(p);!1===e.clip||a.sharedClipKey||f||c.clip(b.clipRect);d&&a.animate();f||(a.animationTimeout=
C(function(){a.afterAnimate()},d));a.isDirty=!1;a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirty||this.isDirtyData,c=this.group,e=this.xAxis,d=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:D(e&&e.left,a.plotLeft),translateY:D(d&&d.top,a.plotTop)}));this.translate();this.render();b&&delete this.kdTree},kdAxisArray:["clientX","plotY"],searchPoint:function(a,b){var c=this.xAxis,e=this.yAxis,d=this.chart.inverted;return this.searchKDTree({clientX:d?
c.len-a.chartY+c.pos:a.chartX-c.pos,plotY:d?e.len-a.chartX+e.pos:a.chartY-e.pos},b)},buildKDTree:function(){function a(c,e,d){var g,h;if(h=c&&c.length)return g=b.kdAxisArray[e%d],c.sort(function(a,b){return a[g]-b[g]}),h=Math.floor(h/2),{point:c[h],left:a(c.slice(0,h),e+1,d),right:a(c.slice(h+1),e+1,d)}}this.buildingKdTree=!0;var b=this,c=-1<b.options.findNearestPointBy.indexOf("y")?2:1;delete b.kdTree;C(function(){b.kdTree=a(b.getValidPoints(null,!b.directTouch),c,c);b.buildingKdTree=!1},b.options.kdNow?
0:1)},searchKDTree:function(a,b){function c(a,b,f,m){var p=b.point,n=e.kdAxisArray[f%m],l,t,q=p;t=k(a[d])&&k(p[d])?Math.pow(a[d]-p[d],2):null;l=k(a[g])&&k(p[g])?Math.pow(a[g]-p[g],2):null;l=(t||0)+(l||0);p.dist=k(l)?Math.sqrt(l):Number.MAX_VALUE;p.distX=k(t)?Math.sqrt(t):Number.MAX_VALUE;n=a[n]-p[n];l=0>n?"left":"right";t=0>n?"right":"left";b[l]&&(l=c(a,b[l],f+1,m),q=l[h]<q[h]?l:p);b[t]&&Math.sqrt(n*n)<q[h]&&(a=c(a,b[t],f+1,m),q=a[h]<q[h]?a:q);return q}var e=this,d=this.kdAxisArray[0],g=this.kdAxisArray[1],
h=b?"distX":"dist";b=-1<e.options.findNearestPointBy.indexOf("y")?2:1;this.kdTree||this.buildingKdTree||this.buildKDTree();if(this.kdTree)return c(a,this.kdTree,b,b)}})})(L);(function(a){function B(a,d,c,f,l){var b=a.chart.inverted;this.axis=a;this.isNegative=c;this.options=d;this.x=f;this.total=null;this.points={};this.stack=l;this.rightCliff=this.leftCliff=0;this.alignOptions={align:d.align||(b?c?"left":"right":"center"),verticalAlign:d.verticalAlign||(b?"middle":c?"bottom":"top"),y:k(d.y,b?4:c?
14:-6),x:k(d.x,b?c?-6:6:0)};this.textAlign=d.textAlign||(b?c?"right":"left":"center")}var A=a.Axis,H=a.Chart,G=a.correctFloat,r=a.defined,f=a.destroyObjectProperties,l=a.each,q=a.format,k=a.pick;a=a.Series;B.prototype={destroy:function(){f(this,this.axis)},render:function(a){var d=this.options,c=d.format,c=c?q(c,this):d.formatter.call(this);this.label?this.label.attr({text:c,visibility:"hidden"}):this.label=this.axis.chart.renderer.text(c,null,null,d.useHTML).css(d.style).attr({align:this.textAlign,
rotation:d.rotation,visibility:"hidden"}).add(a)},setOffset:function(a,d){var c=this.axis,f=c.chart,k=f.inverted,b=c.reversed,b=this.isNegative&&!b||!this.isNegative&&b,p=c.translate(c.usePercentage?100:this.total,0,0,0,1),c=c.translate(0),c=Math.abs(p-c);a=f.xAxis[0].translate(this.x)+a;var h=f.plotHeight,k={x:k?b?p:p-c:a,y:k?h-a-d:b?h-p-c:h-p,width:k?c:d,height:k?d:c};if(d=this.label)d.align(this.alignOptions,null,k),k=d.alignAttr,d[!1===this.options.crop||f.isInsidePlot(k.x,k.y)?"show":"hide"](!0)}};
H.prototype.getStacks=function(){var a=this;l(a.yAxis,function(a){a.stacks&&a.hasVisibleSeries&&(a.oldStacks=a.stacks)});l(a.series,function(d){!d.options.stacking||!0!==d.visible&&!1!==a.options.chart.ignoreHiddenSeries||(d.stackKey=d.type+k(d.options.stack,""))})};A.prototype.buildStacks=function(){var a=this.series,d,c=k(this.options.reversedStacks,!0),f=a.length,l;if(!this.isXAxis){this.usePercentage=!1;for(l=f;l--;)a[c?l:f-l-1].setStackedPoints();for(l=f;l--;)d=a[c?l:f-l-1],d.setStackCliffs&&
d.setStackCliffs();if(this.usePercentage)for(l=0;l<f;l++)a[l].setPercentStacks()}};A.prototype.renderStackTotals=function(){var a=this.chart,d=a.renderer,c=this.stacks,f,k,b=this.stackTotalGroup;b||(this.stackTotalGroup=b=d.g("stack-labels").attr({visibility:"visible",zIndex:6}).add());b.translate(a.plotLeft,a.plotTop);for(f in c)for(k in a=c[f],a)a[k].render(b)};A.prototype.resetStacks=function(){var a=this.stacks,d,c;if(!this.isXAxis)for(d in a)for(c in a[d])a[d][c].touched<this.stacksTouched?(a[d][c].destroy(),
delete a[d][c]):(a[d][c].total=null,a[d][c].cum=null)};A.prototype.cleanStacks=function(){var a,d,c;if(!this.isXAxis)for(d in this.oldStacks&&(a=this.stacks=this.oldStacks),a)for(c in a[d])a[d][c].cum=a[d][c].total};a.prototype.setStackedPoints=function(){if(this.options.stacking&&(!0===this.visible||!1===this.chart.options.chart.ignoreHiddenSeries)){var a=this.processedXData,d=this.processedYData,c=[],f=d.length,l=this.options,b=l.threshold,p=l.startFromThreshold?b:0,h=l.stack,l=l.stacking,t=this.stackKey,
q="-"+t,w=this.negStacks,e=this.yAxis,x=e.stacks,C=e.oldStacks,E,m,y,A,K,J,g;e.stacksTouched+=1;for(K=0;K<f;K++)J=a[K],g=d[K],E=this.getStackIndicator(E,J,this.index),A=E.key,y=(m=w&&g<(p?0:b))?q:t,x[y]||(x[y]={}),x[y][J]||(C[y]&&C[y][J]?(x[y][J]=C[y][J],x[y][J].total=null):x[y][J]=new B(e,e.options.stackLabels,m,J,h)),y=x[y][J],null!==g&&(y.points[A]=y.points[this.index]=[k(y.cum,p)],r(y.cum)||(y.base=A),y.touched=e.stacksTouched,0<E.index&&!1===this.singleStacks&&(y.points[A][0]=y.points[this.index+
","+J+",0"][0])),"percent"===l?(m=m?t:q,w&&x[m]&&x[m][J]?(m=x[m][J],y.total=m.total=Math.max(m.total,y.total)+Math.abs(g)||0):y.total=G(y.total+(Math.abs(g)||0))):y.total=G(y.total+(g||0)),y.cum=k(y.cum,p)+(g||0),null!==g&&(y.points[A].push(y.cum),c[K]=y.cum);"percent"===l&&(e.usePercentage=!0);this.stackedYData=c;e.oldStacks={}}};a.prototype.setPercentStacks=function(){var a=this,d=a.stackKey,c=a.yAxis.stacks,f=a.processedXData,k;l([d,"-"+d],function(b){for(var d=f.length,h,n;d--;)if(h=f[d],k=a.getStackIndicator(k,
h,a.index,b),h=(n=c[b]&&c[b][h])&&n.points[k.key])n=n.total?100/n.total:0,h[0]=G(h[0]*n),h[1]=G(h[1]*n),a.stackedYData[d]=h[1]})};a.prototype.getStackIndicator=function(a,d,c,f){!r(a)||a.x!==d||f&&a.key!==f?a={x:d,index:0,key:f}:a.index++;a.key=[c,d,a.index].join();return a}})(L);(function(a){var B=a.addEvent,A=a.animate,H=a.Axis,G=a.createElement,r=a.css,f=a.defined,l=a.each,q=a.erase,k=a.extend,u=a.fireEvent,d=a.inArray,c=a.isNumber,n=a.isObject,z=a.merge,b=a.pick,p=a.Point,h=a.Series,t=a.seriesTypes,
D=a.setAnimation,w=a.splat;k(a.Chart.prototype,{addSeries:function(a,c,d){var e,h=this;a&&(c=b(c,!0),u(h,"addSeries",{options:a},function(){e=h.initSeries(a);h.isDirtyLegend=!0;h.linkSeries();c&&h.redraw(d)}));return e},addAxis:function(a,c,d,h){var e=c?"xAxis":"yAxis",f=this.options;a=z(a,{index:this[e].length,isX:c});new H(this,a);f[e]=w(f[e]||{});f[e].push(a);b(d,!0)&&this.redraw(h)},showLoading:function(a){var b=this,c=b.options,e=b.loadingDiv,d=c.loading,h=function(){e&&r(e,{left:b.plotLeft+
"px",top:b.plotTop+"px",width:b.plotWidth+"px",height:b.plotHeight+"px"})};e||(b.loadingDiv=e=G("div",{className:"highcharts-loading highcharts-loading-hidden"},null,b.container),b.loadingSpan=G("span",{className:"highcharts-loading-inner"},null,e),B(b,"redraw",h));e.className="highcharts-loading";b.loadingSpan.innerHTML=a||c.lang.loading;r(e,k(d.style,{zIndex:10}));r(b.loadingSpan,d.labelStyle);b.loadingShown||(r(e,{opacity:0,display:""}),A(e,{opacity:d.style.opacity||.5},{duration:d.showDuration||
0}));b.loadingShown=!0;h()},hideLoading:function(){var a=this.options,b=this.loadingDiv;b&&(b.className="highcharts-loading highcharts-loading-hidden",A(b,{opacity:0},{duration:a.loading.hideDuration||100,complete:function(){r(b,{display:"none"})}}));this.loadingShown=!1},propsRequireDirtyBox:"backgroundColor borderColor borderWidth margin marginTop marginRight marginBottom marginLeft spacing spacingTop spacingRight spacingBottom spacingLeft borderRadius plotBackgroundColor plotBackgroundImage plotBorderColor plotBorderWidth plotShadow shadow".split(" "),
propsRequireUpdateSeries:"chart.inverted chart.polar chart.ignoreHiddenSeries chart.type colors plotOptions".split(" "),update:function(a,h){var e,k={credits:"addCredits",title:"setTitle",subtitle:"setSubtitle"},m=a.chart,p,n;if(m){z(!0,this.options.chart,m);"className"in m&&this.setClassName(m.className);if("inverted"in m||"polar"in m)this.propFromSeries(),p=!0;"alignTicks"in m&&(p=!0);for(e in m)m.hasOwnProperty(e)&&(-1!==d("chart."+e,this.propsRequireUpdateSeries)&&(n=!0),-1!==d(e,this.propsRequireDirtyBox)&&
(this.isDirtyBox=!0));"style"in m&&this.renderer.setStyle(m.style)}for(e in a){if(this[e]&&"function"===typeof this[e].update)this[e].update(a[e],!1);else if("function"===typeof this[k[e]])this[k[e]](a[e]);"chart"!==e&&-1!==d(e,this.propsRequireUpdateSeries)&&(n=!0)}a.colors&&(this.options.colors=a.colors);a.plotOptions&&z(!0,this.options.plotOptions,a.plotOptions);l(["xAxis","yAxis","series","colorAxis","pane"],function(b){a[b]&&l(w(a[b]),function(a,c){(c=f(a.id)&&this.get(a.id)||this[b][c])&&c.coll===
b&&c.update(a,!1)},this)},this);p&&l(this.axes,function(a){a.update({},!1)});n&&l(this.series,function(a){a.update({},!1)});a.loading&&z(!0,this.options.loading,a.loading);e=m&&m.width;m=m&&m.height;c(e)&&e!==this.chartWidth||c(m)&&m!==this.chartHeight?this.setSize(e,m):b(h,!0)&&this.redraw()},setSubtitle:function(a){this.setTitle(void 0,a)}});k(p.prototype,{update:function(a,c,d,h){function e(){f.applyOptions(a);null===f.y&&p&&(f.graphic=p.destroy());n(a,!0)&&(p&&p.element&&a&&a.marker&&a.marker.symbol&&
(f.graphic=p.destroy()),a&&a.dataLabels&&f.dataLabel&&(f.dataLabel=f.dataLabel.destroy()));l=f.index;k.updateParallelArrays(f,l);t.data[l]=n(t.data[l],!0)||n(a,!0)?f.options:a;k.isDirty=k.isDirtyData=!0;!k.fixedBox&&k.hasCartesianSeries&&(g.isDirtyBox=!0);"point"===t.legendType&&(g.isDirtyLegend=!0);c&&g.redraw(d)}var f=this,k=f.series,p=f.graphic,l,g=k.chart,t=k.options;c=b(c,!0);!1===h?e():f.firePointEvent("update",{options:a},e)},remove:function(a,b){this.series.removePoint(d(this,this.series.data),
a,b)}});k(h.prototype,{addPoint:function(a,c,d,h){var e=this.options,f=this.data,k=this.chart,p=this.xAxis,p=p&&p.hasNames&&p.names,n=e.data,g,l,t=this.xData,q,w;c=b(c,!0);g={series:this};this.pointClass.prototype.applyOptions.apply(g,[a]);w=g.x;q=t.length;if(this.requireSorting&&w<t[q-1])for(l=!0;q&&t[q-1]>w;)q--;this.updateParallelArrays(g,"splice",q,0,0);this.updateParallelArrays(g,q);p&&g.name&&(p[w]=g.name);n.splice(q,0,a);l&&(this.data.splice(q,0,null),this.processData());"point"===e.legendType&&
this.generatePoints();d&&(f[0]&&f[0].remove?f[0].remove(!1):(f.shift(),this.updateParallelArrays(g,"shift"),n.shift()));this.isDirtyData=this.isDirty=!0;c&&k.redraw(h)},removePoint:function(a,c,d){var e=this,h=e.data,f=h[a],k=e.points,p=e.chart,n=function(){k&&k.length===h.length&&k.splice(a,1);h.splice(a,1);e.options.data.splice(a,1);e.updateParallelArrays(f||{series:e},"splice",a,1);f&&f.destroy();e.isDirty=!0;e.isDirtyData=!0;c&&p.redraw()};D(d,p);c=b(c,!0);f?f.firePointEvent("remove",null,n):
n()},remove:function(a,c,d){function e(){h.destroy();f.isDirtyLegend=f.isDirtyBox=!0;f.linkSeries();b(a,!0)&&f.redraw(c)}var h=this,f=h.chart;!1!==d?u(h,"remove",null,e):e()},update:function(a,c){var e=this,d=this.chart,h=this.userOptions,f=this.oldType||this.type,p=a.type||h.type||d.options.chart.type,n=t[f].prototype,q=["group","markerGroup","dataLabelsGroup"],g;if(p&&p!==f||void 0!==a.zIndex)q.length=0;l(q,function(a){q[a]=e[a];delete e[a]});a=z(h,{animation:!1,index:this.index,pointStart:this.xData[0]},
{data:this.options.data},a);this.remove(!1,null,!1);for(g in n)this[g]=void 0;k(this,t[p||f].prototype);l(q,function(a){e[a]=q[a]});this.init(d,a);this.oldType=f;d.linkSeries();b(c,!0)&&d.redraw(!1)}});k(H.prototype,{update:function(a,c){var e=this.chart;a=e.options[this.coll][this.options.index]=z(this.userOptions,a);this.destroy(!0);this.init(e,k(a,{events:void 0}));e.isDirtyBox=!0;b(c,!0)&&e.redraw()},remove:function(a){for(var c=this.chart,e=this.coll,d=this.series,h=d.length;h--;)d[h]&&d[h].remove(!1);
q(c.axes,this);q(c[e],this);c.options[e].splice(this.options.index,1);l(c[e],function(a,b){a.options.index=b});this.destroy();c.isDirtyBox=!0;b(a,!0)&&c.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}})})(L);(function(a){var B=a.color,A=a.each,H=a.map,G=a.pick,r=a.Series,f=a.seriesType;f("area","line",{softThreshold:!1,threshold:0},{singleStacks:!1,getStackPoints:function(){var a=[],f=[],k=this.xAxis,r=this.yAxis,d=r.stacks[this.stackKey],
c={},n=this.points,z=this.index,b=r.series,p=b.length,h,t=G(r.options.reversedStacks,!0)?1:-1,D,w;if(this.options.stacking){for(D=0;D<n.length;D++)c[n[D].x]=n[D];for(w in d)null!==d[w].total&&f.push(w);f.sort(function(a,b){return a-b});h=H(b,function(){return this.visible});A(f,function(b,n){var e=0,l,m;if(c[b]&&!c[b].isNull)a.push(c[b]),A([-1,1],function(a){var e=1===a?"rightNull":"leftNull",k=0,q=d[f[n+a]];if(q)for(D=z;0<=D&&D<p;)l=q.points[D],l||(D===z?c[b][e]=!0:h[D]&&(m=d[b].points[D])&&(k-=
m[1]-m[0])),D+=t;c[b][1===a?"rightCliff":"leftCliff"]=k});else{for(D=z;0<=D&&D<p;){if(l=d[b].points[D]){e=l[1];break}D+=t}e=r.translate(e,0,1,0,1);a.push({isNull:!0,plotX:k.translate(b,0,0,0,1),x:b,plotY:e,yBottom:e})}})}return a},getGraphPath:function(a){var f=r.prototype.getGraphPath,k=this.options,l=k.stacking,d=this.yAxis,c,n,z=[],b=[],p=this.index,h,t=d.stacks[this.stackKey],D=k.threshold,w=d.getThreshold(k.threshold),e,k=k.connectNulls||"percent"===l,x=function(c,e,f){var k=a[c];c=l&&t[k.x].points[p];
var m=k[f+"Null"]||0;f=k[f+"Cliff"]||0;var n,q,k=!0;f||m?(n=(m?c[0]:c[1])+f,q=c[0]+f,k=!!m):!l&&a[e]&&a[e].isNull&&(n=q=D);void 0!==n&&(b.push({plotX:h,plotY:null===n?w:d.getThreshold(n),isNull:k,isCliff:!0}),z.push({plotX:h,plotY:null===q?w:d.getThreshold(q),doCurve:!1}))};a=a||this.points;l&&(a=this.getStackPoints());for(c=0;c<a.length;c++)if(n=a[c].isNull,h=G(a[c].rectPlotX,a[c].plotX),e=G(a[c].yBottom,w),!n||k)k||x(c,c-1,"left"),n&&!l&&k||(b.push(a[c]),z.push({x:c,plotX:h,plotY:e})),k||x(c,c+
1,"right");c=f.call(this,b,!0,!0);z.reversed=!0;n=f.call(this,z,!0,!0);n.length&&(n[0]="L");n=c.concat(n);f=f.call(this,b,!1,k);n.xMap=c.xMap;this.areaPath=n;return f},drawGraph:function(){this.areaPath=[];r.prototype.drawGraph.apply(this);var a=this,f=this.areaPath,k=this.options,u=[["area","highcharts-area",this.color,k.fillColor]];A(this.zones,function(d,c){u.push(["zone-area-"+c,"highcharts-area highcharts-zone-area-"+c+" "+d.className,d.color||a.color,d.fillColor||k.fillColor])});A(u,function(d){var c=
d[0],n=a[c];n?(n.endX=f.xMap,n.animate({d:f})):(n=a[c]=a.chart.renderer.path(f).addClass(d[1]).attr({fill:G(d[3],B(d[2]).setOpacity(G(k.fillOpacity,.75)).get()),zIndex:0}).add(a.group),n.isArea=!0);n.startX=f.xMap;n.shiftUnit=k.step?2:1})},drawLegendSymbol:a.LegendSymbolMixin.drawRectangle})})(L);(function(a){var B=a.pick;a=a.seriesType;a("spline","line",{},{getPointSpline:function(a,H,G){var r=H.plotX,f=H.plotY,l=a[G-1];G=a[G+1];var q,k,u,d;if(l&&!l.isNull&&!1!==l.doCurve&&!H.isCliff&&G&&!G.isNull&&
!1!==G.doCurve&&!H.isCliff){a=l.plotY;u=G.plotX;G=G.plotY;var c=0;q=(1.5*r+l.plotX)/2.5;k=(1.5*f+a)/2.5;u=(1.5*r+u)/2.5;d=(1.5*f+G)/2.5;u!==q&&(c=(d-k)*(u-r)/(u-q)+f-d);k+=c;d+=c;k>a&&k>f?(k=Math.max(a,f),d=2*f-k):k<a&&k<f&&(k=Math.min(a,f),d=2*f-k);d>G&&d>f?(d=Math.max(G,f),k=2*f-d):d<G&&d<f&&(d=Math.min(G,f),k=2*f-d);H.rightContX=u;H.rightContY=d}H=["C",B(l.rightContX,l.plotX),B(l.rightContY,l.plotY),B(q,r),B(k,f),r,f];l.rightContX=l.rightContY=null;return H}})})(L);(function(a){var B=a.seriesTypes.area.prototype,
A=a.seriesType;A("areaspline","spline",a.defaultPlotOptions.area,{getStackPoints:B.getStackPoints,getGraphPath:B.getGraphPath,setStackCliffs:B.setStackCliffs,drawGraph:B.drawGraph,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle})})(L);(function(a){var B=a.animObject,A=a.color,H=a.each,G=a.extend,r=a.isNumber,f=a.merge,l=a.pick,q=a.Series,k=a.seriesType,u=a.svg;k("column","line",{borderRadius:0,crisp:!0,groupPadding:.2,marker:null,pointPadding:.1,minPointLength:0,cropThreshold:50,pointRange:null,
states:{hover:{halo:!1,brightness:.1,shadow:!1},select:{color:"#cccccc",borderColor:"#000000",shadow:!1}},dataLabels:{align:null,verticalAlign:null,y:null},softThreshold:!1,startFromThreshold:!0,stickyTracking:!1,tooltip:{distance:6},threshold:0,borderColor:"#ffffff"},{cropShoulder:0,directTouch:!0,trackerGroups:["group","dataLabelsGroup"],negStacks:!0,init:function(){q.prototype.init.apply(this,arguments);var a=this,c=a.chart;c.hasRendered&&H(c.series,function(c){c.type===a.type&&(c.isDirty=!0)})},
getColumnMetrics:function(){var a=this,c=a.options,f=a.xAxis,k=a.yAxis,b=f.reversed,p,h={},t=0;!1===c.grouping?t=1:H(a.chart.series,function(b){var c=b.options,e=b.yAxis,d;b.type===a.type&&b.visible&&k.len===e.len&&k.pos===e.pos&&(c.stacking?(p=b.stackKey,void 0===h[p]&&(h[p]=t++),d=h[p]):!1!==c.grouping&&(d=t++),b.columnIndex=d)});var q=Math.min(Math.abs(f.transA)*(f.ordinalSlope||c.pointRange||f.closestPointRange||f.tickInterval||1),f.len),w=q*c.groupPadding,e=(q-2*w)/(t||1),c=Math.min(c.maxPointWidth||
f.len,l(c.pointWidth,e*(1-2*c.pointPadding)));a.columnMetrics={width:c,offset:(e-c)/2+(w+((a.columnIndex||0)+(b?1:0))*e-q/2)*(b?-1:1)};return a.columnMetrics},crispCol:function(a,c,f,k){var b=this.chart,d=this.borderWidth,h=-(d%2?.5:0),d=d%2?.5:1;b.inverted&&b.renderer.isVML&&(d+=1);this.options.crisp&&(f=Math.round(a+f)+h,a=Math.round(a)+h,f-=a);k=Math.round(c+k)+d;h=.5>=Math.abs(c)&&.5<k;c=Math.round(c)+d;k-=c;h&&k&&(--c,k+=1);return{x:a,y:c,width:f,height:k}},translate:function(){var a=this,c=
a.chart,f=a.options,k=a.dense=2>a.closestPointRange*a.xAxis.transA,k=a.borderWidth=l(f.borderWidth,k?0:1),b=a.yAxis,p=a.translatedThreshold=b.getThreshold(f.threshold),h=l(f.minPointLength,5),t=a.getColumnMetrics(),r=t.width,w=a.barW=Math.max(r,1+2*k),e=a.pointXOffset=t.offset;c.inverted&&(p-=.5);f.pointPadding&&(w=Math.ceil(w));q.prototype.translate.apply(a);H(a.points,function(d){var f=l(d.yBottom,p),k=999+Math.abs(f),k=Math.min(Math.max(-k,d.plotY),b.len+k),m=d.plotX+e,n=w,t=Math.min(k,f),q,u=
Math.max(k,f)-t;Math.abs(u)<h&&h&&(u=h,q=!b.reversed&&!d.negative||b.reversed&&d.negative,t=Math.abs(t-p)>h?f-h:p-(q?h:0));d.barX=m;d.pointWidth=r;d.tooltipPos=c.inverted?[b.len+b.pos-c.plotLeft-k,a.xAxis.len-m-n/2,u]:[m+n/2,k+b.pos-c.plotTop,u];d.shapeType="rect";d.shapeArgs=a.crispCol.apply(a,d.isNull?[d.plotX,b.len/2,0,0]:[m,t,n,u])})},getSymbol:a.noop,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,drawGraph:function(){this.group[this.dense?"addClass":"removeClass"]("highcharts-dense-data")},
pointAttribs:function(a,c){var d=this.options,k,b=this.pointAttrToOptions||{};k=b.stroke||"borderColor";var p=b["stroke-width"]||"borderWidth",h=a&&a.color||this.color,l=a[k]||d[k]||this.color||h,q=a[p]||d[p]||this[p]||0,b=d.dashStyle;a&&this.zones.length&&(h=(h=a.getZone())&&h.color||a.options.color||this.color);c&&(a=f(d.states[c],a.options.states&&a.options.states[c]||{}),c=a.brightness,h=a.color||void 0!==c&&A(h).brighten(a.brightness).get()||h,l=a[k]||l,q=a[p]||q,b=a.dashStyle||b);k={fill:h,
stroke:l,"stroke-width":q};d.borderRadius&&(k.r=d.borderRadius);b&&(k.dashstyle=b);return k},drawPoints:function(){var a=this,c=this.chart,k=a.options,l=c.renderer,b=k.animationLimit||250,p;H(a.points,function(d){var h=d.graphic;if(r(d.plotY)&&null!==d.y){p=d.shapeArgs;if(h)h[c.pointCount<b?"animate":"attr"](f(p));else d.graphic=h=l[d.shapeType](p).add(d.group||a.group);h.attr(a.pointAttribs(d,d.selected&&"select")).shadow(k.shadow,null,k.stacking&&!k.borderRadius);h.addClass(d.getClassName(),!0)}else h&&
(d.graphic=h.destroy())})},animate:function(a){var c=this,d=this.yAxis,f=c.options,b=this.chart.inverted,k={};u&&(a?(k.scaleY=.001,a=Math.min(d.pos+d.len,Math.max(d.pos,d.toPixels(f.threshold))),b?k.translateX=a-d.len:k.translateY=a,c.group.attr(k)):(k[b?"translateX":"translateY"]=d.pos,c.group.animate(k,G(B(c.options.animation),{step:function(a,b){c.group.attr({scaleY:Math.max(.001,b.pos)})}})),c.animate=null))},remove:function(){var a=this,c=a.chart;c.hasRendered&&H(c.series,function(c){c.type===
a.type&&(c.isDirty=!0)});q.prototype.remove.apply(a,arguments)}})})(L);(function(a){a=a.seriesType;a("bar","column",null,{inverted:!0})})(L);(function(a){var B=a.Series;a=a.seriesType;a("scatter","line",{lineWidth:0,findNearestPointBy:"xy",marker:{enabled:!0},tooltip:{headerFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e \x3cspan style\x3d"font-size: 0.85em"\x3e {series.name}\x3c/span\x3e\x3cbr/\x3e',pointFormat:"x: \x3cb\x3e{point.x}\x3c/b\x3e\x3cbr/\x3ey: \x3cb\x3e{point.y}\x3c/b\x3e\x3cbr/\x3e"}},
{sorted:!1,requireSorting:!1,noSharedTooltip:!0,trackerGroups:["group","markerGroup","dataLabelsGroup"],takeOrdinalPosition:!1,drawGraph:function(){this.options.lineWidth&&B.prototype.drawGraph.call(this)}})})(L);(function(a){var B=a.pick,A=a.relativeLength;a.CenteredSeriesMixin={getCenter:function(){var a=this.options,G=this.chart,r=2*(a.slicedOffset||0),f=G.plotWidth-2*r,G=G.plotHeight-2*r,l=a.center,l=[B(l[0],"50%"),B(l[1],"50%"),a.size||"100%",a.innerSize||0],q=Math.min(f,G),k,u;for(k=0;4>k;++k)u=
l[k],a=2>k||2===k&&/%$/.test(u),l[k]=A(u,[f,G,q,l[2]][k])+(a?r:0);l[3]>l[2]&&(l[3]=l[2]);return l}}})(L);(function(a){var B=a.addEvent,A=a.defined,H=a.each,G=a.extend,r=a.inArray,f=a.noop,l=a.pick,q=a.Point,k=a.Series,u=a.seriesType,d=a.setAnimation;u("pie","line",{center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30,enabled:!0,formatter:function(){return null===this.y?void 0:this.point.name},x:0},ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,
stickyTracking:!1,tooltip:{followPointer:!0},borderColor:"#ffffff",borderWidth:1,states:{hover:{brightness:.1,shadow:!1}}},{isCartesian:!1,requireSorting:!1,directTouch:!0,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttribs:a.seriesTypes.column.prototype.pointAttribs,animate:function(a){var c=this,d=c.points,b=c.startAngleRad;a||(H(d,function(a){var d=a.graphic,f=a.shapeArgs;d&&(d.attr({r:a.startR||c.center[3]/2,start:b,end:b}),d.animate({r:f.r,start:f.start,end:f.end},
c.options.animation))}),c.animate=null)},updateTotals:function(){var a,d=0,f=this.points,b=f.length,k,h=this.options.ignoreHiddenPoint;for(a=0;a<b;a++)k=f[a],0>k.y&&(k.y=null),d+=h&&!k.visible?0:k.y;this.total=d;for(a=0;a<b;a++)k=f[a],k.percentage=0<d&&(k.visible||!h)?k.y/d*100:0,k.total=d},generatePoints:function(){k.prototype.generatePoints.call(this);this.updateTotals()},translate:function(a){this.generatePoints();var c=0,d=this.options,b=d.slicedOffset,f=b+(d.borderWidth||0),h,k,q,w=d.startAngle||
0,e=this.startAngleRad=Math.PI/180*(w-90),w=(this.endAngleRad=Math.PI/180*(l(d.endAngle,w+360)-90))-e,r=this.points,u=d.dataLabels.distance,d=d.ignoreHiddenPoint,E,m=r.length,y;a||(this.center=a=this.getCenter());this.getX=function(b,c){q=Math.asin(Math.min((b-a[1])/(a[2]/2+u),1));return a[0]+(c?-1:1)*Math.cos(q)*(a[2]/2+u)};for(E=0;E<m;E++){y=r[E];h=e+c*w;if(!d||y.visible)c+=y.percentage/100;k=e+c*w;y.shapeType="arc";y.shapeArgs={x:a[0],y:a[1],r:a[2]/2,innerR:a[3]/2,start:Math.round(1E3*h)/1E3,end:Math.round(1E3*
k)/1E3};q=(k+h)/2;q>1.5*Math.PI?q-=2*Math.PI:q<-Math.PI/2&&(q+=2*Math.PI);y.slicedTranslation={translateX:Math.round(Math.cos(q)*b),translateY:Math.round(Math.sin(q)*b)};h=Math.cos(q)*a[2]/2;k=Math.sin(q)*a[2]/2;y.tooltipPos=[a[0]+.7*h,a[1]+.7*k];y.half=q<-Math.PI/2||q>Math.PI/2?1:0;y.angle=q;f=Math.min(f,u/5);y.labelPos=[a[0]+h+Math.cos(q)*u,a[1]+k+Math.sin(q)*u,a[0]+h+Math.cos(q)*f,a[1]+k+Math.sin(q)*f,a[0]+h,a[1]+k,0>u?"center":y.half?"right":"left",q]}},drawGraph:null,drawPoints:function(){var a=
this,d=a.chart.renderer,f,b,k,h,l=a.options.shadow;l&&!a.shadowGroup&&(a.shadowGroup=d.g("shadow").add(a.group));H(a.points,function(c){if(null!==c.y){b=c.graphic;h=c.shapeArgs;f=c.getTranslate();var p=c.shadowGroup;l&&!p&&(p=c.shadowGroup=d.g("shadow").add(a.shadowGroup));p&&p.attr(f);k=a.pointAttribs(c,c.selected&&"select");b?b.setRadialReference(a.center).attr(k).animate(G(h,f)):(c.graphic=b=d[c.shapeType](h).setRadialReference(a.center).attr(f).add(a.group),c.visible||b.attr({visibility:"hidden"}),
b.attr(k).attr({"stroke-linejoin":"round"}).shadow(l,p));b.addClass(c.getClassName())}})},searchPoint:f,sortByAngle:function(a,d){a.sort(function(a,b){return void 0!==a.angle&&(b.angle-a.angle)*d})},drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,getCenter:a.CenteredSeriesMixin.getCenter,getSymbol:f},{init:function(){q.prototype.init.apply(this,arguments);var a=this,d;a.name=l(a.name,"Slice");d=function(c){a.slice("select"===c.type)};B(a,"select",d);B(a,"unselect",d);return a},setVisible:function(a,
d){var c=this,b=c.series,f=b.chart,h=b.options.ignoreHiddenPoint;d=l(d,h);a!==c.visible&&(c.visible=c.options.visible=a=void 0===a?!c.visible:a,b.options.data[r(c,b.data)]=c.options,H(["graphic","dataLabel","connector","shadowGroup"],function(b){if(c[b])c[b][a?"show":"hide"](!0)}),c.legendItem&&f.legend.colorizeItem(c,a),a||"hover"!==c.state||c.setState(""),h&&(b.isDirty=!0),d&&f.redraw())},slice:function(a,f,k){var b=this.series;d(k,b.chart);l(f,!0);this.sliced=this.options.sliced=A(a)?a:!this.sliced;
b.options.data[r(this,b.data)]=this.options;this.graphic.animate(this.getTranslate());this.shadowGroup&&this.shadowGroup.animate(this.getTranslate())},getTranslate:function(){return this.sliced?this.slicedTranslation:{translateX:0,translateY:0}},haloPath:function(a){var c=this.shapeArgs;return this.sliced||!this.visible?[]:this.series.chart.renderer.symbols.arc(c.x,c.y,c.r+a,c.r+a,{innerR:this.shapeArgs.r,start:c.start,end:c.end})}})})(L);(function(a){var B=a.addEvent,A=a.arrayMax,H=a.defined,G=a.each,
r=a.extend,f=a.format,l=a.map,q=a.merge,k=a.noop,u=a.pick,d=a.relativeLength,c=a.Series,n=a.seriesTypes,z=a.stableSort;a.distribute=function(a,c){function b(a,b){return a.target-b.target}var d,f=!0,k=a,e=[],p;p=0;for(d=a.length;d--;)p+=a[d].size;if(p>c){z(a,function(a,b){return(b.rank||0)-(a.rank||0)});for(p=d=0;p<=c;)p+=a[d].size,d++;e=a.splice(d-1,a.length)}z(a,b);for(a=l(a,function(a){return{size:a.size,targets:[a.target]}});f;){for(d=a.length;d--;)f=a[d],p=(Math.min.apply(0,f.targets)+Math.max.apply(0,
f.targets))/2,f.pos=Math.min(Math.max(0,p-f.size/2),c-f.size);d=a.length;for(f=!1;d--;)0<d&&a[d-1].pos+a[d-1].size>a[d].pos&&(a[d-1].size+=a[d].size,a[d-1].targets=a[d-1].targets.concat(a[d].targets),a[d-1].pos+a[d-1].size>c&&(a[d-1].pos=c-a[d-1].size),a.splice(d,1),f=!0)}d=0;G(a,function(a){var b=0;G(a.targets,function(){k[d].pos=a.pos+b;b+=k[d].size;d++})});k.push.apply(k,e);z(k,b)};c.prototype.drawDataLabels=function(){var a=this,c=a.options,d=c.dataLabels,k=a.points,l,n,e=a.hasRendered||0,r,C,
E=u(d.defer,!0),m=a.chart.renderer;if(d.enabled||a._hasPointLabels)a.dlProcessOptions&&a.dlProcessOptions(d),C=a.plotGroup("dataLabelsGroup","data-labels",E&&!e?"hidden":"visible",d.zIndex||6),E&&(C.attr({opacity:+e}),e||B(a,"afterAnimate",function(){a.visible&&C.show(!0);C[c.animation?"animate":"attr"]({opacity:1},{duration:200})})),n=d,G(k,function(b){var e,h=b.dataLabel,k,g,p,t=b.connector,w=!h,x;l=b.dlOptions||b.options&&b.options.dataLabels;if(e=u(l&&l.enabled,n.enabled)&&null!==b.y)for(g in d=
q(n,l),k=b.getLabelConfig(),r=d.format?f(d.format,k):d.formatter.call(k,d),x=d.style,p=d.rotation,x.color=u(d.color,x.color,a.color,"#000000"),"contrast"===x.color&&(b.contrastColor=m.getContrast(b.color||a.color),x.color=d.inside||0>d.distance||c.stacking?b.contrastColor:"#000000"),c.cursor&&(x.cursor=c.cursor),k={fill:d.backgroundColor,stroke:d.borderColor,"stroke-width":d.borderWidth,r:d.borderRadius||0,rotation:p,padding:d.padding,zIndex:1},k)void 0===k[g]&&delete k[g];!h||e&&H(r)?e&&H(r)&&(h?
k.text=r:(h=b.dataLabel=m[p?"text":"label"](r,0,-9999,d.shape,null,null,d.useHTML,null,"data-label"),h.addClass("highcharts-data-label-color-"+b.colorIndex+" "+(d.className||"")+(d.useHTML?"highcharts-tracker":""))),h.attr(k),h.css(x).shadow(d.shadow),h.added||h.add(C),a.alignDataLabel(b,h,d,null,w)):(b.dataLabel=h.destroy(),t&&(b.connector=t.destroy()))})};c.prototype.alignDataLabel=function(a,c,d,f,k){var b=this.chart,e=b.inverted,h=u(a.plotX,-9999),l=u(a.plotY,-9999),p=c.getBBox(),m,n=d.rotation,
q=d.align,t=this.visible&&(a.series.forceDL||b.isInsidePlot(h,Math.round(l),e)||f&&b.isInsidePlot(h,e?f.x+1:f.y+f.height-1,e)),D="justify"===u(d.overflow,"justify");t&&(m=d.style.fontSize,m=b.renderer.fontMetrics(m,c).b,f=r({x:e?b.plotWidth-l:h,y:Math.round(e?b.plotHeight-h:l),width:0,height:0},f),r(d,{width:p.width,height:p.height}),n?(D=!1,e=b.renderer.rotCorr(m,n),e={x:f.x+d.x+f.width/2+e.x,y:f.y+d.y+{top:0,middle:.5,bottom:1}[d.verticalAlign]*f.height},c[k?"attr":"animate"](e).attr({align:q}),
h=(n+720)%360,h=180<h&&360>h,"left"===q?e.y-=h?p.height:0:"center"===q?(e.x-=p.width/2,e.y-=p.height/2):"right"===q&&(e.x-=p.width,e.y-=h?0:p.height)):(c.align(d,null,f),e=c.alignAttr),D?a.isLabelJustified=this.justifyDataLabel(c,d,e,p,f,k):u(d.crop,!0)&&(t=b.isInsidePlot(e.x,e.y)&&b.isInsidePlot(e.x+p.width,e.y+p.height)),d.shape&&!n&&c.attr({anchorX:a.plotX,anchorY:a.plotY}));t||(c.attr({y:-9999}),c.placed=!1)};c.prototype.justifyDataLabel=function(a,c,d,f,k,l){var b=this.chart,h=c.align,p=c.verticalAlign,
n,m,q=a.box?0:a.padding||0;n=d.x+q;0>n&&("right"===h?c.align="left":c.x=-n,m=!0);n=d.x+f.width-q;n>b.plotWidth&&("left"===h?c.align="right":c.x=b.plotWidth-n,m=!0);n=d.y+q;0>n&&("bottom"===p?c.verticalAlign="top":c.y=-n,m=!0);n=d.y+f.height-q;n>b.plotHeight&&("top"===p?c.verticalAlign="bottom":c.y=b.plotHeight-n,m=!0);m&&(a.placed=!l,a.align(c,null,k));return m};n.pie&&(n.pie.prototype.drawDataLabels=function(){var b=this,d=b.data,f,k=b.chart,n=b.options.dataLabels,q=u(n.connectorPadding,10),e=u(n.connectorWidth,
1),r=k.plotWidth,C=k.plotHeight,E,m=n.distance,y=b.center,z=y[2]/2,B=y[1],H=0<m,g,F,L,N,P=[[],[]],O,v,M,R,S=[0,0,0,0];b.visible&&(n.enabled||b._hasPointLabels)&&(G(d,function(a){a.dataLabel&&a.visible&&a.dataLabel.shortened&&(a.dataLabel.attr({width:"auto"}).css({width:"auto",textOverflow:"clip"}),a.dataLabel.shortened=!1)}),c.prototype.drawDataLabels.apply(b),G(d,function(a){a.dataLabel&&a.visible&&(P[a.half].push(a),a.dataLabel._pos=null)}),G(P,function(c,e){var d,h,p=c.length,t,w,u;if(p)for(b.sortByAngle(c,
e-.5),0<m&&(d=Math.max(0,B-z-m),h=Math.min(B+z+m,k.plotHeight),t=l(c,function(a){if(a.dataLabel)return u=a.dataLabel.getBBox().height||21,{target:a.labelPos[1]-d+u/2,size:u,rank:a.y}}),a.distribute(t,h+u-d)),R=0;R<p;R++)f=c[R],L=f.labelPos,g=f.dataLabel,M=!1===f.visible?"hidden":"inherit",w=L[1],t?void 0===t[R].pos?M="hidden":(N=t[R].size,v=d+t[R].pos):v=w,O=n.justify?y[0]+(e?-1:1)*(z+m):b.getX(v<d+2||v>h-2?w:v,e),g._attr={visibility:M,align:L[6]},g._pos={x:O+n.x+({left:q,right:-q}[L[6]]||0),y:v+
n.y-10},L.x=O,L.y=v,null===b.options.size&&(F=g.getBBox().width,w=null,O-F<q?(w=Math.round(F-O+q),S[3]=Math.max(w,S[3])):O+F>r-q&&(w=Math.round(O+F-r+q),S[1]=Math.max(w,S[1])),0>v-N/2?S[0]=Math.max(Math.round(-v+N/2),S[0]):v+N/2>C&&(S[2]=Math.max(Math.round(v+N/2-C),S[2])),g.sideOverflow=w)}),0===A(S)||this.verifyDataLabelOverflow(S))&&(this.placeDataLabels(),H&&e&&G(this.points,function(a){var c;E=a.connector;if((g=a.dataLabel)&&g._pos&&a.visible){M=g._attr.visibility;if(c=!E)a.connector=E=k.renderer.path().addClass("highcharts-data-label-connector highcharts-color-"+
a.colorIndex).add(b.dataLabelsGroup),E.attr({"stroke-width":e,stroke:n.connectorColor||a.color||"#666666"});E[c?"attr":"animate"]({d:b.connectorPath(a.labelPos)});E.attr("visibility",M)}else E&&(a.connector=E.destroy())}))},n.pie.prototype.connectorPath=function(a){var b=a.x,c=a.y;return u(this.options.dataLabels.softConnector,!0)?["M",b+("left"===a[6]?5:-5),c,"C",b,c,2*a[2]-a[4],2*a[3]-a[5],a[2],a[3],"L",a[4],a[5]]:["M",b+("left"===a[6]?5:-5),c,"L",a[2],a[3],"L",a[4],a[5]]},n.pie.prototype.placeDataLabels=
function(){G(this.points,function(a){var b=a.dataLabel;b&&a.visible&&((a=b._pos)?(b.sideOverflow&&(b._attr.width=b.getBBox().width-b.sideOverflow,b.css({width:b._attr.width+"px",textOverflow:"ellipsis"}),b.shortened=!0),b.attr(b._attr),b[b.moved?"animate":"attr"](a),b.moved=!0):b&&b.attr({y:-9999}))},this)},n.pie.prototype.alignDataLabel=k,n.pie.prototype.verifyDataLabelOverflow=function(a){var b=this.center,c=this.options,f=c.center,k=c.minSize||80,l,e;null!==f[0]?l=Math.max(b[2]-Math.max(a[1],a[3]),
k):(l=Math.max(b[2]-a[1]-a[3],k),b[0]+=(a[3]-a[1])/2);null!==f[1]?l=Math.max(Math.min(l,b[2]-Math.max(a[0],a[2])),k):(l=Math.max(Math.min(l,b[2]-a[0]-a[2]),k),b[1]+=(a[0]-a[2])/2);l<b[2]?(b[2]=l,b[3]=Math.min(d(c.innerSize||0,l),l),this.translate(b),this.drawDataLabels&&this.drawDataLabels()):e=!0;return e});n.column&&(n.column.prototype.alignDataLabel=function(a,d,f,k,l){var b=this.chart.inverted,e=a.series,h=a.dlBox||a.shapeArgs,n=u(a.below,a.plotY>u(this.translatedThreshold,e.yAxis.len)),p=u(f.inside,
!!this.options.stacking);h&&(k=q(h),0>k.y&&(k.height+=k.y,k.y=0),h=k.y+k.height-e.yAxis.len,0<h&&(k.height-=h),b&&(k={x:e.yAxis.len-k.y-k.height,y:e.xAxis.len-k.x-k.width,width:k.height,height:k.width}),p||(b?(k.x+=n?0:k.width,k.width=0):(k.y+=n?k.height:0,k.height=0)));f.align=u(f.align,!b||p?"center":n?"right":"left");f.verticalAlign=u(f.verticalAlign,b||p?"middle":n?"top":"bottom");c.prototype.alignDataLabel.call(this,a,d,f,k,l);a.isLabelJustified&&a.contrastColor&&a.dataLabel.css({color:a.contrastColor})})})(L);
(function(a){var B=a.Chart,A=a.each,H=a.pick,G=a.addEvent;B.prototype.callbacks.push(function(a){function f(){var f=[];A(a.series||[],function(a){var k=a.options.dataLabels,l=a.dataLabelCollections||["dataLabel"];(k.enabled||a._hasPointLabels)&&!k.allowOverlap&&a.visible&&A(l,function(d){A(a.points,function(a){a[d]&&(a[d].labelrank=H(a.labelrank,a.shapeArgs&&a.shapeArgs.height),f.push(a[d]))})})});a.hideOverlappingLabels(f)}f();G(a,"redraw",f)});B.prototype.hideOverlappingLabels=function(a){var f=
a.length,l,q,k,r,d,c,n,z,b,p=function(a,b,c,d,e,f,k,l){return!(e>a+c||e+k<a||f>b+d||f+l<b)};for(q=0;q<f;q++)if(l=a[q])l.oldOpacity=l.opacity,l.newOpacity=1;a.sort(function(a,b){return(b.labelrank||0)-(a.labelrank||0)});for(q=0;q<f;q++)for(k=a[q],l=q+1;l<f;++l)if(r=a[l],k&&r&&k!==r&&k.placed&&r.placed&&0!==k.newOpacity&&0!==r.newOpacity&&(d=k.alignAttr,c=r.alignAttr,n=k.parentGroup,z=r.parentGroup,b=2*(k.box?0:k.padding),d=p(d.x+n.translateX,d.y+n.translateY,k.width-b,k.height-b,c.x+z.translateX,c.y+
z.translateY,r.width-b,r.height-b)))(k.labelrank<r.labelrank?k:r).newOpacity=0;A(a,function(a){var b,c;a&&(c=a.newOpacity,a.oldOpacity!==c&&a.placed&&(c?a.show(!0):b=function(){a.hide()},a.alignAttr.opacity=c,a[a.isOld?"animate":"attr"](a.alignAttr,null,b)),a.isOld=!0)})}})(L);(function(a){var B=a.addEvent,A=a.Chart,H=a.createElement,G=a.css,r=a.defaultOptions,f=a.defaultPlotOptions,l=a.each,q=a.extend,k=a.fireEvent,u=a.hasTouch,d=a.inArray,c=a.isObject,n=a.Legend,z=a.merge,b=a.pick,p=a.Point,h=a.Series,
t=a.seriesTypes,D=a.svg;a=a.TrackerMixin={drawTrackerPoint:function(){var a=this,b=a.chart.pointer,c=function(a){var c=b.getPointFromEvent(a);if(void 0!==c)c.onMouseOver(a)};l(a.points,function(a){a.graphic&&(a.graphic.element.point=a);a.dataLabel&&(a.dataLabel.div?a.dataLabel.div.point=a:a.dataLabel.element.point=a)});a._hasTracking||(l(a.trackerGroups,function(e){if(a[e]){a[e].addClass("highcharts-tracker").on("mouseover",c).on("mouseout",function(a){b.onTrackerMouseOut(a)});if(u)a[e].on("touchstart",
c);a.options.cursor&&a[e].css(G).css({cursor:a.options.cursor})}}),a._hasTracking=!0)},drawTrackerGraph:function(){var a=this,b=a.options,c=b.trackByArea,d=[].concat(c?a.areaPath:a.graphPath),f=d.length,h=a.chart,k=h.pointer,n=h.renderer,p=h.options.tooltip.snap,q=a.tracker,g,r=function(){if(h.hoverSeries!==a)a.onMouseOver()},t="rgba(192,192,192,"+(D?.0001:.002)+")";if(f&&!c)for(g=f+1;g--;)"M"===d[g]&&d.splice(g+1,0,d[g+1]-p,d[g+2],"L"),(g&&"M"===d[g]||g===f)&&d.splice(g,0,"L",d[g-2]+p,d[g-1]);q?
q.attr({d:d}):a.graph&&(a.tracker=n.path(d).attr({"stroke-linejoin":"round",visibility:a.visible?"visible":"hidden",stroke:t,fill:c?t:"none","stroke-width":a.graph.strokeWidth()+(c?0:2*p),zIndex:2}).add(a.group),l([a.tracker,a.markerGroup],function(a){a.addClass("highcharts-tracker").on("mouseover",r).on("mouseout",function(a){k.onTrackerMouseOut(a)});b.cursor&&a.css({cursor:b.cursor});if(u)a.on("touchstart",r)}))}};t.column&&(t.column.prototype.drawTracker=a.drawTrackerPoint);t.pie&&(t.pie.prototype.drawTracker=
a.drawTrackerPoint);t.scatter&&(t.scatter.prototype.drawTracker=a.drawTrackerPoint);q(n.prototype,{setItemEvents:function(a,b,c){var d=this,e=d.chart.renderer.boxWrapper,f="highcharts-legend-"+(a.series?"point":"series")+"-active";(c?b:a.legendGroup).on("mouseover",function(){a.setState("hover");e.addClass(f);b.css(d.options.itemHoverStyle)}).on("mouseout",function(){b.css(a.visible?d.itemStyle:d.itemHiddenStyle);e.removeClass(f);a.setState()}).on("click",function(b){var c=function(){a.setVisible&&
a.setVisible()};b={browserEvent:b};a.firePointEvent?a.firePointEvent("legendItemClick",b,c):k(a,"legendItemClick",b,c)})},createCheckboxForItem:function(a){a.checkbox=H("input",{type:"checkbox",checked:a.selected,defaultChecked:a.selected},this.options.itemCheckboxStyle,this.chart.container);B(a.checkbox,"click",function(b){k(a.series||a,"checkboxClick",{checked:b.target.checked,item:a},function(){a.select()})})}});r.legend.itemStyle.cursor="pointer";q(A.prototype,{showResetZoom:function(){var a=
this,b=r.lang,c=a.options.chart.resetZoomButton,d=c.theme,f=d.states,h="chart"===c.relativeTo?null:"plotBox";this.resetZoomButton=a.renderer.button(b.resetZoom,null,null,function(){a.zoomOut()},d,f&&f.hover).attr({align:c.position.align,title:b.resetZoomTitle}).addClass("highcharts-reset-zoom").add().align(c.position,!1,h)},zoomOut:function(){var a=this;k(a,"selection",{resetSelection:!0},function(){a.zoom()})},zoom:function(a){var d,f=this.pointer,h=!1,k;!a||a.resetSelection?l(this.axes,function(a){d=
a.zoom()}):l(a.xAxis.concat(a.yAxis),function(a){var b=a.axis;f[b.isXAxis?"zoomX":"zoomY"]&&(d=b.zoom(a.min,a.max),b.displayBtn&&(h=!0))});k=this.resetZoomButton;h&&!k?this.showResetZoom():!h&&c(k)&&(this.resetZoomButton=k.destroy());d&&this.redraw(b(this.options.chart.animation,a&&a.animation,100>this.pointCount))},pan:function(a,b){var c=this,d=c.hoverPoints,e;d&&l(d,function(a){a.setState()});l("xy"===b?[1,0]:[1],function(b){b=c[b?"xAxis":"yAxis"][0];var d=b.horiz,f=a[d?"chartX":"chartY"],d=d?
"mouseDownX":"mouseDownY",h=c[d],k=(b.pointRange||0)/2,g=b.getExtremes(),l=b.toValue(h-f,!0)+k,k=b.toValue(h+b.len-f,!0)-k,m=k<l,h=m?k:l,l=m?l:k,m=b.toValue(b.toPixels(g.min)-b.minPixelPadding),k=b.toValue(b.toPixels(g.max)+b.minPixelPadding),m=Math.min(g.dataMin,m)-h,g=l-Math.max(g.dataMax,k);b.series.length&&0>m&&0>g&&(b.setExtremes(h,l,!1,!1,{trigger:"pan"}),e=!0);c[d]=f});e&&c.redraw(!1);G(c.container,{cursor:"move"})}});q(p.prototype,{select:function(a,c){var e=this,f=e.series,h=f.chart;a=b(a,
!e.selected);e.firePointEvent(a?"select":"unselect",{accumulate:c},function(){e.selected=e.options.selected=a;f.options.data[d(e,f.data)]=e.options;e.setState(a&&"select");c||l(h.getSelectedPoints(),function(a){a.selected&&a!==e&&(a.selected=a.options.selected=!1,f.options.data[d(a,f.data)]=a.options,a.setState(""),a.firePointEvent("unselect"))})})},onMouseOver:function(a){var b=this.series.chart.pointer;this.firePointEvent("mouseOver");b.runPointActions(a,this)},onMouseOut:function(){var a=this.series.chart;
this.firePointEvent("mouseOut");l(a.hoverPoints||[],function(a){a.setState()});a.hoverPoints=a.hoverPoint=null},importEvents:function(){if(!this.hasImportedEvents){var a=z(this.series.options.point,this.options).events,b;this.events=a;for(b in a)B(this,b,a[b]);this.hasImportedEvents=!0}},setState:function(a,c){var d=Math.floor(this.plotX),e=this.plotY,h=this.series,k=h.options.states[a]||{},l=f[h.type].marker&&h.options.marker,n=l&&!1===l.enabled,p=l&&l.states&&l.states[a]||{},r=!1===p.enabled,g=
h.stateMarkerGraphic,t=this.marker||{},u=h.chart,w=h.halo,z,A=l&&h.markerAttribs;a=a||"";if(!(a===this.state&&!c||this.selected&&"select"!==a||!1===k.enabled||a&&(r||n&&!1===p.enabled)||a&&t.states&&t.states[a]&&!1===t.states[a].enabled)){A&&(z=h.markerAttribs(this,a));if(this.graphic)this.state&&this.graphic.removeClass("highcharts-point-"+this.state),a&&this.graphic.addClass("highcharts-point-"+a),this.graphic.attr(h.pointAttribs(this,a)),z&&this.graphic.animate(z,b(u.options.chart.animation,p.animation,
l.animation)),g&&g.hide();else{if(a&&p){l=t.symbol||h.symbol;g&&g.currentSymbol!==l&&(g=g.destroy());if(g)g[c?"animate":"attr"]({x:z.x,y:z.y});else l&&(h.stateMarkerGraphic=g=u.renderer.symbol(l,z.x,z.y,z.width,z.height).add(h.markerGroup),g.currentSymbol=l);g&&g.attr(h.pointAttribs(this,a))}g&&(g[a&&u.isInsidePlot(d,e,u.inverted)?"show":"hide"](),g.element.point=this)}(d=k.halo)&&d.size?(w||(h.halo=w=u.renderer.path().add(A?h.markerGroup:h.group)),w[c?"animate":"attr"]({d:this.haloPath(d.size)}),
w.attr({"class":"highcharts-halo highcharts-color-"+b(this.colorIndex,h.colorIndex)}),w.point=this,w.attr(q({fill:this.color||h.color,"fill-opacity":d.opacity,zIndex:-1},d.attributes))):w&&w.point&&w.point.haloPath&&w.animate({d:w.point.haloPath(0)});this.state=a}},haloPath:function(a){return this.series.chart.renderer.symbols.circle(Math.floor(this.plotX)-a,this.plotY-a,2*a,2*a)}});q(h.prototype,{onMouseOver:function(){var a=this.chart,b=a.hoverSeries;if(b&&b!==this)b.onMouseOut();this.options.events.mouseOver&&
k(this,"mouseOver");this.setState("hover");a.hoverSeries=this},onMouseOut:function(){var a=this.options,b=this.chart,c=b.tooltip,d=b.hoverPoint;b.hoverSeries=null;if(d)d.onMouseOut();this&&a.events.mouseOut&&k(this,"mouseOut");!c||this.stickyTracking||c.shared&&!this.noSharedTooltip||c.hide();this.setState()},setState:function(a){var c=this,d=c.options,f=c.graph,h=d.states,k=d.lineWidth,d=0;a=a||"";if(c.state!==a&&(l([c.group,c.markerGroup,c.dataLabelsGroup],function(b){b&&(c.state&&b.removeClass("highcharts-series-"+
c.state),a&&b.addClass("highcharts-series-"+a))}),c.state=a,!h[a]||!1!==h[a].enabled)&&(a&&(k=h[a].lineWidth||k+(h[a].lineWidthPlus||0)),f&&!f.dashstyle))for(k={"stroke-width":k},f.animate(k,b(c.chart.options.chart.animation,h[a]&&h[a].animation));c["zone-graph-"+d];)c["zone-graph-"+d].attr(k),d+=1},setVisible:function(a,b){var c=this,d=c.chart,e=c.legendItem,f,h=d.options.chart.ignoreHiddenSeries,n=c.visible;f=(c.visible=a=c.options.visible=c.userOptions.visible=void 0===a?!n:a)?"show":"hide";l(["group",
"dataLabelsGroup","markerGroup","tracker","tt"],function(a){if(c[a])c[a][f]()});if(d.hoverSeries===c||(d.hoverPoint&&d.hoverPoint.series)===c)c.onMouseOut();e&&d.legend.colorizeItem(c,a);c.isDirty=!0;c.options.stacking&&l(d.series,function(a){a.options.stacking&&a.visible&&(a.isDirty=!0)});l(c.linkedSeries,function(b){b.setVisible(a,!1)});h&&(d.isDirtyBox=!0);!1!==b&&d.redraw();k(c,f)},show:function(){this.setVisible(!0)},hide:function(){this.setVisible(!1)},select:function(a){this.selected=a=void 0===
a?!this.selected:a;this.checkbox&&(this.checkbox.checked=a);k(this,a?"select":"unselect")},drawTracker:a.drawTrackerGraph})})(L);(function(a){var B=a.Chart,A=a.each,H=a.inArray,G=a.isArray,r=a.isObject,f=a.pick,l=a.splat;B.prototype.setResponsive=function(f){var k=this.options.responsive,l=[],d=this.currentResponsive;k&&k.rules&&A(k.rules,function(c){void 0===c._id&&(c._id=a.uniqueKey());this.matchResponsiveRule(c,l,f)},this);var c=a.merge.apply(0,a.map(l,function(c){return a.find(k.rules,function(a){return a._id===
c}).chartOptions})),l=l.toString()||void 0;l!==(d&&d.ruleIds)&&(d&&this.update(d.undoOptions,f),l?(this.currentResponsive={ruleIds:l,mergedOptions:c,undoOptions:this.currentOptions(c)},this.update(c,f)):this.currentResponsive=void 0)};B.prototype.matchResponsiveRule=function(a,k){var l=a.condition;(l.callback||function(){return this.chartWidth<=f(l.maxWidth,Number.MAX_VALUE)&&this.chartHeight<=f(l.maxHeight,Number.MAX_VALUE)&&this.chartWidth>=f(l.minWidth,0)&&this.chartHeight>=f(l.minHeight,0)}).call(this)&&
k.push(a._id)};B.prototype.currentOptions=function(a){function f(a,c,k,q){var b,d;for(b in a)if(!q&&-1<H(b,["series","xAxis","yAxis"]))for(a[b]=l(a[b]),k[b]=[],d=0;d<a[b].length;d++)c[b][d]&&(k[b][d]={},f(a[b][d],c[b][d],k[b][d],q+1));else r(a[b])?(k[b]=G(a[b])?[]:{},f(a[b],c[b]||{},k[b],q+1)):k[b]=c[b]||null}var q={};f(a,this.options,q,0);return q}})(L);return L});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 17043 17044 17045 17046 17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 17151 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 17353 17354 17355 17356 17357 17358 17359 17360 17361 17362 17363 17364 17365 17366 17367 17368 17369 17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 17507 17508 17509 17510 17511 17512 17513 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 17531 17532 17533 17534 17535 17536 17537 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 17598 17599 17600 17601 17602 17603 17604 17605 17606 17607 17608 17609 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 17639 17640 17641 17642 17643 17644 17645 17646 17647 17648 17649 17650 17651 17652 17653 17654 17655 17656 17657 17658 17659 17660 17661 17662 17663 17664 17665 17666 17667 17668 17669 17670 17671 17672 17673 17674 17675 17676 17677 17678 17679 17680 17681 17682 17683 17684 17685 17686 17687 17688 17689 17690 17691 17692 17693 17694 17695 17696 17697 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 17748 17749 17750 17751 17752 17753 17754 17755 17756 17757 17758 17759 17760 17761 17762 17763 17764 17765 17766 17767 17768 17769 17770 17771 17772 17773 17774 17775 17776 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 17787 17788 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 17799 17800 17801 17802 17803 17804 17805 17806 17807 17808 17809 17810 17811 17812 17813 17814 17815 17816 17817 17818 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 17843 17844 17845 17846 17847 17848 17849 17850 17851 17852 17853 17854 17855 17856 17857 17858 17859 17860 17861 17862 17863 17864 17865 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 17880 17881 17882 17883 17884 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 17931 17932 17933 17934 17935 17936 17937 17938 17939 17940 17941 17942 17943 17944 17945 17946 17947 17948 17949 17950 17951 17952 17953 17954 17955 17956 17957 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 17988 17989 17990 17991 17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 18002 18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 18038 18039 18040 18041 18042 18043 18044 18045 18046 18047 18048 18049 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 18103 18104 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 18167 18168 18169 18170 18171 18172 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 18185 18186 18187 18188 18189 18190 18191 18192 18193 18194 18195 18196 18197 18198 18199 18200 18201 18202 18203 18204 18205 18206 18207 18208 18209 18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 18242 18243 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 18470 18471 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 18559 18560 18561 18562 18563 18564 18565 18566 18567 18568 18569 18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 18793 18794 18795 18796 18797 18798 18799 18800 18801 18802 18803 18804 18805 18806 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 18880 18881 18882 18883 18884 18885 18886 18887 18888 18889 18890 18891 18892 18893 18894 18895 18896 18897 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 19000 19001 19002 19003 19004 19005 19006 19007 19008 19009 19010 19011 19012 19013 19014 19015 19016 19017 19018 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 19038 19039 19040 19041 19042 19043 19044 19045 19046 19047 19048 19049 19050 19051 19052 19053 19054 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 19088 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 19101 19102 19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352 19353 19354 19355 19356 19357 19358 19359 19360 19361 19362 19363 19364 19365 19366 19367 19368 19369 19370 19371 19372 19373 19374 19375 19376 19377 19378 19379 19380 19381 19382 19383 19384 19385 19386 19387 19388 19389 19390 19391 19392 19393 19394 19395 19396 19397 19398 19399 19400 19401 19402 19403 19404 19405 19406 19407 19408 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 19440 19441 19442 19443 19444 19445 19446 19447 19448 19449 19450 19451 19452 19453 19454 19455 19456 19457 19458 19459 19460 19461 19462 19463 19464 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 19483 19484 19485 19486 19487 19488 19489 19490 19491 19492 19493 19494 19495 19496 19497 19498 19499 19500 19501 19502 19503 19504 19505 19506 19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 19545 19546 19547 19548 19549 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 19565 19566 19567 19568 19569 19570 19571 19572 19573 19574 19575 19576 19577 19578 19579 19580 19581 19582 19583 19584 19585 19586 19587 19588 19589 19590 19591 19592 19593 19594 19595 19596 19597 19598 19599 19600 19601 19602 19603 19604 19605 19606 19607 19608 19609 19610 19611 19612 19613 19614 19615 19616 19617 19618 19619 19620 19621 19622 19623 19624 19625 19626 19627 19628 19629 19630 19631 19632 19633 19634 19635 19636 19637 19638 19639 19640 19641 19642 19643 19644 19645 19646 19647 19648 19649 19650 19651 19652 19653 19654 19655 19656 19657 19658 19659 19660 19661 19662 19663 19664 19665 19666 19667 19668 19669 19670 19671 19672 19673 19674 19675 19676 19677 19678 19679 19680 19681 19682 19683 19684 19685 19686 19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 19711 19712 19713 19714 19715 19716 19717 19718 19719 19720 19721 19722 19723 19724 19725 19726 19727 19728 19729 19730 19731 19732 19733 19734 19735 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 19760 19761 19762 19763 19764 19765 19766 19767 19768 19769 19770 19771 19772 19773 19774 19775 19776 19777 19778 19779 19780 19781 19782 19783 19784 19785 19786 19787 19788 19789 19790 19791 19792 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 19865 19866 19867 19868 19869 19870 19871 19872 19873 19874 19875 19876 19877 19878 19879 19880 19881 19882 19883 19884 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 20131 20132 20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 20148 20149 20150 20151 20152 20153 20154 20155 20156 20157 20158 20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 20326 20327 20328 20329 20330 20331 20332 20333 20334 20335 20336 20337 20338 20339 20340 20341 20342 20343 20344 20345 20346 20347 20348 20349 20350 20351 20352 20353 20354 20355 20356 20357 20358 20359 20360 20361 20362 20363 20364 20365 20366 20367 20368 20369 20370 20371 20372 20373 20374 20375 20376 20377 20378 20379 20380 20381 20382 20383 20384 20385 20386 20387 20388 20389 20390 20391 20392 20393 20394 20395 20396 20397 20398 20399 20400 20401 20402 20403 20404 20405 20406 20407 20408 20409 20410 20411 20412 20413 20414 20415 20416 20417 20418 20419 20420 20421 20422 20423 20424 20425 20426 20427 20428 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 20485 20486 20487 20488 20489 20490 20491 20492 20493 20494 20495 20496 20497 20498 20499 20500 20501 20502 20503 20504 20505 20506 20507 20508 20509 20510 20511 20512 20513 20514 20515 20516 20517 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 20530 20531 20532 20533 20534 20535 20536 20537 20538 20539 20540 20541 20542 20543 20544 20545 20546 20547 20548 20549 20550 20551 20552 20553 20554 20555 20556 20557 20558 20559 20560 20561 20562 20563 20564 20565 20566 20567 20568 20569 20570 20571 20572 20573 20574 20575 20576 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 20607 20608 20609 20610 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 20646 20647 20648 20649 20650 20651 20652 20653 20654 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 20672 20673 20674 20675 20676 20677 20678 20679 20680 20681 20682 20683 20684 20685 20686 20687 20688 20689 20690 20691 20692 20693 20694 20695 20696 20697 20698 20699 20700 20701 20702 20703 20704 20705 20706 20707 20708 20709 20710 20711 20712 20713 20714 20715 20716 20717 20718 20719 20720 20721 20722 20723 20724 20725 20726 20727 20728 20729 20730 20731 20732 20733 20734 20735 20736 20737 20738 20739 20740 20741 20742 20743 20744 20745 20746 20747 20748 20749 20750 20751 20752 20753 20754 20755 20756 20757 20758 20759 20760 20761 20762 20763 20764 20765 20766 20767 20768 20769 20770 20771 20772 20773 20774 20775 20776 20777 20778 20779 20780 20781 20782 20783 20784 20785 20786 20787 20788 20789 20790 20791 20792 20793 20794 20795 20796 20797 20798 20799 20800 20801 20802 20803 20804 20805 20806 20807 20808 20809 20810 20811 20812 20813 20814 20815 20816 20817 20818 20819 20820 20821 20822 20823 20824 20825 20826 20827 20828 20829 20830 20831 20832 20833 20834 20835 20836 20837 20838 20839 20840 20841 20842 20843 20844 20845 20846 20847 20848 20849 20850 20851 20852 20853 20854 20855 20856 20857 20858 20859 20860 20861 20862 20863 20864 20865 20866 20867 20868 20869 20870 20871 20872 20873 20874 20875 20876 20877 20878 20879 20880 20881 20882 20883 20884 20885 20886 20887 20888 20889 20890 20891 20892 20893 20894 20895 20896 20897 20898 20899 20900 20901 20902 20903 20904 20905 20906 20907 20908 20909 20910 20911 20912 20913 20914 20915 20916 20917 20918 20919 20920 20921 20922 20923 20924 20925 20926 20927 20928 20929 20930 20931 20932 20933 20934 20935 20936 20937 20938 20939 20940 20941 20942 20943 20944 20945 20946 20947 20948 20949 20950 20951 20952 20953 20954 20955 20956 20957 20958 20959 20960 20961 20962 20963 20964 20965 20966 20967 20968 20969 20970 20971 20972 20973 20974 20975 20976 20977 20978 20979 20980 20981 20982 20983 20984 20985 20986 20987 20988 20989 20990 20991 20992 20993 20994 20995 20996 20997 20998 20999 21000 21001 21002 21003 21004 21005 21006 21007 21008 21009 21010 21011 21012 21013 21014 21015 21016 21017 21018 21019 21020 21021 21022 21023 21024 21025 21026 21027 21028 21029 21030 21031 21032 21033 21034 21035 21036 21037 21038 21039 21040 21041 21042 21043 21044 21045 21046 21047 21048 21049 21050 21051 21052 21053 21054 21055 21056 21057 21058 21059 21060 21061 21062 21063 21064 21065 21066 21067 21068 21069 21070 21071 21072 21073 21074 21075 21076 21077 21078 21079 21080 21081 21082 21083 21084 21085 21086 21087 21088 21089 21090 21091 21092 21093 21094 21095 21096 21097 21098 21099 21100 21101 21102 21103 21104 21105 21106 21107 21108 21109 21110 21111 21112 21113 21114 21115 21116 21117 21118 21119 21120 21121 21122 21123 21124 21125 21126 21127 21128 21129 21130 21131 21132 21133 21134 21135 21136 21137 21138 21139 21140 21141 21142 21143 21144 21145 21146 21147 21148 21149 21150 21151 21152 21153 21154 21155 21156 21157 21158 21159 21160 21161 21162 21163 21164 21165 21166 21167 21168 21169 21170 21171 21172 21173 21174 21175 21176 21177 21178 21179 21180 21181 21182 21183 21184 21185 21186 21187 21188 21189 21190 21191 21192 21193 21194 21195 21196 21197 21198 21199 21200 21201 21202 21203 21204 21205 21206 21207 21208 21209 21210 21211 21212 21213 21214 21215 21216 21217 21218 21219 21220 21221 21222 21223 21224 21225 21226 21227 21228 21229 21230 21231 21232 21233 21234 21235 21236 21237 21238 21239 21240 21241 21242 21243 21244 21245 21246 21247 21248 21249 21250 21251 21252 21253 21254 21255 21256 21257 21258 21259 21260 21261 21262 21263 21264 21265 21266 21267 21268 21269 21270 21271 21272 21273 21274 21275 21276 21277 21278 21279 21280 21281 21282 21283 21284 21285 21286 21287 21288 21289 21290 21291 21292 21293 21294 21295 21296 21297 21298 21299 21300 21301 21302 21303 21304 21305 21306 21307 21308 21309 21310 21311 21312 21313 21314 21315 21316 21317 21318 21319 21320 21321 21322 21323 21324 21325 21326 21327 21328 21329 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 21345 21346 21347 21348 21349 21350 21351 21352 21353 21354 21355 21356 21357 21358 21359 21360 21361 21362 21363 21364 21365 21366 21367 21368 21369 21370 21371 21372 21373 21374 21375 21376 21377 21378 21379 21380 21381 21382 21383 21384 21385 21386 21387 21388 21389 21390 21391 21392 21393 21394 21395 21396 21397 21398 21399 21400 21401 21402 21403 21404 21405 21406 21407 21408 21409 21410 21411 21412 21413 21414 21415 21416 21417 21418 21419 21420 21421 21422 21423 21424 21425 21426 21427 21428 21429 21430 21431 21432 21433 21434 21435 21436 21437 21438 21439 21440 21441 21442 21443 21444 21445 21446 21447 21448 21449 21450 21451 21452 21453 21454 21455 21456 21457 21458 21459 21460 21461 21462 21463 21464 21465 21466 21467 21468 21469 21470 21471 21472 21473 21474 21475 21476 21477 21478 21479 21480 21481 21482 21483 21484 21485 21486 21487 21488 21489 21490 21491 21492 21493 21494 21495 21496 21497 21498 21499 21500 21501 21502 21503 21504 21505 21506 21507 21508 21509 21510 21511 21512 21513 21514 21515 21516 21517 21518 21519 21520 21521 21522 21523 21524 21525 21526 21527 21528 21529 21530 21531 21532 21533 21534 21535 21536 21537 21538 21539 21540 21541 21542 21543 21544 21545 21546 21547 21548 21549 21550 21551 21552 21553 21554 21555 21556 21557 21558 21559 21560 21561 21562 21563 21564 21565 21566 21567 21568 21569 21570 21571 21572 21573 21574 21575 21576 21577 21578 21579 21580 21581 21582 21583 21584 21585 21586 21587 21588 21589 21590 21591 21592 21593 21594 21595 21596 21597 21598 21599 21600 21601 21602 21603 21604 21605 21606 21607 21608 21609 21610 21611 21612 21613 21614 21615 21616 21617 21618 21619 21620 21621 21622 21623 21624 21625 21626 21627 21628 21629 21630 21631 21632 21633 21634 21635 21636 21637 21638 21639 21640 21641 21642 21643 21644 21645 21646 21647 21648 21649 21650 21651 21652 21653 21654 21655 21656 21657 21658 21659 21660 21661 21662 21663 21664 21665 21666 21667 21668 21669 21670 21671 21672 21673 21674 21675 21676 21677 21678 21679 21680 21681 21682 21683 21684 21685 21686 21687 21688 21689 21690 21691 21692 21693 21694 21695 21696 21697 21698 21699 21700 21701 21702 21703 21704 21705 21706 21707 21708 21709 21710 21711 21712 21713 21714 21715 21716 21717 21718 21719 21720 21721 21722 21723 21724 21725 21726 21727 21728 21729 21730 21731 21732 21733 21734 21735 21736 21737 21738 21739 21740 21741 21742 21743 21744 21745 21746 21747 21748 21749 21750 21751 21752 21753 21754 21755 21756 21757 21758 21759 21760 21761 21762 21763 21764 21765 21766 21767 21768 21769 21770 21771 21772 21773 21774 21775 21776 21777 21778 21779 21780 21781 21782 21783 21784 21785 21786 21787 21788 21789 21790 21791 21792 21793 21794 21795 21796 21797 21798 21799 21800 21801 21802 21803 21804 21805 21806 21807 21808 21809 21810 21811 21812 21813 21814 21815 21816 21817 21818 21819 21820 21821 21822 21823 21824 21825 21826 21827 21828 21829 21830 21831 21832 21833 21834 21835 21836 21837 21838 21839 21840 21841 21842 21843 21844 21845 21846 21847 21848 21849 21850 21851 21852 21853 21854 21855 21856 21857 21858 21859 21860 21861 21862 21863 21864 21865 21866 21867 21868 21869 21870 21871 21872 21873 21874 21875 21876 21877 21878 21879 21880 21881 21882 21883 21884 21885 21886 21887 21888 21889 21890 21891 21892 21893 21894 21895 21896 21897 21898 21899 21900 21901 21902 21903 21904 21905 21906 21907 21908 21909 21910 21911 21912 21913 21914 21915 21916 21917 21918 21919 21920 21921 21922 21923 21924 21925 21926 21927 21928 21929 21930 21931 21932 21933 21934 21935 21936 21937 21938 21939 21940 21941 21942 21943 21944 21945 21946 21947 21948 21949 21950 21951 21952 21953 21954 21955 21956 21957 21958 21959 21960 21961 21962 21963 21964 21965 21966 21967 21968 21969 21970 21971 21972 21973 21974 21975 21976 21977 21978 21979 21980 21981 21982 21983 21984 21985 21986 21987 21988 21989 21990 21991 21992 21993 21994 21995 21996 21997 21998 21999 22000 22001 22002 22003 22004 22005 22006 22007 22008 22009 22010 22011 22012 22013 22014 22015 22016 22017 22018 22019 22020 22021 22022 22023 22024 22025 22026 22027 22028 22029 22030 22031 22032 22033 22034 22035 22036 22037 22038 22039 22040 22041 22042 22043 22044 22045 22046 22047 22048 22049 22050 22051 22052 22053 22054 22055 22056 22057 22058 22059 22060 22061 22062 22063 22064 22065 22066 22067 22068 22069 22070 22071 22072 22073 22074 22075 22076 22077 22078 22079 22080 22081 22082 22083 22084 22085 22086 22087 22088 22089 22090 22091 22092 22093 22094 22095 22096 22097 22098 22099 22100 22101 22102 22103 22104 22105 22106 22107 22108 22109 22110 22111 22112 22113 22114 22115 22116 22117 22118 22119 22120 22121 22122 22123 22124 22125 22126 22127 22128 22129 22130 22131 22132 22133 22134 22135 22136 22137 22138 22139 22140 22141 22142 22143 22144 22145 22146 22147 22148 22149 22150 22151 22152 22153 22154 22155 22156 22157 22158 22159 22160 22161 22162 22163 22164 22165 22166 22167 22168 22169 22170 22171 22172 22173 22174 22175 22176 22177 22178 22179 22180 22181 22182 22183 22184 22185 22186 22187 22188 22189 22190 22191 22192 22193 22194 22195 22196 22197 22198 22199 22200 22201 22202 22203 22204 22205 22206 22207 22208 22209 22210 22211 22212 22213 22214 22215 22216 22217 22218 22219 22220 22221 22222 22223 22224 22225 22226 22227 22228 22229 22230 22231 22232 22233 22234 22235 22236 22237 22238 22239 22240 22241 22242 22243 22244 22245 22246 22247 22248 22249 22250 22251 22252 22253 22254 22255 22256 22257 22258 22259 22260 22261 22262 22263 22264 22265 22266 22267 22268 22269 22270 22271 22272 22273 22274 22275 22276 22277 22278 22279 22280 22281 22282 22283 22284 22285 22286 22287 22288 22289 22290 22291 22292 22293 22294 22295 22296 22297 22298 22299 22300 22301 22302 22303 22304 22305 22306 22307 22308 22309 22310 22311 22312 22313 22314 22315 22316 22317 22318 22319 22320 22321 22322 22323 22324 22325 22326 22327 22328 22329 22330 22331 22332 22333 22334 22335 22336 22337 22338 22339 22340 22341 22342 22343 22344 22345 22346 22347 22348 22349 22350 22351 22352 22353 22354 22355 22356 22357 22358 22359 22360 22361 22362 22363 22364 22365 22366 22367 22368 22369 22370 22371 22372 22373 22374 22375 22376 22377 22378 22379 22380 22381 22382 22383 22384 22385 22386 22387 22388 22389 22390 22391 22392 22393 22394 22395 22396 22397 22398 22399 22400 22401 22402 22403 22404 22405 22406 22407 22408 22409 22410 22411 22412 22413 22414 22415 22416 22417 22418 22419 22420 22421 22422 22423 22424 22425 22426 22427 22428 22429 22430 22431 22432 22433 22434 22435 22436 22437 22438 22439 22440 22441 22442 22443 22444 22445 22446 22447 22448 22449 22450 22451 22452 22453 22454 22455 22456 22457 22458 22459 22460 22461 22462 22463 22464 22465 22466 22467 22468 22469 22470 22471 22472 22473 22474 22475 22476 22477 22478 22479 22480 22481 22482 22483 22484 22485 22486 22487 22488 22489 22490 22491 22492 22493 22494 22495 22496 22497 22498 22499 22500 22501 22502 22503 22504 22505 22506 22507 22508 22509 22510 22511 22512 22513 22514 22515 22516 22517 22518 22519 22520 22521 22522 22523 22524 22525 22526 22527 22528 22529 22530 22531 22532 22533 22534 22535 22536 22537 22538 22539 22540 22541 22542 22543 22544 22545 22546 22547 22548 22549 22550 22551 22552 22553 22554 22555 22556 22557 22558 22559 22560 22561 22562 22563 22564 22565 22566 22567 22568 22569 22570 22571 22572 22573 22574 22575 22576 22577 22578 22579 22580 22581 22582 22583 22584 22585 22586 22587 22588 22589 22590 22591 22592 22593 22594 22595 22596 22597 22598 22599 22600 22601 22602 22603 22604 22605 22606 22607 22608 22609 22610 22611 22612 22613 22614 22615 22616 22617 22618 22619 22620 22621 22622 22623 22624 22625 22626 22627 22628 22629 22630 22631 22632 22633 22634 22635 22636 22637 22638 22639 22640 22641 22642 22643 22644 22645 22646 22647 22648 22649 22650 22651 22652 22653 22654 22655 22656 22657 22658 22659 22660 22661 22662 22663 22664 22665 22666 22667 22668 22669 22670 22671 22672 22673 22674 22675 22676 22677 22678 22679 22680 22681 22682 22683 22684 22685 22686 22687 22688 22689 22690 22691 22692 22693 22694 22695 22696 22697 22698 22699 22700 22701 22702 22703 22704 22705 22706 22707 22708 22709 22710 22711 22712 22713 22714 22715 22716 22717 22718 22719 22720 22721 22722 22723 22724 22725 22726 22727 22728 22729 22730 22731 22732 22733 22734 22735 22736 22737 22738 22739 22740 22741 22742 22743 22744 22745 22746 22747 22748 22749 22750 22751 22752 22753 22754 22755 22756 22757 22758 22759 22760 22761 22762 22763 22764 22765 22766 22767 22768 22769 22770 22771 22772 22773 22774 22775 22776 22777 22778 22779 22780 22781 22782 22783 22784 22785 22786 22787 22788 22789 22790 22791 22792 22793 22794 22795 22796 22797 22798 22799 22800 22801 22802 22803 22804 22805 22806 22807 22808 22809 22810 22811 22812 22813 22814 22815 22816 22817 22818 22819 22820 22821 22822 22823 22824 22825 22826 22827 22828 22829 22830 22831 22832 22833 22834 22835 22836 22837 22838 22839 22840 22841 22842 22843 22844 22845 22846 22847 22848 22849 22850 22851 22852 22853 22854 22855 22856 22857 22858 22859 22860 22861 22862 22863 22864 22865 22866 22867 22868 22869 22870 22871 22872 22873 22874 22875 22876 22877 22878 22879 22880 22881 22882 22883 22884 22885 22886 22887 22888 22889 22890 22891 22892 22893 22894 22895 22896 22897 22898 22899 22900 22901 22902 22903 22904 22905 22906 22907 22908 22909 22910 22911 22912 22913 22914 22915 22916 22917 22918 22919 22920 22921 22922 22923 22924 22925 22926 22927 22928 22929 22930 22931 22932 22933 22934 22935 22936 22937 22938 22939 22940 22941 22942 22943 22944 22945 22946 22947 22948 22949 22950 22951 22952 22953 22954 22955 22956 22957 22958 22959 22960 22961 22962 22963 22964 22965 22966 22967 22968 22969 22970 22971 22972 22973 22974 22975 22976 22977 22978 22979 22980 22981 22982 22983 22984 22985 22986 22987 22988 22989 22990 22991 22992 22993 22994 22995 22996 22997 22998 22999 23000 23001 23002 23003 23004 23005 23006 23007 23008 23009 23010 23011 23012 23013 23014 23015 23016 23017 23018 23019 23020 23021 23022 23023 23024 23025 23026 23027 23028 23029 23030 23031 23032 23033 23034 23035 23036 23037 23038 23039 23040 23041 23042 23043 23044 23045 23046 23047 23048 23049 23050 23051 23052 23053 23054 23055 23056 23057 23058 23059 23060 23061 23062 23063 23064 23065 23066 23067 23068 23069 23070 23071 23072 23073 23074 23075 23076 23077 23078 23079 23080 23081 23082 23083 23084 23085 23086 23087 23088 23089 23090 23091 23092 23093 23094 23095 23096 23097 23098 23099 23100 23101 23102 23103 23104 23105 23106 23107 23108 23109 23110 23111 23112 23113 23114 23115 23116 23117 23118 23119 23120 23121 23122 23123 23124 23125 23126 23127 23128 23129 23130 23131 23132 23133 23134 23135 23136 23137 23138 23139 23140 23141 23142 23143 23144 23145 23146 23147 23148 23149 23150 23151 23152 23153 23154 23155 23156 23157 23158 23159 23160 23161 23162 23163 23164 23165 23166 23167 23168 23169 23170 23171 23172 23173 23174 23175 23176 23177 23178 23179 23180 23181 23182 23183 23184 23185 23186 23187 23188 23189 23190 23191 23192 23193 23194 23195 23196 23197 23198 23199 23200 23201 23202 23203 23204 23205 23206 23207 23208 23209 23210 23211 23212 23213 23214 23215 23216 23217 23218 23219 23220 23221 23222 23223 23224 23225 23226 23227 23228 23229 23230 23231 23232 23233 23234 23235 23236 23237 23238 23239 23240 23241 23242 23243 23244 23245 23246 23247 23248 23249 23250 23251 23252 23253 23254 23255 23256 23257 23258 23259 23260 23261 23262 23263 23264 23265 23266 23267 23268 23269 23270 23271 23272 23273 23274 23275 23276 23277 23278 23279 23280 23281 23282 23283 23284 23285 23286 23287 23288 23289 23290 23291 23292 23293 23294 23295 23296 23297 23298 23299 23300 23301 23302 23303 23304 23305 23306 23307 23308 23309 23310 23311 23312 23313 23314 23315 23316 23317 23318 23319 23320 23321 23322 23323 23324 23325 23326 23327 23328 23329 23330 23331 23332 23333 23334 23335 23336 23337 23338 23339 23340 23341 23342 23343 23344 23345 23346 23347 23348 23349 23350 23351 23352 23353 23354 23355 23356 23357 23358 23359 23360 23361 23362 23363 23364 23365 23366 23367 23368 23369 23370 23371 23372 23373 23374 23375 23376 23377 23378 23379 23380 23381 23382 23383 23384 23385 23386 23387 23388 23389 23390 23391 23392 23393 23394 23395 23396 23397 23398 23399 23400 23401 23402 23403 23404 23405 23406 23407 23408 23409 23410 23411 23412 23413 23414 23415 23416 23417 23418 23419 23420 23421 23422 23423 23424 23425 23426 23427 23428 23429 23430 23431 23432 23433 23434 23435 23436 23437 23438 23439 23440 23441 23442 23443 23444 23445 23446 23447 23448 23449 23450 23451 23452 23453 23454 23455 23456 23457 23458 23459 23460 23461 23462 23463 23464 23465 23466 23467 23468 23469 23470 23471 23472 23473 23474 23475 23476 23477 23478 23479 23480 23481 23482 23483 23484 23485 23486 23487 23488 23489 23490 23491 23492 23493 23494 23495 23496 23497 23498 23499 23500 23501 23502 23503 23504 23505 23506 23507 23508 23509 23510 23511 23512 23513 23514 23515 23516 23517 23518 23519 23520 23521 23522 23523 23524 23525 23526 23527 23528 23529 23530 23531 23532 23533 23534 23535 23536 23537 23538 23539 23540 23541 23542 23543 23544 23545 23546 23547 23548 23549 23550 23551 23552 23553 23554 23555 23556 23557 23558 23559 23560 23561 23562 23563 23564 23565 23566 23567 23568 23569 23570 23571 23572 23573 23574 23575 23576 23577 23578 23579 23580 23581 23582 23583 23584 23585 23586 23587 23588 23589 23590 23591 23592 23593 23594 23595 23596 23597 23598 23599 23600 23601 23602 23603 23604 23605 23606 23607 23608 23609 23610 23611 23612 23613 23614 23615 23616 23617 23618 23619 23620 23621 23622 23623 23624 23625 23626 23627 23628 23629 23630 23631 23632 23633 23634 23635 23636 23637 23638 23639 23640 23641 23642 23643 23644 23645 23646 23647 23648 23649 23650 23651 23652 23653 23654 23655 23656 23657 23658 23659 23660 23661 23662 23663 23664 23665 23666 23667 23668 23669 23670 23671 23672 23673 23674 23675 23676 23677 23678 23679 23680 23681 23682 23683 23684 23685 23686 23687 23688 23689 23690 23691 23692 23693 23694 23695 23696 23697 23698 23699 23700 23701 23702 23703 23704 23705 23706 23707 23708 23709 23710 23711 23712 23713 23714 23715 23716 23717 23718 23719 23720 23721 23722 23723 23724 23725 23726 23727 23728 23729 23730 23731 23732 23733 23734 23735 23736 23737 23738 23739 23740 23741 23742 23743 23744 23745 23746 23747 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(root, factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = root.document ?
factory(root) :
factory;
} else {
root.Highcharts = factory(root);
}
}(typeof window !== 'undefined' ? window : this, function(win) {
var Highcharts = (function() {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/* global window */
var win = window,
doc = win.document;
var SVG_NS = 'http://www.w3.org/2000/svg',
userAgent = (win.navigator && win.navigator.userAgent) || '',
svg = doc && doc.createElementNS && !!doc.createElementNS(SVG_NS, 'svg').createSVGRect,
isMS = /(edge|msie|trident)/i.test(userAgent) && !window.opera,
vml = !svg,
isFirefox = /Firefox/.test(userAgent),
hasBidiBug = isFirefox && parseInt(userAgent.split('Firefox/')[1], 10) < 4; // issue #38
var Highcharts = win.Highcharts ? win.Highcharts.error(16, true) : {
product: 'Highcharts',
version: '5.0.10',
deg2rad: Math.PI * 2 / 360,
doc: doc,
hasBidiBug: hasBidiBug,
hasTouch: doc && doc.documentElement.ontouchstart !== undefined,
isMS: isMS,
isWebKit: /AppleWebKit/.test(userAgent),
isFirefox: isFirefox,
isTouchDevice: /(Mobile|Android|Windows Phone)/.test(userAgent),
SVG_NS: SVG_NS,
chartCount: 0,
seriesTypes: {},
symbolSizes: {},
svg: svg,
vml: vml,
win: win,
charts: [],
marginNames: ['plotTop', 'marginRight', 'marginBottom', 'plotLeft'],
noop: function() {
return undefined;
}
};
return Highcharts;
}());
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/* eslint max-len: ["warn", 80, 4] */
/**
* The Highcharts object is the placeholder for all other members, and various
* utility functions.
* @namespace Highcharts
*/
var timers = [];
var charts = H.charts,
doc = H.doc,
win = H.win;
/**
* Provide error messages for debugging, with links to online explanation. This
* function can be overridden to provide custom error handling.
*
* @function #error
* @memberOf Highcharts
* @param {Number|String} code - The error code. See [errors.xml]{@link
* https://github.com/highcharts/highcharts/blob/master/errors/errors.xml}
* for available codes. If it is a string, the error message is printed
* directly in the console.
* @param {Boolean} [stop=false] - Whether to throw an error or just log a
* warning in the console.
*/
H.error = function(code, stop) {
var msg = H.isNumber(code) ?
'Highcharts error #' + code + ': www.highcharts.com/errors/' + code :
code;
if (stop) {
throw new Error(msg);
}
// else ...
if (win.console) {
console.log(msg); // eslint-disable-line no-console
}
};
/**
* An animator object. One instance applies to one property (attribute or style
* prop) on one element.
*
* @constructor Fx
* @memberOf Highcharts
* @param {HTMLDOMElement|SVGElement} elem - The element to animate.
* @param {AnimationOptions} options - Animation options.
* @param {string} prop - The single attribute or CSS property to animate.
*/
H.Fx = function(elem, options, prop) {
this.options = options;
this.elem = elem;
this.prop = prop;
};
H.Fx.prototype = {
/**
* Set the current step of a path definition on SVGElement.
*
* @function #dSetter
* @memberOf Highcharts.Fx
*/
dSetter: function() {
var start = this.paths[0],
end = this.paths[1],
ret = [],
now = this.now,
i = start.length,
startVal;
// Land on the final path without adjustment points appended in the ends
if (now === 1) {
ret = this.toD;
} else if (i === end.length && now < 1) {
while (i--) {
startVal = parseFloat(start[i]);
ret[i] =
isNaN(startVal) ? // a letter instruction like M or L
start[i] :
now * (parseFloat(end[i] - startVal)) + startVal;
}
// If animation is finished or length not matching, land on right value
} else {
ret = end;
}
this.elem.attr('d', ret, null, true);
},
/**
* Update the element with the current animation step.
*
* @function #update
* @memberOf Highcharts.Fx
*/
update: function() {
var elem = this.elem,
prop = this.prop, // if destroyed, it is null
now = this.now,
step = this.options.step;
// Animation setter defined from outside
if (this[prop + 'Setter']) {
this[prop + 'Setter']();
// Other animations on SVGElement
} else if (elem.attr) {
if (elem.element) {
elem.attr(prop, now, null, true);
}
// HTML styles, raw HTML content like container size
} else {
elem.style[prop] = now + this.unit;
}
if (step) {
step.call(elem, now, this);
}
},
/**
* Run an animation.
*
* @function #run
* @memberOf Highcharts.Fx
* @param {Number} from - The current value, value to start from.
* @param {Number} to - The end value, value to land on.
* @param {String} [unit] - The property unit, for example `px`.
* @returns {void}
*/
run: function(from, to, unit) {
var self = this,
timer = function(gotoEnd) {
return timer.stopped ? false : self.step(gotoEnd);
},
i;
this.startTime = +new Date();
this.start = from;
this.end = to;
this.unit = unit;
this.now = this.start;
this.pos = 0;
timer.elem = this.elem;
timer.prop = this.prop;
if (timer() && timers.push(timer) === 1) {
timer.timerId = setInterval(function() {
for (i = 0; i < timers.length; i++) {
if (!timers[i]()) {
timers.splice(i--, 1);
}
}
if (!timers.length) {
clearInterval(timer.timerId);
}
}, 13);
}
},
/**
* Run a single step in the animation.
*
* @function #step
* @memberOf Highcharts.Fx
* @param {Boolean} [gotoEnd] - Whether to go to the endpoint of the
* animation after abort.
* @returns {Boolean} Returns `true` if animation continues.
*/
step: function(gotoEnd) {
var t = +new Date(),
ret,
done,
options = this.options,
elem = this.elem,
complete = options.complete,
duration = options.duration,
curAnim = options.curAnim,
i;
if (elem.attr && !elem.element) { // #2616, element is destroyed
ret = false;
} else if (gotoEnd || t >= duration + this.startTime) {
this.now = this.end;
this.pos = 1;
this.update();
curAnim[this.prop] = true;
done = true;
for (i in curAnim) {
if (curAnim[i] !== true) {
done = false;
}
}
if (done && complete) {
complete.call(elem);
}
ret = false;
} else {
this.pos = options.easing((t - this.startTime) / duration);
this.now = this.start + ((this.end - this.start) * this.pos);
this.update();
ret = true;
}
return ret;
},
/**
* Prepare start and end values so that the path can be animated one to one.
*
* @function #initPath
* @memberOf Highcharts.Fx
* @param {SVGElement} elem - The SVGElement item.
* @param {String} fromD - Starting path definition.
* @param {Array} toD - Ending path definition.
* @returns {Array} An array containing start and end paths in array form
* so that they can be animated in parallel.
*/
initPath: function(elem, fromD, toD) {
fromD = fromD || '';
var shift,
startX = elem.startX,
endX = elem.endX,
bezier = fromD.indexOf('C') > -1,
numParams = bezier ? 7 : 3,
fullLength,
slice,
i,
start = fromD.split(' '),
end = toD.slice(), // copy
isArea = elem.isArea,
positionFactor = isArea ? 2 : 1,
reverse;
/**
* In splines make moveTo and lineTo points have six parameters like
* bezier curves, to allow animation one-to-one.
*/
function sixify(arr) {
var isOperator,
nextIsOperator;
i = arr.length;
while (i--) {
// Fill in dummy coordinates only if the next operator comes
// three places behind (#5788)
isOperator = arr[i] === 'M' || arr[i] === 'L';
nextIsOperator = /[a-zA-Z]/.test(arr[i + 3]);
if (isOperator && nextIsOperator) {
arr.splice(
i + 1, 0,
arr[i + 1], arr[i + 2],
arr[i + 1], arr[i + 2]
);
}
}
}
/**
* Insert an array at the given position of another array
*/
function insertSlice(arr, subArr, index) {
[].splice.apply(
arr, [index, 0].concat(subArr)
);
}
/**
* If shifting points, prepend a dummy point to the end path.
*/
function prepend(arr, other) {
while (arr.length < fullLength) {
// Move to, line to or curve to?
arr[0] = other[fullLength - arr.length];
// Prepend a copy of the first point
insertSlice(arr, arr.slice(0, numParams), 0);
// For areas, the bottom path goes back again to the left, so we
// need to append a copy of the last point.
if (isArea) {
insertSlice(
arr,
arr.slice(arr.length - numParams), arr.length
);
i--;
}
}
arr[0] = 'M';
}
/**
* Copy and append last point until the length matches the end length
*/
function append(arr, other) {
var i = (fullLength - arr.length) / numParams;
while (i > 0 && i--) {
// Pull out the slice that is going to be appended or inserted.
// In a line graph, the positionFactor is 1, and the last point
// is sliced out. In an area graph, the positionFactor is 2,
// causing the middle two points to be sliced out, since an area
// path starts at left, follows the upper path then turns and
// follows the bottom back.
slice = arr.slice().splice(
(arr.length / positionFactor) - numParams,
numParams * positionFactor
);
// Move to, line to or curve to?
slice[0] = other[fullLength - numParams - (i * numParams)];
// Disable first control point
if (bezier) {
slice[numParams - 6] = slice[numParams - 2];
slice[numParams - 5] = slice[numParams - 1];
}
// Now insert the slice, either in the middle (for areas) or at
// the end (for lines)
insertSlice(arr, slice, arr.length / positionFactor);
if (isArea) {
i--;
}
}
}
if (bezier) {
sixify(start);
sixify(end);
}
// For sideways animation, find out how much we need to shift to get the
// start path Xs to match the end path Xs.
if (startX && endX) {
for (i = 0; i < startX.length; i++) {
// Moving left, new points coming in on right
if (startX[i] === endX[0]) {
shift = i;
break;
// Moving right
} else if (startX[0] ===
endX[endX.length - startX.length + i]) {
shift = i;
reverse = true;
break;
}
}
if (shift === undefined) {
start = [];
}
}
if (start.length && H.isNumber(shift)) {
// The common target length for the start and end array, where both
// arrays are padded in opposite ends
fullLength = end.length + shift * positionFactor * numParams;
if (!reverse) {
prepend(end, start);
append(start, end);
} else {
prepend(start, end);
append(end, start);
}
}
return [start, end];
}
}; // End of Fx prototype
/**
* Utility function to extend an object with the members of another.
*
* @function #extend
* @memberOf Highcharts
* @param {Object} a - The object to be extended.
* @param {Object} b - The object to add to the first one.
* @returns {Object} Object a, the original object.
*/
H.extend = function(a, b) {
var n;
if (!a) {
a = {};
}
for (n in b) {
a[n] = b[n];
}
return a;
};
/**
* Utility function to deep merge two or more objects and return a third object.
* If the first argument is true, the contents of the second object is copied
* into the first object. The merge function can also be used with a single
* object argument to create a deep copy of an object.
*
* @function #merge
* @memberOf Highcharts
* @param {Boolean} [extend] - Whether to extend the left-side object (a) or
return a whole new object.
* @param {Object} a - The first object to extend. When only this is given, the
function returns a deep copy.
* @param {...Object} [n] - An object to merge into the previous one.
* @returns {Object} - The merged object. If the first argument is true, the
* return is the same as the second argument.
*/
H.merge = function() {
var i,
args = arguments,
len,
ret = {},
doCopy = function(copy, original) {
var value, key;
// An object is replacing a primitive
if (typeof copy !== 'object') {
copy = {};
}
for (key in original) {
if (original.hasOwnProperty(key)) {
value = original[key];
// Copy the contents of objects, but not arrays or DOM nodes
if (H.isObject(value, true) &&
key !== 'renderTo' &&
typeof value.nodeType !== 'number') {
copy[key] = doCopy(copy[key] || {}, value);
// Primitives and arrays are copied over directly
} else {
copy[key] = original[key];
}
}
}
return copy;
};
// If first argument is true, copy into the existing object. Used in
// setOptions.
if (args[0] === true) {
ret = args[1];
args = Array.prototype.slice.call(args, 2);
}
// For each argument, extend the return
len = args.length;
for (i = 0; i < len; i++) {
ret = doCopy(ret, args[i]);
}
return ret;
};
/**
* Shortcut for parseInt
* @ignore
* @param {Object} s
* @param {Number} mag Magnitude
*/
H.pInt = function(s, mag) {
return parseInt(s, mag || 10);
};
/**
* Utility function to check for string type.
*
* @function #isString
* @memberOf Highcharts
* @param {Object} s - The item to check.
* @returns {Boolean} - True if the argument is a string.
*/
H.isString = function(s) {
return typeof s === 'string';
};
/**
* Utility function to check if an item is an array.
*
* @function #isArray
* @memberOf Highcharts
* @param {Object} obj - The item to check.
* @returns {Boolean} - True if the argument is an array.
*/
H.isArray = function(obj) {
var str = Object.prototype.toString.call(obj);
return str === '[object Array]' || str === '[object Array Iterator]';
};
/**
* Utility function to check if an item is of type object.
*
* @function #isObject
* @memberOf Highcharts
* @param {Object} obj - The item to check.
* @param {Boolean} [strict=false] - Also checks that the object is not an
* array.
* @returns {Boolean} - True if the argument is an object.
*/
H.isObject = function(obj, strict) {
return obj && typeof obj === 'object' && (!strict || !H.isArray(obj));
};
/**
* Utility function to check if an item is of type number.
*
* @function #isNumber
* @memberOf Highcharts
* @param {Object} n - The item to check.
* @returns {Boolean} - True if the item is a number and is not NaN.
*/
H.isNumber = function(n) {
return typeof n === 'number' && !isNaN(n);
};
/**
* Remove the last occurence of an item from an array.
*
* @function #erase
* @memberOf Highcharts
* @param {Array} arr - The array.
* @param {*} item - The item to remove.
*/
H.erase = function(arr, item) {
var i = arr.length;
while (i--) {
if (arr[i] === item) {
arr.splice(i, 1);
break;
}
}
};
/**
* Check if an object is null or undefined.
*
* @function #defined
* @memberOf Highcharts
* @param {Object} obj - The object to check.
* @returns {Boolean} - False if the object is null or undefined, otherwise
* true.
*/
H.defined = function(obj) {
return obj !== undefined && obj !== null;
};
/**
* Set or get an attribute or an object of attributes. To use as a setter, pass
* a key and a value, or let the second argument be a collection of keys and
* values. To use as a getter, pass only a string as the second argument.
*
* @function #attr
* @memberOf Highcharts
* @param {Object} elem - The DOM element to receive the attribute(s).
* @param {String|Object} [prop] - The property or an object of key-value pairs.
* @param {String} [value] - The value if a single property is set.
* @returns {*} When used as a getter, return the value.
*/
H.attr = function(elem, prop, value) {
var key,
ret;
// if the prop is a string
if (H.isString(prop)) {
// set the value
if (H.defined(value)) {
elem.setAttribute(prop, value);
// get the value
} else if (elem && elem.getAttribute) {
ret = elem.getAttribute(prop);
}
// else if prop is defined, it is a hash of key/value pairs
} else if (H.defined(prop) && H.isObject(prop)) {
for (key in prop) {
elem.setAttribute(key, prop[key]);
}
}
return ret;
};
/**
* Check if an element is an array, and if not, make it into an array.
*
* @function #splat
* @memberOf Highcharts
* @param obj {*} - The object to splat.
* @returns {Array} The produced or original array.
*/
H.splat = function(obj) {
return H.isArray(obj) ? obj : [obj];
};
/**
* Set a timeout if the delay is given, otherwise perform the function
* synchronously.
*
* @function #syncTimeout
* @memberOf Highcharts
* @param {Function} fn - The function callback.
* @param {Number} delay - Delay in milliseconds.
* @param {Object} [context] - The context.
* @returns {Number} An identifier for the timeout that can later be cleared
* with clearTimeout.
*/
H.syncTimeout = function(fn, delay, context) {
if (delay) {
return setTimeout(fn, delay, context);
}
fn.call(0, context);
};
/**
* Return the first value that is not null or undefined.
*
* @function #pick
* @memberOf Highcharts
* @param {...*} items - Variable number of arguments to inspect.
* @returns {*} The value of the first argument that is not null or undefined.
*/
H.pick = function() {
var args = arguments,
i,
arg,
length = args.length;
for (i = 0; i < length; i++) {
arg = args[i];
if (arg !== undefined && arg !== null) {
return arg;
}
}
};
/**
* @typedef {Object} CSSObject - A style object with camel case property names.
* The properties can be whatever styles are supported on the given SVG or HTML
* element.
* @example
* {
* fontFamily: 'monospace',
* fontSize: '1.2em'
* }
*/
/**
* Set CSS on a given element.
*
* @function #css
* @memberOf Highcharts
* @param {HTMLDOMElement} el - A HTML DOM element.
* @param {CSSObject} styles - Style object with camel case property names.
* @returns {void}
*/
H.css = function(el, styles) {
if (H.isMS && !H.svg) { // #2686
if (styles && styles.opacity !== undefined) {
styles.filter = 'alpha(opacity=' + (styles.opacity * 100) + ')';
}
}
H.extend(el.style, styles);
};
/**
* A HTML DOM element.
* @typedef {Object} HTMLDOMElement
*/
/**
* Utility function to create an HTML element with attributes and styles.
*
* @function #createElement
* @memberOf Highcharts
* @param {String} tag - The HTML tag.
* @param {Object} [attribs] - Attributes as an object of key-value pairs.
* @param {CSSObject} [styles] - Styles as an object of key-value pairs.
* @param {Object} [parent] - The parent HTML object.
* @param {Boolean} [nopad=false] - If true, remove all padding, border and
* margin.
* @returns {HTMLDOMElement} The created DOM element.
*/
H.createElement = function(tag, attribs, styles, parent, nopad) {
var el = doc.createElement(tag),
css = H.css;
if (attribs) {
H.extend(el, attribs);
}
if (nopad) {
css(el, {
padding: 0,
border: 'none',
margin: 0
});
}
if (styles) {
css(el, styles);
}
if (parent) {
parent.appendChild(el);
}
return el;
};
/**
* Extend a prototyped class by new members.
*
* @function #extendClass
* @memberOf Highcharts
* @param {Object} parent - The parent prototype to inherit.
* @param {Object} members - A collection of prototype members to add or
* override compared to the parent prototype.
* @returns {Object} A new prototype.
*/
H.extendClass = function(parent, members) {
var object = function() {};
object.prototype = new parent(); // eslint-disable-line new-cap
H.extend(object.prototype, members);
return object;
};
/**
* Left-pad a string to a given length by adding a character repetetively.
*
* @function #pad
* @memberOf Highcharts
* @param {Number} number - The input string or number.
* @param {Number} length - The desired string length.
* @param {String} [padder=0] - The character to pad with.
* @returns {String} The padded string.
*/
H.pad = function(number, length, padder) {
return new Array((length || 2) + 1 -
String(number).length).join(padder || 0) + number;
};
/**
* @typedef {Number|String} RelativeSize - If a number is given, it defines the
* pixel length. If a percentage string is given, like for example `'50%'`,
* the setting defines a length relative to a base size, for example the size
* of a container.
*/
/**
* Return a length based on either the integer value, or a percentage of a base.
*
* @function #relativeLength
* @memberOf Highcharts
* @param {RelativeSize} value - A percentage string or a number.
* @param {Number} base - The full length that represents 100%.
* @returns {Number} The computed length.
*/
H.relativeLength = function(value, base) {
return (/%$/).test(value) ?
base * parseFloat(value) / 100 :
parseFloat(value);
};
/**
* Wrap a method with extended functionality, preserving the original function.
*
* @function #wrap
* @memberOf Highcharts
* @param {Object} obj - The context object that the method belongs to. In real
* cases, this is often a prototype.
* @param {String} method - The name of the method to extend.
* @param {Function} func - A wrapper function callback. This function is called
* with the same arguments as the original function, except that the
* original function is unshifted and passed as the first argument.
* @returns {void}
*/
H.wrap = function(obj, method, func) {
var proceed = obj[method];
obj[method] = function() {
var args = Array.prototype.slice.call(arguments),
outerArgs = arguments,
ctx = this,
ret;
ctx.proceed = function() {
proceed.apply(ctx, arguments.length ? arguments : outerArgs);
};
args.unshift(proceed);
ret = func.apply(this, args);
ctx.proceed = null;
return ret;
};
};
/**
* Get the time zone offset based on the current timezone information as set in
* the global options.
*
* @function #getTZOffset
* @memberOf Highcharts
* @param {Number} timestamp - The JavaScript timestamp to inspect.
* @return {Number} - The timezone offset in minutes compared to UTC.
*/
H.getTZOffset = function(timestamp) {
var d = H.Date;
return ((d.hcGetTimezoneOffset && d.hcGetTimezoneOffset(timestamp)) ||
d.hcTimezoneOffset || 0) * 60000;
};
/**
* Format a date, based on the syntax for PHP's [strftime]{@link
* http://www.php.net/manual/en/function.strftime.php} function.
*
* @function #dateFormat
* @memberOf Highcharts
* @param {String} format - The desired format where various time
* representations are prefixed with %.
* @param {Number} timestamp - The JavaScript timestamp.
* @param {Boolean} [capitalize=false] - Upper case first letter in the return.
* @returns {String} The formatted date.
*/
H.dateFormat = function(format, timestamp, capitalize) {
if (!H.defined(timestamp) || isNaN(timestamp)) {
return H.defaultOptions.lang.invalidDate || '';
}
format = H.pick(format, '%Y-%m-%d %H:%M:%S');
var D = H.Date,
date = new D(timestamp - H.getTZOffset(timestamp)),
key, // used in for constuct below
// get the basic time values
hours = date[D.hcGetHours](),
day = date[D.hcGetDay](),
dayOfMonth = date[D.hcGetDate](),
month = date[D.hcGetMonth](),
fullYear = date[D.hcGetFullYear](),
lang = H.defaultOptions.lang,
langWeekdays = lang.weekdays,
shortWeekdays = lang.shortWeekdays,
pad = H.pad,
// List all format keys. Custom formats can be added from the outside.
replacements = H.extend({
//-- Day
// Short weekday, like 'Mon'
'a': shortWeekdays ?
shortWeekdays[day] : langWeekdays[day].substr(0, 3),
// Long weekday, like 'Monday'
'A': langWeekdays[day],
// Two digit day of the month, 01 to 31
'd': pad(dayOfMonth),
// Day of the month, 1 through 31
'e': pad(dayOfMonth, 2, ' '),
'w': day,
// Week (none implemented)
//'W': weekNumber(),
//-- Month
// Short month, like 'Jan'
'b': lang.shortMonths[month],
// Long month, like 'January'
'B': lang.months[month],
// Two digit month number, 01 through 12
'm': pad(month + 1),
//-- Year
// Two digits year, like 09 for 2009
'y': fullYear.toString().substr(2, 2),
// Four digits year, like 2009
'Y': fullYear,
//-- Time
// Two digits hours in 24h format, 00 through 23
'H': pad(hours),
// Hours in 24h format, 0 through 23
'k': hours,
// Two digits hours in 12h format, 00 through 11
'I': pad((hours % 12) || 12),
// Hours in 12h format, 1 through 12
'l': (hours % 12) || 12,
// Two digits minutes, 00 through 59
'M': pad(date[D.hcGetMinutes]()),
// Upper case AM or PM
'p': hours < 12 ? 'AM' : 'PM',
// Lower case AM or PM
'P': hours < 12 ? 'am' : 'pm',
// Two digits seconds, 00 through 59
'S': pad(date.getSeconds()),
// Milliseconds (naming from Ruby)
'L': pad(Math.round(timestamp % 1000), 3)
}, H.dateFormats);
// Do the replaces
for (key in replacements) {
// Regex would do it in one line, but this is faster
while (format.indexOf('%' + key) !== -1) {
format = format.replace(
'%' + key,
typeof replacements[key] === 'function' ?
replacements[key](timestamp) :
replacements[key]
);
}
}
// Optionally capitalize the string and return
return capitalize ?
format.substr(0, 1).toUpperCase() + format.substr(1) :
format;
};
/**
* Format a single variable. Similar to sprintf, without the % prefix.
*
* @example
* formatSingle('.2f', 5); // => '5.00'.
*
* @function #formatSingle
* @memberOf Highcharts
* @param {String} format The format string.
* @param {*} val The value.
* @returns {String} The formatted representation of the value.
*/
H.formatSingle = function(format, val) {
var floatRegex = /f$/,
decRegex = /\.([0-9])/,
lang = H.defaultOptions.lang,
decimals;
if (floatRegex.test(format)) { // float
decimals = format.match(decRegex);
decimals = decimals ? decimals[1] : -1;
if (val !== null) {
val = H.numberFormat(
val,
decimals,
lang.decimalPoint,
format.indexOf(',') > -1 ? lang.thousandsSep : ''
);
}
} else {
val = H.dateFormat(format, val);
}
return val;
};
/**
* Format a string according to a subset of the rules of Python's String.format
* method.
*
* @function #format
* @memberOf Highcharts
* @param {String} str The string to format.
* @param {Object} ctx The context, a collection of key-value pairs where each
* key is replaced by its value.
* @returns {String} The formatted string.
*
* @example
* var s = Highcharts.format(
* 'The {color} fox was {len:.2f} feet long',
* { color: 'red', len: Math.PI }
* );
* // => The red fox was 3.14 feet long
*/
H.format = function(str, ctx) {
var splitter = '{',
isInside = false,
segment,
valueAndFormat,
path,
i,
len,
ret = [],
val,
index;
while (str) {
index = str.indexOf(splitter);
if (index === -1) {
break;
}
segment = str.slice(0, index);
if (isInside) { // we're on the closing bracket looking back
valueAndFormat = segment.split(':');
path = valueAndFormat.shift().split('.'); // get first and leave
len = path.length;
val = ctx;
// Assign deeper paths
for (i = 0; i < len; i++) {
val = val[path[i]];
}
// Format the replacement
if (valueAndFormat.length) {
val = H.formatSingle(valueAndFormat.join(':'), val);
}
// Push the result and advance the cursor
ret.push(val);
} else {
ret.push(segment);
}
str = str.slice(index + 1); // the rest
isInside = !isInside; // toggle
splitter = isInside ? '}' : '{'; // now look for next matching bracket
}
ret.push(str);
return ret.join('');
};
/**
* Get the magnitude of a number.
*
* @function #getMagnitude
* @memberOf Highcharts
* @param {Number} number The number.
* @returns {Number} The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2
* etc.
*/
H.getMagnitude = function(num) {
return Math.pow(10, Math.floor(Math.log(num) / Math.LN10));
};
/**
* Take an interval and normalize it to multiples of round numbers.
*
* @todo Move this function to the Axis prototype. It is here only for
* historical reasons.
* @function #normalizeTickInterval
* @memberOf Highcharts
* @param {Number} interval - The raw, un-rounded interval.
* @param {Array} [multiples] - Allowed multiples.
* @param {Number} [magnitude] - The magnitude of the number.
* @param {Boolean} [allowDecimals] - Whether to allow decimals.
* @param {Boolean} [hasTickAmount] - If it has tickAmount, avoid landing
* on tick intervals lower than original.
* @returns {Number} The normalized interval.
*/
H.normalizeTickInterval = function(interval, multiples, magnitude,
allowDecimals, hasTickAmount) {
var normalized,
i,
retInterval = interval;
// round to a tenfold of 1, 2, 2.5 or 5
magnitude = H.pick(magnitude, 1);
normalized = interval / magnitude;
// multiples for a linear scale
if (!multiples) {
multiples = hasTickAmount ?
// Finer grained ticks when the tick amount is hard set, including
// when alignTicks is true on multiple axes (#4580).
[1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :
// Else, let ticks fall on rounder numbers
[1, 2, 2.5, 5, 10];
// the allowDecimals option
if (allowDecimals === false) {
if (magnitude === 1) {
multiples = H.grep(multiples, function(num) {
return num % 1 === 0;
});
} else if (magnitude <= 0.1) {
multiples = [1 / magnitude];
}
}
}
// normalize the interval to the nearest multiple
for (i = 0; i < multiples.length; i++) {
retInterval = multiples[i];
// only allow tick amounts smaller than natural
if ((hasTickAmount && retInterval * magnitude >= interval) ||
(!hasTickAmount && (normalized <= (multiples[i] +
(multiples[i + 1] || multiples[i])) / 2))) {
break;
}
}
// Multiply back to the correct magnitude. Correct floats to appropriate
// precision (#6085).
retInterval = H.correctFloat(
retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10)
);
return retInterval;
};
/**
* Sort an object array and keep the order of equal items. The ECMAScript
* standard does not specify the behaviour when items are equal.
*
* @function #stableSort
* @memberOf Highcharts
* @param {Array} arr - The array to sort.
* @param {Function} sortFunction - The function to sort it with, like with
* regular Array.prototype.sort.
* @returns {void}
*/
H.stableSort = function(arr, sortFunction) {
var length = arr.length,
sortValue,
i;
// Add index to each item
for (i = 0; i < length; i++) {
arr[i].safeI = i; // stable sort index
}
arr.sort(function(a, b) {
sortValue = sortFunction(a, b);
return sortValue === 0 ? a.safeI - b.safeI : sortValue;
});
// Remove index from items
for (i = 0; i < length; i++) {
delete arr[i].safeI; // stable sort index
}
};
/**
* Non-recursive method to find the lowest member of an array. `Math.min` raises
* a maximum call stack size exceeded error in Chrome when trying to apply more
* than 150.000 points. This method is slightly slower, but safe.
*
* @function #arrayMin
* @memberOf Highcharts
* @param {Array} data An array of numbers.
* @returns {Number} The lowest number.
*/
H.arrayMin = function(data) {
var i = data.length,
min = data[0];
while (i--) {
if (data[i] < min) {
min = data[i];
}
}
return min;
};
/**
* Non-recursive method to find the lowest member of an array. `Math.max` raises
* a maximum call stack size exceeded error in Chrome when trying to apply more
* than 150.000 points. This method is slightly slower, but safe.
*
* @function #arrayMax
* @memberOf Highcharts
* @param {Array} data - An array of numbers.
* @returns {Number} The highest number.
*/
H.arrayMax = function(data) {
var i = data.length,
max = data[0];
while (i--) {
if (data[i] > max) {
max = data[i];
}
}
return max;
};
/**
* Utility method that destroys any SVGElement instances that are properties on
* the given object. It loops all properties and invokes destroy if there is a
* destroy method. The property is then delete.
*
* @function #destroyObjectProperties
* @memberOf Highcharts
* @param {Object} obj - The object to destroy properties on.
* @param {Object} [except] - Exception, do not destroy this property, only
* delete it.
* @returns {void}
*/
H.destroyObjectProperties = function(obj, except) {
var n;
for (n in obj) {
// If the object is non-null and destroy is defined
if (obj[n] && obj[n] !== except && obj[n].destroy) {
// Invoke the destroy
obj[n].destroy();
}
// Delete the property from the object.
delete obj[n];
}
};
/**
* Discard a HTML element by moving it to the bin and delete.
*
* @function #discardElement
* @memberOf Highcharts
* @param {HTMLDOMElement} element - The HTML node to discard.
* @returns {void}
*/
H.discardElement = function(element) {
var garbageBin = H.garbageBin;
// create a garbage bin element, not part of the DOM
if (!garbageBin) {
garbageBin = H.createElement('div');
}
// move the node and empty bin
if (element) {
garbageBin.appendChild(element);
}
garbageBin.innerHTML = '';
};
/**
* Fix JS round off float errors.
*
* @function #correctFloat
* @memberOf Highcharts
* @param {Number} num - A float number to fix.
* @param {Number} [prec=14] - The precision.
* @returns {Number} The corrected float number.
*/
H.correctFloat = function(num, prec) {
return parseFloat(
num.toPrecision(prec || 14)
);
};
/**
* Set the global animation to either a given value, or fall back to the given
* chart's animation option.
*
* @function #setAnimation
* @memberOf Highcharts
* @param {Boolean|Animation} animation - The animation object.
* @param {Object} chart - The chart instance.
* @returns {void}
* @todo This function always relates to a chart, and sets a property on the
* renderer, so it should be moved to the SVGRenderer.
*/
H.setAnimation = function(animation, chart) {
chart.renderer.globalAnimation = H.pick(
animation,
chart.options.chart.animation,
true
);
};
/**
* Get the animation in object form, where a disabled animation is always
* returned as `{ duration: 0 }`.
*
* @function #animObject
* @memberOf Highcharts
* @param {Boolean|AnimationOptions} animation - An animation setting. Can be an
* object with duration, complete and easing properties, or a boolean to
* enable or disable.
* @returns {AnimationOptions} An object with at least a duration property.
*/
H.animObject = function(animation) {
return H.isObject(animation) ?
H.merge(animation) : {
duration: animation ? 500 : 0
};
};
/**
* The time unit lookup
*/
H.timeUnits = {
millisecond: 1,
second: 1000,
minute: 60000,
hour: 3600000,
day: 24 * 3600000,
week: 7 * 24 * 3600000,
month: 28 * 24 * 3600000,
year: 364 * 24 * 3600000
};
/**
* Format a number and return a string based on input settings.
*
* @function #numberFormat
* @memberOf Highcharts
* @param {Number} number - The input number to format.
* @param {Number} decimals - The amount of decimals. A value of -1 preserves
* the amount in the input number.
* @param {String} [decimalPoint] - The decimal point, defaults to the one given
* in the lang options.
* @param {String} [thousandsSep] - The thousands separator, defaults to the one
* given in the lang options.
* @returns {String} The formatted number.
*/
H.numberFormat = function(number, decimals, decimalPoint, thousandsSep) {
number = +number || 0;
decimals = +decimals;
var lang = H.defaultOptions.lang,
origDec = (number.toString().split('.')[1] || '').length,
strinteger,
thousands,
ret,
roundedNumber;
if (decimals === -1) {
// Preserve decimals. Not huge numbers (#3793).
decimals = Math.min(origDec, 20);
} else if (!H.isNumber(decimals)) {
decimals = 2;
}
// Add another decimal to avoid rounding errors of float numbers. (#4573)
// Then use toFixed to handle rounding.
roundedNumber = (
Math.abs(number) + Math.pow(10, -Math.max(decimals, origDec) - 1)
).toFixed(decimals);
// A string containing the positive integer component of the number
strinteger = String(H.pInt(roundedNumber));
// Leftover after grouping into thousands. Can be 0, 1 or 3.
thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;
// Language
decimalPoint = H.pick(decimalPoint, lang.decimalPoint);
thousandsSep = H.pick(thousandsSep, lang.thousandsSep);
// Start building the return
ret = number < 0 ? '-' : '';
// Add the leftover after grouping into thousands. For example, in the
// number 42 000 000, this line adds 42.
ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';
// Add the remaining thousands groups, joined by the thousands separator
ret += strinteger
.substr(thousands)
.replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);
// Add the decimal point and the decimal component
if (decimals) {
// Get the decimal component
ret += decimalPoint + roundedNumber.slice(-decimals);
}
return ret;
};
/**
* Easing definition
* @ignore
* @param {Number} pos Current position, ranging from 0 to 1.
*/
Math.easeInOutSine = function(pos) {
return -0.5 * (Math.cos(Math.PI * pos) - 1);
};
/**
* Get the computed CSS value for given element and property, only for numerical
* properties. For width and height, the dimension of the inner box (excluding
* padding) is returned. Used for fitting the chart within the container.
*
* @function #getStyle
* @memberOf Highcharts
* @param {HTMLDOMElement} el - A HTML element.
* @param {String} prop - The property name.
* @returns {Number} - The numeric value.
*/
H.getStyle = function(el, prop) {
var style;
// For width and height, return the actual inner pixel size (#4913)
if (prop === 'width') {
return Math.min(el.offsetWidth, el.scrollWidth) -
H.getStyle(el, 'padding-left') -
H.getStyle(el, 'padding-right');
} else if (prop === 'height') {
return Math.min(el.offsetHeight, el.scrollHeight) -
H.getStyle(el, 'padding-top') -
H.getStyle(el, 'padding-bottom');
}
// Otherwise, get the computed style
style = win.getComputedStyle(el, undefined);
return style && H.pInt(style.getPropertyValue(prop));
};
/**
* Search for an item in an array.
*
* @function #inArray
* @memberOf Highcharts
* @param {*} item - The item to search for.
* @param {arr} arr - The array or node collection to search in.
* @returns {Number} - The index within the array, or -1 if not found.
*/
H.inArray = function(item, arr) {
return arr.indexOf ? arr.indexOf(item) : [].indexOf.call(arr, item);
};
/**
* Filter an array by a callback.
*
* @function #grep
* @memberOf Highcharts
* @param {Array} arr - The array to filter.
* @param {Function} callback - The callback function. The function receives the
* item as the first argument. Return `true` if the item is to be
* preserved.
* @returns {Array} - A new, filtered array.
*/
H.grep = function(arr, callback) {
return [].filter.call(arr, callback);
};
/**
* Return the value of the first element in the array that satisfies the
* provided testing function.
*
* @function #find
* @memberOf Highcharts
* @param {Array} arr - The array to test.
* @param {Function} callback - The callback function. The function receives the
* item as the first argument. Return `true` if this item satisfies the
* condition.
* @returns {Mixed} - The value of the element.
*/
H.find = function(arr, callback) {
return [].find.call(arr, callback);
};
/**
* Map an array by a callback.
*
* @function #map
* @memberOf Highcharts
* @param {Array} arr - The array to map.
* @param {Function} fn - The callback function. Return the new value for the
* new array.
* @returns {Array} - A new array item with modified items.
*/
H.map = function(arr, fn) {
var results = [],
i = 0,
len = arr.length;
for (; i < len; i++) {
results[i] = fn.call(arr[i], arr[i], i, arr);
}
return results;
};
/**
* Get the element's offset position, corrected for `overflow: auto`.
*
* @function #offset
* @memberOf Highcharts
* @param {HTMLDOMElement} el - The HTML element.
* @returns {Object} An object containing `left` and `top` properties for the
* position in the page.
*/
H.offset = function(el) {
var docElem = doc.documentElement,
box = el.getBoundingClientRect();
return {
top: box.top + (win.pageYOffset || docElem.scrollTop) -
(docElem.clientTop || 0),
left: box.left + (win.pageXOffset || docElem.scrollLeft) -
(docElem.clientLeft || 0)
};
};
/**
* Stop running animation.
*
* @todo A possible extension to this would be to stop a single property, when
* we want to continue animating others. Then assign the prop to the timer
* in the Fx.run method, and check for the prop here. This would be an
* improvement in all cases where we stop the animation from .attr. Instead of
* stopping everything, we can just stop the actual attributes we're setting.
*
* @function #stop
* @memberOf Highcharts
* @param {SVGElement} el - The SVGElement to stop animation on.
* @param {string} [prop] - The property to stop animating. If given, the stop
* method will stop a single property from animating, while others continue.
* @returns {void}
*/
H.stop = function(el, prop) {
var i = timers.length;
// Remove timers related to this element (#4519)
while (i--) {
if (timers[i].elem === el && (!prop || prop === timers[i].prop)) {
timers[i].stopped = true; // #4667
}
}
};
/**
* Iterate over an array.
*
* @function #each
* @memberOf Highcharts
* @param {Array} arr - The array to iterate over.
* @param {Function} fn - The iterator callback. It passes three arguments:
* * item - The array item.
* * index - The item's index in the array.
* * arr - The array that each is being applied to.
* @param {Object} [ctx] The context.
*/
H.each = function(arr, fn, ctx) { // modern browsers
return Array.prototype.forEach.call(arr, fn, ctx);
};
/**
* Add an event listener.
*
* @function #addEvent
* @memberOf Highcharts
* @param {Object} el - The element or object to add a listener to. It can be a
* {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
* @param {String} type - The event type.
* @param {Function} fn - The function callback to execute when the event is
* fired.
* @returns {Function} A callback function to remove the added event.
*/
H.addEvent = function(el, type, fn) {
var events = el.hcEvents = el.hcEvents || {};
function wrappedFn(e) {
e.target = e.srcElement || win; // #2820
fn.call(el, e);
}
// Handle DOM events in modern browsers
if (el.addEventListener) {
el.addEventListener(type, fn, false);
// Handle old IE implementation
} else if (el.attachEvent) {
if (!el.hcEventsIE) {
el.hcEventsIE = {};
}
// Link wrapped fn with original fn, so we can get this in removeEvent
el.hcEventsIE[fn.toString()] = wrappedFn;
el.attachEvent('on' + type, wrappedFn);
}
if (!events[type]) {
events[type] = [];
}
events[type].push(fn);
// Return a function that can be called to remove this event.
return function() {
H.removeEvent(el, type, fn);
};
};
/**
* Remove an event that was added with {@link Highcharts#addEvent}.
*
* @function #removeEvent
* @memberOf Highcharts
* @param {Object} el - The element to remove events on.
* @param {String} [type] - The type of events to remove. If undefined, all
* events are removed from the element.
* @param {Function} [fn] - The specific callback to remove. If undefined, all
* events that match the element and optionally the type are removed.
* @returns {void}
*/
H.removeEvent = function(el, type, fn) {
var events,
hcEvents = el.hcEvents,
index;
function removeOneEvent(type, fn) {
if (el.removeEventListener) {
el.removeEventListener(type, fn, false);
} else if (el.attachEvent) {
fn = el.hcEventsIE[fn.toString()];
el.detachEvent('on' + type, fn);
}
}
function removeAllEvents() {
var types,
len,
n;
if (!el.nodeName) {
return; // break on non-DOM events
}
if (type) {
types = {};
types[type] = true;
} else {
types = hcEvents;
}
for (n in types) {
if (hcEvents[n]) {
len = hcEvents[n].length;
while (len--) {
removeOneEvent(n, hcEvents[n][len]);
}
}
}
}
if (hcEvents) {
if (type) {
events = hcEvents[type] || [];
if (fn) {
index = H.inArray(fn, events);
if (index > -1) {
events.splice(index, 1);
hcEvents[type] = events;
}
removeOneEvent(type, fn);
} else {
removeAllEvents();
hcEvents[type] = [];
}
} else {
removeAllEvents();
el.hcEvents = {};
}
}
};
/**
* Fire an event that was registered with {@link Highcharts#addEvent}.
*
* @function #fireEvent
* @memberOf Highcharts
* @param {Object} el - The object to fire the event on. It can be a
* {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
* @param {String} type - The type of event.
* @param {Object} [eventArguments] - Custom event arguments that are passed on
* as an argument to the event handler.
* @param {Function} [defaultFunction] - The default function to execute if the
* other listeners haven't returned false.
* @returns {void}
*/
H.fireEvent = function(el, type, eventArguments, defaultFunction) {
var e,
hcEvents = el.hcEvents,
events,
len,
i,
fn;
eventArguments = eventArguments || {};
if (doc.createEvent && (el.dispatchEvent || el.fireEvent)) {
e = doc.createEvent('Events');
e.initEvent(type, true, true);
//e.target = el;
H.extend(e, eventArguments);
if (el.dispatchEvent) {
el.dispatchEvent(e);
} else {
el.fireEvent(type, e);
}
} else if (hcEvents) {
events = hcEvents[type] || [];
len = events.length;
if (!eventArguments.target) { // We're running a custom event
H.extend(eventArguments, {
// Attach a simple preventDefault function to skip default
// handler if called. The built-in defaultPrevented property is
// not overwritable (#5112)
preventDefault: function() {
eventArguments.defaultPrevented = true;
},
// Setting target to native events fails with clicking the
// zoom-out button in Chrome.
target: el,
// If the type is not set, we're running a custom event (#2297).
// If it is set, we're running a browser event, and setting it
// will cause en error in IE8 (#2465).
type: type
});
}
for (i = 0; i < len; i++) {
fn = events[i];
// If the event handler return false, prevent the default handler
// from executing
if (fn && fn.call(el, eventArguments) === false) {
eventArguments.preventDefault();
}
}
}
// Run the default if not prevented
if (defaultFunction && !eventArguments.defaultPrevented) {
defaultFunction(eventArguments);
}
};
/**
* An animation configuration. Animation configurations can also be defined as
* booleans, where `false` turns off animation and `true` defaults to a duration
* of 500ms.
* @typedef {Object} AnimationOptions
* @property {Number} duration - The animation duration in milliseconds.
* @property {String} [easing] - The name of an easing function as defined on
* the `Math` object.
* @property {Function} [complete] - A callback function to exectute when the
* animation finishes.
* @property {Function} [step] - A callback function to execute on each step of
* each attribute or CSS property that's being animated. The first argument
* contains information about the animation and progress.
*/
/**
* The global animate method, which uses Fx to create individual animators.
*
* @function #animate
* @memberOf Highcharts
* @param {HTMLDOMElement|SVGElement} el - The element to animate.
* @param {Object} params - An object containing key-value pairs of the
* properties to animate. Supports numeric as pixel-based CSS properties
* for HTML objects and attributes for SVGElements.
* @param {AnimationOptions} [opt] - Animation options.
*/
H.animate = function(el, params, opt) {
var start,
unit = '',
end,
fx,
args,
prop;
if (!H.isObject(opt)) { // Number or undefined/null
args = arguments;
opt = {
duration: args[2],
easing: args[3],
complete: args[4]
};
}
if (!H.isNumber(opt.duration)) {
opt.duration = 400;
}
opt.easing = typeof opt.easing === 'function' ?
opt.easing :
(Math[opt.easing] || Math.easeInOutSine);
opt.curAnim = H.merge(params);
for (prop in params) {
// Stop current running animation of this property
H.stop(el, prop);
fx = new H.Fx(el, opt, prop);
end = null;
if (prop === 'd') {
fx.paths = fx.initPath(
el,
el.d,
params.d
);
fx.toD = params.d;
start = 0;
end = 1;
} else if (el.attr) {
start = el.attr(prop);
} else {
start = parseFloat(H.getStyle(el, prop)) || 0;
if (prop !== 'opacity') {
unit = 'px';
}
}
if (!end) {
end = params[prop];
}
if (end && end.match && end.match('px')) {
end = end.replace(/px/g, ''); // #4351
}
fx.run(start, end, unit);
}
};
/**
* Factory to create new series prototypes.
*
* @function #seriesType
* @memberOf Highcharts
*
* @param {String} type - The series type name.
* @param {String} parent - The parent series type name. Use `line` to inherit
* from the basic {@link Series} object.
* @param {Object} options - The additional default options that is merged with
* the parent's options.
* @param {Object} props - The properties (functions and primitives) to set on
* the new prototype.
* @param {Object} [pointProps] - Members for a series-specific extension of the
* {@link Point} prototype if needed.
* @returns {*} - The newly created prototype as extended from {@link Series}
* or its derivatives.
*/
// docs: add to API + extending Highcharts
H.seriesType = function(type, parent, options, props, pointProps) {
var defaultOptions = H.getOptions(),
seriesTypes = H.seriesTypes;
// Merge the options
defaultOptions.plotOptions[type] = H.merge(
defaultOptions.plotOptions[parent],
options
);
// Create the class
seriesTypes[type] = H.extendClass(seriesTypes[parent] ||
function() {}, props);
seriesTypes[type].prototype.type = type;
// Create the point class if needed
if (pointProps) {
seriesTypes[type].prototype.pointClass =
H.extendClass(H.Point, pointProps);
}
return seriesTypes[type];
};
/**
* Get a unique key for using in internal element id's and pointers. The key
* is composed of a random hash specific to this Highcharts instance, and a
* counter.
* @function #uniqueKey
* @memberOf Highcharts
* @return {string} The key.
* @example
* var id = H.uniqueKey(); // => 'highcharts-x45f6hp-0'
*/
H.uniqueKey = (function() {
var uniqueKeyHash = Math.random().toString(36).substring(2, 9),
idCounter = 0;
return function() {
return 'highcharts-' + uniqueKeyHash + '-' + idCounter++;
};
}());
/**
* Register Highcharts as a plugin in jQuery
*/
if (win.jQuery) {
win.jQuery.fn.highcharts = function() {
var args = [].slice.call(arguments);
if (this[0]) { // this[0] is the renderTo div
// Create the chart
if (args[0]) {
new H[ // eslint-disable-line no-new
// Constructor defaults to Chart
H.isString(args[0]) ? args.shift() : 'Chart'
](this[0], args[0], args[1]);
return this;
}
// When called without parameters or with the return argument,
// return an existing chart
return charts[H.attr(this[0], 'data-highcharts-chart')];
}
};
}
/**
* Compatibility section to add support for legacy IE. This can be removed if
* old IE support is not needed.
*/
if (doc && !doc.defaultView) {
H.getStyle = function(el, prop) {
var val,
alias = {
width: 'clientWidth',
height: 'clientHeight'
}[prop];
if (el.style[prop]) {
return H.pInt(el.style[prop]);
}
if (prop === 'opacity') {
prop = 'filter';
}
// Getting the rendered width and height
if (alias) {
el.style.zoom = 1;
return Math.max(el[alias] - 2 * H.getStyle(el, 'padding'), 0);
}
val = el.currentStyle[prop.replace(/\-(\w)/g, function(a, b) {
return b.toUpperCase();
})];
if (prop === 'filter') {
val = val.replace(
/alpha\(opacity=([0-9]+)\)/,
function(a, b) {
return b / 100;
}
);
}
return val === '' ? 1 : H.pInt(val);
};
}
if (!Array.prototype.forEach) {
H.each = function(arr, fn, ctx) { // legacy
var i = 0,
len = arr.length;
for (; i < len; i++) {
if (fn.call(ctx, arr[i], i, arr) === false) {
return i;
}
}
};
}
if (!Array.prototype.indexOf) {
H.inArray = function(item, arr) {
var len,
i = 0;
if (arr) {
len = arr.length;
for (; i < len; i++) {
if (arr[i] === item) {
return i;
}
}
}
return -1;
};
}
if (!Array.prototype.filter) {
H.grep = function(elements, fn) {
var ret = [],
i = 0,
length = elements.length;
for (; i < length; i++) {
if (fn(elements[i], i)) {
ret.push(elements[i]);
}
}
return ret;
};
}
if (!Array.prototype.find) {
H.find = function(arr, fn) {
var i,
length = arr.length;
for (i = 0; i < length; i++) {
if (fn(arr[i], i)) {
return arr[i];
}
}
};
}
//--- End compatibility section ---
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var each = H.each,
isNumber = H.isNumber,
map = H.map,
merge = H.merge,
pInt = H.pInt;
/**
* @typedef {string} ColorString
* A valid color to be parsed and handled by Highcharts. Highcharts internally
* supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
* rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
* browsers and displayed correctly, but Highcharts is not able to process them
* and apply concepts like opacity and brightening.
*/
/**
* Handle color operations. The object methods are chainable.
* @param {String} input The input color in either rbga or hex format
*/
H.Color = function(input) {
// Backwards compatibility, allow instanciation without new
if (!(this instanceof H.Color)) {
return new H.Color(input);
}
// Initialize
this.init(input);
};
H.Color.prototype = {
// Collection of parsers. This can be extended from the outside by pushing parsers
// to Highcharts.Color.prototype.parsers.
parsers: [{
// RGBA color
regex: /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,
parse: function(result) {
return [pInt(result[1]), pInt(result[2]), pInt(result[3]), parseFloat(result[4], 10)];
}
}, {
// RGB color
regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
parse: function(result) {
return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
}
}],
// Collection of named colors. Can be extended from the outside by adding
// colors to Highcharts.Color.prototype.names.
names: {
white: '#ffffff',
black: '#000000'
},
/**
* Parse the input color to rgba array
* @param {String} input
*/
init: function(input) {
var result,
rgba,
i,
parser,
len;
this.input = input = this.names[
input && input.toLowerCase ?
input.toLowerCase() :
''
] || input;
// Gradients
if (input && input.stops) {
this.stops = map(input.stops, function(stop) {
return new H.Color(stop[1]);
});
// Solid colors
} else {
// Check if it's possible to do bitmasking instead of regex
if (input && input[0] === '#') {
len = input.length;
input = parseInt(input.substr(1), 16);
// Handle long-form, e.g. #AABBCC
if (len === 7) {
rgba = [
(input & 0xFF0000) >> 16,
(input & 0xFF00) >> 8,
(input & 0xFF),
1
];
// Handle short-form, e.g. #ABC
// In short form, the value is assumed to be the same
// for both nibbles for each component. e.g. #ABC = #AABBCC
} else if (len === 4) {
rgba = [
((input & 0xF00) >> 4) | (input & 0xF00) >> 8,
((input & 0xF0) >> 4) | (input & 0xF0),
((input & 0xF) << 4) | (input & 0xF),
1
];
}
}
// Otherwise, check regex parsers
if (!rgba) {
i = this.parsers.length;
while (i-- && !rgba) {
parser = this.parsers[i];
result = parser.regex.exec(input);
if (result) {
rgba = parser.parse(result);
}
}
}
}
this.rgba = rgba || [];
},
/**
* Return the color a specified format
* @param {String} format
*/
get: function(format) {
var input = this.input,
rgba = this.rgba,
ret;
if (this.stops) {
ret = merge(input);
ret.stops = [].concat(ret.stops);
each(this.stops, function(stop, i) {
ret.stops[i] = [ret.stops[i][0], stop.get(format)];
});
// it's NaN if gradient colors on a column chart
} else if (rgba && isNumber(rgba[0])) {
if (format === 'rgb' || (!format && rgba[3] === 1)) {
ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
} else if (format === 'a') {
ret = rgba[3];
} else {
ret = 'rgba(' + rgba.join(',') + ')';
}
} else {
ret = input;
}
return ret;
},
/**
* Brighten the color
* @param {Number} alpha
*/
brighten: function(alpha) {
var i,
rgba = this.rgba;
if (this.stops) {
each(this.stops, function(stop) {
stop.brighten(alpha);
});
} else if (isNumber(alpha) && alpha !== 0) {
for (i = 0; i < 3; i++) {
rgba[i] += pInt(alpha * 255);
if (rgba[i] < 0) {
rgba[i] = 0;
}
if (rgba[i] > 255) {
rgba[i] = 255;
}
}
}
return this;
},
/**
* Set the color's opacity to a given alpha value
* @param {Number} alpha
*/
setOpacity: function(alpha) {
this.rgba[3] = alpha;
return this;
}
};
H.color = function(input) {
return new H.Color(input);
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var SVGElement,
SVGRenderer,
addEvent = H.addEvent,
animate = H.animate,
attr = H.attr,
charts = H.charts,
color = H.color,
css = H.css,
createElement = H.createElement,
defined = H.defined,
deg2rad = H.deg2rad,
destroyObjectProperties = H.destroyObjectProperties,
doc = H.doc,
each = H.each,
extend = H.extend,
erase = H.erase,
grep = H.grep,
hasTouch = H.hasTouch,
inArray = H.inArray,
isArray = H.isArray,
isFirefox = H.isFirefox,
isMS = H.isMS,
isObject = H.isObject,
isString = H.isString,
isWebKit = H.isWebKit,
merge = H.merge,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
removeEvent = H.removeEvent,
splat = H.splat,
stop = H.stop,
svg = H.svg,
SVG_NS = H.SVG_NS,
symbolSizes = H.symbolSizes,
win = H.win;
/**
* @typedef {Object} SVGDOMElement - An SVG DOM element.
*/
/**
* The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
* rendering layer of Highcharts. Combined with the {@link SVGRenderer} object,
* these prototypes allow freeform annotation in the charts or even in HTML
* pages without instanciating a chart. The SVGElement can also wrap HTML
* labels, when `text` or `label` elements are created with the `useHTML`
* parameter.
*
* The SVGElement instances are created through factory functions on the
* {@link SVGRenderer} object, like [rect]{@link SVGRenderer#rect},
* [path]{@link SVGRenderer#path}, [text]{@link SVGRenderer#text}, [label]{@link
* SVGRenderer#label}, [g]{@link SVGRenderer#g} and more.
*
* @class
*/
SVGElement = H.SVGElement = function() {
return this;
};
SVGElement.prototype = {
// Default base for animation
opacity: 1,
SVG_NS: SVG_NS,
/**
* For labels, these CSS properties are applied to the `text` node directly.
* @type {Array.<string>}
*/
textProps: ['direction', 'fontSize', 'fontWeight', 'fontFamily',
'fontStyle', 'color', 'lineHeight', 'width', 'textAlign',
'textDecoration', 'textOverflow', 'textOutline'
],
/**
* Initialize the SVG renderer. This function only exists to make the
* initiation process overridable. It should not be called directly.
*
* @param {SVGRenderer} renderer The SVGRenderer instance to initialize to.
* @param {String} nodeName The SVG node name.
* @returns {void}
*/
init: function(renderer, nodeName) {
/**
* The DOM node. Each SVGRenderer instance wraps a main DOM node, but
* may also represent more nodes.
* @type {SVGDOMNode|HTMLDOMNode}
*/
this.element = nodeName === 'span' ?
createElement(nodeName) :
doc.createElementNS(this.SVG_NS, nodeName);
/**
* The renderer that the SVGElement belongs to.
* @type {SVGRenderer}
*/
this.renderer = renderer;
},
/**
* Animate to given attributes or CSS properties.
*
* @param {SVGAttributes} params SVG attributes or CSS to animate.
* @param {AnimationOptions} [options] Animation options.
* @param {Function} [complete] Function to perform at the end of animation.
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
animate: function(params, options, complete) {
var animOptions = H.animObject(
pick(options, this.renderer.globalAnimation, true)
);
if (animOptions.duration !== 0) {
if (complete) { // allows using a callback with the global animation without overwriting it
animOptions.complete = complete;
}
animate(this, params, animOptions);
} else {
this.attr(params, null, complete);
if (animOptions.step) {
animOptions.step.call(this);
}
}
return this;
},
/**
* @typedef {Object} GradientOptions
* @property {Object} linearGradient Holds an object that defines the start
* position and the end position relative to the shape.
* @property {Number} linearGradient.x1 Start horizontal position of the
* gradient. Ranges 0-1.
* @property {Number} linearGradient.x2 End horizontal position of the
* gradient. Ranges 0-1.
* @property {Number} linearGradient.y1 Start vertical position of the
* gradient. Ranges 0-1.
* @property {Number} linearGradient.y2 End vertical position of the
* gradient. Ranges 0-1.
* @property {Object} radialGradient Holds an object that defines the center
* position and the radius.
* @property {Number} radialGradient.cx Center horizontal position relative
* to the shape. Ranges 0-1.
* @property {Number} radialGradient.cy Center vertical position relative
* to the shape. Ranges 0-1.
* @property {Number} radialGradient.r Radius relative to the shape. Ranges
* 0-1.
* @property {Array.<Array>} stops The first item in each tuple is the
* position in the gradient, where 0 is the start of the gradient and 1
* is the end of the gradient. Multiple stops can be applied. The second
* item is the color for each stop. This color can also be given in the
* rgba format.
*
* @example
* // Linear gradient used as a color option
* color: {
* linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
* stops: [
* [0, '#003399'], // start
* [0.5, '#ffffff'], // middle
* [1, '#3366AA'] // end
* ]
* }
* }
*/
/**
* Build and apply an SVG gradient out of a common JavaScript configuration
* object. This function is called from the attribute setters.
*
* @private
* @param {GradientOptions} color The gradient options structure.
* @param {string} prop The property to apply, can either be `fill` or
* `stroke`.
* @param {SVGDOMElement} elem SVG DOM element to apply the gradient on.
*/
colorGradient: function(color, prop, elem) {
var renderer = this.renderer,
colorObject,
gradName,
gradAttr,
radAttr,
gradients,
gradientObject,
stops,
stopColor,
stopOpacity,
radialReference,
n,
id,
key = [],
value;
// Apply linear or radial gradients
if (color.radialGradient) {
gradName = 'radialGradient';
} else if (color.linearGradient) {
gradName = 'linearGradient';
}
if (gradName) {
gradAttr = color[gradName];
gradients = renderer.gradients;
stops = color.stops;
radialReference = elem.radialReference;
// Keep < 2.2 kompatibility
if (isArray(gradAttr)) {
color[gradName] = gradAttr = {
x1: gradAttr[0],
y1: gradAttr[1],
x2: gradAttr[2],
y2: gradAttr[3],
gradientUnits: 'userSpaceOnUse'
};
}
// Correct the radial gradient for the radial reference system
if (
gradName === 'radialGradient' &&
radialReference &&
!defined(gradAttr.gradientUnits)
) {
radAttr = gradAttr; // Save the radial attributes for updating
gradAttr = merge(
gradAttr,
renderer.getRadialAttr(radialReference, radAttr), {
gradientUnits: 'userSpaceOnUse'
}
);
}
// Build the unique key to detect whether we need to create a new element (#1282)
for (n in gradAttr) {
if (n !== 'id') {
key.push(n, gradAttr[n]);
}
}
for (n in stops) {
key.push(stops[n]);
}
key = key.join(',');
// Check if a gradient object with the same config object is created within this renderer
if (gradients[key]) {
id = gradients[key].attr('id');
} else {
// Set the id and create the element
gradAttr.id = id = H.uniqueKey();
gradients[key] = gradientObject = renderer.createElement(gradName)
.attr(gradAttr)
.add(renderer.defs);
gradientObject.radAttr = radAttr;
// The gradient needs to keep a list of stops to be able to destroy them
gradientObject.stops = [];
each(stops, function(stop) {
var stopObject;
if (stop[1].indexOf('rgba') === 0) {
colorObject = H.color(stop[1]);
stopColor = colorObject.get('rgb');
stopOpacity = colorObject.get('a');
} else {
stopColor = stop[1];
stopOpacity = 1;
}
stopObject = renderer.createElement('stop').attr({
offset: stop[0],
'stop-color': stopColor,
'stop-opacity': stopOpacity
}).add(gradientObject);
// Add the stop element to the gradient
gradientObject.stops.push(stopObject);
});
}
// Set the reference to the gradient object
value = 'url(' + renderer.url + '#' + id + ')';
elem.setAttribute(prop, value);
elem.gradient = key;
// Allow the color to be concatenated into tooltips formatters etc. (#2995)
color.toString = function() {
return value;
};
}
},
/**
* Apply a text outline through a custom CSS property, by copying the text
* element and apply stroke to the copy. Used internally. Contrast checks
* at http://jsfiddle.net/highcharts/43soe9m1/2/ .
*
* @private
* @param {String} textOutline A custom CSS `text-outline` setting, defined
* by `width color`.
* @example
* // Specific color
* text.css({
* textOutline: '1px black'
* });
* // Automatic contrast
* text.css({
* color: '#000000', // black text
* textOutline: '1px contrast' // => white outline
* });
*/
applyTextOutline: function(textOutline) {
var elem = this.element,
tspans,
tspan,
hasContrast = textOutline.indexOf('contrast') !== -1,
styles = {},
color,
strokeWidth,
firstRealChild,
i;
// When the text shadow is set to contrast, use dark stroke for light
// text and vice versa.
if (hasContrast) {
styles.textOutline = textOutline = textOutline.replace(
/contrast/g,
this.renderer.getContrast(elem.style.fill)
);
}
// Extract the stroke width and color
textOutline = textOutline.split(' ');
color = textOutline[textOutline.length - 1];
strokeWidth = textOutline[0];
if (strokeWidth && strokeWidth !== 'none' && H.svg) {
this.fakeTS = true; // Fake text shadow
tspans = [].slice.call(elem.getElementsByTagName('tspan'));
// In order to get the right y position of the clone,
// copy over the y setter
this.ySetter = this.xSetter;
// Since the stroke is applied on center of the actual outline, we
// need to double it to get the correct stroke-width outside the
// glyphs.
strokeWidth = strokeWidth.replace(
/(^[\d\.]+)(.*?)$/g,
function(match, digit, unit) {
return (2 * digit) + unit;
}
);
// Remove shadows from previous runs. Iterate from the end to
// support removing items inside the cycle (#6472).
i = tspans.length;
while (i--) {
tspan = tspans[i];
if (tspan.getAttribute('class') === 'highcharts-text-outline') {
// Remove then erase
erase(tspans, elem.removeChild(tspan));
}
}
// For each of the tspans, create a stroked copy behind it.
firstRealChild = elem.firstChild;
each(tspans, function(tspan, y) {
var clone;
// Let the first line start at the correct X position
if (y === 0) {
tspan.setAttribute('x', elem.getAttribute('x'));
y = elem.getAttribute('y');
tspan.setAttribute('y', y || 0);
if (y === null) {
elem.setAttribute('y', 0);
}
}
// Create the clone and apply outline properties
clone = tspan.cloneNode(1);
attr(clone, {
'class': 'highcharts-text-outline',
'fill': color,
'stroke': color,
'stroke-width': strokeWidth,
'stroke-linejoin': 'round'
});
elem.insertBefore(clone, firstRealChild);
});
}
},
/**
*
* @typedef {Object} SVGAttributes An object of key-value pairs for SVG
* attributes. Attributes in Highcharts elements for the most parts
* correspond to SVG, but some are specific to Highcharts, like `zIndex`,
* `rotation`, `translateX`, `translateY`, `scaleX` and `scaleY`. SVG
* attributes containing a hyphen are _not_ camel-cased, they should be
* quoted to preserve the hyphen.
* @example
* {
* 'stroke': '#ff0000', // basic
* 'stroke-width': 2, // hyphenated
* 'rotation': 45 // custom
* 'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
* }
*/
/**
* Apply native and custom attributes to the SVG elements.
*
* In order to set the rotation center for rotation, set x and y to 0 and
* use `translateX` and `translateY` attributes to position the element
* instead.
*
* Attributes frequently used in Highcharts are `fill`, `stroke`,
* `stroke-width`.
*
* @param {SVGAttributes|String} hash - The native and custom SVG
* attributes.
* @param {string} [val] - If the type of the first argument is `string`,
* the second can be a value, which will serve as a single attribute
* setter. If the first argument is a string and the second is undefined,
* the function serves as a getter and the current value of the property
* is returned.
* @param {Function} complete - A callback function to execute after setting
* the attributes. This makes the function compliant and interchangeable
* with the {@link SVGElement#animate} function.
* @param {boolean} continueAnimation - Used internally when `.attr` is
* called as part of an animation step. Otherwise, calling `.attr` for an
* attribute will stop animation for that attribute.
*
* @returns {SVGElement|string|number} If used as a setter, it returns the
* current {@link SVGElement} so the calls can be chained. If used as a
* getter, the current value of the attribute is returned.
*
* @example
* // Set multiple attributes
* element.attr({
* stroke: 'red',
* fill: 'blue',
* x: 10,
* y: 10
* });
*
* // Set a single attribute
* element.attr('stroke', 'red');
*
* // Get an attribute
* element.attr('stroke'); // => 'red'
*
*/
attr: function(hash, val, complete, continueAnimation) {
var key,
value,
element = this.element,
hasSetSymbolSize,
ret = this,
skipAttr,
setter;
// single key-value pair
if (typeof hash === 'string' && val !== undefined) {
key = hash;
hash = {};
hash[key] = val;
}
// used as a getter: first argument is a string, second is undefined
if (typeof hash === 'string') {
ret = (this[hash + 'Getter'] || this._defaultGetter).call(this, hash, element);
// setter
} else {
for (key in hash) {
value = hash[key];
skipAttr = false;
// Unless .attr is from the animator update, stop current
// running animation of this property
if (!continueAnimation) {
stop(this, key);
}
// Special handling of symbol attributes
if (
this.symbolName &&
/^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)$/
.test(key)
) {
if (!hasSetSymbolSize) {
this.symbolAttr(hash);
hasSetSymbolSize = true;
}
skipAttr = true;
}
if (this.rotation && (key === 'x' || key === 'y')) {
this.doTransform = true;
}
if (!skipAttr) {
setter = this[key + 'Setter'] || this._defaultSetter;
setter.call(this, value, key, element);
// Let the shadow follow the main element
if (this.shadows && /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) {
this.updateShadows(key, value, setter);
}
}
}
// Update transform. Do this outside the loop to prevent redundant updating for batch setting
// of attributes.
if (this.doTransform) {
this.updateTransform();
this.doTransform = false;
}
}
// In accordance with animate, run a complete callback
if (complete) {
complete();
}
return ret;
},
/**
* Update the shadow elements with new attributes.
*
* @private
* @param {String} key - The attribute name.
* @param {String|Number} value - The value of the attribute.
* @param {Function} setter - The setter function, inherited from the
* parent wrapper
* @returns {void}
*/
updateShadows: function(key, value, setter) {
var shadows = this.shadows,
i = shadows.length;
while (i--) {
setter.call(
shadows[i],
key === 'height' ?
Math.max(value - (shadows[i].cutHeight || 0), 0) :
key === 'd' ? this.d : value,
key,
shadows[i]
);
}
},
/**
* Add a class name to an element.
*
* @param {string} className - The new class name to add.
* @param {boolean} [replace=false] - When true, the existing class name(s)
* will be overwritten with the new one. When false, the new one is
* added.
* @returns {SVGElement} Return the SVG element for chainability.
*/
addClass: function(className, replace) {
var currentClassName = this.attr('class') || '';
if (currentClassName.indexOf(className) === -1) {
if (!replace) {
className =
(currentClassName + (currentClassName ? ' ' : '') +
className).replace(' ', ' ');
}
this.attr('class', className);
}
return this;
},
/**
* Check if an element has the given class name.
* @param {string} className - The class name to check for.
* @return {Boolean}
*/
hasClass: function(className) {
return attr(this.element, 'class').indexOf(className) !== -1;
},
/**
* Remove a class name from the element.
* @param {string} className The class name to remove.
* @return {SVGElement} Returns the SVG element for chainability.
*/
removeClass: function(className) {
attr(this.element, 'class', (attr(this.element, 'class') || '').replace(className, ''));
return this;
},
/**
* If one of the symbol size affecting parameters are changed,
* check all the others only once for each call to an element's
* .attr() method
* @param {Object} hash - The attributes to set.
* @private
*/
symbolAttr: function(hash) {
var wrapper = this;
each(['x', 'y', 'r', 'start', 'end', 'width', 'height', 'innerR', 'anchorX', 'anchorY'], function(key) {
wrapper[key] = pick(hash[key], wrapper[key]);
});
wrapper.attr({
d: wrapper.renderer.symbols[wrapper.symbolName](
wrapper.x,
wrapper.y,
wrapper.width,
wrapper.height,
wrapper
)
});
},
/**
* Apply a clipping rectangle to this element.
*
* @param {ClipRect} [clipRect] - The clipping rectangle. If skipped, the
* current clip is removed.
* @returns {SVGElement} Returns the SVG element to allow chaining.
*/
clip: function(clipRect) {
return this.attr(
'clip-path',
clipRect ?
'url(' + this.renderer.url + '#' + clipRect.id + ')' :
'none'
);
},
/**
* Calculate the coordinates needed for drawing a rectangle crisply and
* return the calculated attributes.
*
* @param {Object} rect - A rectangle.
* @param {number} rect.x - The x position.
* @param {number} rect.y - The y position.
* @param {number} rect.width - The width.
* @param {number} rect.height - The height.
* @param {number} [strokeWidth] - The stroke width to consider when
* computing crisp positioning. It can also be set directly on the rect
* parameter.
*
* @returns {{x: Number, y: Number, width: Number, height: Number}} The
* modified rectangle arguments.
*/
crisp: function(rect, strokeWidth) {
var wrapper = this,
key,
attribs = {},
normalizer;
strokeWidth = strokeWidth || rect.strokeWidth || 0;
normalizer = Math.round(strokeWidth) % 2 / 2; // Math.round because strokeWidth can sometimes have roundoff errors
// normalize for crisp edges
rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
rect.width = Math.floor((rect.width || wrapper.width || 0) - 2 * normalizer);
rect.height = Math.floor((rect.height || wrapper.height || 0) - 2 * normalizer);
if (defined(rect.strokeWidth)) {
rect.strokeWidth = strokeWidth;
}
for (key in rect) {
if (wrapper[key] !== rect[key]) { // only set attribute if changed
wrapper[key] = attribs[key] = rect[key];
}
}
return attribs;
},
/**
* Set styles for the element. In addition to CSS styles supported by
* native SVG and HTML elements, there are also some custom made for
* Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
* elements.
* @param {CSSObject} styles The new CSS styles.
* @returns {SVGElement} Return the SVG element for chaining.
*/
css: function(styles) {
var oldStyles = this.styles,
newStyles = {},
elem = this.element,
textWidth,
n,
serializedCss = '',
hyphenate,
hasNew = !oldStyles,
// These CSS properties are interpreted internally by the SVG
// renderer, but are not supported by SVG and should not be added to
// the DOM. In styled mode, no CSS should find its way to the DOM
// whatsoever (#6173, #6474).
svgPseudoProps = ['textOutline', 'textOverflow', 'width'];
// convert legacy
if (styles && styles.color) {
styles.fill = styles.color;
}
// Filter out existing styles to increase performance (#2640)
if (oldStyles) {
for (n in styles) {
if (styles[n] !== oldStyles[n]) {
newStyles[n] = styles[n];
hasNew = true;
}
}
}
if (hasNew) {
// Merge the new styles with the old ones
if (oldStyles) {
styles = extend(
oldStyles,
newStyles
);
}
// Get the text width from style
textWidth = this.textWidth = (
styles &&
styles.width &&
styles.width !== 'auto' &&
elem.nodeName.toLowerCase() === 'text' &&
pInt(styles.width)
);
// store object
this.styles = styles;
if (textWidth && (!svg && this.renderer.forExport)) {
delete styles.width;
}
// serialize and set style attribute
if (isMS && !svg) {
css(this.element, styles);
} else {
hyphenate = function(a, b) {
return '-' + b.toLowerCase();
};
for (n in styles) {
if (inArray(n, svgPseudoProps) === -1) {
serializedCss +=
n.replace(/([A-Z])/g, hyphenate) + ':' +
styles[n] + ';';
}
}
if (serializedCss) {
attr(elem, 'style', serializedCss); // #1881
}
}
if (this.added) {
// Rebuild text after added. Cache mechanisms in the buildText
// will prevent building if there are no significant changes.
if (this.element.nodeName === 'text') {
this.renderer.buildText(this);
}
// Apply text outline after added
if (styles && styles.textOutline) {
this.applyTextOutline(styles.textOutline);
}
}
}
return this;
},
/**
* Get the current stroke width. In classic mode, the setter registers it
* directly on the element.
* @returns {number} The stroke width in pixels.
* @ignore
*/
strokeWidth: function() {
return this['stroke-width'] || 0;
},
/**
* Add an event listener. This is a simple setter that replaces all other
* events of the same type, opposed to the {@link Highcharts#addEvent}
* function.
* @param {string} eventType - The event type. If the type is `click`,
* Highcharts will internally translate it to a `touchstart` event on
* touch devices, to prevent the browser from waiting for a click event
* from firing.
* @param {Function} handler - The handler callback.
* @returns {SVGElement} The SVGElement for chaining.
*/
on: function(eventType, handler) {
var svgElement = this,
element = svgElement.element;
// touch
if (hasTouch && eventType === 'click') {
element.ontouchstart = function(e) {
svgElement.touchEventFired = Date.now(); // #2269
e.preventDefault();
handler.call(element, e);
};
element.onclick = function(e) {
if (win.navigator.userAgent.indexOf('Android') === -1 ||
Date.now() - (svgElement.touchEventFired || 0) > 1100) {
handler.call(element, e);
}
};
} else {
// simplest possible event model for internal use
element['on' + eventType] = handler;
}
return this;
},
/**
* Set the coordinates needed to draw a consistent radial gradient across
* a shape regardless of positioning inside the chart. Used on pie slices
* to make all the slices have the same radial reference point.
*
* @param {Array} coordinates The center reference. The format is
* `[centerX, centerY, diameter]` in pixels.
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
setRadialReference: function(coordinates) {
var existingGradient = this.renderer.gradients[this.element.gradient];
this.element.radialReference = coordinates;
// On redrawing objects with an existing gradient, the gradient needs
// to be repositioned (#3801)
if (existingGradient && existingGradient.radAttr) {
existingGradient.animate(
this.renderer.getRadialAttr(
coordinates,
existingGradient.radAttr
)
);
}
return this;
},
/**
* Move an object and its children by x and y values.
*
* @param {number} x - The x value.
* @param {number} y - The y value.
*/
translate: function(x, y) {
return this.attr({
translateX: x,
translateY: y
});
},
/**
* Invert a group, rotate and flip. This is used internally on inverted
* charts, where the points and graphs are drawn as if not inverted, then
* the series group elements are inverted.
*
* @param {boolean} inverted - Whether to invert or not. An inverted shape
* can be un-inverted by setting it to false.
* @returns {SVGElement} Return the SVGElement for chaining.
*/
invert: function(inverted) {
var wrapper = this;
wrapper.inverted = inverted;
wrapper.updateTransform();
return wrapper;
},
/**
* Update the transform attribute based on internal properties. Deals with
* the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
* attributes and updates the SVG `transform` attribute.
* @private
* @returns {void}
*/
updateTransform: function() {
var wrapper = this,
translateX = wrapper.translateX || 0,
translateY = wrapper.translateY || 0,
scaleX = wrapper.scaleX,
scaleY = wrapper.scaleY,
inverted = wrapper.inverted,
rotation = wrapper.rotation,
element = wrapper.element,
transform;
// flipping affects translate as adjustment for flipping around the group's axis
if (inverted) {
translateX += wrapper.width;
translateY += wrapper.height;
}
// Apply translate. Nearly all transformed elements have translation, so instead
// of checking for translate = 0, do it always (#1767, #1846).
transform = ['translate(' + translateX + ',' + translateY + ')'];
// apply rotation
if (inverted) {
transform.push('rotate(90) scale(-1,1)');
} else if (rotation) { // text rotation
transform.push('rotate(' + rotation + ' ' + (element.getAttribute('x') || 0) + ' ' + (element.getAttribute('y') || 0) + ')');
// Delete bBox memo when the rotation changes
//delete wrapper.bBox;
}
// apply scale
if (defined(scaleX) || defined(scaleY)) {
transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')');
}
if (transform.length) {
element.setAttribute('transform', transform.join(' '));
}
},
/**
* Bring the element to the front.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
toFront: function() {
var element = this.element;
element.parentNode.appendChild(element);
return this;
},
/**
* Align the element relative to the chart or another box.
* ß
* @param {Object} [alignOptions] The alignment options. The function can be
* called without this parameter in order to re-align an element after the
* box has been updated.
* @param {string} [alignOptions.align=left] Horizontal alignment. Can be
* one of `left`, `center` and `right`.
* @param {string} [alignOptions.verticalAlign=top] Vertical alignment. Can
* be one of `top`, `middle` and `bottom`.
* @param {number} [alignOptions.x=0] Horizontal pixel offset from
* alignment.
* @param {number} [alignOptions.y=0] Vertical pixel offset from alignment.
* @param {Boolean} [alignByTranslate=false] Use the `transform` attribute
* with translateX and translateY custom attributes to align this elements
* rather than `x` and `y` attributes.
* @param {String|Object} box The box to align to, needs a width and height.
* When the box is a string, it refers to an object in the Renderer. For
* example, when box is `spacingBox`, it refers to `Renderer.spacingBox`
* which holds `width`, `height`, `x` and `y` properties.
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
align: function(alignOptions, alignByTranslate, box) {
var align,
vAlign,
x,
y,
attribs = {},
alignTo,
renderer = this.renderer,
alignedObjects = renderer.alignedObjects,
alignFactor,
vAlignFactor;
// First call on instanciate
if (alignOptions) {
this.alignOptions = alignOptions;
this.alignByTranslate = alignByTranslate;
if (!box || isString(box)) { // boxes other than renderer handle this internally
this.alignTo = alignTo = box || 'renderer';
erase(alignedObjects, this); // prevent duplicates, like legendGroup after resize
alignedObjects.push(this);
box = null; // reassign it below
}
// When called on resize, no arguments are supplied
} else {
alignOptions = this.alignOptions;
alignByTranslate = this.alignByTranslate;
alignTo = this.alignTo;
}
box = pick(box, renderer[alignTo], renderer);
// Assign variables
align = alignOptions.align;
vAlign = alignOptions.verticalAlign;
x = (box.x || 0) + (alignOptions.x || 0); // default: left align
y = (box.y || 0) + (alignOptions.y || 0); // default: top align
// Align
if (align === 'right') {
alignFactor = 1;
} else if (align === 'center') {
alignFactor = 2;
}
if (alignFactor) {
x += (box.width - (alignOptions.width || 0)) / alignFactor;
}
attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);
// Vertical align
if (vAlign === 'bottom') {
vAlignFactor = 1;
} else if (vAlign === 'middle') {
vAlignFactor = 2;
}
if (vAlignFactor) {
y += (box.height - (alignOptions.height || 0)) / vAlignFactor;
}
attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);
// Animate only if already placed
this[this.placed ? 'animate' : 'attr'](attribs);
this.placed = true;
this.alignAttr = attribs;
return this;
},
/**
* Get the bounding box (width, height, x and y) for the element. Generally
* used to get rendered text size. Since this is called a lot in charts,
* the results are cached based on text properties, in order to save DOM
* traffic. The returned bounding box includes the rotation, so for example
* a single text line of rotation 90 will report a greater height, and a
* width corresponding to the line-height.
*
* @param {boolean} [reload] Skip the cache and get the updated DOM bouding
* box.
* @param {number} [rot] Override the element's rotation. This is internally
* used on axis labels with a value of 0 to find out what the bounding box
* would be have been if it were not rotated.
* @returns {Object} The bounding box with `x`, `y`, `width` and `height`
* properties.
*/
getBBox: function(reload, rot) {
var wrapper = this,
bBox, // = wrapper.bBox,
renderer = wrapper.renderer,
width,
height,
rotation,
rad,
element = wrapper.element,
styles = wrapper.styles,
fontSize,
textStr = wrapper.textStr,
toggleTextShadowShim,
cache = renderer.cache,
cacheKeys = renderer.cacheKeys,
cacheKey;
rotation = pick(rot, wrapper.rotation);
rad = rotation * deg2rad;
fontSize = styles && styles.fontSize;
if (textStr !== undefined) {
cacheKey = textStr.toString();
// Since numbers are monospaced, and numerical labels appear a lot
// in a chart, we assume that a label of n characters has the same
// bounding box as others of the same length. Unless there is inner
// HTML in the label. In that case, leave the numbers as is (#5899).
if (cacheKey.indexOf('<') === -1) {
cacheKey = cacheKey.replace(/[0-9]/g, '0');
}
// Properties that affect bounding box
cacheKey += [
'',
rotation || 0,
fontSize,
styles && styles.width,
styles && styles.textOverflow // #5968
]
.join(',');
}
if (cacheKey && !reload) {
bBox = cache[cacheKey];
}
// No cache found
if (!bBox) {
// SVG elements
if (element.namespaceURI === wrapper.SVG_NS || renderer.forExport) {
try { // Fails in Firefox if the container has display: none.
// When the text shadow shim is used, we need to hide the fake shadows
// to get the correct bounding box (#3872)
toggleTextShadowShim = this.fakeTS && function(display) {
each(element.querySelectorAll('.highcharts-text-outline'), function(tspan) {
tspan.style.display = display;
});
};
// Workaround for #3842, Firefox reporting wrong bounding box for shadows
if (toggleTextShadowShim) {
toggleTextShadowShim('none');
}
bBox = element.getBBox ?
// SVG: use extend because IE9 is not allowed to change width and height in case
// of rotation (below)
extend({}, element.getBBox()) : {
// Legacy IE in export mode
width: element.offsetWidth,
height: element.offsetHeight
};
// #3842
if (toggleTextShadowShim) {
toggleTextShadowShim('');
}
} catch (e) {}
// If the bBox is not set, the try-catch block above failed. The other condition
// is for Opera that returns a width of -Infinity on hidden elements.
if (!bBox || bBox.width < 0) {
bBox = {
width: 0,
height: 0
};
}
// VML Renderer or useHTML within SVG
} else {
bBox = wrapper.htmlGetBBox();
}
// True SVG elements as well as HTML elements in modern browsers using the .useHTML option
// need to compensated for rotation
if (renderer.isSVG) {
width = bBox.width;
height = bBox.height;
// Workaround for wrong bounding box in IE, Edge and Chrome on
// Windows. With Highcharts' default font, IE and Edge report
// a box height of 16.899 and Chrome rounds it to 17. If this
// stands uncorrected, it results in more padding added below
// the text than above when adding a label border or background.
// Also vertical positioning is affected.
// http://jsfiddle.net/highcharts/em37nvuj/
// (#1101, #1505, #1669, #2568, #6213).
if (
styles &&
styles.fontSize === '11px' &&
Math.round(height) === 17
) {
bBox.height = height = 14;
}
// Adjust for rotated text
if (rotation) {
bBox.width = Math.abs(height * Math.sin(rad)) + Math.abs(width * Math.cos(rad));
bBox.height = Math.abs(height * Math.cos(rad)) + Math.abs(width * Math.sin(rad));
}
}
// Cache it. When loading a chart in a hidden iframe in Firefox and IE/Edge, the
// bounding box height is 0, so don't cache it (#5620).
if (cacheKey && bBox.height > 0) {
// Rotate (#4681)
while (cacheKeys.length > 250) {
delete cache[cacheKeys.shift()];
}
if (!cache[cacheKey]) {
cacheKeys.push(cacheKey);
}
cache[cacheKey] = bBox;
}
}
return bBox;
},
/**
* Show the element after it has been hidden.
*
* @param {boolean} [inherit=false] Set the visibility attribute to
* `inherit` rather than `visible`. The difference is that an element with
* `visibility="visible"` will be visible even if the parent is hidden.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
show: function(inherit) {
return this.attr({
visibility: inherit ? 'inherit' : 'visible'
});
},
/**
* Hide the element, equivalent to setting the `visibility` attribute to
* `hidden`.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
hide: function() {
return this.attr({
visibility: 'hidden'
});
},
/**
* Fade out an element by animating its opacity down to 0, and hide it on
* complete. Used internally for the tooltip.
*
* @param {number} [duration=150] The fade duration in milliseconds.
*/
fadeOut: function(duration) {
var elemWrapper = this;
elemWrapper.animate({
opacity: 0
}, {
duration: duration || 150,
complete: function() {
elemWrapper.attr({
y: -9999
}); // #3088, assuming we're only using this for tooltips
}
});
},
/**
* Add the element to the DOM. All elements must be added this way.
*
* @param {SVGElement|SVGDOMElement} [parent] The parent item to add it to.
* If undefined, the element is added to the {@link SVGRenderer.box}.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*
* @sample highcharts/members/renderer-g - Elements added to a group
*/
add: function(parent) {
var renderer = this.renderer,
element = this.element,
inserted;
if (parent) {
this.parentGroup = parent;
}
// mark as inverted
this.parentInverted = parent && parent.inverted;
// build formatted text
if (this.textStr !== undefined) {
renderer.buildText(this);
}
// Mark as added
this.added = true;
// If we're adding to renderer root, or other elements in the group
// have a z index, we need to handle it
if (!parent || parent.handleZ || this.zIndex) {
inserted = this.zIndexSetter();
}
// If zIndex is not handled, append at the end
if (!inserted) {
(parent ? parent.element : renderer.box).appendChild(element);
}
// fire an event for internal hooks
if (this.onAdd) {
this.onAdd();
}
return this;
},
/**
* Removes an element from the DOM.
*
* @private
* @param {SVGDOMElement|HTMLDOMElement} element The DOM node to remove.
*/
safeRemoveChild: function(element) {
var parentNode = element.parentNode;
if (parentNode) {
parentNode.removeChild(element);
}
},
/**
* Destroy the element and element wrapper and clear up the DOM and event
* hooks.
*
* @returns {void}
*/
destroy: function() {
var wrapper = this,
element = wrapper.element || {},
parentToClean = wrapper.renderer.isSVG && element.nodeName === 'SPAN' && wrapper.parentGroup,
grandParent,
key,
i;
// remove events
element.onclick = element.onmouseout = element.onmouseover = element.onmousemove = element.point = null;
stop(wrapper); // stop running animations
if (wrapper.clipPath) {
// Look for existing references to this clipPath and remove them
// before destroying the element (#6196).
each(
wrapper.element.ownerSVGElement.querySelectorAll('[clip-path]'),
function(el) {
if (el.getAttribute('clip-path')
.indexOf(wrapper.clipPath.element.id) > -1) {
el.removeAttribute('clip-path');
}
}
);
wrapper.clipPath = wrapper.clipPath.destroy();
}
// Destroy stops in case this is a gradient object
if (wrapper.stops) {
for (i = 0; i < wrapper.stops.length; i++) {
wrapper.stops[i] = wrapper.stops[i].destroy();
}
wrapper.stops = null;
}
// remove element
wrapper.safeRemoveChild(element);
wrapper.destroyShadows();
// In case of useHTML, clean up empty containers emulating SVG groups (#1960, #2393, #2697).
while (parentToClean && parentToClean.div && parentToClean.div.childNodes.length === 0) {
grandParent = parentToClean.parentGroup;
wrapper.safeRemoveChild(parentToClean.div);
delete parentToClean.div;
parentToClean = grandParent;
}
// remove from alignObjects
if (wrapper.alignTo) {
erase(wrapper.renderer.alignedObjects, wrapper);
}
for (key in wrapper) {
delete wrapper[key];
}
return null;
},
/**
* @typedef {Object} ShadowOptions
* @property {string} [color=#000000] The shadow color.
* @property {number} [offsetX=1] The horizontal offset from the element.
* @property {number} [offsetY=1] The vertical offset from the element.
* @property {number} [opacity=0.15] The shadow opacity.
* @property {number} [width=3] The shadow width or distance from the
* element.
*/
/**
* Add a shadow to the element. Must be called after the element is added to
* the DOM. In styled mode, this method is not used, instead use `defs` and
* filters.
*
* @param {boolean|ShadowOptions} shadowOptions The shadow options. If
* `true`, the default options are applied. If `false`, the current
* shadow will be removed.
* @param {SVGElement} [group] The SVG group element where the shadows will
* be applied. The default is to add it to the same parent as the current
* element. Internally, this is ised for pie slices, where all the
* shadows are added to an element behind all the slices.
* @param {boolean} [cutOff] Used internally for column shadows.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*
* @example
* renderer.rect(10, 100, 100, 100)
* .attr({ fill: 'red' })
* .shadow(true);
*/
shadow: function(shadowOptions, group, cutOff) {
var shadows = [],
i,
shadow,
element = this.element,
strokeWidth,
shadowWidth,
shadowElementOpacity,
// compensate for inverted plot area
transform;
if (!shadowOptions) {
this.destroyShadows();
} else if (!this.shadows) {
shadowWidth = pick(shadowOptions.width, 3);
shadowElementOpacity = (shadowOptions.opacity || 0.15) / shadowWidth;
transform = this.parentInverted ?
'(-1,-1)' :
'(' + pick(shadowOptions.offsetX, 1) + ', ' + pick(shadowOptions.offsetY, 1) + ')';
for (i = 1; i <= shadowWidth; i++) {
shadow = element.cloneNode(0);
strokeWidth = (shadowWidth * 2) + 1 - (2 * i);
attr(shadow, {
'isShadow': 'true',
'stroke': shadowOptions.color || '#000000',
'stroke-opacity': shadowElementOpacity * i,
'stroke-width': strokeWidth,
'transform': 'translate' + transform,
'fill': 'none'
});
if (cutOff) {
attr(shadow, 'height', Math.max(attr(shadow, 'height') - strokeWidth, 0));
shadow.cutHeight = strokeWidth;
}
if (group) {
group.element.appendChild(shadow);
} else {
element.parentNode.insertBefore(shadow, element);
}
shadows.push(shadow);
}
this.shadows = shadows;
}
return this;
},
/**
* Destroy shadows on the element.
* @private
*/
destroyShadows: function() {
each(this.shadows || [], function(shadow) {
this.safeRemoveChild(shadow);
}, this);
this.shadows = undefined;
},
xGetter: function(key) {
if (this.element.nodeName === 'circle') {
if (key === 'x') {
key = 'cx';
} else if (key === 'y') {
key = 'cy';
}
}
return this._defaultGetter(key);
},
/**
* Get the current value of an attribute or pseudo attribute, used mainly
* for animation. Called internally from the {@link SVGRenderer#attr}
* function.
*
* @private
*/
_defaultGetter: function(key) {
var ret = pick(this[key], this.element ? this.element.getAttribute(key) : null, 0);
if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
ret = parseFloat(ret);
}
return ret;
},
dSetter: function(value, key, element) {
if (value && value.join) { // join path
value = value.join(' ');
}
if (/(NaN| {2}|^$)/.test(value)) {
value = 'M 0 0';
}
element.setAttribute(key, value);
this[key] = value;
},
dashstyleSetter: function(value) {
var i,
strokeWidth = this['stroke-width'];
// If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new strokeWidth
// function, we should be able to use that instead.
if (strokeWidth === 'inherit') {
strokeWidth = 1;
}
value = value && value.toLowerCase();
if (value) {
value = value
.replace('shortdashdotdot', '3,1,1,1,1,1,')
.replace('shortdashdot', '3,1,1,1')
.replace('shortdot', '1,1,')
.replace('shortdash', '3,1,')
.replace('longdash', '8,3,')
.replace(/dot/g, '1,3,')
.replace('dash', '4,3,')
.replace(/,$/, '')
.split(','); // ending comma
i = value.length;
while (i--) {
value[i] = pInt(value[i]) * strokeWidth;
}
value = value.join(',')
.replace(/NaN/g, 'none'); // #3226
this.element.setAttribute('stroke-dasharray', value);
}
},
alignSetter: function(value) {
var convert = {
left: 'start',
center: 'middle',
right: 'end'
};
this.element.setAttribute('text-anchor', convert[value]);
},
opacitySetter: function(value, key, element) {
this[key] = value;
element.setAttribute(key, value);
},
titleSetter: function(value) {
var titleNode = this.element.getElementsByTagName('title')[0];
if (!titleNode) {
titleNode = doc.createElementNS(this.SVG_NS, 'title');
this.element.appendChild(titleNode);
}
// Remove text content if it exists
if (titleNode.firstChild) {
titleNode.removeChild(titleNode.firstChild);
}
titleNode.appendChild(
doc.createTextNode(
(String(pick(value), '')).replace(/<[^>]*>/g, '') // #3276, #3895
)
);
},
textSetter: function(value) {
if (value !== this.textStr) {
// Delete bBox memo when the text changes
delete this.bBox;
this.textStr = value;
if (this.added) {
this.renderer.buildText(this);
}
}
},
fillSetter: function(value, key, element) {
if (typeof value === 'string') {
element.setAttribute(key, value);
} else if (value) {
this.colorGradient(value, key, element);
}
},
visibilitySetter: function(value, key, element) {
// IE9-11 doesn't handle visibilty:inherit well, so we remove the attribute instead (#2881, #3909)
if (value === 'inherit') {
element.removeAttribute(key);
} else {
element.setAttribute(key, value);
}
},
zIndexSetter: function(value, key) {
var renderer = this.renderer,
parentGroup = this.parentGroup,
parentWrapper = parentGroup || renderer,
parentNode = parentWrapper.element || renderer.box,
childNodes,
otherElement,
otherZIndex,
element = this.element,
inserted,
run = this.added,
i;
if (defined(value)) {
element.zIndex = value; // So we can read it for other elements in the group
value = +value;
if (this[key] === value) { // Only update when needed (#3865)
run = false;
}
this[key] = value;
}
// Insert according to this and other elements' zIndex. Before .add() is called,
// nothing is done. Then on add, or by later calls to zIndexSetter, the node
// is placed on the right place in the DOM.
if (run) {
value = this.zIndex;
if (value && parentGroup) {
parentGroup.handleZ = true;
}
childNodes = parentNode.childNodes;
for (i = 0; i < childNodes.length && !inserted; i++) {
otherElement = childNodes[i];
otherZIndex = otherElement.zIndex;
if (otherElement !== element && (
// Insert before the first element with a higher zIndex
pInt(otherZIndex) > value ||
// If no zIndex given, insert before the first element with a zIndex
(!defined(value) && defined(otherZIndex)) ||
// Negative zIndex versus no zIndex:
// On all levels except the highest. If the parent is <svg>,
// then we don't want to put items before <desc> or <defs>
(value < 0 && !defined(otherZIndex) && parentNode !== renderer.box)
)) {
parentNode.insertBefore(element, otherElement);
inserted = true;
}
}
if (!inserted) {
parentNode.appendChild(element);
}
}
return inserted;
},
_defaultSetter: function(value, key, element) {
element.setAttribute(key, value);
}
};
// Some shared setters and getters
SVGElement.prototype.yGetter = SVGElement.prototype.xGetter;
SVGElement.prototype.translateXSetter = SVGElement.prototype.translateYSetter =
SVGElement.prototype.rotationSetter = SVGElement.prototype.verticalAlignSetter =
SVGElement.prototype.scaleXSetter = SVGElement.prototype.scaleYSetter = function(value, key) {
this[key] = value;
this.doTransform = true;
};
// WebKit and Batik have problems with a stroke-width of zero, so in this case we remove the
// stroke attribute altogether. #1270, #1369, #3065, #3072.
SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter = function(value, key, element) {
this[key] = value;
// Only apply the stroke attribute if the stroke width is defined and larger than 0
if (this.stroke && this['stroke-width']) {
SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element); // use prototype as instance may be overridden
element.setAttribute('stroke-width', this['stroke-width']);
this.hasStroke = true;
} else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
element.removeAttribute('stroke');
this.hasStroke = false;
}
};
/**
* Allows direct access to the Highcharts rendering layer in order to draw
* primitive shapes like circles, rectangles, paths or text directly on a chart,
* or independent from any chart. The SVGRenderer represents a wrapper object
* for SVGin modern browsers and through the VMLRenderer, for VML in IE < 8.
*
* An existing chart's renderer can be accessed through {@link Chart#renderer}.
* The renderer can also be used completely decoupled from a chart.
*
* @param {HTMLDOMElement} container - Where to put the SVG in the web page.
* @param {number} width - The width of the SVG.
* @param {number} height - The height of the SVG.
* @param {boolean} [forExport=false] - Whether the rendered content is intended
* for export.
* @param {boolean} [allowHTML=true] - Whether the renderer is allowed to
* include HTML text, which will be projected on top of the SVG.
*
* @example
* // Use directly without a chart object.
* var renderer = new Highcharts.Renderer(parentNode, 600, 400);
*
* @sample highcharts/members/renderer-on-chart - Annotating a chart programmatically.
* @sample highcharts/members/renderer-basic - Independedt SVG drawing.
*
* @class
*/
SVGRenderer = H.SVGRenderer = function() {
this.init.apply(this, arguments);
};
SVGRenderer.prototype = {
/**
* A pointer to the renderer's associated Element class. The VMLRenderer
* will have a pointer to VMLElement here.
* @type {SVGElement}
*/
Element: SVGElement,
SVG_NS: SVG_NS,
/**
* Initialize the SVGRenderer. Overridable initiator function that takes
* the same parameters as the constructor.
*/
init: function(container, width, height, style, forExport, allowHTML) {
var renderer = this,
boxWrapper,
element,
desc;
boxWrapper = renderer.createElement('svg')
.attr({
'version': '1.1',
'class': 'highcharts-root'
})
.css(this.getStyle(style));
element = boxWrapper.element;
container.appendChild(element);
// For browsers other than IE, add the namespace attribute (#1978)
if (container.innerHTML.indexOf('xmlns') === -1) {
attr(element, 'xmlns', this.SVG_NS);
}
// object properties
renderer.isSVG = true;
/**
* The root `svg` node of the renderer.
* @type {SVGDOMElement}
*/
this.box = element;
/**
* The wrapper for the root `svg` node of the renderer.
* @type {SVGElement}
*/
this.boxWrapper = boxWrapper;
renderer.alignedObjects = [];
/**
* Page url used for internal references.
* @type {string}
*/
// #24, #672, #1070
this.url = (isFirefox || isWebKit) && doc.getElementsByTagName('base').length ?
win.location.href
.replace(/#.*?$/, '') // remove the hash
.replace(/<[^>]*>/g, '') // wing cut HTML
.replace(/([\('\)])/g, '\\$1') // escape parantheses and quotes
.replace(/ /g, '%20') : // replace spaces (needed for Safari only)
'';
// Add description
desc = this.createElement('desc').add();
desc.element.appendChild(doc.createTextNode('Created with Highcharts 5.0.10'));
renderer.defs = this.createElement('defs').add();
renderer.allowHTML = allowHTML;
renderer.forExport = forExport;
renderer.gradients = {}; // Object where gradient SvgElements are stored
renderer.cache = {}; // Cache for numerical bounding boxes
renderer.cacheKeys = [];
renderer.imgCount = 0;
renderer.setSize(width, height, false);
// Issue 110 workaround:
// In Firefox, if a div is positioned by percentage, its pixel position may land
// between pixels. The container itself doesn't display this, but an SVG element
// inside this container will be drawn at subpixel precision. In order to draw
// sharp lines, this must be compensated for. This doesn't seem to work inside
// iframes though (like in jsFiddle).
var subPixelFix, rect;
if (isFirefox && container.getBoundingClientRect) {
subPixelFix = function() {
css(container, {
left: 0,
top: 0
});
rect = container.getBoundingClientRect();
css(container, {
left: (Math.ceil(rect.left) - rect.left) + 'px',
top: (Math.ceil(rect.top) - rect.top) + 'px'
});
};
// run the fix now
subPixelFix();
// run it on resize
renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
}
},
/**
* Get the global style setting for the renderer.
* @private
* @param {CSSObject} style - Style settings.
* @return {CSSObject} The style settings mixed with defaults.
*/
getStyle: function(style) {
this.style = extend({
fontFamily: '"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif', // default font
fontSize: '12px'
}, style);
return this.style;
},
/**
* Apply the global style on the renderer, mixed with the default styles.
* @param {CSSObject} style - CSS to apply.
*/
setStyle: function(style) {
this.boxWrapper.css(this.getStyle(style));
},
/**
* Detect whether the renderer is hidden. This happens when one of the
* parent elements has display: none. Used internally to detect when we need
* to render preliminarily in another div to get the text bounding boxes
* right.
*
* @returns {boolean} True if it is hidden.
*/
isHidden: function() { // #608
return !this.boxWrapper.getBBox().width;
},
/**
* Destroys the renderer and its allocated members.
*/
destroy: function() {
var renderer = this,
rendererDefs = renderer.defs;
renderer.box = null;
renderer.boxWrapper = renderer.boxWrapper.destroy();
// Call destroy on all gradient elements
destroyObjectProperties(renderer.gradients || {});
renderer.gradients = null;
// Defs are null in VMLRenderer
// Otherwise, destroy them here.
if (rendererDefs) {
renderer.defs = rendererDefs.destroy();
}
// Remove sub pixel fix handler (#982)
if (renderer.unSubPixelFix) {
renderer.unSubPixelFix();
}
renderer.alignedObjects = null;
return null;
},
/**
* Create a wrapper for an SVG element. Serves as a factory for
* {@link SVGElement}, but this function is itself mostly called from
* primitive factories like {@link SVGRenderer#path}, {@link
* SVGRenderer#rect} or {@link SVGRenderer#text}.
*
* @param {string} nodeName - The node name, for example `rect`, `g` etc.
* @returns {SVGElement} The generated SVGElement.
*/
createElement: function(nodeName) {
var wrapper = new this.Element();
wrapper.init(this, nodeName);
return wrapper;
},
/**
* Dummy function for plugins, called every time the renderer is updated.
* Prior to Highcharts 5, this was used for the canvg renderer.
* @function
*/
draw: noop,
/**
* Get converted radial gradient attributes according to the radial
* reference. Used internally from the {@link SVGElement#colorGradient}
* function.
*
* @private
*/
getRadialAttr: function(radialReference, gradAttr) {
return {
cx: (radialReference[0] - radialReference[2] / 2) + gradAttr.cx * radialReference[2],
cy: (radialReference[1] - radialReference[2] / 2) + gradAttr.cy * radialReference[2],
r: gradAttr.r * radialReference[2]
};
},
getSpanWidth: function(wrapper, tspan) {
var renderer = this,
bBox = wrapper.getBBox(true),
actualWidth = bBox.width;
// Old IE cannot measure the actualWidth for SVG elements (#2314)
if (!svg && renderer.forExport) {
actualWidth = renderer.measureSpanWidth(tspan.firstChild.data, wrapper.styles);
}
return actualWidth;
},
applyEllipsis: function(wrapper, tspan, text, width) {
var renderer = this,
actualWidth = renderer.getSpanWidth(wrapper, tspan),
wasTooLong = actualWidth > width,
str = text,
currentIndex,
minIndex = 0,
maxIndex = text.length,
updateTSpan = function(s) {
tspan.removeChild(tspan.firstChild);
if (s) {
tspan.appendChild(doc.createTextNode(s));
}
};
if (wasTooLong) {
while (minIndex <= maxIndex) {
currentIndex = Math.ceil((minIndex + maxIndex) / 2);
str = text.substring(0, currentIndex) + '\u2026';
updateTSpan(str);
actualWidth = renderer.getSpanWidth(wrapper, tspan);
if (minIndex === maxIndex) {
// Complete
minIndex = maxIndex + 1;
} else if (actualWidth > width) {
// Too large. Set max index to current.
maxIndex = currentIndex - 1;
} else {
// Within width. Set min index to current.
minIndex = currentIndex;
}
}
// If max index was 0 it means just ellipsis was also to large.
if (maxIndex === 0) {
// Remove ellipses.
updateTSpan('');
}
}
return wasTooLong;
},
/**
* Parse a simple HTML string into SVG tspans. Called internally when text
* is set on an SVGElement. The function supports a subset of HTML tags,
* CSS text features like `width`, `text-overflow`, `white-space`, and
* also attributes like `href` and `style`.
* @private
* @param {SVGElement} wrapper The parent SVGElement.
*/
buildText: function(wrapper) {
var textNode = wrapper.element,
renderer = this,
forExport = renderer.forExport,
textStr = pick(wrapper.textStr, '').toString(),
hasMarkup = textStr.indexOf('<') !== -1,
lines,
childNodes = textNode.childNodes,
clsRegex,
styleRegex,
hrefRegex,
wasTooLong,
parentX = attr(textNode, 'x'),
textStyles = wrapper.styles,
width = wrapper.textWidth,
textLineHeight = textStyles && textStyles.lineHeight,
textOutline = textStyles && textStyles.textOutline,
ellipsis = textStyles && textStyles.textOverflow === 'ellipsis',
noWrap = textStyles && textStyles.whiteSpace === 'nowrap',
fontSize = textStyles && textStyles.fontSize,
textCache,
isSubsequentLine,
i = childNodes.length,
tempParent = width && !wrapper.added && this.box,
getLineHeight = function(tspan) {
var fontSizeStyle;
fontSizeStyle = /(px|em)$/.test(tspan && tspan.style.fontSize) ?
tspan.style.fontSize :
(fontSize || renderer.style.fontSize || 12);
return textLineHeight ?
pInt(textLineHeight) :
renderer.fontMetrics(
fontSizeStyle,
// Get the computed size from parent if not explicit
tspan.getAttribute('style') ? tspan : textNode
).h;
},
unescapeAngleBrackets = function(inputStr) {
return inputStr.replace(/</g, '<').replace(/>/g, '>');
};
// The buildText code is quite heavy, so if we're not changing something
// that affects the text, skip it (#6113).
textCache = [
textStr,
ellipsis,
noWrap,
textLineHeight,
textOutline,
fontSize,
width
].join(',');
if (textCache === wrapper.textCache) {
return;
}
wrapper.textCache = textCache;
/// remove old text
while (i--) {
textNode.removeChild(childNodes[i]);
}
// Skip tspans, add text directly to text node. The forceTSpan is a hook
// used in text outline hack.
if (!hasMarkup && !textOutline && !ellipsis && !width && textStr.indexOf(' ') === -1) {
textNode.appendChild(doc.createTextNode(unescapeAngleBrackets(textStr)));
// Complex strings, add more logic
} else {
clsRegex = /<.*class="([^"]+)".*>/;
styleRegex = /<.*style="([^"]+)".*>/;
hrefRegex = /<.*href="(http[^"]+)".*>/;
if (tempParent) {
tempParent.appendChild(textNode); // attach it to the DOM to read offset width
}
if (hasMarkup) {
lines = textStr
.replace(/<(b|strong)>/g, '<span style="font-weight:bold">')
.replace(/<(i|em)>/g, '<span style="font-style:italic">')
.replace(/<a/g, '<span')
.replace(/<\/(b|strong|i|em|a)>/g, '</span>')
.split(/<br.*?>/g);
} else {
lines = [textStr];
}
// Trim empty lines (#5261)
lines = grep(lines, function(line) {
return line !== '';
});
// build the lines
each(lines, function buildTextLines(line, lineNo) {
var spans,
spanNo = 0;
line = line
.replace(/^\s+|\s+$/g, '') // Trim to prevent useless/costly process on the spaces (#5258)
.replace(/<span/g, '|||<span')
.replace(/<\/span>/g, '</span>|||');
spans = line.split('|||');
each(spans, function buildTextSpans(span) {
if (span !== '' || spans.length === 1) {
var attributes = {},
tspan = doc.createElementNS(renderer.SVG_NS, 'tspan'),
spanCls,
spanStyle; // #390
if (clsRegex.test(span)) {
spanCls = span.match(clsRegex)[1];
attr(tspan, 'class', spanCls);
}
if (styleRegex.test(span)) {
spanStyle = span.match(styleRegex)[1].replace(/(;| |^)color([ :])/, '$1fill$2');
attr(tspan, 'style', spanStyle);
}
if (hrefRegex.test(span) && !forExport) { // Not for export - #1529
attr(tspan, 'onclick', 'location.href=\"' + span.match(hrefRegex)[1] + '\"');
css(tspan, {
cursor: 'pointer'
});
}
span = unescapeAngleBrackets(span.replace(/<(.|\n)*?>/g, '') || ' ');
// Nested tags aren't supported, and cause crash in Safari (#1596)
if (span !== ' ') {
// add the text node
tspan.appendChild(doc.createTextNode(span));
if (!spanNo) { // first span in a line, align it to the left
if (lineNo && parentX !== null) {
attributes.x = parentX;
}
} else {
attributes.dx = 0; // #16
}
// add attributes
attr(tspan, attributes);
// Append it
textNode.appendChild(tspan);
// first span on subsequent line, add the line height
if (!spanNo && isSubsequentLine) {
// allow getting the right offset height in exporting in IE
if (!svg && forExport) {
css(tspan, {
display: 'block'
});
}
// Set the line height based on the font size of either
// the text element or the tspan element
attr(
tspan,
'dy',
getLineHeight(tspan)
);
}
/*if (width) {
renderer.breakText(wrapper, width);
}*/
// Check width and apply soft breaks or ellipsis
if (width) {
var words = span.replace(/([^\^])-/g, '$1- ').split(' '), // #1273
hasWhiteSpace = spans.length > 1 || lineNo || (words.length > 1 && !noWrap),
tooLong,
rest = [],
actualWidth,
dy = getLineHeight(tspan),
rotation = wrapper.rotation;
if (ellipsis) {
wasTooLong = renderer.applyEllipsis(wrapper, tspan, span, width);
}
while (!ellipsis && hasWhiteSpace && (words.length || rest.length)) {
wrapper.rotation = 0; // discard rotation when computing box
actualWidth = renderer.getSpanWidth(wrapper, tspan);
tooLong = actualWidth > width;
// For ellipsis, do a binary search for the correct string length
if (wasTooLong === undefined) {
wasTooLong = tooLong; // First time
}
// Looping down, this is the first word sequence that is not too long,
// so we can move on to build the next line.
if (!tooLong || words.length === 1) {
words = rest;
rest = [];
if (words.length && !noWrap) {
tspan = doc.createElementNS(SVG_NS, 'tspan');
attr(tspan, {
dy: dy,
x: parentX
});
if (spanStyle) { // #390
attr(tspan, 'style', spanStyle);
}
textNode.appendChild(tspan);
}
if (actualWidth > width) { // a single word is pressing it out
width = actualWidth;
}
} else { // append to existing line tspan
tspan.removeChild(tspan.firstChild);
rest.unshift(words.pop());
}
if (words.length) {
tspan.appendChild(doc.createTextNode(words.join(' ').replace(/- /g, '-')));
}
}
wrapper.rotation = rotation;
}
spanNo++;
}
}
});
// To avoid beginning lines that doesn't add to the textNode (#6144)
isSubsequentLine = isSubsequentLine || textNode.childNodes.length;
});
if (wasTooLong) {
wrapper.attr('title', wrapper.textStr);
}
if (tempParent) {
tempParent.removeChild(textNode); // attach it to the DOM to read offset width
}
// Apply the text outline
if (textOutline && wrapper.applyTextOutline) {
wrapper.applyTextOutline(textOutline);
}
}
},
/*
breakText: function (wrapper, width) {
var bBox = wrapper.getBBox(),
node = wrapper.element,
textLength = node.textContent.length,
pos = Math.round(width * textLength / bBox.width), // try this position first, based on average character width
increment = 0,
finalPos;
if (bBox.width > width) {
while (finalPos === undefined) {
textLength = node.getSubStringLength(0, pos);
if (textLength <= width) {
if (increment === -1) {
finalPos = pos;
} else {
increment = 1;
}
} else {
if (increment === 1) {
finalPos = pos - 1;
} else {
increment = -1;
}
}
pos += increment;
}
}
console.log('width', width, 'stringWidth', node.getSubStringLength(0, finalPos))
},
*/
/**
* Returns white for dark colors and black for bright colors.
*
* @param {ColorString} rgba - The color to get the contrast for.
* @returns {string} The contrast color, either `#000000` or `#FFFFFF`.
*/
getContrast: function(rgba) {
rgba = color(rgba).rgba;
// The threshold may be discussed. Here's a proposal for adding
// different weight to the color channels (#6216)
/*
rgba[0] *= 1; // red
rgba[1] *= 1.2; // green
rgba[2] *= 0.7; // blue
*/
return rgba[0] + rgba[1] + rgba[2] > 2 * 255 ? '#000000' : '#FFFFFF';
},
/**
* Create a button with preset states.
* @param {string} text - The text or HTML to draw.
* @param {number} x - The x position of the button's left side.
* @param {number} y - The y position of the button's top side.
* @param {Function} callback - The function to execute on button click or
* touch.
* @param {SVGAttributes} [normalState] - SVG attributes for the normal
* state.
* @param {SVGAttributes} [hoverState] - SVG attributes for the hover state.
* @param {SVGAttributes} [pressedState] - SVG attributes for the pressed
* state.
* @param {SVGAttributes} [disabledState] - SVG attributes for the disabled
* state.
* @param {Symbol} [shape=rect] - The shape type.
* @returns {SVGRenderer} The button element.
*/
button: function(text, x, y, callback, normalState, hoverState, pressedState, disabledState, shape) {
var label = this.label(text, x, y, shape, null, null, null, null, 'button'),
curState = 0;
// Default, non-stylable attributes
label.attr(merge({
'padding': 8,
'r': 2
}, normalState));
// Presentational
var normalStyle,
hoverStyle,
pressedStyle,
disabledStyle;
// Normal state - prepare the attributes
normalState = merge({
fill: '#f7f7f7',
stroke: '#cccccc',
'stroke-width': 1,
style: {
color: '#333333',
cursor: 'pointer',
fontWeight: 'normal'
}
}, normalState);
normalStyle = normalState.style;
delete normalState.style;
// Hover state
hoverState = merge(normalState, {
fill: '#e6e6e6'
}, hoverState);
hoverStyle = hoverState.style;
delete hoverState.style;
// Pressed state
pressedState = merge(normalState, {
fill: '#e6ebf5',
style: {
color: '#000000',
fontWeight: 'bold'
}
}, pressedState);
pressedStyle = pressedState.style;
delete pressedState.style;
// Disabled state
disabledState = merge(normalState, {
style: {
color: '#cccccc'
}
}, disabledState);
disabledStyle = disabledState.style;
delete disabledState.style;
// Add the events. IE9 and IE10 need mouseover and mouseout to funciton (#667).
addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function() {
if (curState !== 3) {
label.setState(1);
}
});
addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function() {
if (curState !== 3) {
label.setState(curState);
}
});
label.setState = function(state) {
// Hover state is temporary, don't record it
if (state !== 1) {
label.state = curState = state;
}
// Update visuals
label.removeClass(/highcharts-button-(normal|hover|pressed|disabled)/)
.addClass('highcharts-button-' + ['normal', 'hover', 'pressed', 'disabled'][state || 0]);
label.attr([normalState, hoverState, pressedState, disabledState][state || 0])
.css([normalStyle, hoverStyle, pressedStyle, disabledStyle][state || 0]);
};
// Presentational attributes
label
.attr(normalState)
.css(extend({
cursor: 'default'
}, normalStyle));
return label
.on('click', function(e) {
if (curState !== 3) {
callback.call(label, e);
}
});
},
/**
* Make a straight line crisper by not spilling out to neighbour pixels.
*
* @param {Array} points - The original points on the format `['M', 0, 0,
* 'L', 100, 0]`.
* @param {number} width - The width of the line.
* @returns {Array} The original points array, but modified to render
* crisply.
*/
crispLine: function(points, width) {
// normalize to a crisp line
if (points[1] === points[4]) {
// Substract due to #1129. Now bottom and left axis gridlines behave the same.
points[1] = points[4] = Math.round(points[1]) - (width % 2 / 2);
}
if (points[2] === points[5]) {
points[2] = points[5] = Math.round(points[2]) + (width % 2 / 2);
}
return points;
},
/**
* Draw a path, wraps the SVG `path` element.
*
* @param {Array} [path] An SVG path definition in array form.
*
* @example
* var path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
* .attr({ stroke: '#ff00ff' })
* .add();
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw a path, wraps the SVG `path` element.
*
* @param {SVGAttributes} [attribs] The initial attributes.
* @returns {SVGElement} The generated wrapper element.
*/
path: function(path) {
var attribs = {
fill: 'none'
};
if (isArray(path)) {
attribs.d = path;
} else if (isObject(path)) { // attributes
extend(attribs, path);
}
return this.createElement('path').attr(attribs);
},
/**
* Draw a circle, wraps the SVG `circle` element.
*
* @param {number} [x] The center x position.
* @param {number} [y] The center y position.
* @param {number} [r] The radius.
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw a circle, wraps the SVG `circle` element.
*
* @param {SVGAttributes} [attribs] The initial attributes.
* @returns {SVGElement} The generated wrapper element.
*/
circle: function(x, y, r) {
var attribs = isObject(x) ? x : {
x: x,
y: y,
r: r
},
wrapper = this.createElement('circle');
// Setting x or y translates to cx and cy
wrapper.xSetter = wrapper.ySetter = function(value, key, element) {
element.setAttribute('c' + key, value);
};
return wrapper.attr(attribs);
},
/**
* Draw and return an arc.
* @param {number} [x=0] Center X position.
* @param {number} [y=0] Center Y position.
* @param {number} [r=0] The outer radius of the arc.
* @param {number} [innerR=0] Inner radius like used in donut charts.
* @param {number} [start=0] The starting angle of the arc in radians, where
* 0 is to the right and `-Math.PI/2` is up.
* @param {number} [end=0] The ending angle of the arc in radians, where 0
* is to the right and `-Math.PI/2` is up.
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw and return an arc. Overloaded function that takes arguments object.
* @param {SVGAttributes} attribs Initial SVG attributes.
* @returns {SVGElement} The generated wrapper element.
*/
arc: function(x, y, r, innerR, start, end) {
var arc,
options;
if (isObject(x)) {
options = x;
y = options.y;
r = options.r;
innerR = options.innerR;
start = options.start;
end = options.end;
x = options.x;
} else {
options = {
innerR: innerR,
start: start,
end: end
};
}
// Arcs are defined as symbols for the ability to set
// attributes in attr and animate
arc = this.symbol('arc', x, y, r, r, options);
arc.r = r; // #959
return arc;
},
/**
* Draw and return a rectangle.
* @param {number} [x] Left position.
* @param {number} [y] Top position.
* @param {number} [width] Width of the rectangle.
* @param {number} [height] Height of the rectangle.
* @param {number} [r] Border corner radius.
* @param {number} [strokeWidth] A stroke width can be supplied to allow
* crisp drawing.
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw and return a rectangle.
* @param {SVGAttributes} [attributes] General SVG attributes for the
* rectangle.
* @returns {SVGElement} The generated wrapper element.
*/
rect: function(x, y, width, height, r, strokeWidth) {
r = isObject(x) ? x.r : r;
var wrapper = this.createElement('rect'),
attribs = isObject(x) ? x : x === undefined ? {} : {
x: x,
y: y,
width: Math.max(width, 0),
height: Math.max(height, 0)
};
if (strokeWidth !== undefined) {
attribs.strokeWidth = strokeWidth;
attribs = wrapper.crisp(attribs);
}
attribs.fill = 'none';
if (r) {
attribs.r = r;
}
wrapper.rSetter = function(value, key, element) {
attr(element, {
rx: value,
ry: value
});
};
return wrapper.attr(attribs);
},
/**
* Resize the {@link SVGRenderer#box} and re-align all aligned child
* elements.
* @param {number} width The new pixel width.
* @param {number} height The new pixel height.
* @param {boolean} animate Whether to animate.
*/
setSize: function(width, height, animate) {
var renderer = this,
alignedObjects = renderer.alignedObjects,
i = alignedObjects.length;
renderer.width = width;
renderer.height = height;
renderer.boxWrapper.animate({
width: width,
height: height
}, {
step: function() {
this.attr({
viewBox: '0 0 ' + this.attr('width') + ' ' + this.attr('height')
});
},
duration: pick(animate, true) ? undefined : 0
});
while (i--) {
alignedObjects[i].align();
}
},
/**
* Create and return an svg group element.
*
* @param {string} [name] The group will be given a class name of
* `highcharts-{name}`. This can be used for styling and scripting.
* @returns {SVGElement} The generated wrapper element.
*/
g: function(name) {
var elem = this.createElement('g');
return name ? elem.attr({
'class': 'highcharts-' + name
}) : elem;
},
/**
* Display an image.
* @param {string} src The image source.
* @param {number} [x] The X position.
* @param {number} [y] The Y position.
* @param {number} [width] The image width. If omitted, it defaults to the
* image file width.
* @param {number} [height] The image height. If omitted it defaults to the
* image file height.
* @returns {SVGElement} The generated wrapper element.
*/
image: function(src, x, y, width, height) {
var attribs = {
preserveAspectRatio: 'none'
},
elemWrapper;
// optional properties
if (arguments.length > 1) {
extend(attribs, {
x: x,
y: y,
width: width,
height: height
});
}
elemWrapper = this.createElement('image').attr(attribs);
// set the href in the xlink namespace
if (elemWrapper.element.setAttributeNS) {
elemWrapper.element.setAttributeNS('http://www.w3.org/1999/xlink',
'href', src);
} else {
// could be exporting in IE
// using href throws "not supported" in ie7 and under, requries regex shim to fix later
elemWrapper.element.setAttribute('hc-svg-href', src);
}
return elemWrapper;
},
/**
* Draw a symbol out of pre-defined shape paths from {@SVGRenderer#symbols}.
* It is used in Highcharts for point makers, which cake a `symbol` option,
* and label and button backgrounds like in the tooltip and stock flags.
*
* @param {Symbol} symbol - The symbol name.
* @param {number} x - The X coordinate for the top left position.
* @param {number} y - The Y coordinate for the top left position.
* @param {number} width - The pixel width.
* @param {number} height - The pixel height.
* @param {Object} [options] - Additional options, depending on the actual
* symbol drawn.
* @param {number} [options.anchorX] - The anchor X position for the
* `callout` symbol. This is where the chevron points to.
* @param {number} [options.anchorY] - The anchor Y position for the
* `callout` symbol. This is where the chevron points to.
* @param {number} [options.end] - The end angle of an `arc` symbol.
* @param {boolean} [options.open] - Whether to draw `arc` symbol open or
* closed.
* @param {number} [options.r] - The radius of an `arc` symbol, or the
* border radius for the `callout` symbol.
* @param {number} [options.start] - The start angle of an `arc` symbol.
*/
symbol: function(symbol, x, y, width, height, options) {
var ren = this,
obj,
// get the symbol definition function
symbolFn = this.symbols[symbol],
// check if there's a path defined for this symbol
path = defined(x) && symbolFn && this.symbols[symbol](
Math.round(x),
Math.round(y),
width,
height,
options
),
imageRegex = /^url\((.*?)\)$/,
imageSrc,
centerImage;
if (symbolFn) {
obj = this.path(path);
obj.attr('fill', 'none');
// expando properties for use in animate and attr
extend(obj, {
symbolName: symbol,
x: x,
y: y,
width: width,
height: height
});
if (options) {
extend(obj, options);
}
// image symbols
} else if (imageRegex.test(symbol)) {
imageSrc = symbol.match(imageRegex)[1];
// Create the image synchronously, add attribs async
obj = this.image(imageSrc);
// The image width is not always the same as the symbol width. The
// image may be centered within the symbol, as is the case when
// image shapes are used as label backgrounds, for example in flags.
obj.imgwidth = pick(
symbolSizes[imageSrc] && symbolSizes[imageSrc].width,
options && options.width
);
obj.imgheight = pick(
symbolSizes[imageSrc] && symbolSizes[imageSrc].height,
options && options.height
);
/**
* Set the size and position
*/
centerImage = function() {
obj.attr({
width: obj.width,
height: obj.height
});
};
/**
* Width and height setters that take both the image's physical size
* and the label size into consideration, and translates the image
* to center within the label.
*/
each(['width', 'height'], function(key) {
obj[key + 'Setter'] = function(value, key) {
var attribs = {},
imgSize = this['img' + key],
trans = key === 'width' ? 'translateX' : 'translateY';
this[key] = value;
if (defined(imgSize)) {
if (this.element) {
this.element.setAttribute(key, imgSize);
}
if (!this.alignByTranslate) {
attribs[trans] = ((this[key] || 0) - imgSize) / 2;
this.attr(attribs);
}
}
};
});
if (defined(x)) {
obj.attr({
x: x,
y: y
});
}
obj.isImg = true;
if (defined(obj.imgwidth) && defined(obj.imgheight)) {
centerImage();
} else {
// Initialize image to be 0 size so export will still function if there's no cached sizes.
obj.attr({
width: 0,
height: 0
});
// Create a dummy JavaScript image to get the width and height. Due to a bug in IE < 8,
// the created element must be assigned to a variable in order to load (#292).
createElement('img', {
onload: function() {
var chart = charts[ren.chartIndex];
// Special case for SVGs on IE11, the width is not accessible until the image is
// part of the DOM (#2854).
if (this.width === 0) {
css(this, {
position: 'absolute',
top: '-999em'
});
doc.body.appendChild(this);
}
// Center the image
symbolSizes[imageSrc] = { // Cache for next
width: this.width,
height: this.height
};
obj.imgwidth = this.width;
obj.imgheight = this.height;
if (obj.element) {
centerImage();
}
// Clean up after #2854 workaround.
if (this.parentNode) {
this.parentNode.removeChild(this);
}
// Fire the load event when all external images are loaded
ren.imgCount--;
if (!ren.imgCount && chart && chart.onload) {
chart.onload();
}
},
src: imageSrc
});
this.imgCount++;
}
}
return obj;
},
/**
* @typedef {string} Symbol
*
* Can be one of `arc`, `callout`, `circle`, `diamond`, `square`,
* `triangle`, `triangle-down`. Symbols are used internally for point
* markers, button and label borders and backgrounds, or custom shapes.
* Extendable by adding to {@link SVGRenderer#symbols}.
*/
/**
* An extendable collection of functions for defining symbol paths.
*/
symbols: {
'circle': function(x, y, w, h) {
// Return a full arc
return this.arc(x + w / 2, y + h / 2, w / 2, h / 2, {
start: 0,
end: Math.PI * 2,
open: false
});
},
'square': function(x, y, w, h) {
return [
'M', x, y,
'L', x + w, y,
x + w, y + h,
x, y + h,
'Z'
];
},
'triangle': function(x, y, w, h) {
return [
'M', x + w / 2, y,
'L', x + w, y + h,
x, y + h,
'Z'
];
},
'triangle-down': function(x, y, w, h) {
return [
'M', x, y,
'L', x + w, y,
x + w / 2, y + h,
'Z'
];
},
'diamond': function(x, y, w, h) {
return [
'M', x + w / 2, y,
'L', x + w, y + h / 2,
x + w / 2, y + h,
x, y + h / 2,
'Z'
];
},
'arc': function(x, y, w, h, options) {
var start = options.start,
rx = options.r || w,
ry = options.r || h || w,
end = options.end - 0.001, // to prevent cos and sin of start and end from becoming equal on 360 arcs (related: #1561)
innerRadius = options.innerR,
open = options.open,
cosStart = Math.cos(start),
sinStart = Math.sin(start),
cosEnd = Math.cos(end),
sinEnd = Math.sin(end),
longArc = options.end - start < Math.PI ? 0 : 1,
arc;
arc = [
'M',
x + rx * cosStart,
y + ry * sinStart,
'A', // arcTo
rx, // x radius
ry, // y radius
0, // slanting
longArc, // long or short arc
1, // clockwise
x + rx * cosEnd,
y + ry * sinEnd
];
if (defined(innerRadius)) {
arc.push(
open ? 'M' : 'L',
x + innerRadius * cosEnd,
y + innerRadius * sinEnd,
'A', // arcTo
innerRadius, // x radius
innerRadius, // y radius
0, // slanting
longArc, // long or short arc
0, // clockwise
x + innerRadius * cosStart,
y + innerRadius * sinStart
);
}
arc.push(open ? '' : 'Z'); // close
return arc;
},
/**
* Callout shape used for default tooltips, also used for rounded rectangles in VML
*/
callout: function(x, y, w, h, options) {
var arrowLength = 6,
halfDistance = 6,
r = Math.min((options && options.r) || 0, w, h),
safeDistance = r + halfDistance,
anchorX = options && options.anchorX,
anchorY = options && options.anchorY,
path;
path = [
'M', x + r, y,
'L', x + w - r, y, // top side
'C', x + w, y, x + w, y, x + w, y + r, // top-right corner
'L', x + w, y + h - r, // right side
'C', x + w, y + h, x + w, y + h, x + w - r, y + h, // bottom-right corner
'L', x + r, y + h, // bottom side
'C', x, y + h, x, y + h, x, y + h - r, // bottom-left corner
'L', x, y + r, // left side
'C', x, y, x, y, x + r, y // top-left corner
];
// Anchor on right side
if (anchorX && anchorX > w) {
// Chevron
if (anchorY > y + safeDistance && anchorY < y + h - safeDistance) {
path.splice(13, 3,
'L', x + w, anchorY - halfDistance,
x + w + arrowLength, anchorY,
x + w, anchorY + halfDistance,
x + w, y + h - r
);
// Simple connector
} else {
path.splice(13, 3,
'L', x + w, h / 2,
anchorX, anchorY,
x + w, h / 2,
x + w, y + h - r
);
}
// Anchor on left side
} else if (anchorX && anchorX < 0) {
// Chevron
if (anchorY > y + safeDistance && anchorY < y + h - safeDistance) {
path.splice(33, 3,
'L', x, anchorY + halfDistance,
x - arrowLength, anchorY,
x, anchorY - halfDistance,
x, y + r
);
// Simple connector
} else {
path.splice(33, 3,
'L', x, h / 2,
anchorX, anchorY,
x, h / 2,
x, y + r
);
}
} else if (anchorY && anchorY > h && anchorX > x + safeDistance && anchorX < x + w - safeDistance) { // replace bottom
path.splice(23, 3,
'L', anchorX + halfDistance, y + h,
anchorX, y + h + arrowLength,
anchorX - halfDistance, y + h,
x + r, y + h
);
} else if (anchorY && anchorY < 0 && anchorX > x + safeDistance && anchorX < x + w - safeDistance) { // replace top
path.splice(3, 3,
'L', anchorX - halfDistance, y,
anchorX, y - arrowLength,
anchorX + halfDistance, y,
w - r, y
);
}
return path;
}
},
/**
* @typedef {SVGElement} ClipRect - A clipping rectangle that can be applied
* to one or more {@link SVGElement} instances. It is instanciated with the
* {@link SVGRenderer#clipRect} function and applied with the {@link
* SVGElement#clip} function.
*
* @example
* var circle = renderer.circle(100, 100, 100)
* .attr({ fill: 'red' })
* .add();
* var clipRect = renderer.clipRect(100, 100, 100, 100);
*
* // Leave only the lower right quarter visible
* circle.clip(clipRect);
*/
/**
* Define a clipping rectangle
* @param {String} id
* @param {number} x
* @param {number} y
* @param {number} width
* @param {number} height
* @returns {ClipRect} A clipping rectangle.
*/
clipRect: function(x, y, width, height) {
var wrapper,
id = H.uniqueKey(),
clipPath = this.createElement('clipPath').attr({
id: id
}).add(this.defs);
wrapper = this.rect(x, y, width, height, 0).add(clipPath);
wrapper.id = id;
wrapper.clipPath = clipPath;
wrapper.count = 0;
return wrapper;
},
/**
* Add text to the SVG object
* @param {String} str
* @param {number} x Left position
* @param {number} y Top position
* @param {Boolean} useHTML Use HTML to render the text
*/
text: function(str, x, y, useHTML) {
// declare variables
var renderer = this,
fakeSVG = !svg && renderer.forExport,
wrapper,
attribs = {};
if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
return renderer.html(str, x, y);
}
attribs.x = Math.round(x || 0); // X is always needed for line-wrap logic
if (y) {
attribs.y = Math.round(y);
}
if (str || str === 0) {
attribs.text = str;
}
wrapper = renderer.createElement('text')
.attr(attribs);
// Prevent wrapping from creating false offsetWidths in export in legacy IE (#1079, #1063)
if (fakeSVG) {
wrapper.css({
position: 'absolute'
});
}
if (!useHTML) {
wrapper.xSetter = function(value, key, element) {
var tspans = element.getElementsByTagName('tspan'),
tspan,
parentVal = element.getAttribute(key),
i;
for (i = 0; i < tspans.length; i++) {
tspan = tspans[i];
// If the x values are equal, the tspan represents a linebreak
if (tspan.getAttribute(key) === parentVal) {
tspan.setAttribute(key, value);
}
}
element.setAttribute(key, value);
};
}
return wrapper;
},
/**
* Utility to return the baseline offset and total line height from the font
* size.
*
* @param {?string} fontSize The current font size to inspect. If not given,
* the font size will be found from the DOM element.
* @param {SVGElement|SVGDOMElement} [elem] The element to inspect for a
* current font size.
* @returns {Object} An object containing `h`: the line height, `b`: the
* baseline relative to the top of the box, and `f`: the font size.
*/
fontMetrics: function(fontSize, elem) {
var lineHeight,
baseline;
fontSize = fontSize ||
// When the elem is a DOM element (#5932)
(elem && elem.style && elem.style.fontSize) ||
// Fall back on the renderer style default
(this.style && this.style.fontSize);
// Handle different units
if (/px/.test(fontSize)) {
fontSize = pInt(fontSize);
} else if (/em/.test(fontSize)) {
// The em unit depends on parent items
fontSize = parseFloat(fontSize) *
(elem ? this.fontMetrics(null, elem.parentNode).f : 16);
} else {
fontSize = 12;
}
// Empirical values found by comparing font size and bounding box
// height. Applies to the default font family.
// http://jsfiddle.net/highcharts/7xvn7/
lineHeight = fontSize < 24 ? fontSize + 3 : Math.round(fontSize * 1.2);
baseline = Math.round(lineHeight * 0.8);
return {
h: lineHeight,
b: baseline,
f: fontSize
};
},
/**
* Correct X and Y positioning of a label for rotation (#1764)
*/
rotCorr: function(baseline, rotation, alterY) {
var y = baseline;
if (rotation && alterY) {
y = Math.max(y * Math.cos(rotation * deg2rad), 4);
}
return {
x: (-baseline / 3) * Math.sin(rotation * deg2rad),
y: y
};
},
/**
* Add a label, a text item that can hold a colored or gradient background
* as well as a border and shadow. Supported custom attributes include
* `padding`.
*
* @param {string} str
* @param {number} x
* @param {number} y
* @param {String} shape
* @param {number} anchorX In case the shape has a pointer, like a flag, this is the
* coordinates it should be pinned to
* @param {number} anchorY
* @param {Boolean} baseline Whether to position the label relative to the text baseline,
* like renderer.text, or to the upper border of the rectangle.
* @param {String} className Class name for the group
*/
label: function(str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
var renderer = this,
wrapper = renderer.g(className !== 'button' && 'label'),
text = wrapper.text = renderer.text('', 0, 0, useHTML)
.attr({
zIndex: 1
}),
box,
bBox,
alignFactor = 0,
padding = 3,
paddingLeft = 0,
width,
height,
wrapperX,
wrapperY,
textAlign,
deferredAttr = {},
strokeWidth,
baselineOffset,
hasBGImage = /^url\((.*?)\)$/.test(shape),
needsBox = hasBGImage,
getCrispAdjust,
updateBoxSize,
updateTextPadding,
boxAttr;
if (className) {
wrapper.addClass('highcharts-' + className);
}
needsBox = hasBGImage;
getCrispAdjust = function() {
return (strokeWidth || 0) % 2 / 2;
};
/**
* This function runs after the label is added to the DOM (when the bounding box is
* available), and after the text of the label is updated to detect the new bounding
* box and reflect it in the border box.
*/
updateBoxSize = function() {
var style = text.element.style,
crispAdjust,
attribs = {};
bBox = (width === undefined || height === undefined || textAlign) && defined(text.textStr) &&
text.getBBox(); //#3295 && 3514 box failure when string equals 0
wrapper.width = (width || bBox.width || 0) + 2 * padding + paddingLeft;
wrapper.height = (height || bBox.height || 0) + 2 * padding;
// Update the label-scoped y offset
baselineOffset = padding + renderer.fontMetrics(style && style.fontSize, text).b;
if (needsBox) {
// Create the border box if it is not already present
if (!box) {
wrapper.box = box = renderer.symbols[shape] || hasBGImage ? // Symbol definition exists (#5324)
renderer.symbol(shape) :
renderer.rect();
box.addClass(
(className === 'button' ? '' : 'highcharts-label-box') + // Don't use label className for buttons
(className ? ' highcharts-' + className + '-box' : '')
);
box.add(wrapper);
crispAdjust = getCrispAdjust();
attribs.x = crispAdjust;
attribs.y = (baseline ? -baselineOffset : 0) + crispAdjust;
}
// Apply the box attributes
attribs.width = Math.round(wrapper.width);
attribs.height = Math.round(wrapper.height);
box.attr(extend(attribs, deferredAttr));
deferredAttr = {};
}
};
/**
* This function runs after setting text or padding, but only if padding is changed
*/
updateTextPadding = function() {
var textX = paddingLeft + padding,
textY;
// determin y based on the baseline
textY = baseline ? 0 : baselineOffset;
// compensate for alignment
if (defined(width) && bBox && (textAlign === 'center' || textAlign === 'right')) {
textX += {
center: 0.5,
right: 1
}[textAlign] * (width - bBox.width);
}
// update if anything changed
if (textX !== text.x || textY !== text.y) {
text.attr('x', textX);
if (textY !== undefined) {
text.attr('y', textY);
}
}
// record current values
text.x = textX;
text.y = textY;
};
/**
* Set a box attribute, or defer it if the box is not yet created
* @param {Object} key
* @param {Object} value
*/
boxAttr = function(key, value) {
if (box) {
box.attr(key, value);
} else {
deferredAttr[key] = value;
}
};
/**
* After the text element is added, get the desired size of the border box
* and add it before the text in the DOM.
*/
wrapper.onAdd = function() {
text.add(wrapper);
wrapper.attr({
text: (str || str === 0) ? str : '', // alignment is available now // #3295: 0 not rendered if given as a value
x: x,
y: y
});
if (box && defined(anchorX)) {
wrapper.attr({
anchorX: anchorX,
anchorY: anchorY
});
}
};
/*
* Add specific attribute setters.
*/
// only change local variables
wrapper.widthSetter = function(value) {
width = H.isNumber(value) ? value : null; // width:auto => null
};
wrapper.heightSetter = function(value) {
height = value;
};
wrapper['text-alignSetter'] = function(value) {
textAlign = value;
};
wrapper.paddingSetter = function(value) {
if (defined(value) && value !== padding) {
padding = wrapper.padding = value;
updateTextPadding();
}
};
wrapper.paddingLeftSetter = function(value) {
if (defined(value) && value !== paddingLeft) {
paddingLeft = value;
updateTextPadding();
}
};
// change local variable and prevent setting attribute on the group
wrapper.alignSetter = function(value) {
value = {
left: 0,
center: 0.5,
right: 1
}[value];
if (value !== alignFactor) {
alignFactor = value;
if (bBox) { // Bounding box exists, means we're dynamically changing
wrapper.attr({
x: wrapperX
}); // #5134
}
}
};
// apply these to the box and the text alike
wrapper.textSetter = function(value) {
if (value !== undefined) {
text.textSetter(value);
}
updateBoxSize();
updateTextPadding();
};
// apply these to the box but not to the text
wrapper['stroke-widthSetter'] = function(value, key) {
if (value) {
needsBox = true;
}
strokeWidth = this['stroke-width'] = value;
boxAttr(key, value);
};
wrapper.strokeSetter = wrapper.fillSetter = wrapper.rSetter = function(value, key) {
if (key === 'fill' && value) {
needsBox = true;
}
boxAttr(key, value);
};
wrapper.anchorXSetter = function(value, key) {
anchorX = value;
boxAttr(key, Math.round(value) - getCrispAdjust() - wrapperX);
};
wrapper.anchorYSetter = function(value, key) {
anchorY = value;
boxAttr(key, value - wrapperY);
};
// rename attributes
wrapper.xSetter = function(value) {
wrapper.x = value; // for animation getter
if (alignFactor) {
value -= alignFactor * ((width || bBox.width) + 2 * padding);
}
wrapperX = Math.round(value);
wrapper.attr('translateX', wrapperX);
};
wrapper.ySetter = function(value) {
wrapperY = wrapper.y = Math.round(value);
wrapper.attr('translateY', wrapperY);
};
// Redirect certain methods to either the box or the text
var baseCss = wrapper.css;
return extend(wrapper, {
/**
* Pick up some properties and apply them to the text instead of the
* wrapper.
* @ignore
*/
css: function(styles) {
if (styles) {
var textStyles = {};
styles = merge(styles); // create a copy to avoid altering the original object (#537)
each(wrapper.textProps, function(prop) {
if (styles[prop] !== undefined) {
textStyles[prop] = styles[prop];
delete styles[prop];
}
});
text.css(textStyles);
}
return baseCss.call(wrapper, styles);
},
/**
* Return the bounding box of the box, not the group.
* @ignore
*/
getBBox: function() {
return {
width: bBox.width + 2 * padding,
height: bBox.height + 2 * padding,
x: bBox.x - padding,
y: bBox.y - padding
};
},
/**
* Apply the shadow to the box.
* @ignore
*/
shadow: function(b) {
if (b) {
updateBoxSize();
if (box) {
box.shadow(b);
}
}
return wrapper;
},
/**
* Destroy and release memory.
* @ignore
*/
destroy: function() {
// Added by button implementation
removeEvent(wrapper.element, 'mouseenter');
removeEvent(wrapper.element, 'mouseleave');
if (text) {
text = text.destroy();
}
if (box) {
box = box.destroy();
}
// Call base implementation to destroy the rest
SVGElement.prototype.destroy.call(wrapper);
// Release local pointers (#1298)
wrapper = renderer = updateBoxSize = updateTextPadding = boxAttr = null;
}
});
}
}; // end SVGRenderer
// general renderer
H.Renderer = SVGRenderer;
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var attr = H.attr,
createElement = H.createElement,
css = H.css,
defined = H.defined,
each = H.each,
extend = H.extend,
isFirefox = H.isFirefox,
isMS = H.isMS,
isWebKit = H.isWebKit,
pInt = H.pInt,
SVGElement = H.SVGElement,
SVGRenderer = H.SVGRenderer,
win = H.win,
wrap = H.wrap;
// Extend SvgElement for useHTML option
extend(SVGElement.prototype, /** @lends SVGElement.prototype */ {
/**
* Apply CSS to HTML elements. This is used in text within SVG rendering and
* by the VML renderer
*/
htmlCss: function(styles) {
var wrapper = this,
element = wrapper.element,
textWidth = styles && element.tagName === 'SPAN' && styles.width;
if (textWidth) {
delete styles.width;
wrapper.textWidth = textWidth;
wrapper.updateTransform();
}
if (styles && styles.textOverflow === 'ellipsis') {
styles.whiteSpace = 'nowrap';
styles.overflow = 'hidden';
}
wrapper.styles = extend(wrapper.styles, styles);
css(wrapper.element, styles);
return wrapper;
},
/**
* VML and useHTML method for calculating the bounding box based on offsets
* @param {Boolean} refresh Whether to force a fresh value from the DOM or to
* use the cached value
*
* @return {Object} A hash containing values for x, y, width and height
*/
htmlGetBBox: function() {
var wrapper = this,
element = wrapper.element;
// faking getBBox in exported SVG in legacy IE
// faking getBBox in exported SVG in legacy IE (is this a duplicate of the fix for #1079?)
if (element.nodeName === 'text') {
element.style.position = 'absolute';
}
return {
x: element.offsetLeft,
y: element.offsetTop,
width: element.offsetWidth,
height: element.offsetHeight
};
},
/**
* VML override private method to update elements based on internal
* properties based on SVG transform
*/
htmlUpdateTransform: function() {
// aligning non added elements is expensive
if (!this.added) {
this.alignOnAdd = true;
return;
}
var wrapper = this,
renderer = wrapper.renderer,
elem = wrapper.element,
translateX = wrapper.translateX || 0,
translateY = wrapper.translateY || 0,
x = wrapper.x || 0,
y = wrapper.y || 0,
align = wrapper.textAlign || 'left',
alignCorrection = {
left: 0,
center: 0.5,
right: 1
}[align],
styles = wrapper.styles;
// apply translate
css(elem, {
marginLeft: translateX,
marginTop: translateY
});
if (wrapper.shadows) { // used in labels/tooltip
each(wrapper.shadows, function(shadow) {
css(shadow, {
marginLeft: translateX + 1,
marginTop: translateY + 1
});
});
}
// apply inversion
if (wrapper.inverted) { // wrapper is a group
each(elem.childNodes, function(child) {
renderer.invertChild(child, elem);
});
}
if (elem.tagName === 'SPAN') {
var rotation = wrapper.rotation,
baseline,
textWidth = pInt(wrapper.textWidth),
whiteSpace = styles && styles.whiteSpace,
currentTextTransform = [rotation, align, elem.innerHTML, wrapper.textWidth, wrapper.textAlign].join(',');
if (currentTextTransform !== wrapper.cTT) { // do the calculations and DOM access only if properties changed
baseline = renderer.fontMetrics(elem.style.fontSize).b;
// Renderer specific handling of span rotation
if (defined(rotation)) {
wrapper.setSpanRotation(rotation, alignCorrection, baseline);
}
// Reset multiline/ellipsis in order to read width (#4928, #5417)
css(elem, {
width: '',
whiteSpace: whiteSpace || 'nowrap'
});
// Update textWidth
if (elem.offsetWidth > textWidth && /[ \-]/.test(elem.textContent || elem.innerText)) { // #983, #1254
css(elem, {
width: textWidth + 'px',
display: 'block',
whiteSpace: whiteSpace || 'normal' // #3331
});
}
wrapper.getSpanCorrection(elem.offsetWidth, baseline, alignCorrection, rotation, align);
}
// apply position with correction
css(elem, {
left: (x + (wrapper.xCorr || 0)) + 'px',
top: (y + (wrapper.yCorr || 0)) + 'px'
});
// force reflow in webkit to apply the left and top on useHTML element (#1249)
if (isWebKit) {
baseline = elem.offsetHeight; // assigned to baseline for lint purpose
}
// record current text transform
wrapper.cTT = currentTextTransform;
}
},
/**
* Set the rotation of an individual HTML span
*/
setSpanRotation: function(rotation, alignCorrection, baseline) {
var rotationStyle = {},
cssTransformKey = isMS ? '-ms-transform' : isWebKit ? '-webkit-transform' : isFirefox ? 'MozTransform' : win.opera ? '-o-transform' : '';
rotationStyle[cssTransformKey] = rotationStyle.transform = 'rotate(' + rotation + 'deg)';
rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] = rotationStyle.transformOrigin = (alignCorrection * 100) + '% ' + baseline + 'px';
css(this.element, rotationStyle);
},
/**
* Get the correction in X and Y positioning as the element is rotated.
*/
getSpanCorrection: function(width, baseline, alignCorrection) {
this.xCorr = -width * alignCorrection;
this.yCorr = -baseline;
}
});
// Extend SvgRenderer for useHTML option.
extend(SVGRenderer.prototype, /** @lends SVGRenderer.prototype */ {
/**
* Create HTML text node. This is used by the VML renderer as well as the SVG
* renderer through the useHTML option.
*
* @param {String} str
* @param {Number} x
* @param {Number} y
*/
html: function(str, x, y) {
var wrapper = this.createElement('span'),
element = wrapper.element,
renderer = wrapper.renderer,
isSVG = renderer.isSVG,
addSetters = function(element, style) {
// These properties are set as attributes on the SVG group, and as
// identical CSS properties on the div. (#3542)
each(['opacity', 'visibility'], function(prop) {
wrap(element, prop + 'Setter', function(proceed, value, key, elem) {
proceed.call(this, value, key, elem);
style[key] = value;
});
});
};
// Text setter
wrapper.textSetter = function(value) {
if (value !== element.innerHTML) {
delete this.bBox;
}
element.innerHTML = this.textStr = value;
wrapper.htmlUpdateTransform();
};
// Add setters for the element itself (#4938)
if (isSVG) { // #4938, only for HTML within SVG
addSetters(wrapper, wrapper.element.style);
}
// Various setters which rely on update transform
wrapper.xSetter = wrapper.ySetter = wrapper.alignSetter = wrapper.rotationSetter = function(value, key) {
if (key === 'align') {
key = 'textAlign'; // Do not overwrite the SVGElement.align method. Same as VML.
}
wrapper[key] = value;
wrapper.htmlUpdateTransform();
};
// Set the default attributes
wrapper
.attr({
text: str,
x: Math.round(x),
y: Math.round(y)
})
.css({
fontFamily: this.style.fontFamily,
fontSize: this.style.fontSize,
position: 'absolute'
});
// Keep the whiteSpace style outside the wrapper.styles collection
element.style.whiteSpace = 'nowrap';
// Use the HTML specific .css method
wrapper.css = wrapper.htmlCss;
// This is specific for HTML within SVG
if (isSVG) {
wrapper.add = function(svgGroupWrapper) {
var htmlGroup,
container = renderer.box.parentNode,
parentGroup,
parents = [];
this.parentGroup = svgGroupWrapper;
// Create a mock group to hold the HTML elements
if (svgGroupWrapper) {
htmlGroup = svgGroupWrapper.div;
if (!htmlGroup) {
// Read the parent chain into an array and read from top down
parentGroup = svgGroupWrapper;
while (parentGroup) {
parents.push(parentGroup);
// Move up to the next parent group
parentGroup = parentGroup.parentGroup;
}
// Ensure dynamically updating position when any parent is translated
each(parents.reverse(), function(parentGroup) {
var htmlGroupStyle,
cls = attr(parentGroup.element, 'class');
if (cls) {
cls = {
className: cls
};
} // else null
// Create a HTML div and append it to the parent div to emulate
// the SVG group structure
htmlGroup = parentGroup.div = parentGroup.div || createElement('div', cls, {
position: 'absolute',
left: (parentGroup.translateX || 0) + 'px',
top: (parentGroup.translateY || 0) + 'px',
display: parentGroup.display,
opacity: parentGroup.opacity, // #5075
pointerEvents: parentGroup.styles && parentGroup.styles.pointerEvents // #5595
}, htmlGroup || container); // the top group is appended to container
// Shortcut
htmlGroupStyle = htmlGroup.style;
// Set listeners to update the HTML div's position whenever the SVG group
// position is changed
extend(parentGroup, {
on: function() {
wrapper.on.apply({
element: parents[0].div
}, arguments);
return parentGroup;
},
translateXSetter: function(value, key) {
htmlGroupStyle.left = value + 'px';
parentGroup[key] = value;
parentGroup.doTransform = true;
},
translateYSetter: function(value, key) {
htmlGroupStyle.top = value + 'px';
parentGroup[key] = value;
parentGroup.doTransform = true;
}
});
addSetters(parentGroup, htmlGroupStyle);
});
}
} else {
htmlGroup = container;
}
htmlGroup.appendChild(element);
// Shared with VML:
wrapper.added = true;
if (wrapper.alignOnAdd) {
wrapper.htmlUpdateTransform();
}
return wrapper;
};
}
return wrapper;
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var VMLRenderer,
VMLRendererExtension,
VMLElement,
createElement = H.createElement,
css = H.css,
defined = H.defined,
deg2rad = H.deg2rad,
discardElement = H.discardElement,
doc = H.doc,
each = H.each,
erase = H.erase,
extend = H.extend,
extendClass = H.extendClass,
isArray = H.isArray,
isNumber = H.isNumber,
isObject = H.isObject,
merge = H.merge,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
svg = H.svg,
SVGElement = H.SVGElement,
SVGRenderer = H.SVGRenderer,
win = H.win;
/* ****************************************************************************
* *
* START OF INTERNET EXPLORER <= 8 SPECIFIC CODE *
* *
* For applications and websites that don't need IE support, like platform *
* targeted mobile apps and web apps, this code can be removed. *
* *
*****************************************************************************/
/**
* @constructor
*/
if (!svg) {
/**
* The VML element wrapper.
*/
VMLElement = {
docMode8: doc && doc.documentMode === 8,
/**
* Initialize a new VML element wrapper. It builds the markup as a string
* to minimize DOM traffic.
* @param {Object} renderer
* @param {Object} nodeName
*/
init: function(renderer, nodeName) {
var wrapper = this,
markup = ['<', nodeName, ' filled="f" stroked="f"'],
style = ['position: ', 'absolute', ';'],
isDiv = nodeName === 'div';
// divs and shapes need size
if (nodeName === 'shape' || isDiv) {
style.push('left:0;top:0;width:1px;height:1px;');
}
style.push('visibility: ', isDiv ? 'hidden' : 'visible');
markup.push(' style="', style.join(''), '"/>');
// create element with default attributes and style
if (nodeName) {
markup = isDiv || nodeName === 'span' || nodeName === 'img' ?
markup.join('') :
renderer.prepVML(markup);
wrapper.element = createElement(markup);
}
wrapper.renderer = renderer;
},
/**
* Add the node to the given parent
* @param {Object} parent
*/
add: function(parent) {
var wrapper = this,
renderer = wrapper.renderer,
element = wrapper.element,
box = renderer.box,
inverted = parent && parent.inverted,
// get the parent node
parentNode = parent ?
parent.element || parent :
box;
if (parent) {
this.parentGroup = parent;
}
// if the parent group is inverted, apply inversion on all children
if (inverted) { // only on groups
renderer.invertChild(element, parentNode);
}
// append it
parentNode.appendChild(element);
// align text after adding to be able to read offset
wrapper.added = true;
if (wrapper.alignOnAdd && !wrapper.deferUpdateTransform) {
wrapper.updateTransform();
}
// fire an event for internal hooks
if (wrapper.onAdd) {
wrapper.onAdd();
}
// IE8 Standards can't set the class name before the element is appended
if (this.className) {
this.attr('class', this.className);
}
return wrapper;
},
/**
* VML always uses htmlUpdateTransform
*/
updateTransform: SVGElement.prototype.htmlUpdateTransform,
/**
* Set the rotation of a span with oldIE's filter
*/
setSpanRotation: function() {
// Adjust for alignment and rotation. Rotation of useHTML content is not yet implemented
// but it can probably be implemented for Firefox 3.5+ on user request. FF3.5+
// has support for CSS3 transform. The getBBox method also needs to be updated
// to compensate for the rotation, like it currently does for SVG.
// Test case: http://jsfiddle.net/highcharts/Ybt44/
var rotation = this.rotation,
costheta = Math.cos(rotation * deg2rad),
sintheta = Math.sin(rotation * deg2rad);
css(this.element, {
filter: rotation ? ['progid:DXImageTransform.Microsoft.Matrix(M11=', costheta,
', M12=', -sintheta, ', M21=', sintheta, ', M22=', costheta,
', sizingMethod=\'auto expand\')'
].join('') : 'none'
});
},
/**
* Get the positioning correction for the span after rotating.
*/
getSpanCorrection: function(width, baseline, alignCorrection, rotation, align) {
var costheta = rotation ? Math.cos(rotation * deg2rad) : 1,
sintheta = rotation ? Math.sin(rotation * deg2rad) : 0,
height = pick(this.elemHeight, this.element.offsetHeight),
quad,
nonLeft = align && align !== 'left';
// correct x and y
this.xCorr = costheta < 0 && -width;
this.yCorr = sintheta < 0 && -height;
// correct for baseline and corners spilling out after rotation
quad = costheta * sintheta < 0;
this.xCorr += sintheta * baseline * (quad ? 1 - alignCorrection : alignCorrection);
this.yCorr -= costheta * baseline * (rotation ? (quad ? alignCorrection : 1 - alignCorrection) : 1);
// correct for the length/height of the text
if (nonLeft) {
this.xCorr -= width * alignCorrection * (costheta < 0 ? -1 : 1);
if (rotation) {
this.yCorr -= height * alignCorrection * (sintheta < 0 ? -1 : 1);
}
css(this.element, {
textAlign: align
});
}
},
/**
* Converts a subset of an SVG path definition to its VML counterpart. Takes an array
* as the parameter and returns a string.
*/
pathToVML: function(value) {
// convert paths
var i = value.length,
path = [];
while (i--) {
// Multiply by 10 to allow subpixel precision.
// Substracting half a pixel seems to make the coordinates
// align with SVG, but this hasn't been tested thoroughly
if (isNumber(value[i])) {
path[i] = Math.round(value[i] * 10) - 5;
} else if (value[i] === 'Z') { // close the path
path[i] = 'x';
} else {
path[i] = value[i];
// When the start X and end X coordinates of an arc are too close,
// they are rounded to the same value above. In this case, substract or
// add 1 from the end X and Y positions. #186, #760, #1371, #1410.
if (value.isArc && (value[i] === 'wa' || value[i] === 'at')) {
// Start and end X
if (path[i + 5] === path[i + 7]) {
path[i + 7] += value[i + 7] > value[i + 5] ? 1 : -1;
}
// Start and end Y
if (path[i + 6] === path[i + 8]) {
path[i + 8] += value[i + 8] > value[i + 6] ? 1 : -1;
}
}
}
}
// Loop up again to handle path shortcuts (#2132)
/*while (i++ < path.length) {
if (path[i] === 'H') { // horizontal line to
path[i] = 'L';
path.splice(i + 2, 0, path[i - 1]);
} else if (path[i] === 'V') { // vertical line to
path[i] = 'L';
path.splice(i + 1, 0, path[i - 2]);
}
}*/
return path.join(' ') || 'x';
},
/**
* Set the element's clipping to a predefined rectangle
*
* @param {String} id The id of the clip rectangle
*/
clip: function(clipRect) {
var wrapper = this,
clipMembers,
cssRet;
if (clipRect) {
clipMembers = clipRect.members;
erase(clipMembers, wrapper); // Ensure unique list of elements (#1258)
clipMembers.push(wrapper);
wrapper.destroyClip = function() {
erase(clipMembers, wrapper);
};
cssRet = clipRect.getCSS(wrapper);
} else {
if (wrapper.destroyClip) {
wrapper.destroyClip();
}
cssRet = {
clip: wrapper.docMode8 ? 'inherit' : 'rect(auto)'
}; // #1214
}
return wrapper.css(cssRet);
},
/**
* Set styles for the element
* @param {Object} styles
*/
css: SVGElement.prototype.htmlCss,
/**
* Removes a child either by removeChild or move to garbageBin.
* Issue 490; in VML removeChild results in Orphaned nodes according to sIEve, discardElement does not.
*/
safeRemoveChild: function(element) {
// discardElement will detach the node from its parent before attaching it
// to the garbage bin. Therefore it is important that the node is attached and have parent.
if (element.parentNode) {
discardElement(element);
}
},
/**
* Extend element.destroy by removing it from the clip members array
*/
destroy: function() {
if (this.destroyClip) {
this.destroyClip();
}
return SVGElement.prototype.destroy.apply(this);
},
/**
* Add an event listener. VML override for normalizing event parameters.
* @param {String} eventType
* @param {Function} handler
*/
on: function(eventType, handler) {
// simplest possible event model for internal use
this.element['on' + eventType] = function() {
var evt = win.event;
evt.target = evt.srcElement;
handler(evt);
};
return this;
},
/**
* In stacked columns, cut off the shadows so that they don't overlap
*/
cutOffPath: function(path, length) {
var len;
path = path.split(/[ ,]/); // The extra comma tricks the trailing comma remover in "gulp scripts" task
len = path.length;
if (len === 9 || len === 11) {
path[len - 4] = path[len - 2] = pInt(path[len - 2]) - 10 * length;
}
return path.join(' ');
},
/**
* Apply a drop shadow by copying elements and giving them different strokes
* @param {Boolean|Object} shadowOptions
*/
shadow: function(shadowOptions, group, cutOff) {
var shadows = [],
i,
element = this.element,
renderer = this.renderer,
shadow,
elemStyle = element.style,
markup,
path = element.path,
strokeWidth,
modifiedPath,
shadowWidth,
shadowElementOpacity;
// some times empty paths are not strings
if (path && typeof path.value !== 'string') {
path = 'x';
}
modifiedPath = path;
if (shadowOptions) {
shadowWidth = pick(shadowOptions.width, 3);
shadowElementOpacity = (shadowOptions.opacity || 0.15) / shadowWidth;
for (i = 1; i <= 3; i++) {
strokeWidth = (shadowWidth * 2) + 1 - (2 * i);
// Cut off shadows for stacked column items
if (cutOff) {
modifiedPath = this.cutOffPath(path.value, strokeWidth + 0.5);
}
markup = ['<shape isShadow="true" strokeweight="', strokeWidth,
'" filled="false" path="', modifiedPath,
'" coordsize="10 10" style="', element.style.cssText, '" />'
];
shadow = createElement(renderer.prepVML(markup),
null, {
left: pInt(elemStyle.left) + pick(shadowOptions.offsetX, 1),
top: pInt(elemStyle.top) + pick(shadowOptions.offsetY, 1)
}
);
if (cutOff) {
shadow.cutOff = strokeWidth + 1;
}
// apply the opacity
markup = [
'<stroke color="',
shadowOptions.color || '#000000',
'" opacity="', shadowElementOpacity * i, '"/>'
];
createElement(renderer.prepVML(markup), null, null, shadow);
// insert it
if (group) {
group.element.appendChild(shadow);
} else {
element.parentNode.insertBefore(shadow, element);
}
// record it
shadows.push(shadow);
}
this.shadows = shadows;
}
return this;
},
updateShadows: noop, // Used in SVG only
setAttr: function(key, value) {
if (this.docMode8) { // IE8 setAttribute bug
this.element[key] = value;
} else {
this.element.setAttribute(key, value);
}
},
classSetter: function(value) {
// IE8 Standards mode has problems retrieving the className unless set like this.
// IE8 Standards can't set the class name before the element is appended.
(this.added ? this.element : this).className = value;
},
dashstyleSetter: function(value, key, element) {
var strokeElem = element.getElementsByTagName('stroke')[0] ||
createElement(this.renderer.prepVML(['<stroke/>']), null, null, element);
strokeElem[key] = value || 'solid';
this[key] = value;
/* because changing stroke-width will change the dash length
and cause an epileptic effect */
},
dSetter: function(value, key, element) {
var i,
shadows = this.shadows;
value = value || [];
this.d = value.join && value.join(' '); // used in getter for animation
element.path = value = this.pathToVML(value);
// update shadows
if (shadows) {
i = shadows.length;
while (i--) {
shadows[i].path = shadows[i].cutOff ? this.cutOffPath(value, shadows[i].cutOff) : value;
}
}
this.setAttr(key, value);
},
fillSetter: function(value, key, element) {
var nodeName = element.nodeName;
if (nodeName === 'SPAN') { // text color
element.style.color = value;
} else if (nodeName !== 'IMG') { // #1336
element.filled = value !== 'none';
this.setAttr('fillcolor', this.renderer.color(value, element, key, this));
}
},
'fill-opacitySetter': function(value, key, element) {
createElement(
this.renderer.prepVML(['<', key.split('-')[0], ' opacity="', value, '"/>']),
null,
null,
element
);
},
opacitySetter: noop, // Don't bother - animation is too slow and filters introduce artifacts
rotationSetter: function(value, key, element) {
var style = element.style;
this[key] = style[key] = value; // style is for #1873
// Correction for the 1x1 size of the shape container. Used in gauge needles.
style.left = -Math.round(Math.sin(value * deg2rad) + 1) + 'px';
style.top = Math.round(Math.cos(value * deg2rad)) + 'px';
},
strokeSetter: function(value, key, element) {
this.setAttr('strokecolor', this.renderer.color(value, element, key, this));
},
'stroke-widthSetter': function(value, key, element) {
element.stroked = !!value; // VML "stroked" attribute
this[key] = value; // used in getter, issue #113
if (isNumber(value)) {
value += 'px';
}
this.setAttr('strokeweight', value);
},
titleSetter: function(value, key) {
this.setAttr(key, value);
},
visibilitySetter: function(value, key, element) {
// Handle inherited visibility
if (value === 'inherit') {
value = 'visible';
}
// Let the shadow follow the main element
if (this.shadows) {
each(this.shadows, function(shadow) {
shadow.style[key] = value;
});
}
// Instead of toggling the visibility CSS property, move the div out of the viewport.
// This works around #61 and #586
if (element.nodeName === 'DIV') {
value = value === 'hidden' ? '-999em' : 0;
// In order to redraw, IE7 needs the div to be visible when tucked away
// outside the viewport. So the visibility is actually opposite of
// the expected value. This applies to the tooltip only.
if (!this.docMode8) {
element.style[key] = value ? 'visible' : 'hidden';
}
key = 'top';
}
element.style[key] = value;
},
xSetter: function(value, key, element) {
this[key] = value; // used in getter
if (key === 'x') {
key = 'left';
} else if (key === 'y') {
key = 'top';
}
/* else {
value = Math.max(0, value); // don't set width or height below zero (#311)
}*/
// clipping rectangle special
if (this.updateClipping) {
this[key] = value; // the key is now 'left' or 'top' for 'x' and 'y'
this.updateClipping();
} else {
// normal
element.style[key] = value;
}
},
zIndexSetter: function(value, key, element) {
element.style[key] = value;
}
};
VMLElement['stroke-opacitySetter'] = VMLElement['fill-opacitySetter'];
H.VMLElement = VMLElement = extendClass(SVGElement, VMLElement);
// Some shared setters
VMLElement.prototype.ySetter =
VMLElement.prototype.widthSetter =
VMLElement.prototype.heightSetter =
VMLElement.prototype.xSetter;
/**
* The VML renderer
*/
VMLRendererExtension = { // inherit SVGRenderer
Element: VMLElement,
isIE8: win.navigator.userAgent.indexOf('MSIE 8.0') > -1,
/**
* Initialize the VMLRenderer
* @param {Object} container
* @param {Number} width
* @param {Number} height
*/
init: function(container, width, height) {
var renderer = this,
boxWrapper,
box,
css;
renderer.alignedObjects = [];
boxWrapper = renderer.createElement('div')
.css({
position: 'relative'
});
box = boxWrapper.element;
container.appendChild(boxWrapper.element);
// generate the containing box
renderer.isVML = true;
renderer.box = box;
renderer.boxWrapper = boxWrapper;
renderer.gradients = {};
renderer.cache = {}; // Cache for numerical bounding boxes
renderer.cacheKeys = [];
renderer.imgCount = 0;
renderer.setSize(width, height, false);
// The only way to make IE6 and IE7 print is to use a global namespace. However,
// with IE8 the only way to make the dynamic shapes visible in screen and print mode
// seems to be to add the xmlns attribute and the behaviour style inline.
if (!doc.namespaces.hcv) {
doc.namespaces.add('hcv', 'urn:schemas-microsoft-com:vml');
// Setup default CSS (#2153, #2368, #2384)
css = 'hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke' +
'{ behavior:url(#default#VML); display: inline-block; } ';
try {
doc.createStyleSheet().cssText = css;
} catch (e) {
doc.styleSheets[0].cssText += css;
}
}
},
/**
* Detect whether the renderer is hidden. This happens when one of the parent elements
* has display: none
*/
isHidden: function() {
return !this.box.offsetWidth;
},
/**
* Define a clipping rectangle. In VML it is accomplished by storing the values
* for setting the CSS style to all associated members.
*
* @param {Number} x
* @param {Number} y
* @param {Number} width
* @param {Number} height
*/
clipRect: function(x, y, width, height) {
// create a dummy element
var clipRect = this.createElement(),
isObj = isObject(x);
// mimic a rectangle with its style object for automatic updating in attr
return extend(clipRect, {
members: [],
count: 0,
left: (isObj ? x.x : x) + 1,
top: (isObj ? x.y : y) + 1,
width: (isObj ? x.width : width) - 1,
height: (isObj ? x.height : height) - 1,
getCSS: function(wrapper) {
var element = wrapper.element,
nodeName = element.nodeName,
isShape = nodeName === 'shape',
inverted = wrapper.inverted,
rect = this,
top = rect.top - (isShape ? element.offsetTop : 0),
left = rect.left,
right = left + rect.width,
bottom = top + rect.height,
ret = {
clip: 'rect(' +
Math.round(inverted ? left : top) + 'px,' +
Math.round(inverted ? bottom : right) + 'px,' +
Math.round(inverted ? right : bottom) + 'px,' +
Math.round(inverted ? top : left) + 'px)'
};
// issue 74 workaround
if (!inverted && wrapper.docMode8 && nodeName === 'DIV') {
extend(ret, {
width: right + 'px',
height: bottom + 'px'
});
}
return ret;
},
// used in attr and animation to update the clipping of all members
updateClipping: function() {
each(clipRect.members, function(member) {
// Member.element is falsy on deleted series, like in
// stock/members/series-remove demo. Should be removed
// from members, but this will do.
if (member.element) {
member.css(clipRect.getCSS(member));
}
});
}
});
},
/**
* Take a color and return it if it's a string, make it a gradient if it's a
* gradient configuration object, and apply opacity.
*
* @param {Object} color The color or config object
*/
color: function(color, elem, prop, wrapper) {
var renderer = this,
colorObject,
regexRgba = /^rgba/,
markup,
fillType,
ret = 'none';
// Check for linear or radial gradient
if (color && color.linearGradient) {
fillType = 'gradient';
} else if (color && color.radialGradient) {
fillType = 'pattern';
}
if (fillType) {
var stopColor,
stopOpacity,
gradient = color.linearGradient || color.radialGradient,
x1,
y1,
x2,
y2,
opacity1,
opacity2,
color1,
color2,
fillAttr = '',
stops = color.stops,
firstStop,
lastStop,
colors = [],
addFillNode = function() {
// Add the fill subnode. When colors attribute is used, the meanings of opacity and o:opacity2
// are reversed.
markup = ['<fill colors="' + colors.join(',') +
'" opacity="', opacity2, '" o:opacity2="',
opacity1, '" type="', fillType, '" ', fillAttr,
'focus="100%" method="any" />'
];
createElement(renderer.prepVML(markup), null, null, elem);
};
// Extend from 0 to 1
firstStop = stops[0];
lastStop = stops[stops.length - 1];
if (firstStop[0] > 0) {
stops.unshift([
0,
firstStop[1]
]);
}
if (lastStop[0] < 1) {
stops.push([
1,
lastStop[1]
]);
}
// Compute the stops
each(stops, function(stop, i) {
if (regexRgba.test(stop[1])) {
colorObject = H.color(stop[1]);
stopColor = colorObject.get('rgb');
stopOpacity = colorObject.get('a');
} else {
stopColor = stop[1];
stopOpacity = 1;
}
// Build the color attribute
colors.push((stop[0] * 100) + '% ' + stopColor);
// Only start and end opacities are allowed, so we use the first and the last
if (!i) {
opacity1 = stopOpacity;
color2 = stopColor;
} else {
opacity2 = stopOpacity;
color1 = stopColor;
}
});
// Apply the gradient to fills only.
if (prop === 'fill') {
// Handle linear gradient angle
if (fillType === 'gradient') {
x1 = gradient.x1 || gradient[0] || 0;
y1 = gradient.y1 || gradient[1] || 0;
x2 = gradient.x2 || gradient[2] || 0;
y2 = gradient.y2 || gradient[3] || 0;
fillAttr = 'angle="' + (90 - Math.atan(
(y2 - y1) / // y vector
(x2 - x1) // x vector
) * 180 / Math.PI) + '"';
addFillNode();
// Radial (circular) gradient
} else {
var r = gradient.r,
sizex = r * 2,
sizey = r * 2,
cx = gradient.cx,
cy = gradient.cy,
radialReference = elem.radialReference,
bBox,
applyRadialGradient = function() {
if (radialReference) {
bBox = wrapper.getBBox();
cx += (radialReference[0] - bBox.x) / bBox.width - 0.5;
cy += (radialReference[1] - bBox.y) / bBox.height - 0.5;
sizex *= radialReference[2] / bBox.width;
sizey *= radialReference[2] / bBox.height;
}
fillAttr = 'src="' + H.getOptions().global.VMLRadialGradientURL + '" ' +
'size="' + sizex + ',' + sizey + '" ' +
'origin="0.5,0.5" ' +
'position="' + cx + ',' + cy + '" ' +
'color2="' + color2 + '" ';
addFillNode();
};
// Apply radial gradient
if (wrapper.added) {
applyRadialGradient();
} else {
// We need to know the bounding box to get the size and position right
wrapper.onAdd = applyRadialGradient;
}
// The fill element's color attribute is broken in IE8 standards mode, so we
// need to set the parent shape's fillcolor attribute instead.
ret = color1;
}
// Gradients are not supported for VML stroke, return the first color. #722.
} else {
ret = stopColor;
}
// If the color is an rgba color, split it and add a fill node
// to hold the opacity component
} else if (regexRgba.test(color) && elem.tagName !== 'IMG') {
colorObject = H.color(color);
wrapper[prop + '-opacitySetter'](colorObject.get('a'), prop, elem);
ret = colorObject.get('rgb');
} else {
var propNodes = elem.getElementsByTagName(prop); // 'stroke' or 'fill' node
if (propNodes.length) {
propNodes[0].opacity = 1;
propNodes[0].type = 'solid';
}
ret = color;
}
return ret;
},
/**
* Take a VML string and prepare it for either IE8 or IE6/IE7.
* @param {Array} markup A string array of the VML markup to prepare
*/
prepVML: function(markup) {
var vmlStyle = 'display:inline-block;behavior:url(#default#VML);',
isIE8 = this.isIE8;
markup = markup.join('');
if (isIE8) { // add xmlns and style inline
markup = markup.replace('/>', ' xmlns="urn:schemas-microsoft-com:vml" />');
if (markup.indexOf('style="') === -1) {
markup = markup.replace('/>', ' style="' + vmlStyle + '" />');
} else {
markup = markup.replace('style="', 'style="' + vmlStyle);
}
} else { // add namespace
markup = markup.replace('<', '<hcv:');
}
return markup;
},
/**
* Create rotated and aligned text
* @param {String} str
* @param {Number} x
* @param {Number} y
*/
text: SVGRenderer.prototype.html,
/**
* Create and return a path element
* @param {Array} path
*/
path: function(path) {
var attr = {
// subpixel precision down to 0.1 (width and height = 1px)
coordsize: '10 10'
};
if (isArray(path)) {
attr.d = path;
} else if (isObject(path)) { // attributes
extend(attr, path);
}
// create the shape
return this.createElement('shape').attr(attr);
},
/**
* Create and return a circle element. In VML circles are implemented as
* shapes, which is faster than v:oval
* @param {Number} x
* @param {Number} y
* @param {Number} r
*/
circle: function(x, y, r) {
var circle = this.symbol('circle');
if (isObject(x)) {
r = x.r;
y = x.y;
x = x.x;
}
circle.isCircle = true; // Causes x and y to mean center (#1682)
circle.r = r;
return circle.attr({
x: x,
y: y
});
},
/**
* Create a group using an outer div and an inner v:group to allow rotating
* and flipping. A simple v:group would have problems with positioning
* child HTML elements and CSS clip.
*
* @param {String} name The name of the group
*/
g: function(name) {
var wrapper,
attribs;
// set the class name
if (name) {
attribs = {
'className': 'highcharts-' + name,
'class': 'highcharts-' + name
};
}
// the div to hold HTML and clipping
wrapper = this.createElement('div').attr(attribs);
return wrapper;
},
/**
* VML override to create a regular HTML image
* @param {String} src
* @param {Number} x
* @param {Number} y
* @param {Number} width
* @param {Number} height
*/
image: function(src, x, y, width, height) {
var obj = this.createElement('img')
.attr({
src: src
});
if (arguments.length > 1) {
obj.attr({
x: x,
y: y,
width: width,
height: height
});
}
return obj;
},
/**
* For rectangles, VML uses a shape for rect to overcome bugs and rotation problems
*/
createElement: function(nodeName) {
return nodeName === 'rect' ?
this.symbol(nodeName) :
SVGRenderer.prototype.createElement.call(this, nodeName);
},
/**
* In the VML renderer, each child of an inverted div (group) is inverted
* @param {Object} element
* @param {Object} parentNode
*/
invertChild: function(element, parentNode) {
var ren = this,
parentStyle = parentNode.style,
imgStyle = element.tagName === 'IMG' && element.style; // #1111
css(element, {
flip: 'x',
left: pInt(parentStyle.width) - (imgStyle ? pInt(imgStyle.top) : 1),
top: pInt(parentStyle.height) - (imgStyle ? pInt(imgStyle.left) : 1),
rotation: -90
});
// Recursively invert child elements, needed for nested composite
// shapes like box plots and error bars. #1680, #1806.
each(element.childNodes, function(child) {
ren.invertChild(child, element);
});
},
/**
* Symbol definitions that override the parent SVG renderer's symbols
*
*/
symbols: {
// VML specific arc function
arc: function(x, y, w, h, options) {
var start = options.start,
end = options.end,
radius = options.r || w || h,
innerRadius = options.innerR,
cosStart = Math.cos(start),
sinStart = Math.sin(start),
cosEnd = Math.cos(end),
sinEnd = Math.sin(end),
ret;
if (end - start === 0) { // no angle, don't show it.
return ['x'];
}
ret = [
'wa', // clockwise arc to
x - radius, // left
y - radius, // top
x + radius, // right
y + radius, // bottom
x + radius * cosStart, // start x
y + radius * sinStart, // start y
x + radius * cosEnd, // end x
y + radius * sinEnd // end y
];
if (options.open && !innerRadius) {
ret.push(
'e',
'M',
x, // - innerRadius,
y // - innerRadius
);
}
ret.push(
'at', // anti clockwise arc to
x - innerRadius, // left
y - innerRadius, // top
x + innerRadius, // right
y + innerRadius, // bottom
x + innerRadius * cosEnd, // start x
y + innerRadius * sinEnd, // start y
x + innerRadius * cosStart, // end x
y + innerRadius * sinStart, // end y
'x', // finish path
'e' // close
);
ret.isArc = true;
return ret;
},
// Add circle symbol path. This performs significantly faster than v:oval.
circle: function(x, y, w, h, wrapper) {
if (wrapper && defined(wrapper.r)) {
w = h = 2 * wrapper.r;
}
// Center correction, #1682
if (wrapper && wrapper.isCircle) {
x -= w / 2;
y -= h / 2;
}
// Return the path
return [
'wa', // clockwisearcto
x, // left
y, // top
x + w, // right
y + h, // bottom
x + w, // start x
y + h / 2, // start y
x + w, // end x
y + h / 2, // end y
//'x', // finish path
'e' // close
];
},
/**
* Add rectangle symbol path which eases rotation and omits arcsize problems
* compared to the built-in VML roundrect shape. When borders are not rounded,
* use the simpler square path, else use the callout path without the arrow.
*/
rect: function(x, y, w, h, options) {
return SVGRenderer.prototype.symbols[!defined(options) || !options.r ? 'square' : 'callout'].call(0, x, y, w, h, options);
}
}
};
H.VMLRenderer = VMLRenderer = function() {
this.init.apply(this, arguments);
};
VMLRenderer.prototype = merge(SVGRenderer.prototype, VMLRendererExtension);
// general renderer
H.Renderer = VMLRenderer;
}
// This method is used with exporting in old IE, when emulating SVG (see #2314)
SVGRenderer.prototype.measureSpanWidth = function(text, styles) {
var measuringSpan = doc.createElement('span'),
offsetWidth,
textNode = doc.createTextNode(text);
measuringSpan.appendChild(textNode);
css(measuringSpan, styles);
this.box.appendChild(measuringSpan);
offsetWidth = measuringSpan.offsetWidth;
discardElement(measuringSpan); // #2463
return offsetWidth;
};
/* ****************************************************************************
* *
* END OF INTERNET EXPLORER <= 8 SPECIFIC CODE *
* *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var color = H.color,
each = H.each,
getTZOffset = H.getTZOffset,
isTouchDevice = H.isTouchDevice,
merge = H.merge,
pick = H.pick,
svg = H.svg,
win = H.win;
/* ****************************************************************************
* Handle the options *
*****************************************************************************/
H.defaultOptions = {
colors: '#7cb5ec #434348 #90ed7d #f7a35c #8085e9 #f15c80 #e4d354 #2b908f #f45b5b #91e8e1'.split(' '),
symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
lang: {
loading: 'Loading...',
months: [
'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'
],
shortMonths: [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
],
weekdays: [
'Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday'
],
// invalidDate: '',
decimalPoint: '.',
numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'], // SI prefixes used in axis labels
resetZoom: 'Reset zoom',
resetZoomTitle: 'Reset zoom level 1:1',
thousandsSep: ' '
},
global: {
useUTC: true,
//timezoneOffset: 0,
VMLRadialGradientURL: 'http://code.highcharts.com/5.0.10/gfx/vml-radial-gradient.png'
},
chart: {
//animation: true,
//alignTicks: false,
//reflow: true,
//className: null,
//events: { load, selection },
//margin: [null],
//marginTop: null,
//marginRight: null,
//marginBottom: null,
//marginLeft: null,
borderRadius: 0,
defaultSeriesType: 'line',
ignoreHiddenSeries: true,
//inverted: false,
spacing: [10, 10, 15, 10],
//spacingTop: 10,
//spacingRight: 10,
//spacingBottom: 15,
//spacingLeft: 10,
//zoomType: ''
resetZoomButton: {
theme: {
zIndex: 20
},
position: {
align: 'right',
x: -10,
//verticalAlign: 'top',
y: 10
}
// relativeTo: 'plot'
},
width: null,
height: null,
borderColor: '#335cad',
//borderWidth: 0,
//style: {
// fontFamily: '"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif', // default font
// fontSize: '12px'
//},
backgroundColor: '#ffffff',
//plotBackgroundColor: null,
plotBorderColor: '#cccccc'
//plotBorderWidth: 0,
//plotShadow: false
},
title: {
text: 'Chart title',
align: 'center',
// floating: false,
margin: 15,
// x: 0,
// verticalAlign: 'top',
// y: null,
// style: {}, // defined inline
widthAdjust: -44
},
subtitle: {
text: '',
align: 'center',
// floating: false
// x: 0,
// verticalAlign: 'top',
// y: null,
// style: {}, // defined inline
widthAdjust: -44
},
plotOptions: {},
labels: {
//items: [],
style: {
//font: defaultFont,
position: 'absolute',
color: '#333333'
}
},
legend: {
enabled: true,
align: 'center',
//floating: false,
layout: 'horizontal',
labelFormatter: function() {
return this.name;
},
//borderWidth: 0,
borderColor: '#999999',
borderRadius: 0,
navigation: {
activeColor: '#003399',
inactiveColor: '#cccccc'
// animation: true,
// arrowSize: 12
// style: {} // text styles
},
// margin: 20,
// reversed: false,
// backgroundColor: null,
/*style: {
padding: '5px'
},*/
itemStyle: {
color: '#333333',
fontSize: '12px',
fontWeight: 'bold'
},
itemHoverStyle: {
//cursor: 'pointer', removed as of #601
color: '#000000'
},
itemHiddenStyle: {
color: '#cccccc'
},
shadow: false,
itemCheckboxStyle: {
position: 'absolute',
width: '13px', // for IE precision
height: '13px'
},
// itemWidth: undefined,
squareSymbol: true,
// symbolRadius: 0,
// symbolWidth: 16,
symbolPadding: 5,
verticalAlign: 'bottom',
// width: undefined,
x: 0,
y: 0,
title: {
//text: null,
style: {
fontWeight: 'bold'
}
}
},
loading: {
// hideDuration: 100,
// showDuration: 0,
labelStyle: {
fontWeight: 'bold',
position: 'relative',
top: '45%'
},
style: {
position: 'absolute',
backgroundColor: '#ffffff',
opacity: 0.5,
textAlign: 'center'
}
},
tooltip: {
enabled: true,
animation: svg,
//crosshairs: null,
borderRadius: 3,
dateTimeLabelFormats: {
millisecond: '%A, %b %e, %H:%M:%S.%L',
second: '%A, %b %e, %H:%M:%S',
minute: '%A, %b %e, %H:%M',
hour: '%A, %b %e, %H:%M',
day: '%A, %b %e, %Y',
week: 'Week from %A, %b %e, %Y',
month: '%B %Y',
year: '%Y'
},
footerFormat: '',
//formatter: defaultFormatter,
/* todo: em font-size when finished comparing against HC4
headerFormat: '<span style="font-size: 0.85em">{point.key}</span><br/>',
*/
padding: 8,
//shape: 'callout',
//shared: false,
snap: isTouchDevice ? 25 : 10,
backgroundColor: color('#f7f7f7').setOpacity(0.85).get(),
borderWidth: 1,
headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',
shadow: true,
style: {
color: '#333333',
cursor: 'default',
fontSize: '12px',
pointerEvents: 'none', // #1686 http://caniuse.com/#feat=pointer-events
whiteSpace: 'nowrap'
}
//xDateFormat: '%A, %b %e, %Y',
//valueDecimals: null,
//valuePrefix: '',
//valueSuffix: ''
},
credits: {
enabled: true,
href: 'http://www.highcharts.com',
position: {
align: 'right',
x: -10,
verticalAlign: 'bottom',
y: -5
},
style: {
cursor: 'pointer',
color: '#999999',
fontSize: '9px'
},
text: 'Highcharts.com'
}
};
/**
* Sets the getTimezoneOffset function. If the timezone option is set, a default
* getTimezoneOffset function with that timezone is returned. If not, the
* specified getTimezoneOffset function is returned. If neither are specified,
* undefined is returned.
* @return {function} a getTimezoneOffset function or undefined
*/
function getTimezoneOffsetOption() {
var globalOptions = H.defaultOptions.global,
moment = win.moment;
if (globalOptions.timezone) {
if (!moment) {
// getTimezoneOffset-function stays undefined because it depends on
// Moment.js
H.error(25);
} else {
return function(timestamp) {
return -moment.tz(
timestamp,
globalOptions.timezone
).utcOffset();
};
}
}
// If not timezone is set, look for the getTimezoneOffset callback
return globalOptions.useUTC && globalOptions.getTimezoneOffset;
}
/**
* Set the time methods globally based on the useUTC option. Time method can be
* either local time or UTC (default). It is called internally on initiating
* Highcharts and after running `Highcharts.setOptions`.
*
* @private
*/
function setTimeMethods() {
var globalOptions = H.defaultOptions.global,
Date,
useUTC = globalOptions.useUTC,
GET = useUTC ? 'getUTC' : 'get',
SET = useUTC ? 'setUTC' : 'set';
H.Date = Date = globalOptions.Date || win.Date; // Allow using a different Date class
Date.hcTimezoneOffset = useUTC && globalOptions.timezoneOffset;
Date.hcGetTimezoneOffset = getTimezoneOffsetOption();
Date.hcMakeTime = function(year, month, date, hours, minutes, seconds) {
var d;
if (useUTC) {
d = Date.UTC.apply(0, arguments);
d += getTZOffset(d);
} else {
d = new Date(
year,
month,
pick(date, 1),
pick(hours, 0),
pick(minutes, 0),
pick(seconds, 0)
).getTime();
}
return d;
};
each(['Minutes', 'Hours', 'Day', 'Date', 'Month', 'FullYear'], function(s) {
Date['hcGet' + s] = GET + s;
});
each(['Milliseconds', 'Seconds', 'Minutes', 'Hours', 'Date', 'Month', 'FullYear'], function(s) {
Date['hcSet' + s] = SET + s;
});
}
/**
* Merge the default options with custom options and return the new options structure
* @param {Object} options The new custom options
*/
H.setOptions = function(options) {
// Copy in the default options
H.defaultOptions = merge(true, H.defaultOptions, options);
// Apply UTC
setTimeMethods();
return H.defaultOptions;
};
/**
* Get the updated default options. Until 3.0.7, merely exposing defaultOptions for outside modules
* wasn't enough because the setOptions method created a new object.
*/
H.getOptions = function() {
return H.defaultOptions;
};
// Series defaults
H.defaultPlotOptions = H.defaultOptions.plotOptions;
// set the default time methods
setTimeMethods();
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
each = H.each,
erase = H.erase,
merge = H.merge,
pick = H.pick;
/*
* The object wrapper for plot lines and plot bands
* @param {Object} options
*/
H.PlotLineOrBand = function(axis, options) {
this.axis = axis;
if (options) {
this.options = options;
this.id = options.id;
}
};
H.PlotLineOrBand.prototype = {
/**
* Render the plot line or plot band. If it is already existing,
* move it.
*/
render: function() {
var plotLine = this,
axis = plotLine.axis,
horiz = axis.horiz,
options = plotLine.options,
optionsLabel = options.label,
label = plotLine.label,
to = options.to,
from = options.from,
value = options.value,
isBand = defined(from) && defined(to),
isLine = defined(value),
svgElem = plotLine.svgElem,
isNew = !svgElem,
path = [],
addEvent,
eventType,
color = options.color,
zIndex = pick(options.zIndex, 0),
events = options.events,
attribs = {
'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') + (options.className || '')
},
groupAttribs = {},
renderer = axis.chart.renderer,
groupName = isBand ? 'bands' : 'lines',
group,
log2lin = axis.log2lin;
// logarithmic conversion
if (axis.isLog) {
from = log2lin(from);
to = log2lin(to);
value = log2lin(value);
}
// Set the presentational attributes
if (isLine) {
attribs = {
stroke: color,
'stroke-width': options.width
};
if (options.dashStyle) {
attribs.dashstyle = options.dashStyle;
}
} else if (isBand) { // plot band
if (color) {
attribs.fill = color;
}
if (options.borderWidth) {
attribs.stroke = options.borderColor;
attribs['stroke-width'] = options.borderWidth;
}
}
// Grouping and zIndex
groupAttribs.zIndex = zIndex;
groupName += '-' + zIndex;
group = axis.plotLinesAndBandsGroups[groupName];
if (!group) {
axis.plotLinesAndBandsGroups[groupName] = group = renderer.g('plot-' + groupName)
.attr(groupAttribs).add();
}
// Create the path
if (isNew) {
plotLine.svgElem = svgElem =
renderer
.path()
.attr(attribs).add(group);
}
// Set the path or return
if (isLine) {
path = axis.getPlotLinePath(value, svgElem.strokeWidth());
} else if (isBand) { // plot band
path = axis.getPlotBandPath(from, to, options);
} else {
return;
}
// common for lines and bands
if (isNew && path && path.length) {
svgElem.attr({
d: path
});
// events
if (events) {
addEvent = function(eventType) {
svgElem.on(eventType, function(e) {
events[eventType].apply(plotLine, [e]);
});
};
for (eventType in events) {
addEvent(eventType);
}
}
} else if (svgElem) {
if (path) {
svgElem.show();
svgElem.animate({
d: path
});
} else {
svgElem.hide();
if (label) {
plotLine.label = label = label.destroy();
}
}
}
// the plot band/line label
if (optionsLabel && defined(optionsLabel.text) && path && path.length &&
axis.width > 0 && axis.height > 0 && !path.flat) {
// apply defaults
optionsLabel = merge({
align: horiz && isBand && 'center',
x: horiz ? !isBand && 4 : 10,
verticalAlign: !horiz && isBand && 'middle',
y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
rotation: horiz && !isBand && 90
}, optionsLabel);
this.renderLabel(optionsLabel, path, isBand, zIndex);
} else if (label) { // move out of sight
label.hide();
}
// chainable
return plotLine;
},
/**
* Render and align label for plot line or band.
*/
renderLabel: function(optionsLabel, path, isBand, zIndex) {
var plotLine = this,
label = plotLine.label,
renderer = plotLine.axis.chart.renderer,
attribs,
xs,
ys,
x,
y;
// add the SVG element
if (!label) {
attribs = {
align: optionsLabel.textAlign || optionsLabel.align,
rotation: optionsLabel.rotation,
'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') + '-label ' + (optionsLabel.className || '')
};
attribs.zIndex = zIndex;
plotLine.label = label = renderer.text(
optionsLabel.text,
0,
0,
optionsLabel.useHTML
)
.attr(attribs)
.add();
label.css(optionsLabel.style);
}
// get the bounding box and align the label
// #3000 changed to better handle choice between plotband or plotline
xs = [path[1], path[4], (isBand ? path[6] : path[1])];
ys = [path[2], path[5], (isBand ? path[7] : path[2])];
x = arrayMin(xs);
y = arrayMin(ys);
label.align(optionsLabel, false, {
x: x,
y: y,
width: arrayMax(xs) - x,
height: arrayMax(ys) - y
});
label.show();
},
/**
* Remove the plot line or band
*/
destroy: function() {
// remove it from the lookup
erase(this.axis.plotLinesAndBands, this);
delete this.axis;
destroyObjectProperties(this);
}
};
/**
* Object with members for extending the Axis prototype
* @todo Extend directly instead of adding object to Highcharts first
*/
H.AxisPlotLineOrBandExtension = {
/**
* Create the path for a plot band
*/
getPlotBandPath: function(from, to) {
var toPath = this.getPlotLinePath(to, null, null, true),
path = this.getPlotLinePath(from, null, null, true),
// #4964 check if chart is inverted or plotband is on yAxis
horiz = this.horiz,
plus = 1,
outside =
(from < this.min && to < this.min) ||
(from > this.max && to > this.max);
if (path && toPath) {
// Flat paths don't need labels (#3836)
if (outside) {
path.flat = path.toString() === toPath.toString();
plus = 0;
}
// Add 1 pixel, when coordinates are the same
path.push(
horiz && toPath[4] === path[4] ? toPath[4] + plus : toPath[4], !horiz && toPath[5] === path[5] ? toPath[5] + plus : toPath[5],
horiz && toPath[1] === path[1] ? toPath[1] + plus : toPath[1], !horiz && toPath[2] === path[2] ? toPath[2] + plus : toPath[2]
);
} else { // outside the axis area
path = null;
}
return path;
},
addPlotBand: function(options) {
return this.addPlotBandOrLine(options, 'plotBands');
},
addPlotLine: function(options) {
return this.addPlotBandOrLine(options, 'plotLines');
},
/**
* Add a plot band or plot line after render time
*
* @param options {Object} The plotBand or plotLine configuration object
*/
addPlotBandOrLine: function(options, coll) {
var obj = new H.PlotLineOrBand(this, options).render(),
userOptions = this.userOptions;
if (obj) { // #2189
// Add it to the user options for exporting and Axis.update
if (coll) {
userOptions[coll] = userOptions[coll] || [];
userOptions[coll].push(options);
}
this.plotLinesAndBands.push(obj);
}
return obj;
},
/**
* Remove a plot band or plot line from the chart by id
* @param {Object} id
*/
removePlotBandOrLine: function(id) {
var plotLinesAndBands = this.plotLinesAndBands,
options = this.options,
userOptions = this.userOptions,
i = plotLinesAndBands.length;
while (i--) {
if (plotLinesAndBands[i].id === id) {
plotLinesAndBands[i].destroy();
}
}
each([options.plotLines || [], userOptions.plotLines || [], options.plotBands || [], userOptions.plotBands || []], function(arr) {
i = arr.length;
while (i--) {
if (arr[i].id === id) {
erase(arr, arr[i]);
}
}
});
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var correctFloat = H.correctFloat,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
isNumber = H.isNumber,
merge = H.merge,
pick = H.pick,
deg2rad = H.deg2rad;
/**
* The Tick class
*/
H.Tick = function(axis, pos, type, noLabel) {
this.axis = axis;
this.pos = pos;
this.type = type || '';
this.isNew = true;
if (!type && !noLabel) {
this.addLabel();
}
};
H.Tick.prototype = {
/**
* Write the tick label
*/
addLabel: function() {
var tick = this,
axis = tick.axis,
options = axis.options,
chart = axis.chart,
categories = axis.categories,
names = axis.names,
pos = tick.pos,
labelOptions = options.labels,
str,
tickPositions = axis.tickPositions,
isFirst = pos === tickPositions[0],
isLast = pos === tickPositions[tickPositions.length - 1],
value = categories ?
pick(categories[pos], names[pos], pos) :
pos,
label = tick.label,
tickPositionInfo = tickPositions.info,
dateTimeLabelFormat;
// Set the datetime label format. If a higher rank is set for this position, use that. If not,
// use the general format.
if (axis.isDatetimeAxis && tickPositionInfo) {
dateTimeLabelFormat =
options.dateTimeLabelFormats[
tickPositionInfo.higherRanks[pos] || tickPositionInfo.unitName
];
}
// set properties for access in render method
tick.isFirst = isFirst;
tick.isLast = isLast;
// get the string
str = axis.labelFormatter.call({
axis: axis,
chart: chart,
isFirst: isFirst,
isLast: isLast,
dateTimeLabelFormat: dateTimeLabelFormat,
value: axis.isLog ? correctFloat(axis.lin2log(value)) : value
});
// prepare CSS
//css = width && { width: Math.max(1, Math.round(width - 2 * (labelOptions.padding || 10))) + 'px' };
// first call
if (!defined(label)) {
tick.label = label =
defined(str) && labelOptions.enabled ?
chart.renderer.text(
str,
0,
0,
labelOptions.useHTML
)
// without position absolute, IE export sometimes is wrong
.css(merge(labelOptions.style))
.add(axis.labelGroup) :
null;
tick.labelLength = label && label.getBBox().width; // Un-rotated length
tick.rotation = 0; // Base value to detect change for new calls to getBBox
// update
} else if (label) {
label.attr({
text: str
});
}
},
/**
* Get the offset height or width of the label
*/
getLabelSize: function() {
return this.label ?
this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
0;
},
/**
* Handle the label overflow by adjusting the labels to the left and right edge, or
* hide them if they collide into the neighbour label.
*/
handleOverflow: function(xy) {
var axis = this.axis,
pxPos = xy.x,
chartWidth = axis.chart.chartWidth,
spacing = axis.chart.spacing,
leftBound = pick(axis.labelLeft, Math.min(axis.pos, spacing[3])),
rightBound = pick(axis.labelRight, Math.max(axis.pos + axis.len, chartWidth - spacing[1])),
label = this.label,
rotation = this.rotation,
factor = {
left: 0,
center: 0.5,
right: 1
}[axis.labelAlign],
labelWidth = label.getBBox().width,
slotWidth = axis.getSlotWidth(),
modifiedSlotWidth = slotWidth,
xCorrection = factor,
goRight = 1,
leftPos,
rightPos,
textWidth,
css = {};
// Check if the label overshoots the chart spacing box. If it does, move it.
// If it now overshoots the slotWidth, add ellipsis.
if (!rotation) {
leftPos = pxPos - factor * labelWidth;
rightPos = pxPos + (1 - factor) * labelWidth;
if (leftPos < leftBound) {
modifiedSlotWidth = xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
} else if (rightPos > rightBound) {
modifiedSlotWidth = rightBound - xy.x + modifiedSlotWidth * factor;
goRight = -1;
}
modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
xy.x += goRight * (slotWidth - modifiedSlotWidth - xCorrection *
(slotWidth - Math.min(labelWidth, modifiedSlotWidth)));
}
// If the label width exceeds the available space, set a text width to be
// picked up below. Also, if a width has been set before, we need to set a new
// one because the reported labelWidth will be limited by the box (#3938).
if (labelWidth > modifiedSlotWidth || (axis.autoRotation && (label.styles || {}).width)) {
textWidth = modifiedSlotWidth;
}
// Add ellipsis to prevent rotated labels to be clipped against the edge of the chart
} else if (rotation < 0 && pxPos - factor * labelWidth < leftBound) {
textWidth = Math.round(pxPos / Math.cos(rotation * deg2rad) - leftBound);
} else if (rotation > 0 && pxPos + factor * labelWidth > rightBound) {
textWidth = Math.round((chartWidth - pxPos) / Math.cos(rotation * deg2rad));
}
if (textWidth) {
css.width = textWidth;
if (!(axis.options.labels.style || {}).textOverflow) {
css.textOverflow = 'ellipsis';
}
label.css(css);
}
},
/**
* Get the x and y position for ticks and labels
*/
getPosition: function(horiz, pos, tickmarkOffset, old) {
var axis = this.axis,
chart = axis.chart,
cHeight = (old && chart.oldChartHeight) || chart.chartHeight;
return {
x: horiz ?
axis.translate(pos + tickmarkOffset, null, null, old) + axis.transB : axis.left + axis.offset +
(axis.opposite ?
((old && chart.oldChartWidth) || chart.chartWidth) - axis.right - axis.left :
0
),
y: horiz ?
cHeight - axis.bottom + axis.offset - (axis.opposite ? axis.height : 0) : cHeight - axis.translate(pos + tickmarkOffset, null, null, old) - axis.transB
};
},
/**
* Get the x, y position of the tick label
*/
getLabelPosition: function(x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
var axis = this.axis,
transA = axis.transA,
reversed = axis.reversed,
staggerLines = axis.staggerLines,
rotCorr = axis.tickRotCorr || {
x: 0,
y: 0
},
yOffset = labelOptions.y,
line;
if (!defined(yOffset)) {
if (axis.side === 0) {
yOffset = label.rotation ? -8 : -label.getBBox().height;
} else if (axis.side === 2) {
yOffset = rotCorr.y + 8;
} else {
// #3140, #3140
yOffset = Math.cos(label.rotation * deg2rad) * (rotCorr.y - label.getBBox(false, 0).height / 2);
}
}
x = x + labelOptions.x + rotCorr.x - (tickmarkOffset && horiz ?
tickmarkOffset * transA * (reversed ? -1 : 1) : 0);
y = y + yOffset - (tickmarkOffset && !horiz ?
tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
// Correct for staggered labels
if (staggerLines) {
line = (index / (step || 1) % staggerLines);
if (axis.opposite) {
line = staggerLines - line - 1;
}
y += line * (axis.labelOffset / staggerLines);
}
return {
x: x,
y: Math.round(y)
};
},
/**
* Extendible method to return the path of the marker
*/
getMarkPath: function(x, y, tickLength, tickWidth, horiz, renderer) {
return renderer.crispLine([
'M',
x,
y,
'L',
x + (horiz ? 0 : -tickLength),
y + (horiz ? tickLength : 0)
], tickWidth);
},
/**
* Renders the gridLine.
* @param {Boolean} old Whether or not the tick is old
* @param {number} opacity The opacity of the grid line
* @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
* @return {undefined}
*/
renderGridLine: function(old, opacity, reverseCrisp) {
var tick = this,
axis = tick.axis,
options = axis.options,
gridLine = tick.gridLine,
gridLinePath,
attribs = {},
pos = tick.pos,
type = tick.type,
tickmarkOffset = axis.tickmarkOffset,
renderer = axis.chart.renderer;
var gridPrefix = type ? type + 'Grid' : 'grid',
gridLineWidth = options[gridPrefix + 'LineWidth'],
gridLineColor = options[gridPrefix + 'LineColor'],
dashStyle = options[gridPrefix + 'LineDashStyle'];
if (!gridLine) {
attribs.stroke = gridLineColor;
attribs['stroke-width'] = gridLineWidth;
if (dashStyle) {
attribs.dashstyle = dashStyle;
}
if (!type) {
attribs.zIndex = 1;
}
if (old) {
attribs.opacity = 0;
}
tick.gridLine = gridLine = renderer.path()
.attr(attribs)
.addClass(
'highcharts-' + (type ? type + '-' : '') + 'grid-line'
)
.add(axis.gridGroup);
}
// If the parameter 'old' is set, the current call will be followed
// by another call, therefore do not do any animations this time
if (!old && gridLine) {
gridLinePath = axis.getPlotLinePath(
pos + tickmarkOffset,
gridLine.strokeWidth() * reverseCrisp,
old, true
);
if (gridLinePath) {
gridLine[tick.isNew ? 'attr' : 'animate']({
d: gridLinePath,
opacity: opacity
});
}
}
},
/**
* Renders the tick mark.
* @param {Object} xy The position vector of the mark
* @param {number} xy.x The x position of the mark
* @param {number} xy.y The y position of the mark
* @param {number} opacity The opacity of the mark
* @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
* @return {undefined}
*/
renderMark: function(xy, opacity, reverseCrisp) {
var tick = this,
axis = tick.axis,
options = axis.options,
renderer = axis.chart.renderer,
type = tick.type,
tickPrefix = type ? type + 'Tick' : 'tick',
tickSize = axis.tickSize(tickPrefix),
mark = tick.mark,
isNewMark = !mark,
x = xy.x,
y = xy.y;
var tickWidth = pick(
options[tickPrefix + 'Width'], !type && axis.isXAxis ? 1 : 0
), // X axis defaults to 1
tickColor = options[tickPrefix + 'Color'];
if (tickSize) {
// negate the length
if (axis.opposite) {
tickSize[0] = -tickSize[0];
}
// First time, create it
if (isNewMark) {
tick.mark = mark = renderer.path()
.addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
.add(axis.axisGroup);
mark.attr({
stroke: tickColor,
'stroke-width': tickWidth
});
}
mark[isNewMark ? 'attr' : 'animate']({
d: tick.getMarkPath(
x,
y,
tickSize[0],
mark.strokeWidth() * reverseCrisp,
axis.horiz,
renderer),
opacity: opacity
});
}
},
/**
* Renders the tick label.
* Note: The label should already be created in init(), so it should only
* have to be moved into place.
* @param {Object} xy The position vector of the label
* @param {number} xy.x The x position of the label
* @param {number} xy.y The y position of the label
* @param {Boolean} old Whether or not the tick is old
* @param {number} opacity The opacity of the label
* @param {number} index The index of the tick
* @return {undefined}
*/
renderLabel: function(xy, old, opacity, index) {
var tick = this,
axis = tick.axis,
horiz = axis.horiz,
options = axis.options,
label = tick.label,
labelOptions = options.labels,
step = labelOptions.step,
tickmarkOffset = axis.tickmarkOffset,
show = true,
x = xy.x,
y = xy.y;
if (label && isNumber(x)) {
label.xy = xy = tick.getLabelPosition(
x,
y,
label,
horiz,
labelOptions,
tickmarkOffset,
index,
step
);
// Apply show first and show last. If the tick is both first and
// last, it is a single centered tick, in which case we show the
// label anyway (#2100).
if (
(
tick.isFirst &&
!tick.isLast &&
!pick(options.showFirstLabel, 1)
) ||
(
tick.isLast &&
!tick.isFirst &&
!pick(options.showLastLabel, 1)
)
) {
show = false;
// Handle label overflow and show or hide accordingly
} else if (horiz && !axis.isRadial && !labelOptions.step &&
!labelOptions.rotation && !old && opacity !== 0) {
tick.handleOverflow(xy);
}
// apply step
if (step && index % step) {
// show those indices dividable by step
show = false;
}
// Set the new position, and show or hide
if (show && isNumber(xy.y)) {
xy.opacity = opacity;
label[tick.isNew ? 'attr' : 'animate'](xy);
} else {
label.attr('y', -9999); // #1338
}
tick.isNew = false;
}
},
/**
* Put everything in place
*
* @param index {Number}
* @param old {Boolean} Use old coordinates to prepare an animation into new
* position
*/
render: function(index, old, opacity) {
var tick = this,
axis = tick.axis,
horiz = axis.horiz,
pos = tick.pos,
tickmarkOffset = axis.tickmarkOffset,
xy = tick.getPosition(horiz, pos, tickmarkOffset, old),
x = xy.x,
y = xy.y,
reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
(!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687
opacity = pick(opacity, 1);
this.isActive = true;
// Create the grid line
this.renderGridLine(old, opacity, reverseCrisp);
// create the tick mark
this.renderMark(xy, opacity, reverseCrisp);
// the label is created on init - now move it into place
this.renderLabel(xy, old, opacity, index);
},
/**
* Destructor for the tick prototype
*/
destroy: function() {
destroyObjectProperties(this, this.axis);
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animObject = H.animObject,
arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
AxisPlotLineOrBandExtension = H.AxisPlotLineOrBandExtension,
color = H.color,
correctFloat = H.correctFloat,
defaultOptions = H.defaultOptions,
defined = H.defined,
deg2rad = H.deg2rad,
destroyObjectProperties = H.destroyObjectProperties,
each = H.each,
extend = H.extend,
fireEvent = H.fireEvent,
format = H.format,
getMagnitude = H.getMagnitude,
grep = H.grep,
inArray = H.inArray,
isArray = H.isArray,
isNumber = H.isNumber,
isString = H.isString,
merge = H.merge,
normalizeTickInterval = H.normalizeTickInterval,
pick = H.pick,
PlotLineOrBand = H.PlotLineOrBand,
removeEvent = H.removeEvent,
splat = H.splat,
syncTimeout = H.syncTimeout,
Tick = H.Tick;
/**
* Create a new axis object.
* @constructor Axis
* @param {Object} chart
* @param {Object} options
*/
H.Axis = function() {
this.init.apply(this, arguments);
};
H.Axis.prototype = {
/**
* Default options for the X axis - the Y axis has extended defaults
*/
defaultOptions: {
// allowDecimals: null,
// alternateGridColor: null,
// categories: [],
dateTimeLabelFormats: {
millisecond: '%H:%M:%S.%L',
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%e. %b',
week: '%e. %b',
month: '%b \'%y',
year: '%Y'
},
endOnTick: false,
// reversed: false,
labels: {
enabled: true,
// rotation: 0,
// align: 'center',
// step: null,
style: {
color: '#666666',
cursor: 'default',
fontSize: '11px'
},
x: 0
//y: undefined
/*formatter: function () {
return this.value;
},*/
},
//linkedTo: null,
//max: undefined,
//min: undefined,
minPadding: 0.01,
maxPadding: 0.01,
//minRange: null,
//minorTickInterval: null,
minorTickLength: 2,
minorTickPosition: 'outside', // inside or outside
//opposite: false,
//offset: 0,
//plotBands: [{
// events: {},
// zIndex: 1,
// labels: { align, x, verticalAlign, y, style, rotation, textAlign }
//}],
//plotLines: [{
// events: {}
// dashStyle: {}
// zIndex:
// labels: { align, x, verticalAlign, y, style, rotation, textAlign }
//}],
//reversed: false,
// showFirstLabel: true,
// showLastLabel: true,
startOfWeek: 1,
startOnTick: false,
//tickInterval: null,
tickLength: 10,
tickmarkPlacement: 'between', // on or between
tickPixelInterval: 100,
tickPosition: 'outside',
title: {
//text: null,
align: 'middle', // low, middle or high
//margin: 0 for horizontal, 10 for vertical axes,
//rotation: 0,
//side: 'outside',
style: {
color: '#666666'
}
//x: 0,
//y: 0
},
type: 'linear', // linear, logarithmic or datetime
//visible: true
minorGridLineColor: '#f2f2f2',
// minorGridLineDashStyle: null,
minorGridLineWidth: 1,
minorTickColor: '#999999',
//minorTickWidth: 0,
lineColor: '#ccd6eb',
lineWidth: 1,
gridLineColor: '#e6e6e6',
// gridLineDashStyle: 'solid',
// gridLineWidth: 0,
tickColor: '#ccd6eb'
// tickWidth: 1
},
/**
* This options set extends the defaultOptions for Y axes
*/
defaultYAxisOptions: {
endOnTick: true,
tickPixelInterval: 72,
showLastLabel: true,
labels: {
x: -8
},
maxPadding: 0.05,
minPadding: 0.05,
startOnTick: true,
title: {
rotation: 270,
text: 'Values'
},
stackLabels: {
enabled: false,
//align: dynamic,
//y: dynamic,
//x: dynamic,
//verticalAlign: dynamic,
//textAlign: dynamic,
//rotation: 0,
formatter: function() {
return H.numberFormat(this.total, -1);
},
style: {
fontSize: '11px',
fontWeight: 'bold',
color: '#000000',
textOutline: '1px contrast'
}
},
gridLineWidth: 1,
lineWidth: 0
// tickWidth: 0
},
/**
* These options extend the defaultOptions for left axes
*/
defaultLeftAxisOptions: {
labels: {
x: -15
},
title: {
rotation: 270
}
},
/**
* These options extend the defaultOptions for right axes
*/
defaultRightAxisOptions: {
labels: {
x: 15
},
title: {
rotation: 90
}
},
/**
* These options extend the defaultOptions for bottom axes
*/
defaultBottomAxisOptions: {
labels: {
autoRotation: [-45],
x: 0
// overflow: undefined,
// staggerLines: null
},
title: {
rotation: 0
}
},
/**
* These options extend the defaultOptions for top axes
*/
defaultTopAxisOptions: {
labels: {
autoRotation: [-45],
x: 0
// overflow: undefined
// staggerLines: null
},
title: {
rotation: 0
}
},
/**
* Initialize the axis
*/
init: function(chart, userOptions) {
var isXAxis = userOptions.isX,
axis = this;
axis.chart = chart;
// Flag, is the axis horizontal
axis.horiz = chart.inverted ? !isXAxis : isXAxis;
// Flag, isXAxis
axis.isXAxis = isXAxis;
axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
axis.opposite = userOptions.opposite; // needed in setOptions
axis.side = userOptions.side || (axis.horiz ?
(axis.opposite ? 0 : 2) : // top : bottom
(axis.opposite ? 1 : 3)); // right : left
axis.setOptions(userOptions);
var options = this.options,
type = options.type,
isDatetimeAxis = type === 'datetime';
axis.labelFormatter = options.labels.formatter || axis.defaultLabelFormatter; // can be overwritten by dynamic format
// Flag, stagger lines or not
axis.userOptions = userOptions;
//axis.axisTitleMargin = undefined,// = options.title.margin,
axis.minPixelPadding = 0;
axis.reversed = options.reversed;
axis.visible = options.visible !== false;
axis.zoomEnabled = options.zoomEnabled !== false;
// Initial categories
axis.hasNames = type === 'category' || options.categories === true;
axis.categories = options.categories || axis.hasNames;
axis.names = axis.names || []; // Preserve on update (#3830)
// Elements
//axis.axisGroup = undefined;
//axis.gridGroup = undefined;
//axis.axisTitle = undefined;
//axis.axisLine = undefined;
// Placeholder for plotlines and plotbands groups
axis.plotLinesAndBandsGroups = {};
// Shorthand types
axis.isLog = type === 'logarithmic';
axis.isDatetimeAxis = isDatetimeAxis;
axis.positiveValuesOnly = axis.isLog && !axis.allowNegativeLog;
// Flag, if axis is linked to another axis
axis.isLinked = defined(options.linkedTo);
// Linked axis.
//axis.linkedParent = undefined;
// Tick positions
//axis.tickPositions = undefined; // array containing predefined positions
// Tick intervals
//axis.tickInterval = undefined;
//axis.minorTickInterval = undefined;
// Major ticks
axis.ticks = {};
axis.labelEdge = [];
// Minor ticks
axis.minorTicks = {};
// List of plotLines/Bands
axis.plotLinesAndBands = [];
// Alternate bands
axis.alternateBands = {};
// Axis metrics
//axis.left = undefined;
//axis.top = undefined;
//axis.width = undefined;
//axis.height = undefined;
//axis.bottom = undefined;
//axis.right = undefined;
//axis.transA = undefined;
//axis.transB = undefined;
//axis.oldTransA = undefined;
axis.len = 0;
//axis.oldMin = undefined;
//axis.oldMax = undefined;
//axis.oldUserMin = undefined;
//axis.oldUserMax = undefined;
//axis.oldAxisLength = undefined;
axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
axis.range = options.range;
axis.offset = options.offset || 0;
// Dictionary for stacks
axis.stacks = {};
axis.oldStacks = {};
axis.stacksTouched = 0;
// Min and max in the data
//axis.dataMin = undefined,
//axis.dataMax = undefined,
// The axis range
axis.max = null;
axis.min = null;
// User set min and max
//axis.userMin = undefined,
//axis.userMax = undefined,
// Crosshair options
axis.crosshair = pick(options.crosshair, splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1], false);
// Run Axis
var eventType,
events = axis.options.events;
// Register
if (inArray(axis, chart.axes) === -1) { // don't add it again on Axis.update()
if (isXAxis) { // #2713
chart.axes.splice(chart.xAxis.length, 0, axis);
} else {
chart.axes.push(axis);
}
chart[axis.coll].push(axis);
}
axis.series = axis.series || []; // populated by Series
// inverted charts have reversed xAxes as default
if (chart.inverted && isXAxis && axis.reversed === undefined) {
axis.reversed = true;
}
axis.removePlotBand = axis.removePlotBandOrLine;
axis.removePlotLine = axis.removePlotBandOrLine;
// register event listeners
for (eventType in events) {
addEvent(axis, eventType, events[eventType]);
}
// extend logarithmic axis
axis.lin2log = options.linearToLogConverter || axis.lin2log;
if (axis.isLog) {
axis.val2lin = axis.log2lin;
axis.lin2val = axis.lin2log;
}
},
/**
* Merge and set options
*/
setOptions: function(userOptions) {
this.options = merge(
this.defaultOptions,
this.coll === 'yAxis' && this.defaultYAxisOptions, [this.defaultTopAxisOptions, this.defaultRightAxisOptions,
this.defaultBottomAxisOptions, this.defaultLeftAxisOptions
][this.side],
merge(
defaultOptions[this.coll], // if set in setOptions (#1053)
userOptions
)
);
},
/**
* The default label formatter. The context is a special config object for the label.
*/
defaultLabelFormatter: function() {
var axis = this.axis,
value = this.value,
categories = axis.categories,
dateTimeLabelFormat = this.dateTimeLabelFormat,
lang = defaultOptions.lang,
numericSymbols = lang.numericSymbols,
numSymMagnitude = lang.numericSymbolMagnitude || 1000,
i = numericSymbols && numericSymbols.length,
multi,
ret,
formatOption = axis.options.labels.format,
// make sure the same symbol is added for all labels on a linear axis
numericSymbolDetector = axis.isLog ? Math.abs(value) : axis.tickInterval;
if (formatOption) {
ret = format(formatOption, this);
} else if (categories) {
ret = value;
} else if (dateTimeLabelFormat) { // datetime axis
ret = H.dateFormat(dateTimeLabelFormat, value);
} else if (i && numericSymbolDetector >= 1000) {
// Decide whether we should add a numeric symbol like k (thousands) or M (millions).
// If we are to enable this in tooltip or other places as well, we can move this
// logic to the numberFormatter and enable it by a parameter.
while (i-- && ret === undefined) {
multi = Math.pow(numSymMagnitude, i + 1);
if (numericSymbolDetector >= multi && (value * 10) % multi === 0 && numericSymbols[i] !== null && value !== 0) { // #5480
ret = H.numberFormat(value / multi, -1) + numericSymbols[i];
}
}
}
if (ret === undefined) {
if (Math.abs(value) >= 10000) { // add thousands separators
ret = H.numberFormat(value, -1);
} else { // small numbers
ret = H.numberFormat(value, -1, undefined, ''); // #2466
}
}
return ret;
},
/**
* Get the minimum and maximum for the series of each axis
*/
getSeriesExtremes: function() {
var axis = this,
chart = axis.chart;
axis.hasVisibleSeries = false;
// Reset properties in case we're redrawing (#3353)
axis.dataMin = axis.dataMax = axis.threshold = null;
axis.softThreshold = !axis.isXAxis;
if (axis.buildStacks) {
axis.buildStacks();
}
// loop through this axis' series
each(axis.series, function(series) {
if (series.visible || !chart.options.chart.ignoreHiddenSeries) {
var seriesOptions = series.options,
xData,
threshold = seriesOptions.threshold,
seriesDataMin,
seriesDataMax;
axis.hasVisibleSeries = true;
// Validate threshold in logarithmic axes
if (axis.positiveValuesOnly && threshold <= 0) {
threshold = null;
}
// Get dataMin and dataMax for X axes
if (axis.isXAxis) {
xData = series.xData;
if (xData.length) {
// If xData contains values which is not numbers, then filter them out.
// To prevent performance hit, we only do this after we have already
// found seriesDataMin because in most cases all data is valid. #5234.
seriesDataMin = arrayMin(xData);
if (!isNumber(seriesDataMin) && !(seriesDataMin instanceof Date)) { // Date for #5010
xData = grep(xData, function(x) {
return isNumber(x);
});
seriesDataMin = arrayMin(xData); // Do it again with valid data
}
axis.dataMin = Math.min(pick(axis.dataMin, xData[0]), seriesDataMin);
axis.dataMax = Math.max(pick(axis.dataMax, xData[0]), arrayMax(xData));
}
// Get dataMin and dataMax for Y axes, as well as handle stacking and processed data
} else {
// Get this particular series extremes
series.getExtremes();
seriesDataMax = series.dataMax;
seriesDataMin = series.dataMin;
// Get the dataMin and dataMax so far. If percentage is used, the min and max are
// always 0 and 100. If seriesDataMin and seriesDataMax is null, then series
// doesn't have active y data, we continue with nulls
if (defined(seriesDataMin) && defined(seriesDataMax)) {
axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
}
// Adjust to threshold
if (defined(threshold)) {
axis.threshold = threshold;
}
// If any series has a hard threshold, it takes precedence
if (!seriesOptions.softThreshold || axis.positiveValuesOnly) {
axis.softThreshold = false;
}
}
}
});
},
/**
* Translate from axis value to pixel position on the chart, or back
*
*/
translate: function(val, backwards, cvsCoord, old, handleLog, pointPlacement) {
var axis = this.linkedParent || this, // #1417
sign = 1,
cvsOffset = 0,
localA = old ? axis.oldTransA : axis.transA,
localMin = old ? axis.oldMin : axis.min,
returnValue,
minPixelPadding = axis.minPixelPadding,
doPostTranslate = (axis.isOrdinal || axis.isBroken || (axis.isLog && handleLog)) && axis.lin2val;
if (!localA) {
localA = axis.transA;
}
// In vertical axes, the canvas coordinates start from 0 at the top like in
// SVG.
if (cvsCoord) {
sign *= -1; // canvas coordinates inverts the value
cvsOffset = axis.len;
}
// Handle reversed axis
if (axis.reversed) {
sign *= -1;
cvsOffset -= sign * (axis.sector || axis.len);
}
// From pixels to value
if (backwards) { // reverse translation
val = val * sign + cvsOffset;
val -= minPixelPadding;
returnValue = val / localA + localMin; // from chart pixel to value
if (doPostTranslate) { // log and ordinal axes
returnValue = axis.lin2val(returnValue);
}
// From value to pixels
} else {
if (doPostTranslate) { // log and ordinal axes
val = axis.val2lin(val);
}
returnValue = sign * (val - localMin) * localA + cvsOffset +
(sign * minPixelPadding) +
(isNumber(pointPlacement) ? localA * pointPlacement : 0);
}
return returnValue;
},
/**
* Utility method to translate an axis value to pixel position.
* @param {Number} value A value in terms of axis units
* @param {Boolean} paneCoordinates Whether to return the pixel coordinate relative to the chart
* or just the axis/pane itself.
*/
toPixels: function(value, paneCoordinates) {
return this.translate(value, false, !this.horiz, null, true) + (paneCoordinates ? 0 : this.pos);
},
/**
* Utility method to translate a pixel position in to an axis value.
* @param {Number} pixel The pixel value coordinate
* @param {Boolean} paneCoordiantes Whether the input pixel is relative to the chart or just the
* axis/pane itself.
*/
toValue: function(pixel, paneCoordinates) {
return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
},
/**
* Create the path for a plot line that goes from the given value on
* this axis, across the plot to the opposite side
* @param {Number} value
* @param {Number} lineWidth Used for calculation crisp line
* @param {Number] old Use old coordinates (for resizing and rescaling)
*/
getPlotLinePath: function(value, lineWidth, old, force, translatedValue) {
var axis = this,
chart = axis.chart,
axisLeft = axis.left,
axisTop = axis.top,
x1,
y1,
x2,
y2,
cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
cWidth = (old && chart.oldChartWidth) || chart.chartWidth,
skip,
transB = axis.transB,
/**
* Check if x is between a and b. If not, either move to a/b or skip,
* depending on the force parameter.
*/
between = function(x, a, b) {
if (x < a || x > b) {
if (force) {
x = Math.min(Math.max(a, x), b);
} else {
skip = true;
}
}
return x;
};
translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
x1 = x2 = Math.round(translatedValue + transB);
y1 = y2 = Math.round(cHeight - translatedValue - transB);
if (!isNumber(translatedValue)) { // no min or max
skip = true;
} else if (axis.horiz) {
y1 = axisTop;
y2 = cHeight - axis.bottom;
x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
} else {
x1 = axisLeft;
x2 = cWidth - axis.right;
y1 = y2 = between(y1, axisTop, axisTop + axis.height);
}
return skip && !force ?
null :
chart.renderer.crispLine(['M', x1, y1, 'L', x2, y2], lineWidth || 1);
},
/**
* Set the tick positions of a linear axis to round values like whole tens or every five.
*/
getLinearTickPositions: function(tickInterval, min, max) {
var pos,
lastPos,
roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval),
roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval),
tickPositions = [];
// For single points, add a tick regardless of the relative position
// (#2662, #6274)
if (this.single) {
return [min];
}
// Populate the intermediate values
pos = roundedMin;
while (pos <= roundedMax) {
// Place the tick on the rounded value
tickPositions.push(pos);
// Always add the raw tickInterval, not the corrected one.
pos = correctFloat(pos + tickInterval);
// If the interval is not big enough in the current min - max range to actually increase
// the loop variable, we need to break out to prevent endless loop. Issue #619
if (pos === lastPos) {
break;
}
// Record the last value
lastPos = pos;
}
return tickPositions;
},
/**
* Return the minor tick positions. For logarithmic axes, reuse the same logic
* as for major ticks.
*/
getMinorTickPositions: function() {
var axis = this,
options = axis.options,
tickPositions = axis.tickPositions,
minorTickInterval = axis.minorTickInterval,
minorTickPositions = [],
pos,
pointRangePadding = axis.pointRangePadding || 0,
min = axis.min - pointRangePadding, // #1498
max = axis.max + pointRangePadding, // #1498
range = max - min;
// If minor ticks get too dense, they are hard to read, and may cause long running script. So we don't draw them.
if (range && range / minorTickInterval < axis.len / 3) { // #3875
if (axis.isLog) {
// For each interval in the major ticks, compute the minor ticks
// separately.
each(this.paddedTicks, function(pos, i, paddedTicks) {
if (i) {
minorTickPositions.push.apply(
minorTickPositions,
axis.getLogTickPositions(
minorTickInterval,
paddedTicks[i - 1],
paddedTicks[i],
true
)
);
}
});
} else if (axis.isDatetimeAxis && options.minorTickInterval === 'auto') { // #1314
minorTickPositions = minorTickPositions.concat(
axis.getTimeTicks(
axis.normalizeTimeTickInterval(minorTickInterval),
min,
max,
options.startOfWeek
)
);
} else {
for (
pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval
) {
// Very, very, tight grid lines (#5771)
if (pos === minorTickPositions[0]) {
break;
}
minorTickPositions.push(pos);
}
}
}
if (minorTickPositions.length !== 0) {
axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
}
return minorTickPositions;
},
/**
* Adjust the min and max for the minimum range. Keep in mind that the series data is
* not yet processed, so we don't have information on data cropping and grouping, or
* updated axis.pointRange or series.pointRange. The data can't be processed until
* we have finally established min and max.
*/
adjustForMinRange: function() {
var axis = this,
options = axis.options,
min = axis.min,
max = axis.max,
zoomOffset,
spaceAvailable = axis.dataMax - axis.dataMin >= axis.minRange,
closestDataRange,
i,
distance,
xData,
loopLength,
minArgs,
maxArgs,
minRange;
// Set the automatic minimum range based on the closest point distance
if (axis.isXAxis && axis.minRange === undefined && !axis.isLog) {
if (defined(options.min) || defined(options.max)) {
axis.minRange = null; // don't do this again
} else {
// Find the closest distance between raw data points, as opposed to
// closestPointRange that applies to processed points (cropped and grouped)
each(axis.series, function(series) {
xData = series.xData;
loopLength = series.xIncrement ? 1 : xData.length - 1;
for (i = loopLength; i > 0; i--) {
distance = xData[i] - xData[i - 1];
if (closestDataRange === undefined || distance < closestDataRange) {
closestDataRange = distance;
}
}
});
axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
}
}
// if minRange is exceeded, adjust
if (max - min < axis.minRange) {
minRange = axis.minRange;
zoomOffset = (minRange - max + min) / 2;
// if min and max options have been set, don't go beyond it
minArgs = [min - zoomOffset, pick(options.min, min - zoomOffset)];
if (spaceAvailable) { // if space is available, stay within the data range
minArgs[2] = axis.isLog ? axis.log2lin(axis.dataMin) : axis.dataMin;
}
min = arrayMax(minArgs);
maxArgs = [min + minRange, pick(options.max, min + minRange)];
if (spaceAvailable) { // if space is availabe, stay within the data range
maxArgs[2] = axis.isLog ? axis.log2lin(axis.dataMax) : axis.dataMax;
}
max = arrayMin(maxArgs);
// now if the max is adjusted, adjust the min back
if (max - min < minRange) {
minArgs[0] = max - minRange;
minArgs[1] = pick(options.min, max - minRange);
min = arrayMax(minArgs);
}
}
// Record modified extremes
axis.min = min;
axis.max = max;
},
/**
* Find the closestPointRange across all series
*/
getClosest: function() {
var ret;
if (this.categories) {
ret = 1;
} else {
each(this.series, function(series) {
var seriesClosest = series.closestPointRange,
visible = series.visible ||
!series.chart.options.chart.ignoreHiddenSeries;
if (!series.noSharedTooltip &&
defined(seriesClosest) &&
visible
) {
ret = defined(ret) ?
Math.min(ret, seriesClosest) :
seriesClosest;
}
});
}
return ret;
},
/**
* When a point name is given and no x, search for the name in the existing categories,
* or if categories aren't provided, search names or create a new category (#2522).
*/
nameToX: function(point) {
var explicitCategories = isArray(this.categories),
names = explicitCategories ? this.categories : this.names,
nameX = point.options.x,
x;
point.series.requireSorting = false;
if (!defined(nameX)) {
nameX = this.options.uniqueNames === false ?
point.series.autoIncrement() :
inArray(point.name, names);
}
if (nameX === -1) { // The name is not found in currenct categories
if (!explicitCategories) {
x = names.length;
}
} else {
x = nameX;
}
// Write the last point's name to the names array
if (x !== undefined) {
this.names[x] = point.name;
}
return x;
},
/**
* When changes have been done to series data, update the axis.names.
*/
updateNames: function() {
var axis = this;
if (this.names.length > 0) {
this.names.length = 0;
this.minRange = undefined;
each(this.series || [], function(series) {
// Reset incrementer (#5928)
series.xIncrement = null;
// When adding a series, points are not yet generated
if (!series.points || series.isDirtyData) {
series.processData();
series.generatePoints();
}
each(series.points, function(point, i) {
var x;
if (point.options) {
x = axis.nameToX(point);
if (x !== undefined && x !== point.x) {
point.x = x;
series.xData[i] = x;
}
}
});
});
}
},
/**
* Update translation information
*/
setAxisTranslation: function(saveOld) {
var axis = this,
range = axis.max - axis.min,
pointRange = axis.axisPointRange || 0,
closestPointRange,
minPointOffset = 0,
pointRangePadding = 0,
linkedParent = axis.linkedParent,
ordinalCorrection,
hasCategories = !!axis.categories,
transA = axis.transA,
isXAxis = axis.isXAxis;
// Adjust translation for padding. Y axis with categories need to go through the same (#1784).
if (isXAxis || hasCategories || pointRange) {
// Get the closest points
closestPointRange = axis.getClosest();
if (linkedParent) {
minPointOffset = linkedParent.minPointOffset;
pointRangePadding = linkedParent.pointRangePadding;
} else {
each(axis.series, function(series) {
var seriesPointRange = hasCategories ?
1 :
(isXAxis ?
pick(series.options.pointRange, closestPointRange, 0) :
(axis.axisPointRange || 0)), // #2806
pointPlacement = series.options.pointPlacement;
pointRange = Math.max(pointRange, seriesPointRange);
if (!axis.single) {
// minPointOffset is the value padding to the left of the axis in order to make
// room for points with a pointRange, typically columns. When the pointPlacement option
// is 'between' or 'on', this padding does not apply.
minPointOffset = Math.max(
minPointOffset,
isString(pointPlacement) ? 0 : seriesPointRange / 2
);
// Determine the total padding needed to the length of the axis to make room for the
// pointRange. If the series' pointPlacement is 'on', no padding is added.
pointRangePadding = Math.max(
pointRangePadding,
pointPlacement === 'on' ? 0 : seriesPointRange
);
}
});
}
// Record minPointOffset and pointRangePadding
ordinalCorrection = axis.ordinalSlope && closestPointRange ? axis.ordinalSlope / closestPointRange : 1; // #988, #1853
axis.minPointOffset = minPointOffset = minPointOffset * ordinalCorrection;
axis.pointRangePadding = pointRangePadding = pointRangePadding * ordinalCorrection;
// pointRange means the width reserved for each point, like in a column chart
axis.pointRange = Math.min(pointRange, range);
// closestPointRange means the closest distance between points. In columns
// it is mostly equal to pointRange, but in lines pointRange is 0 while closestPointRange
// is some other value
if (isXAxis) {
axis.closestPointRange = closestPointRange;
}
}
// Secondary values
if (saveOld) {
axis.oldTransA = transA;
}
axis.translationSlope = axis.transA = transA =
axis.options.staticScale ||
axis.len / ((range + pointRangePadding) || 1);
axis.transB = axis.horiz ? axis.left : axis.bottom; // translation addend
axis.minPixelPadding = transA * minPointOffset;
},
minFromRange: function() {
return this.max - this.range;
},
/**
* Set the tick positions to round values and optionally extend the extremes
* to the nearest tick
*/
setTickInterval: function(secondPass) {
var axis = this,
chart = axis.chart,
options = axis.options,
isLog = axis.isLog,
log2lin = axis.log2lin,
isDatetimeAxis = axis.isDatetimeAxis,
isXAxis = axis.isXAxis,
isLinked = axis.isLinked,
maxPadding = options.maxPadding,
minPadding = options.minPadding,
length,
linkedParentExtremes,
tickIntervalOption = options.tickInterval,
minTickInterval,
tickPixelIntervalOption = options.tickPixelInterval,
categories = axis.categories,
threshold = axis.threshold,
softThreshold = axis.softThreshold,
thresholdMin,
thresholdMax,
hardMin,
hardMax;
if (!isDatetimeAxis && !categories && !isLinked) {
this.getTickAmount();
}
// Min or max set either by zooming/setExtremes or initial options
hardMin = pick(axis.userMin, options.min);
hardMax = pick(axis.userMax, options.max);
// Linked axis gets the extremes from the parent axis
if (isLinked) {
axis.linkedParent = chart[axis.coll][options.linkedTo];
linkedParentExtremes = axis.linkedParent.getExtremes();
axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
if (options.type !== axis.linkedParent.options.type) {
H.error(11, 1); // Can't link axes of different type
}
// Initial min and max from the extreme data values
} else {
// Adjust to hard threshold
if (!softThreshold && defined(threshold)) {
if (axis.dataMin >= threshold) {
thresholdMin = threshold;
minPadding = 0;
} else if (axis.dataMax <= threshold) {
thresholdMax = threshold;
maxPadding = 0;
}
}
axis.min = pick(hardMin, thresholdMin, axis.dataMin);
axis.max = pick(hardMax, thresholdMax, axis.dataMax);
}
if (isLog) {
if (
axis.positiveValuesOnly &&
!secondPass &&
Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0
) { // #978
H.error(10, 1); // Can't plot negative values on log axis
}
// The correctFloat cures #934, float errors on full tens. But it
// was too aggressive for #4360 because of conversion back to lin,
// therefore use precision 15.
axis.min = correctFloat(log2lin(axis.min), 15);
axis.max = correctFloat(log2lin(axis.max), 15);
}
// handle zoomed range
if (axis.range && defined(axis.max)) {
axis.userMin = axis.min = hardMin = Math.max(axis.min, axis.minFromRange()); // #618
axis.userMax = hardMax = axis.max;
axis.range = null; // don't use it when running setExtremes
}
// Hook for Highstock Scroller. Consider combining with beforePadding.
fireEvent(axis, 'foundExtremes');
// Hook for adjusting this.min and this.max. Used by bubble series.
if (axis.beforePadding) {
axis.beforePadding();
}
// adjust min and max for the minimum range
axis.adjustForMinRange();
// Pad the values to get clear of the chart's edges. To avoid tickInterval taking the padding
// into account, we do this after computing tick interval (#1337).
if (!categories && !axis.axisPointRange && !axis.usePercentage && !isLinked && defined(axis.min) && defined(axis.max)) {
length = axis.max - axis.min;
if (length) {
if (!defined(hardMin) && minPadding) {
axis.min -= length * minPadding;
}
if (!defined(hardMax) && maxPadding) {
axis.max += length * maxPadding;
}
}
}
// Handle options for floor, ceiling, softMin and softMax (#6359)
if (isNumber(options.softMin)) {
axis.min = Math.min(axis.min, options.softMin);
}
if (isNumber(options.softMax)) {
axis.max = Math.max(axis.max, options.softMax);
}
if (isNumber(options.floor)) {
axis.min = Math.max(axis.min, options.floor);
}
if (isNumber(options.ceiling)) {
axis.max = Math.min(axis.max, options.ceiling);
}
// When the threshold is soft, adjust the extreme value only if
// the data extreme and the padded extreme land on either side of the threshold. For example,
// a series of [0, 1, 2, 3] would make the yAxis add a tick for -1 because of the
// default minPadding and startOnTick options. This is prevented by the softThreshold
// option.
if (softThreshold && defined(axis.dataMin)) {
threshold = threshold || 0;
if (!defined(hardMin) && axis.min < threshold && axis.dataMin >= threshold) {
axis.min = threshold;
} else if (!defined(hardMax) && axis.max > threshold && axis.dataMax <= threshold) {
axis.max = threshold;
}
}
// get tickInterval
if (axis.min === axis.max || axis.min === undefined || axis.max === undefined) {
axis.tickInterval = 1;
} else if (isLinked && !tickIntervalOption &&
tickPixelIntervalOption === axis.linkedParent.options.tickPixelInterval) {
axis.tickInterval = tickIntervalOption = axis.linkedParent.tickInterval;
} else {
axis.tickInterval = pick(
tickIntervalOption,
this.tickAmount ? ((axis.max - axis.min) / Math.max(this.tickAmount - 1, 1)) : undefined,
categories ? // for categoried axis, 1 is default, for linear axis use tickPix
1 :
// don't let it be more than the data range
(axis.max - axis.min) * tickPixelIntervalOption / Math.max(axis.len, tickPixelIntervalOption)
);
}
// Now we're finished detecting min and max, crop and group series data. This
// is in turn needed in order to find tick positions in ordinal axes.
if (isXAxis && !secondPass) {
each(axis.series, function(series) {
series.processData(axis.min !== axis.oldMin || axis.max !== axis.oldMax);
});
}
// set the translation factor used in translate function
axis.setAxisTranslation(true);
// hook for ordinal axes and radial axes
if (axis.beforeSetTickPositions) {
axis.beforeSetTickPositions();
}
// hook for extensions, used in Highstock ordinal axes
if (axis.postProcessTickInterval) {
axis.tickInterval = axis.postProcessTickInterval(axis.tickInterval);
}
// In column-like charts, don't cramp in more ticks than there are points (#1943, #4184)
if (axis.pointRange && !tickIntervalOption) {
axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
}
// Before normalizing the tick interval, handle minimum tick interval. This applies only if tickInterval is not defined.
minTickInterval = pick(options.minTickInterval, axis.isDatetimeAxis && axis.closestPointRange);
if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
axis.tickInterval = minTickInterval;
}
// for linear axes, get magnitude and normalize the interval
if (!isDatetimeAxis && !isLog && !tickIntervalOption) {
axis.tickInterval = normalizeTickInterval(
axis.tickInterval,
null,
getMagnitude(axis.tickInterval),
// If the tick interval is between 0.5 and 5 and the axis max is in the order of
// thousands, chances are we are dealing with years. Don't allow decimals. #3363.
pick(options.allowDecimals, !(axis.tickInterval > 0.5 && axis.tickInterval < 5 && axis.max > 1000 && axis.max < 9999)), !!this.tickAmount
);
}
// Prevent ticks from getting so close that we can't draw the labels
if (!this.tickAmount) {
axis.tickInterval = axis.unsquish();
}
this.setTickPositions();
},
/**
* Now we have computed the normalized tickInterval, get the tick positions
*/
setTickPositions: function() {
var options = this.options,
tickPositions,
tickPositionsOption = options.tickPositions,
tickPositioner = options.tickPositioner,
startOnTick = options.startOnTick,
endOnTick = options.endOnTick;
// Set the tickmarkOffset
this.tickmarkOffset = (this.categories && options.tickmarkPlacement === 'between' &&
this.tickInterval === 1) ? 0.5 : 0; // #3202
// get minorTickInterval
this.minorTickInterval = options.minorTickInterval === 'auto' && this.tickInterval ?
this.tickInterval / 5 : options.minorTickInterval;
// When there is only one point, or all points have the same value on
// this axis, then min and max are equal and tickPositions.length is 0
// or 1. In this case, add some padding in order to center the point,
// but leave it with one tick. #1337.
this.single = this.min === this.max && defined(this.min) &&
!this.tickAmount && options.allowDecimals !== false;
// Find the tick positions
this.tickPositions = tickPositions = tickPositionsOption && tickPositionsOption.slice(); // Work on a copy (#1565)
if (!tickPositions) {
if (this.isDatetimeAxis) {
tickPositions = this.getTimeTicks(
this.normalizeTimeTickInterval(this.tickInterval, options.units),
this.min,
this.max,
options.startOfWeek,
this.ordinalPositions,
this.closestPointRange,
true
);
} else if (this.isLog) {
tickPositions = this.getLogTickPositions(this.tickInterval, this.min, this.max);
} else {
tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
}
// Too dense ticks, keep only the first and last (#4477)
if (tickPositions.length > this.len) {
tickPositions = [tickPositions[0], tickPositions.pop()];
}
this.tickPositions = tickPositions;
// Run the tick positioner callback, that allows modifying auto tick positions.
if (tickPositioner) {
tickPositioner = tickPositioner.apply(this, [this.min, this.max]);
if (tickPositioner) {
this.tickPositions = tickPositions = tickPositioner;
}
}
}
// Reset min/max or remove extremes based on start/end on tick
this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
this.trimTicks(tickPositions, startOnTick, endOnTick);
if (!this.isLinked) {
// Substract half a unit (#2619, #2846, #2515, #3390)
if (this.single) {
this.min -= 0.5;
this.max += 0.5;
}
if (!tickPositionsOption && !tickPositioner) {
this.adjustTickAmount();
}
}
},
/**
* Handle startOnTick and endOnTick by either adapting to padding min/max or rounded min/max
*/
trimTicks: function(tickPositions, startOnTick, endOnTick) {
var roundedMin = tickPositions[0],
roundedMax = tickPositions[tickPositions.length - 1],
minPointOffset = this.minPointOffset || 0;
if (!this.isLinked) {
if (startOnTick && roundedMin !== -Infinity) { // #6502
this.min = roundedMin;
} else {
while (this.min - minPointOffset > tickPositions[0]) {
tickPositions.shift();
}
}
if (endOnTick) {
this.max = roundedMax;
} else {
while (this.max + minPointOffset < tickPositions[tickPositions.length - 1]) {
tickPositions.pop();
}
}
// If no tick are left, set one tick in the middle (#3195)
if (tickPositions.length === 0 && defined(roundedMin)) {
tickPositions.push((roundedMax + roundedMin) / 2);
}
}
},
/**
* Check if there are multiple axes in the same pane
* @returns {Boolean} There are other axes
*/
alignToOthers: function() {
var others = {}, // Whether there is another axis to pair with this one
hasOther,
options = this.options;
if (
// Only if alignTicks is true
this.chart.options.chart.alignTicks !== false &&
options.alignTicks !== false &&
// Don't try to align ticks on a log axis, they are not evenly
// spaced (#6021)
!this.isLog
) {
each(this.chart[this.coll], function(axis) {
var otherOptions = axis.options,
horiz = axis.horiz,
key = [
horiz ? otherOptions.left : otherOptions.top,
otherOptions.width,
otherOptions.height,
otherOptions.pane
].join(',');
if (axis.series.length) { // #4442
if (others[key]) {
hasOther = true; // #4201
} else {
others[key] = 1;
}
}
});
}
return hasOther;
},
/**
* Set the max ticks of either the x and y axis collection
*/
getTickAmount: function() {
var options = this.options,
tickAmount = options.tickAmount,
tickPixelInterval = options.tickPixelInterval;
if (!defined(options.tickInterval) && this.len < tickPixelInterval && !this.isRadial &&
!this.isLog && options.startOnTick && options.endOnTick) {
tickAmount = 2;
}
if (!tickAmount && this.alignToOthers()) {
// Add 1 because 4 tick intervals require 5 ticks (including first and last)
tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
}
// For tick amounts of 2 and 3, compute five ticks and remove the intermediate ones. This
// prevents the axis from adding ticks that are too far away from the data extremes.
if (tickAmount < 4) {
this.finalTickAmt = tickAmount;
tickAmount = 5;
}
this.tickAmount = tickAmount;
},
/**
* When using multiple axes, adjust the number of ticks to match the highest
* number of ticks in that group
*/
adjustTickAmount: function() {
var tickInterval = this.tickInterval,
tickPositions = this.tickPositions,
tickAmount = this.tickAmount,
finalTickAmt = this.finalTickAmt,
currentTickAmount = tickPositions && tickPositions.length,
i,
len;
if (currentTickAmount < tickAmount) {
while (tickPositions.length < tickAmount) {
tickPositions.push(correctFloat(
tickPositions[tickPositions.length - 1] + tickInterval
));
}
this.transA *= (currentTickAmount - 1) / (tickAmount - 1);
this.max = tickPositions[tickPositions.length - 1];
// We have too many ticks, run second pass to try to reduce ticks
} else if (currentTickAmount > tickAmount) {
this.tickInterval *= 2;
this.setTickPositions();
}
// The finalTickAmt property is set in getTickAmount
if (defined(finalTickAmt)) {
i = len = tickPositions.length;
while (i--) {
if (
(finalTickAmt === 3 && i % 2 === 1) || // Remove every other tick
(finalTickAmt <= 2 && i > 0 && i < len - 1) // Remove all but first and last
) {
tickPositions.splice(i, 1);
}
}
this.finalTickAmt = undefined;
}
},
/**
* Set the scale based on data min and max, user set min and max or options
*
*/
setScale: function() {
var axis = this,
isDirtyData,
isDirtyAxisLength;
axis.oldMin = axis.min;
axis.oldMax = axis.max;
axis.oldAxisLength = axis.len;
// set the new axisLength
axis.setAxisSize();
//axisLength = horiz ? axisWidth : axisHeight;
isDirtyAxisLength = axis.len !== axis.oldAxisLength;
// is there new data?
each(axis.series, function(series) {
if (series.isDirtyData || series.isDirty ||
series.xAxis.isDirty) { // when x axis is dirty, we need new data extremes for y as well
isDirtyData = true;
}
});
// do we really need to go through all this?
if (isDirtyAxisLength || isDirtyData || axis.isLinked || axis.forceRedraw ||
axis.userMin !== axis.oldUserMin || axis.userMax !== axis.oldUserMax || axis.alignToOthers()) {
if (axis.resetStacks) {
axis.resetStacks();
}
axis.forceRedraw = false;
// get data extremes if needed
axis.getSeriesExtremes();
// get fixed positions based on tickInterval
axis.setTickInterval();
// record old values to decide whether a rescale is necessary later on (#540)
axis.oldUserMin = axis.userMin;
axis.oldUserMax = axis.userMax;
// Mark as dirty if it is not already set to dirty and extremes have changed. #595.
if (!axis.isDirty) {
axis.isDirty = isDirtyAxisLength || axis.min !== axis.oldMin || axis.max !== axis.oldMax;
}
} else if (axis.cleanStacks) {
axis.cleanStacks();
}
},
/**
* Set the extremes and optionally redraw
* @param {Number} newMin
* @param {Number} newMax
* @param {Boolean} redraw
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
* @param {Object} eventArguments
*
*/
setExtremes: function(newMin, newMax, redraw, animation, eventArguments) {
var axis = this,
chart = axis.chart;
redraw = pick(redraw, true); // defaults to true
each(axis.series, function(serie) {
delete serie.kdTree;
});
// Extend the arguments with min and max
eventArguments = extend(eventArguments, {
min: newMin,
max: newMax
});
// Fire the event
fireEvent(axis, 'setExtremes', eventArguments, function() { // the default event handler
axis.userMin = newMin;
axis.userMax = newMax;
axis.eventArgs = eventArguments;
if (redraw) {
chart.redraw(animation);
}
});
},
/**
* Overridable method for zooming chart. Pulled out in a separate method to allow overriding
* in stock charts.
*/
zoom: function(newMin, newMax) {
var dataMin = this.dataMin,
dataMax = this.dataMax,
options = this.options,
min = Math.min(dataMin, pick(options.min, dataMin)),
max = Math.max(dataMax, pick(options.max, dataMax));
if (newMin !== this.min || newMax !== this.max) { // #5790
// Prevent pinch zooming out of range. Check for defined is for #1946. #1734.
if (!this.allowZoomOutside) {
// #6014, sometimes newMax will be smaller than min (or newMin will be larger than max).
if (defined(dataMin)) {
if (newMin < min) {
newMin = min;
}
if (newMin > max) {
newMin = max;
}
}
if (defined(dataMax)) {
if (newMax < min) {
newMax = min;
}
if (newMax > max) {
newMax = max;
}
}
}
// In full view, displaying the reset zoom button is not required
this.displayBtn = newMin !== undefined || newMax !== undefined;
// Do it
this.setExtremes(
newMin,
newMax,
false,
undefined, {
trigger: 'zoom'
}
);
}
return true;
},
/**
* Update the axis metrics
*/
setAxisSize: function() {
var chart = this.chart,
options = this.options,
offsets = options.offsets || [0, 0, 0, 0], // top / right / bottom / left
horiz = this.horiz,
width = pick(options.width, chart.plotWidth - offsets[3] + offsets[1]),
height = pick(options.height, chart.plotHeight - offsets[0] + offsets[2]),
top = pick(options.top, chart.plotTop + offsets[0]),
left = pick(options.left, chart.plotLeft + offsets[3]),
percentRegex = /%$/;
// Check for percentage based input values. Rounding fixes problems with
// column overflow and plot line filtering (#4898, #4899)
if (percentRegex.test(height)) {
height = Math.round(parseFloat(height) / 100 * chart.plotHeight);
}
if (percentRegex.test(top)) {
top = Math.round(parseFloat(top) / 100 * chart.plotHeight + chart.plotTop);
}
// Expose basic values to use in Series object and navigator
this.left = left;
this.top = top;
this.width = width;
this.height = height;
this.bottom = chart.chartHeight - height - top;
this.right = chart.chartWidth - width - left;
// Direction agnostic properties
this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
this.pos = horiz ? left : top; // distance from SVG origin
},
/**
* Get the actual axis extremes
*/
getExtremes: function() {
var axis = this,
isLog = axis.isLog,
lin2log = axis.lin2log;
return {
min: isLog ? correctFloat(lin2log(axis.min)) : axis.min,
max: isLog ? correctFloat(lin2log(axis.max)) : axis.max,
dataMin: axis.dataMin,
dataMax: axis.dataMax,
userMin: axis.userMin,
userMax: axis.userMax
};
},
/**
* Get the zero plane either based on zero or on the min or max value.
* Used in bar and area plots
*/
getThreshold: function(threshold) {
var axis = this,
isLog = axis.isLog,
lin2log = axis.lin2log,
realMin = isLog ? lin2log(axis.min) : axis.min,
realMax = isLog ? lin2log(axis.max) : axis.max;
if (threshold === null) {
threshold = realMin;
} else if (realMin > threshold) {
threshold = realMin;
} else if (realMax < threshold) {
threshold = realMax;
}
return axis.translate(threshold, 0, 1, 0, 1);
},
/**
* Compute auto alignment for the axis label based on which side the axis is on
* and the given rotation for the label
*/
autoLabelAlign: function(rotation) {
var ret,
angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360;
if (angle > 15 && angle < 165) {
ret = 'right';
} else if (angle > 195 && angle < 345) {
ret = 'left';
} else {
ret = 'center';
}
return ret;
},
/**
* Get the tick length and width for the axis.
* @param {String} prefix 'tick' or 'minorTick'
* @returns {Array} An array of tickLength and tickWidth
*/
tickSize: function(prefix) {
var options = this.options,
tickLength = options[prefix + 'Length'],
tickWidth = pick(options[prefix + 'Width'], prefix === 'tick' && this.isXAxis ? 1 : 0); // X axis defaults to 1
if (tickWidth && tickLength) {
// Negate the length
if (options[prefix + 'Position'] === 'inside') {
tickLength = -tickLength;
}
return [tickLength, tickWidth];
}
},
/**
* Return the size of the labels
*/
labelMetrics: function() {
return this.chart.renderer.fontMetrics(
this.options.labels.style && this.options.labels.style.fontSize,
this.ticks[0] && this.ticks[0].label
);
},
/**
* Prevent the ticks from getting so close we can't draw the labels. On a horizontal
* axis, this is handled by rotating the labels, removing ticks and adding ellipsis.
* On a vertical axis remove ticks and add ellipsis.
*/
unsquish: function() {
var labelOptions = this.options.labels,
horiz = this.horiz,
tickInterval = this.tickInterval,
newTickInterval = tickInterval,
slotSize = this.len / (((this.categories ? 1 : 0) + this.max - this.min) / tickInterval),
rotation,
rotationOption = labelOptions.rotation,
labelMetrics = this.labelMetrics(),
step,
bestScore = Number.MAX_VALUE,
autoRotation,
// Return the multiple of tickInterval that is needed to avoid collision
getStep = function(spaceNeeded) {
var step = spaceNeeded / (slotSize || 1);
step = step > 1 ? Math.ceil(step) : 1;
return step * tickInterval;
};
if (horiz) {
autoRotation = !labelOptions.staggerLines && !labelOptions.step && ( // #3971
defined(rotationOption) ? [rotationOption] :
slotSize < pick(labelOptions.autoRotationLimit, 80) && labelOptions.autoRotation
);
if (autoRotation) {
// Loop over the given autoRotation options, and determine which gives the best score. The
// best score is that with the lowest number of steps and a rotation closest to horizontal.
each(autoRotation, function(rot) {
var score;
if (rot === rotationOption || (rot && rot >= -90 && rot <= 90)) { // #3891
step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
score = step + Math.abs(rot / 360);
if (score < bestScore) {
bestScore = score;
rotation = rot;
newTickInterval = step;
}
}
});
}
} else if (!labelOptions.step) { // #4411
newTickInterval = getStep(labelMetrics.h);
}
this.autoRotation = autoRotation;
this.labelRotation = pick(rotation, rotationOption);
return newTickInterval;
},
/**
* Get the general slot width for this axis. This may change between the pre-render (from Axis.getOffset)
* and the final tick rendering and placement (#5086).
*/
getSlotWidth: function() {
var chart = this.chart,
horiz = this.horiz,
labelOptions = this.options.labels,
slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1),
marginLeft = chart.margin[3];
return (
horiz &&
(labelOptions.step || 0) < 2 &&
!labelOptions.rotation && // #4415
((this.staggerLines || 1) * this.len) / slotCount
) || (!horiz && (
(marginLeft && (marginLeft - chart.spacing[3])) ||
chart.chartWidth * 0.33
)); // #1580, #1931
},
/**
* Render the axis labels and determine whether ellipsis or rotation need to be applied
*/
renderUnsquish: function() {
var chart = this.chart,
renderer = chart.renderer,
tickPositions = this.tickPositions,
ticks = this.ticks,
labelOptions = this.options.labels,
horiz = this.horiz,
slotWidth = this.getSlotWidth(),
innerWidth = Math.max(1, Math.round(slotWidth - 2 * (labelOptions.padding || 5))),
attr = {},
labelMetrics = this.labelMetrics(),
textOverflowOption = labelOptions.style && labelOptions.style.textOverflow,
css,
maxLabelLength = 0,
label,
i,
pos;
// Set rotation option unless it is "auto", like in gauges
if (!isString(labelOptions.rotation)) {
attr.rotation = labelOptions.rotation || 0; // #4443
}
// Get the longest label length
each(tickPositions, function(tick) {
tick = ticks[tick];
if (tick && tick.labelLength > maxLabelLength) {
maxLabelLength = tick.labelLength;
}
});
this.maxLabelLength = maxLabelLength;
// Handle auto rotation on horizontal axis
if (this.autoRotation) {
// Apply rotation only if the label is too wide for the slot, and
// the label is wider than its height.
if (maxLabelLength > innerWidth && maxLabelLength > labelMetrics.h) {
attr.rotation = this.labelRotation;
} else {
this.labelRotation = 0;
}
// Handle word-wrap or ellipsis on vertical axis
} else if (slotWidth) {
// For word-wrap or ellipsis
css = {
width: innerWidth + 'px'
};
if (!textOverflowOption) {
css.textOverflow = 'clip';
// On vertical axis, only allow word wrap if there is room for more lines.
i = tickPositions.length;
while (!horiz && i--) {
pos = tickPositions[i];
label = ticks[pos].label;
if (label) {
// Reset ellipsis in order to get the correct bounding box (#4070)
if (label.styles && label.styles.textOverflow === 'ellipsis') {
label.css({
textOverflow: 'clip'
});
// Set the correct width in order to read the bounding box height (#4678, #5034)
} else if (ticks[pos].labelLength > slotWidth) {
label.css({
width: slotWidth + 'px'
});
}
if (label.getBBox().height > this.len / tickPositions.length - (labelMetrics.h - labelMetrics.f)) {
label.specCss = {
textOverflow: 'ellipsis'
};
}
}
}
}
}
// Add ellipsis if the label length is significantly longer than ideal
if (attr.rotation) {
css = {
width: (maxLabelLength > chart.chartHeight * 0.5 ? chart.chartHeight * 0.33 : chart.chartHeight) + 'px'
};
if (!textOverflowOption) {
css.textOverflow = 'ellipsis';
}
}
// Set the explicit or automatic label alignment
this.labelAlign = labelOptions.align || this.autoLabelAlign(this.labelRotation);
if (this.labelAlign) {
attr.align = this.labelAlign;
}
// Apply general and specific CSS
each(tickPositions, function(pos) {
var tick = ticks[pos],
label = tick && tick.label;
if (label) {
label.attr(attr); // This needs to go before the CSS in old IE (#4502)
if (css) {
label.css(merge(css, label.specCss));
}
delete label.specCss;
tick.rotation = attr.rotation;
}
});
// Note: Why is this not part of getLabelPosition?
this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
},
/**
* Return true if the axis has associated data
*/
hasData: function() {
return this.hasVisibleSeries || (defined(this.min) && defined(this.max) && !!this.tickPositions);
},
/**
* Adds the title defined in axis.options.title.
* @param {Boolean} display - whether or not to display the title
*/
addTitle: function(display) {
var axis = this,
renderer = axis.chart.renderer,
horiz = axis.horiz,
opposite = axis.opposite,
options = axis.options,
axisTitleOptions = options.title,
textAlign;
if (!axis.axisTitle) {
textAlign = axisTitleOptions.textAlign;
if (!textAlign) {
textAlign = (horiz ? {
low: 'left',
middle: 'center',
high: 'right'
} : {
low: opposite ? 'right' : 'left',
middle: 'center',
high: opposite ? 'left' : 'right'
})[axisTitleOptions.align];
}
axis.axisTitle = renderer.text(
axisTitleOptions.text,
0,
0,
axisTitleOptions.useHTML
)
.attr({
zIndex: 7,
rotation: axisTitleOptions.rotation || 0,
align: textAlign
})
.addClass('highcharts-axis-title')
.css(axisTitleOptions.style)
.add(axis.axisGroup);
axis.axisTitle.isNew = true;
}
// hide or show the title depending on whether showEmpty is set
axis.axisTitle[display ? 'show' : 'hide'](true);
},
/**
* Generates a tick for initial positioning.
* @param {number} pos - The tick position in axis values.
* @param {number} i - The index of the tick in axis.tickPositions.
*/
generateTick: function(pos) {
var ticks = this.ticks;
if (!ticks[pos]) {
ticks[pos] = new Tick(this, pos);
} else {
ticks[pos].addLabel(); // update labels depending on tick interval
}
},
/**
* Render the tick labels to a preliminary position to get their sizes
*/
getOffset: function() {
var axis = this,
chart = axis.chart,
renderer = chart.renderer,
options = axis.options,
tickPositions = axis.tickPositions,
ticks = axis.ticks,
horiz = axis.horiz,
side = axis.side,
invertedSide = chart.inverted ? [1, 0, 3, 2][side] : side,
hasData,
showAxis,
titleOffset = 0,
titleOffsetOption,
titleMargin = 0,
axisTitleOptions = options.title,
labelOptions = options.labels,
labelOffset = 0, // reset
labelOffsetPadded,
axisOffset = chart.axisOffset,
clipOffset = chart.clipOffset,
clip,
directionFactor = [-1, 1, 1, -1][side],
n,
className = options.className,
axisParent = axis.axisParent, // Used in color axis
lineHeightCorrection,
tickSize = this.tickSize('tick');
// For reuse in Axis.render
hasData = axis.hasData();
axis.showAxis = showAxis = hasData || pick(options.showEmpty, true);
// Set/reset staggerLines
axis.staggerLines = axis.horiz && labelOptions.staggerLines;
// Create the axisGroup and gridGroup elements on first iteration
if (!axis.axisGroup) {
axis.gridGroup = renderer.g('grid')
.attr({
zIndex: options.gridZIndex || 1
})
.addClass('highcharts-' + this.coll.toLowerCase() + '-grid ' + (className || ''))
.add(axisParent);
axis.axisGroup = renderer.g('axis')
.attr({
zIndex: options.zIndex || 2
})
.addClass('highcharts-' + this.coll.toLowerCase() + ' ' + (className || ''))
.add(axisParent);
axis.labelGroup = renderer.g('axis-labels')
.attr({
zIndex: labelOptions.zIndex || 7
})
.addClass('highcharts-' + axis.coll.toLowerCase() + '-labels ' + (className || ''))
.add(axisParent);
}
if (hasData || axis.isLinked) {
// Generate ticks
each(tickPositions, function(pos, i) {
// i is not used here, but may be used in overrides
axis.generateTick(pos, i);
});
axis.renderUnsquish();
// Left side must be align: right and right side must have align: left for labels
if (labelOptions.reserveSpace !== false && (side === 0 || side === 2 || {
1: 'left',
3: 'right'
}[side] === axis.labelAlign || axis.labelAlign === 'center')) {
each(tickPositions, function(pos) {
// get the highest offset
labelOffset = Math.max(
ticks[pos].getLabelSize(),
labelOffset
);
});
}
if (axis.staggerLines) {
labelOffset *= axis.staggerLines;
axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
}
} else { // doesn't have data
for (n in ticks) {
ticks[n].destroy();
delete ticks[n];
}
}
if (axisTitleOptions && axisTitleOptions.text && axisTitleOptions.enabled !== false) {
axis.addTitle(showAxis);
if (showAxis) {
titleOffset = axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
titleOffsetOption = axisTitleOptions.offset;
titleMargin = defined(titleOffsetOption) ? 0 : pick(axisTitleOptions.margin, horiz ? 5 : 10);
}
}
// Render the axis line
axis.renderLine();
// handle automatic or user set offset
axis.offset = directionFactor * pick(options.offset, axisOffset[side]);
axis.tickRotCorr = axis.tickRotCorr || {
x: 0,
y: 0
}; // polar
if (side === 0) {
lineHeightCorrection = -axis.labelMetrics().h;
} else if (side === 2) {
lineHeightCorrection = axis.tickRotCorr.y;
} else {
lineHeightCorrection = 0;
}
// Find the padded label offset
labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
if (labelOffset) {
labelOffsetPadded -= lineHeightCorrection;
labelOffsetPadded += directionFactor * (horiz ? pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) : labelOptions.x);
}
axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
axisOffset[side] = Math.max(
axisOffset[side],
axis.axisTitleMargin + titleOffset + directionFactor * axis.offset,
labelOffsetPadded, // #3027
hasData && tickPositions.length && tickSize ?
tickSize[0] + directionFactor * axis.offset :
0 // #4866
);
// Decide the clipping needed to keep the graph inside the plot area and axis lines
clip = options.offset ? 0 : Math.floor(axis.axisLine.strokeWidth() / 2) * 2; // #4308, #4371
clipOffset[invertedSide] = Math.max(clipOffset[invertedSide], clip);
},
/**
* Get the path for the axis line
*/
getLinePath: function(lineWidth) {
var chart = this.chart,
opposite = this.opposite,
offset = this.offset,
horiz = this.horiz,
lineLeft = this.left + (opposite ? this.width : 0) + offset,
lineTop = chart.chartHeight - this.bottom - (opposite ? this.height : 0) + offset;
if (opposite) {
lineWidth *= -1; // crispify the other way - #1480, #1687
}
return chart.renderer
.crispLine([
'M',
horiz ?
this.left :
lineLeft,
horiz ?
lineTop :
this.top,
'L',
horiz ?
chart.chartWidth - this.right :
lineLeft,
horiz ?
lineTop :
chart.chartHeight - this.bottom
], lineWidth);
},
/**
* Render the axis line
*/
renderLine: function() {
if (!this.axisLine) {
this.axisLine = this.chart.renderer.path()
.addClass('highcharts-axis-line')
.add(this.axisGroup);
this.axisLine.attr({
stroke: this.options.lineColor,
'stroke-width': this.options.lineWidth,
zIndex: 7
});
}
},
/**
* Position the title
*/
getTitlePosition: function() {
// compute anchor points for each of the title align options
var horiz = this.horiz,
axisLeft = this.left,
axisTop = this.top,
axisLength = this.len,
axisTitleOptions = this.options.title,
margin = horiz ? axisLeft : axisTop,
opposite = this.opposite,
offset = this.offset,
xOption = axisTitleOptions.x || 0,
yOption = axisTitleOptions.y || 0,
fontSize = this.chart.renderer.fontMetrics(axisTitleOptions.style && axisTitleOptions.style.fontSize, this.axisTitle).f,
// the position in the length direction of the axis
alongAxis = {
low: margin + (horiz ? 0 : axisLength),
middle: margin + axisLength / 2,
high: margin + (horiz ? axisLength : 0)
}[axisTitleOptions.align],
// the position in the perpendicular direction of the axis
offAxis = (horiz ? axisTop + this.height : axisLeft) +
(horiz ? 1 : -1) * // horizontal axis reverses the margin
(opposite ? -1 : 1) * // so does opposite axes
this.axisTitleMargin +
(this.side === 2 ? fontSize : 0);
return {
x: horiz ?
alongAxis + xOption : offAxis + (opposite ? this.width : 0) + offset + xOption,
y: horiz ?
offAxis + yOption - (opposite ? this.height : 0) + offset : alongAxis + yOption
};
},
/**
* Render a minor tick into the given position. If a minor tick already
* exists in this position, move it.
* @param {number} pos - The position in axis values.
*/
renderMinorTick: function(pos) {
var slideInTicks = this.chart.hasRendered && isNumber(this.oldMin),
minorTicks = this.minorTicks;
if (!minorTicks[pos]) {
minorTicks[pos] = new Tick(this, pos, 'minor');
}
// Render new ticks in old position
if (slideInTicks && minorTicks[pos].isNew) {
minorTicks[pos].render(null, true);
}
minorTicks[pos].render(null, false, 1);
},
/**
* Render a major tick into the given position. If a tick already exists
* in this position, move it.
* @param {number} pos - The position in axis values
* @param {number} i - The tick index
*/
renderTick: function(pos, i) {
var isLinked = this.isLinked,
ticks = this.ticks,
slideInTicks = this.chart.hasRendered && isNumber(this.oldMin);
// Linked axes need an extra check to find out if
if (!isLinked || (pos >= this.min && pos <= this.max)) {
if (!ticks[pos]) {
ticks[pos] = new Tick(this, pos);
}
// render new ticks in old position
if (slideInTicks && ticks[pos].isNew) {
ticks[pos].render(i, true, 0.1);
}
ticks[pos].render(i);
}
},
/**
* Render the axis
*/
render: function() {
var axis = this,
chart = axis.chart,
renderer = chart.renderer,
options = axis.options,
isLog = axis.isLog,
lin2log = axis.lin2log,
isLinked = axis.isLinked,
tickPositions = axis.tickPositions,
axisTitle = axis.axisTitle,
ticks = axis.ticks,
minorTicks = axis.minorTicks,
alternateBands = axis.alternateBands,
stackLabelOptions = options.stackLabels,
alternateGridColor = options.alternateGridColor,
tickmarkOffset = axis.tickmarkOffset,
axisLine = axis.axisLine,
showAxis = axis.showAxis,
animation = animObject(renderer.globalAnimation),
from,
to;
// Reset
axis.labelEdge.length = 0;
//axis.justifyToPlot = overflow === 'justify';
axis.overlap = false;
// Mark all elements inActive before we go over and mark the active ones
each([ticks, minorTicks, alternateBands], function(coll) {
var pos;
for (pos in coll) {
coll[pos].isActive = false;
}
});
// If the series has data draw the ticks. Else only the line and title
if (axis.hasData() || isLinked) {
// minor ticks
if (axis.minorTickInterval && !axis.categories) {
each(axis.getMinorTickPositions(), function(pos) {
axis.renderMinorTick(pos);
});
}
// Major ticks. Pull out the first item and render it last so that
// we can get the position of the neighbour label. #808.
if (tickPositions.length) { // #1300
each(tickPositions, function(pos, i) {
axis.renderTick(pos, i);
});
// In a categorized axis, the tick marks are displayed between labels. So
// we need to add a tick mark and grid line at the left edge of the X axis.
if (tickmarkOffset && (axis.min === 0 || axis.single)) {
if (!ticks[-1]) {
ticks[-1] = new Tick(axis, -1, null, true);
}
ticks[-1].render(-1);
}
}
// alternate grid color
if (alternateGridColor) {
each(tickPositions, function(pos, i) {
to = tickPositions[i + 1] !== undefined ? tickPositions[i + 1] + tickmarkOffset : axis.max - tickmarkOffset;
if (i % 2 === 0 && pos < axis.max && to <= axis.max + (chart.polar ? -tickmarkOffset : tickmarkOffset)) { // #2248, #4660
if (!alternateBands[pos]) {
alternateBands[pos] = new PlotLineOrBand(axis);
}
from = pos + tickmarkOffset; // #949
alternateBands[pos].options = {
from: isLog ? lin2log(from) : from,
to: isLog ? lin2log(to) : to,
color: alternateGridColor
};
alternateBands[pos].render();
alternateBands[pos].isActive = true;
}
});
}
// custom plot lines and bands
if (!axis._addedPlotLB) { // only first time
each((options.plotLines || []).concat(options.plotBands || []), function(plotLineOptions) {
axis.addPlotBandOrLine(plotLineOptions);
});
axis._addedPlotLB = true;
}
} // end if hasData
// Remove inactive ticks
each([ticks, minorTicks, alternateBands], function(coll) {
var pos,
i,
forDestruction = [],
delay = animation.duration,
destroyInactiveItems = function() {
i = forDestruction.length;
while (i--) {
// When resizing rapidly, the same items may be destroyed in different timeouts,
// or the may be reactivated
if (coll[forDestruction[i]] && !coll[forDestruction[i]].isActive) {
coll[forDestruction[i]].destroy();
delete coll[forDestruction[i]];
}
}
};
for (pos in coll) {
if (!coll[pos].isActive) {
// Render to zero opacity
coll[pos].render(pos, false, 0);
coll[pos].isActive = false;
forDestruction.push(pos);
}
}
// When the objects are finished fading out, destroy them
syncTimeout(
destroyInactiveItems,
coll === alternateBands || !chart.hasRendered || !delay ? 0 : delay
);
});
// Set the axis line path
if (axisLine) {
axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
d: this.getLinePath(axisLine.strokeWidth())
});
axisLine.isPlaced = true;
// Show or hide the line depending on options.showEmpty
axisLine[showAxis ? 'show' : 'hide'](true);
}
if (axisTitle && showAxis) {
axisTitle[axisTitle.isNew ? 'attr' : 'animate'](
axis.getTitlePosition()
);
axisTitle.isNew = false;
}
// Stacked totals:
if (stackLabelOptions && stackLabelOptions.enabled) {
axis.renderStackTotals();
}
// End stacked totals
axis.isDirty = false;
},
/**
* Redraw the axis to reflect changes in the data or axis extremes
*/
redraw: function() {
if (this.visible) {
// render the axis
this.render();
// move plot lines and bands
each(this.plotLinesAndBands, function(plotLine) {
plotLine.render();
});
}
// mark associated series as dirty and ready for redraw
each(this.series, function(series) {
series.isDirty = true;
});
},
// Properties to survive after destroy, needed for Axis.update (#4317,
// #5773, #5881).
keepProps: ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'],
/**
* Destroys an Axis instance.
*/
destroy: function(keepEvents) {
var axis = this,
stacks = axis.stacks,
stackKey,
plotLinesAndBands = axis.plotLinesAndBands,
plotGroup,
i,
n;
// Remove the events
if (!keepEvents) {
removeEvent(axis);
}
// Destroy each stack total
for (stackKey in stacks) {
destroyObjectProperties(stacks[stackKey]);
stacks[stackKey] = null;
}
// Destroy collections
each([axis.ticks, axis.minorTicks, axis.alternateBands], function(coll) {
destroyObjectProperties(coll);
});
if (plotLinesAndBands) {
i = plotLinesAndBands.length;
while (i--) { // #1975
plotLinesAndBands[i].destroy();
}
}
// Destroy local variables
each(['stackTotalGroup', 'axisLine', 'axisTitle', 'axisGroup', 'gridGroup', 'labelGroup', 'cross'], function(prop) {
if (axis[prop]) {
axis[prop] = axis[prop].destroy();
}
});
// Destroy each generated group for plotlines and plotbands
for (plotGroup in axis.plotLinesAndBandsGroups) {
axis.plotLinesAndBandsGroups[plotGroup] = axis.plotLinesAndBandsGroups[plotGroup].destroy();
}
// Delete all properties and fall back to the prototype.
for (n in axis) {
if (axis.hasOwnProperty(n) && inArray(n, axis.keepProps) === -1) {
delete axis[n];
}
}
},
/**
* Draw the crosshair
*
* @param {Object} e The event arguments from the modified pointer event
* @param {Object} point The Point object
*/
drawCrosshair: function(e, point) {
var path,
options = this.crosshair,
snap = pick(options.snap, true),
pos,
categorized,
graphic = this.cross;
// Use last available event when updating non-snapped crosshairs without
// mouse interaction (#5287)
if (!e) {
e = this.cross && this.cross.e;
}
if (
// Disabled in options
!this.crosshair ||
// Snap
((defined(point) || !snap) === false)
) {
this.hideCrosshair();
} else {
// Get the path
if (!snap) {
pos = e && (this.horiz ? e.chartX - this.pos : this.len - e.chartY + this.pos);
} else if (defined(point)) {
pos = this.isXAxis ? point.plotX : this.len - point.plotY; // #3834
}
if (defined(pos)) {
path = this.getPlotLinePath(
// First argument, value, only used on radial
point && (this.isXAxis ? point.x : pick(point.stackY, point.y)),
null,
null,
null,
pos // Translated position
) || null; // #3189
}
if (!defined(path)) {
this.hideCrosshair();
return;
}
categorized = this.categories && !this.isRadial;
// Draw the cross
if (!graphic) {
this.cross = graphic = this.chart.renderer
.path()
.addClass('highcharts-crosshair highcharts-crosshair-' +
(categorized ? 'category ' : 'thin ') + options.className)
.attr({
zIndex: pick(options.zIndex, 2)
})
.add();
// Presentational attributes
graphic.attr({
'stroke': options.color || (categorized ? color('#ccd6eb').setOpacity(0.25).get() : '#cccccc'),
'stroke-width': pick(options.width, 1)
});
if (options.dashStyle) {
graphic.attr({
dashstyle: options.dashStyle
});
}
}
graphic.show().attr({
d: path
});
if (categorized && !options.width) {
graphic.attr({
'stroke-width': this.transA
});
}
this.cross.e = e;
}
},
/**
* Hide the crosshair.
*/
hideCrosshair: function() {
if (this.cross) {
this.cross.hide();
}
}
}; // end Axis
extend(H.Axis.prototype, AxisPlotLineOrBandExtension);
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
Date = H.Date,
dateFormat = H.dateFormat,
defaultOptions = H.defaultOptions,
defined = H.defined,
each = H.each,
extend = H.extend,
getMagnitude = H.getMagnitude,
getTZOffset = H.getTZOffset,
normalizeTickInterval = H.normalizeTickInterval,
pick = H.pick,
timeUnits = H.timeUnits;
/**
* Set the tick positions to a time unit that makes sense, for example
* on the first of each month or on every Monday. Return an array
* with the time positions. Used in datetime axes as well as for grouping
* data on a datetime axis.
*
* @param {Object} normalizedInterval The interval in axis values (ms) and the count
* @param {Number} min The minimum in axis values
* @param {Number} max The maximum in axis values
* @param {Number} startOfWeek
*/
Axis.prototype.getTimeTicks = function(normalizedInterval, min, max, startOfWeek) {
var tickPositions = [],
i,
higherRanks = {},
useUTC = defaultOptions.global.useUTC,
minYear, // used in months and years as a basis for Date.UTC()
minDate = new Date(min - Math.abs(getTZOffset(min))), // #6278
makeTime = Date.hcMakeTime,
interval = normalizedInterval.unitRange,
count = normalizedInterval.count,
variableDayLength;
if (defined(min)) { // #1300
minDate[Date.hcSetMilliseconds](interval >= timeUnits.second ? 0 : // #3935
count * Math.floor(minDate.getMilliseconds() / count)); // #3652, #3654
if (interval >= timeUnits.second) { // second
minDate[Date.hcSetSeconds](interval >= timeUnits.minute ? 0 : // #3935
count * Math.floor(minDate.getSeconds() / count));
}
if (interval >= timeUnits.minute) { // minute
minDate[Date.hcSetMinutes](interval >= timeUnits.hour ? 0 :
count * Math.floor(minDate[Date.hcGetMinutes]() / count));
}
if (interval >= timeUnits.hour) { // hour
minDate[Date.hcSetHours](interval >= timeUnits.day ? 0 :
count * Math.floor(minDate[Date.hcGetHours]() / count));
}
if (interval >= timeUnits.day) { // day
minDate[Date.hcSetDate](interval >= timeUnits.month ? 1 :
count * Math.floor(minDate[Date.hcGetDate]() / count));
}
if (interval >= timeUnits.month) { // month
minDate[Date.hcSetMonth](interval >= timeUnits.year ? 0 :
count * Math.floor(minDate[Date.hcGetMonth]() / count));
minYear = minDate[Date.hcGetFullYear]();
}
if (interval >= timeUnits.year) { // year
minYear -= minYear % count;
minDate[Date.hcSetFullYear](minYear);
}
// week is a special case that runs outside the hierarchy
if (interval === timeUnits.week) {
// get start of current week, independent of count
minDate[Date.hcSetDate](minDate[Date.hcGetDate]() - minDate[Date.hcGetDay]() +
pick(startOfWeek, 1));
}
// Get basics for variable time spans
minYear = minDate[Date.hcGetFullYear]();
var minMonth = minDate[Date.hcGetMonth](),
minDateDate = minDate[Date.hcGetDate](),
minHours = minDate[Date.hcGetHours]();
// Handle local timezone offset
if (Date.hcTimezoneOffset || Date.hcGetTimezoneOffset) {
// Detect whether we need to take the DST crossover into
// consideration. If we're crossing over DST, the day length may be
// 23h or 25h and we need to compute the exact clock time for each
// tick instead of just adding hours. This comes at a cost, so first
// we found out if it is needed. #4951.
variableDayLength =
(!useUTC || !!Date.hcGetTimezoneOffset) &&
(
// Long range, assume we're crossing over.
max - min > 4 * timeUnits.month ||
// Short range, check if min and max are in different time
// zones.
getTZOffset(min) !== getTZOffset(max)
);
// Adjust minDate to the offset date
minDate = minDate.getTime();
minDate = new Date(minDate + getTZOffset(minDate));
}
// Iterate and add tick positions at appropriate values
var time = minDate.getTime();
i = 1;
while (time < max) {
tickPositions.push(time);
// if the interval is years, use Date.UTC to increase years
if (interval === timeUnits.year) {
time = makeTime(minYear + i * count, 0);
// if the interval is months, use Date.UTC to increase months
} else if (interval === timeUnits.month) {
time = makeTime(minYear, minMonth + i * count);
// if we're using global time, the interval is not fixed as it jumps
// one hour at the DST crossover
} else if (variableDayLength && (interval === timeUnits.day || interval === timeUnits.week)) {
time = makeTime(minYear, minMonth, minDateDate +
i * count * (interval === timeUnits.day ? 1 : 7));
} else if (variableDayLength && interval === timeUnits.hour) {
time = makeTime(minYear, minMonth, minDateDate, minHours + i * count);
// else, the interval is fixed and we use simple addition
} else {
time += interval * count;
}
i++;
}
// push the last time
tickPositions.push(time);
// Handle higher ranks. Mark new days if the time is on midnight
// (#950, #1649, #1760, #3349). Use a reasonable dropout threshold to
// prevent looping over dense data grouping (#6156).
if (interval <= timeUnits.hour && tickPositions.length < 10000) {
each(tickPositions, function(time) {
if (
// Speed optimization, no need to run dateFormat unless
// we're on a full or half hour
time % 1800000 === 0 &&
// Check for local or global midnight
dateFormat('%H%M%S%L', time) === '000000000'
) {
higherRanks[time] = 'day';
}
});
}
}
// record information on the chosen unit - for dynamic label formatter
tickPositions.info = extend(normalizedInterval, {
higherRanks: higherRanks,
totalRange: interval * count
});
return tickPositions;
};
/**
* Get a normalized tick interval for dates. Returns a configuration object with
* unit range (interval), count and name. Used to prepare data for getTimeTicks.
* Previously this logic was part of getTimeTicks, but as getTimeTicks now runs
* of segments in stock charts, the normalizing logic was extracted in order to
* prevent it for running over again for each segment having the same interval.
* #662, #697.
*/
Axis.prototype.normalizeTimeTickInterval = function(tickInterval, unitsOption) {
var units = unitsOption || [
[
'millisecond', // unit name
[1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
],
[
'second', [1, 2, 5, 10, 15, 30]
],
[
'minute', [1, 2, 5, 10, 15, 30]
],
[
'hour', [1, 2, 3, 4, 6, 8, 12]
],
[
'day', [1, 2]
],
[
'week', [1, 2]
],
[
'month', [1, 2, 3, 4, 6]
],
[
'year',
null
]
],
unit = units[units.length - 1], // default unit is years
interval = timeUnits[unit[0]],
multiples = unit[1],
count,
i;
// loop through the units to find the one that best fits the tickInterval
for (i = 0; i < units.length; i++) {
unit = units[i];
interval = timeUnits[unit[0]];
multiples = unit[1];
if (units[i + 1]) {
// lessThan is in the middle between the highest multiple and the next unit.
var lessThan = (interval * multiples[multiples.length - 1] +
timeUnits[units[i + 1][0]]) / 2;
// break and keep the current unit
if (tickInterval <= lessThan) {
break;
}
}
}
// prevent 2.5 years intervals, though 25, 250 etc. are allowed
if (interval === timeUnits.year && tickInterval < 5 * interval) {
multiples = [1, 2, 5];
}
// get the count
count = normalizeTickInterval(
tickInterval / interval,
multiples,
unit[0] === 'year' ? Math.max(getMagnitude(tickInterval / interval), 1) : 1 // #1913, #2360
);
return {
unitRange: interval,
count: count,
unitName: unit[0]
};
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
getMagnitude = H.getMagnitude,
map = H.map,
normalizeTickInterval = H.normalizeTickInterval,
pick = H.pick;
/**
* Methods defined on the Axis prototype
*/
/**
* Set the tick positions of a logarithmic axis
*/
Axis.prototype.getLogTickPositions = function(interval, min, max, minor) {
var axis = this,
options = axis.options,
axisLength = axis.len,
lin2log = axis.lin2log,
log2lin = axis.log2lin,
// Since we use this method for both major and minor ticks,
// use a local variable and return the result
positions = [];
// Reset
if (!minor) {
axis._minorAutoInterval = null;
}
// First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
if (interval >= 0.5) {
interval = Math.round(interval);
positions = axis.getLinearTickPositions(interval, min, max);
// Second case: We need intermediary ticks. For example
// 1, 2, 4, 6, 8, 10, 20, 40 etc.
} else if (interval >= 0.08) {
var roundedMin = Math.floor(min),
intermediate,
i,
j,
len,
pos,
lastPos,
break2;
if (interval > 0.3) {
intermediate = [1, 2, 4];
} else if (interval > 0.15) { // 0.2 equals five minor ticks per 1, 10, 100 etc
intermediate = [1, 2, 4, 6, 8];
} else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
}
for (i = roundedMin; i < max + 1 && !break2; i++) {
len = intermediate.length;
for (j = 0; j < len && !break2; j++) {
pos = log2lin(lin2log(i) * intermediate[j]);
if (pos > min && (!minor || lastPos <= max) && lastPos !== undefined) { // #1670, lastPos is #3113
positions.push(lastPos);
}
if (lastPos > max) {
break2 = true;
}
lastPos = pos;
}
}
// Third case: We are so deep in between whole logarithmic values that
// we might as well handle the tick positions like a linear axis. For
// example 1.01, 1.02, 1.03, 1.04.
} else {
var realMin = lin2log(min),
realMax = lin2log(max),
tickIntervalOption = options[minor ? 'minorTickInterval' : 'tickInterval'],
filteredTickIntervalOption = tickIntervalOption === 'auto' ? null : tickIntervalOption,
tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1),
totalPixelLength = minor ? axisLength / axis.tickPositions.length : axisLength;
interval = pick(
filteredTickIntervalOption,
axis._minorAutoInterval,
(realMax - realMin) * tickPixelIntervalOption / (totalPixelLength || 1)
);
interval = normalizeTickInterval(
interval,
null,
getMagnitude(interval)
);
positions = map(axis.getLinearTickPositions(
interval,
realMin,
realMax
), log2lin);
if (!minor) {
axis._minorAutoInterval = interval / 5;
}
}
// Set the axis-level tickInterval variable
if (!minor) {
axis.tickInterval = interval;
}
return positions;
};
Axis.prototype.log2lin = function(num) {
return Math.log(num) / Math.LN10;
};
Axis.prototype.lin2log = function(num) {
return Math.pow(10, num);
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var dateFormat = H.dateFormat,
each = H.each,
extend = H.extend,
format = H.format,
isNumber = H.isNumber,
map = H.map,
merge = H.merge,
pick = H.pick,
splat = H.splat,
syncTimeout = H.syncTimeout,
timeUnits = H.timeUnits;
/**
* The tooltip object
* @param {Object} chart The chart instance
* @param {Object} options Tooltip options
*/
H.Tooltip = function() {
this.init.apply(this, arguments);
};
H.Tooltip.prototype = {
init: function(chart, options) {
// Save the chart and options
this.chart = chart;
this.options = options;
// Keep track of the current series
//this.currentSeries = undefined;
// List of crosshairs
this.crosshairs = [];
// Current values of x and y when animating
this.now = {
x: 0,
y: 0
};
// The tooltip is initially hidden
this.isHidden = true;
// Public property for getting the shared state.
this.split = options.split && !chart.inverted;
this.shared = options.shared || this.split;
},
/**
* Destroy the single tooltips in a split tooltip.
* If the tooltip is active then it is not destroyed, unless forced to.
* @param {boolean} force Force destroy all tooltips.
* @return {undefined}
*/
cleanSplit: function(force) {
each(this.chart.series, function(series) {
var tt = series && series.tt;
if (tt) {
if (!tt.isActive || force) {
series.tt = tt.destroy();
} else {
tt.isActive = false;
}
}
});
},
/**
* Create the Tooltip label element if it doesn't exist, then return the
* label.
*/
getLabel: function() {
var renderer = this.chart.renderer,
options = this.options;
if (!this.label) {
// Create the label
if (this.split) {
this.label = renderer.g('tooltip');
} else {
this.label = renderer.label(
'',
0,
0,
options.shape || 'callout',
null,
null,
options.useHTML,
null,
'tooltip'
)
.attr({
padding: options.padding,
r: options.borderRadius
});
this.label
.attr({
'fill': options.backgroundColor,
'stroke-width': options.borderWidth
})
// #2301, #2657
.css(options.style)
.shadow(options.shadow);
}
this.label
.attr({
zIndex: 8
})
.add();
}
return this.label;
},
update: function(options) {
this.destroy();
this.init(this.chart, merge(true, this.options, options));
},
/**
* Destroy the tooltip and its elements.
*/
destroy: function() {
// Destroy and clear local variables
if (this.label) {
this.label = this.label.destroy();
}
if (this.split && this.tt) {
this.cleanSplit(this.chart, true);
this.tt = this.tt.destroy();
}
clearTimeout(this.hideTimer);
clearTimeout(this.tooltipTimeout);
},
/**
* Provide a soft movement for the tooltip
*
* @param {Number} x
* @param {Number} y
* @private
*/
move: function(x, y, anchorX, anchorY) {
var tooltip = this,
now = tooltip.now,
animate = tooltip.options.animation !== false && !tooltip.isHidden &&
// When we get close to the target position, abort animation and land on the right place (#3056)
(Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
skipAnchor = tooltip.followPointer || tooltip.len > 1;
// Get intermediate values for animation
extend(now, {
x: animate ? (2 * now.x + x) / 3 : x,
y: animate ? (now.y + y) / 2 : y,
anchorX: skipAnchor ? undefined : animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
anchorY: skipAnchor ? undefined : animate ? (now.anchorY + anchorY) / 2 : anchorY
});
// Move to the intermediate value
tooltip.getLabel().attr(now);
// Run on next tick of the mouse tracker
if (animate) {
// Never allow two timeouts
clearTimeout(this.tooltipTimeout);
// Set the fixed interval ticking for the smooth tooltip
this.tooltipTimeout = setTimeout(function() {
// The interval function may still be running during destroy,
// so check that the chart is really there before calling.
if (tooltip) {
tooltip.move(x, y, anchorX, anchorY);
}
}, 32);
}
},
/**
* Hide the tooltip
*/
hide: function(delay) {
var tooltip = this;
clearTimeout(this.hideTimer); // disallow duplicate timers (#1728, #1766)
delay = pick(delay, this.options.hideDelay, 500);
if (!this.isHidden) {
this.hideTimer = syncTimeout(function() {
tooltip.getLabel()[delay ? 'fadeOut' : 'hide']();
tooltip.isHidden = true;
}, delay);
}
},
/**
* Extendable method to get the anchor position of the tooltip
* from a point or set of points
*/
getAnchor: function(points, mouseEvent) {
var ret,
chart = this.chart,
inverted = chart.inverted,
plotTop = chart.plotTop,
plotLeft = chart.plotLeft,
plotX = 0,
plotY = 0,
yAxis,
xAxis;
points = splat(points);
// Pie uses a special tooltipPos
ret = points[0].tooltipPos;
// When tooltip follows mouse, relate the position to the mouse
if (this.followPointer && mouseEvent) {
if (mouseEvent.chartX === undefined) {
mouseEvent = chart.pointer.normalize(mouseEvent);
}
ret = [
mouseEvent.chartX - chart.plotLeft,
mouseEvent.chartY - plotTop
];
}
// When shared, use the average position
if (!ret) {
each(points, function(point) {
yAxis = point.series.yAxis;
xAxis = point.series.xAxis;
plotX += point.plotX + (!inverted && xAxis ? xAxis.left - plotLeft : 0);
plotY += (point.plotLow ? (point.plotLow + point.plotHigh) / 2 : point.plotY) +
(!inverted && yAxis ? yAxis.top - plotTop : 0); // #1151
});
plotX /= points.length;
plotY /= points.length;
ret = [
inverted ? chart.plotWidth - plotY : plotX,
this.shared && !inverted && points.length > 1 && mouseEvent ?
mouseEvent.chartY - plotTop : // place shared tooltip next to the mouse (#424)
inverted ? chart.plotHeight - plotX : plotY
];
}
return map(ret, Math.round);
},
/**
* Place the tooltip in a chart without spilling over
* and not covering the point it self.
*/
getPosition: function(boxWidth, boxHeight, point) {
var chart = this.chart,
distance = this.distance,
ret = {},
h = point.h || 0, // #4117
swapped,
first = ['y', chart.chartHeight, boxHeight,
point.plotY + chart.plotTop, chart.plotTop,
chart.plotTop + chart.plotHeight
],
second = ['x', chart.chartWidth, boxWidth,
point.plotX + chart.plotLeft, chart.plotLeft,
chart.plotLeft + chart.plotWidth
],
// The far side is right or bottom
preferFarSide = !this.followPointer && pick(point.ttBelow, !chart.inverted === !!point.negative), // #4984
/**
* Handle the preferred dimension. When the preferred dimension is tooltip
* on top or bottom of the point, it will look for space there.
*/
firstDimension = function(dim, outerSize, innerSize, point, min, max) {
var roomLeft = innerSize < point - distance,
roomRight = point + distance + innerSize < outerSize,
alignedLeft = point - distance - innerSize,
alignedRight = point + distance;
if (preferFarSide && roomRight) {
ret[dim] = alignedRight;
} else if (!preferFarSide && roomLeft) {
ret[dim] = alignedLeft;
} else if (roomLeft) {
ret[dim] = Math.min(max - innerSize, alignedLeft - h < 0 ? alignedLeft : alignedLeft - h);
} else if (roomRight) {
ret[dim] = Math.max(
min,
alignedRight + h + innerSize > outerSize ?
alignedRight :
alignedRight + h
);
} else {
return false;
}
},
/**
* Handle the secondary dimension. If the preferred dimension is tooltip
* on top or bottom of the point, the second dimension is to align the tooltip
* above the point, trying to align center but allowing left or right
* align within the chart box.
*/
secondDimension = function(dim, outerSize, innerSize, point) {
var retVal;
// Too close to the edge, return false and swap dimensions
if (point < distance || point > outerSize - distance) {
retVal = false;
// Align left/top
} else if (point < innerSize / 2) {
ret[dim] = 1;
// Align right/bottom
} else if (point > outerSize - innerSize / 2) {
ret[dim] = outerSize - innerSize - 2;
// Align center
} else {
ret[dim] = point - innerSize / 2;
}
return retVal;
},
/**
* Swap the dimensions
*/
swap = function(count) {
var temp = first;
first = second;
second = temp;
swapped = count;
},
run = function() {
if (firstDimension.apply(0, first) !== false) {
if (secondDimension.apply(0, second) === false && !swapped) {
swap(true);
run();
}
} else if (!swapped) {
swap(true);
run();
} else {
ret.x = ret.y = 0;
}
};
// Under these conditions, prefer the tooltip on the side of the point
if (chart.inverted || this.len > 1) {
swap();
}
run();
return ret;
},
/**
* In case no user defined formatter is given, this will be used. Note that the context
* here is an object holding point, series, x, y etc.
*
* @returns {String|Array<String>}
*/
defaultFormatter: function(tooltip) {
var items = this.points || splat(this),
s;
// Build the header
s = [tooltip.tooltipFooterHeaderFormatter(items[0])];
// build the values
s = s.concat(tooltip.bodyFormatter(items));
// footer
s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));
return s;
},
/**
* Refresh the tooltip's text and position.
* @param {Object|Array} pointOrPoints Rither a point or an array of points
*/
refresh: function(pointOrPoints, mouseEvent) {
var tooltip = this,
label,
options = tooltip.options,
x,
y,
point = pointOrPoints,
anchor,
textConfig = {},
text,
pointConfig = [],
formatter = options.formatter || tooltip.defaultFormatter,
shared = tooltip.shared,
currentSeries;
clearTimeout(this.hideTimer);
// get the reference point coordinates (pie charts use tooltipPos)
tooltip.followPointer = splat(point)[0].series.tooltipOptions.followPointer;
anchor = tooltip.getAnchor(point, mouseEvent);
x = anchor[0];
y = anchor[1];
// shared tooltip, array is sent over
if (shared && !(point.series && point.series.noSharedTooltip)) {
each(point, function(item) {
item.setState('hover');
pointConfig.push(item.getLabelConfig());
});
textConfig = {
x: point[0].category,
y: point[0].y
};
textConfig.points = pointConfig;
point = point[0];
// single point tooltip
} else {
textConfig = point.getLabelConfig();
}
this.len = pointConfig.length; // #6128
text = formatter.call(textConfig, tooltip);
// register the current series
currentSeries = point.series;
this.distance = pick(currentSeries.tooltipOptions.distance, 16);
// update the inner HTML
if (text === false) {
this.hide();
} else {
label = tooltip.getLabel();
// show it
if (tooltip.isHidden) {
label.attr({
opacity: 1
}).show();
}
// update text
if (tooltip.split) {
this.renderSplit(text, pointOrPoints);
} else {
label.attr({
text: text && text.join ? text.join('') : text
});
// Set the stroke color of the box to reflect the point
label.removeClass(/highcharts-color-[\d]+/g)
.addClass('highcharts-color-' + pick(point.colorIndex, currentSeries.colorIndex));
label.attr({
stroke: options.borderColor || point.color || currentSeries.color || '#666666'
});
tooltip.updatePosition({
plotX: x,
plotY: y,
negative: point.negative,
ttBelow: point.ttBelow,
h: anchor[2] || 0
});
}
this.isHidden = false;
}
},
/**
* Render the split tooltip. Loops over each point's text and adds
* a label next to the point, then uses the distribute function to
* find best non-overlapping positions.
*/
renderSplit: function(labels, points) {
var tooltip = this,
boxes = [],
chart = this.chart,
ren = chart.renderer,
rightAligned = true,
options = this.options,
headerHeight,
tooltipLabel = this.getLabel();
// Create the individual labels for header and points, ignore footer
each(labels.slice(0, points.length + 1), function(str, i) {
var point = points[i - 1] ||
// Item 0 is the header. Instead of this, we could also use the crosshair label
{
isHeader: true,
plotX: points[0].plotX
},
owner = point.series || tooltip,
tt = owner.tt,
series = point.series || {},
colorClass = 'highcharts-color-' + pick(point.colorIndex, series.colorIndex, 'none'),
target,
x,
bBox,
boxWidth;
// Store the tooltip referance on the series
if (!tt) {
owner.tt = tt = ren.label(null, null, null, 'callout')
.addClass('highcharts-tooltip-box ' + colorClass)
.attr({
'padding': options.padding,
'r': options.borderRadius,
'fill': options.backgroundColor,
'stroke': point.color || series.color || '#333333',
'stroke-width': options.borderWidth
})
.add(tooltipLabel);
}
tt.isActive = true;
tt.attr({
text: str
});
tt.css(options.style);
// Get X position now, so we can move all to the other side in case of overflow
bBox = tt.getBBox();
boxWidth = bBox.width + tt.strokeWidth();
if (point.isHeader) {
headerHeight = bBox.height;
x = Math.max(
0, // No left overflow
Math.min(
point.plotX + chart.plotLeft - boxWidth / 2,
chart.chartWidth - boxWidth // No right overflow (#5794)
)
);
} else {
x = point.plotX + chart.plotLeft - pick(options.distance, 16) -
boxWidth;
}
// If overflow left, we don't use this x in the next loop
if (x < 0) {
rightAligned = false;
}
// Prepare for distribution
target = (point.series && point.series.yAxis && point.series.yAxis.pos) + (point.plotY || 0);
target -= chart.plotTop;
boxes.push({
target: point.isHeader ? chart.plotHeight + headerHeight : target,
rank: point.isHeader ? 1 : 0,
size: owner.tt.getBBox().height + 1,
point: point,
x: x,
tt: tt
});
});
// Clean previous run (for missing points)
this.cleanSplit();
// Distribute and put in place
H.distribute(boxes, chart.plotHeight + headerHeight);
each(boxes, function(box) {
var point = box.point,
series = point.series;
// Put the label in place
box.tt.attr({
visibility: box.pos === undefined ? 'hidden' : 'inherit',
x: (rightAligned || point.isHeader ?
box.x :
point.plotX + chart.plotLeft + pick(options.distance, 16)),
y: box.pos + chart.plotTop,
anchorX: point.isHeader ?
point.plotX + chart.plotLeft : point.plotX + series.xAxis.pos,
anchorY: point.isHeader ?
box.pos + chart.plotTop - 15 : point.plotY + series.yAxis.pos
});
});
},
/**
* Find the new position and perform the move
*/
updatePosition: function(point) {
var chart = this.chart,
label = this.getLabel(),
pos = (this.options.positioner || this.getPosition).call(
this,
label.width,
label.height,
point
);
// do the move
this.move(
Math.round(pos.x),
Math.round(pos.y || 0), // can be undefined (#3977)
point.plotX + chart.plotLeft,
point.plotY + chart.plotTop
);
},
/**
* Get the optimal date format for a point, based on a range.
* @param {number} range - The time range
* @param {number|Date} date - The date of the point in question
* @param {number} startOfWeek - An integer representing the first day of
* the week, where 0 is Sunday
* @param {Object} dateTimeLabelFormats - A map of time units to formats
* @return {string} - the optimal date format for a point
*/
getDateFormat: function(range, date, startOfWeek, dateTimeLabelFormats) {
var dateStr = dateFormat('%m-%d %H:%M:%S.%L', date),
format,
n,
blank = '01-01 00:00:00.000',
strpos = {
millisecond: 15,
second: 12,
minute: 9,
hour: 6,
day: 3
},
lastN = 'millisecond'; // for sub-millisecond data, #4223
for (n in timeUnits) {
// If the range is exactly one week and we're looking at a Sunday/Monday, go for the week format
if (range === timeUnits.week && +dateFormat('%w', date) === startOfWeek &&
dateStr.substr(6) === blank.substr(6)) {
n = 'week';
break;
}
// The first format that is too great for the range
if (timeUnits[n] > range) {
n = lastN;
break;
}
// If the point is placed every day at 23:59, we need to show
// the minutes as well. #2637.
if (strpos[n] && dateStr.substr(strpos[n]) !== blank.substr(strpos[n])) {
break;
}
// Weeks are outside the hierarchy, only apply them on Mondays/Sundays like in the first condition
if (n !== 'week') {
lastN = n;
}
}
if (n) {
format = dateTimeLabelFormats[n];
}
return format;
},
/**
* Get the best X date format based on the closest point range on the axis.
*/
getXDateFormat: function(point, options, xAxis) {
var xDateFormat,
dateTimeLabelFormats = options.dateTimeLabelFormats,
closestPointRange = xAxis && xAxis.closestPointRange;
if (closestPointRange) {
xDateFormat = this.getDateFormat(
closestPointRange,
point.x,
xAxis.options.startOfWeek,
dateTimeLabelFormats
);
} else {
xDateFormat = dateTimeLabelFormats.day;
}
return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
},
/**
* Format the footer/header of the tooltip
* #3397: abstraction to enable formatting of footer and header
*/
tooltipFooterHeaderFormatter: function(labelConfig, isFooter) {
var footOrHead = isFooter ? 'footer' : 'header',
series = labelConfig.series,
tooltipOptions = series.tooltipOptions,
xDateFormat = tooltipOptions.xDateFormat,
xAxis = series.xAxis,
isDateTime = xAxis && xAxis.options.type === 'datetime' && isNumber(labelConfig.key),
formatString = tooltipOptions[footOrHead + 'Format'];
// Guess the best date format based on the closest point distance (#568, #3418)
if (isDateTime && !xDateFormat) {
xDateFormat = this.getXDateFormat(labelConfig, tooltipOptions, xAxis);
}
// Insert the footer date format if any
if (isDateTime && xDateFormat) {
formatString = formatString.replace('{point.key}', '{point.key:' + xDateFormat + '}');
}
return format(formatString, {
point: labelConfig,
series: series
});
},
/**
* Build the body (lines) of the tooltip by iterating over the items and returning one entry for each item,
* abstracting this functionality allows to easily overwrite and extend it.
*/
bodyFormatter: function(items) {
return map(items, function(item) {
var tooltipOptions = item.series.tooltipOptions;
return (tooltipOptions.pointFormatter || item.point.tooltipFormatter)
.call(item.point, tooltipOptions.pointFormat);
});
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
attr = H.attr,
charts = H.charts,
color = H.color,
css = H.css,
defined = H.defined,
doc = H.doc,
each = H.each,
extend = H.extend,
fireEvent = H.fireEvent,
offset = H.offset,
pick = H.pick,
removeEvent = H.removeEvent,
splat = H.splat,
Tooltip = H.Tooltip,
win = H.win;
/**
* The mouse tracker object. All methods starting with "on" are primary DOM
* event handlers. Subsequent methods should be named differently from what they
* are doing.
*
* @constructor Pointer
* @param {Object} chart The Chart instance
* @param {Object} options The root options object
*/
H.Pointer = function(chart, options) {
this.init(chart, options);
};
H.Pointer.prototype = {
/**
* Initialize Pointer
*/
init: function(chart, options) {
// Store references
this.options = options;
this.chart = chart;
// Do we need to handle click on a touch device?
this.runChartClick = options.chart.events && !!options.chart.events.click;
this.pinchDown = [];
this.lastValidTouch = {};
if (Tooltip && options.tooltip.enabled) {
chart.tooltip = new Tooltip(chart, options.tooltip);
this.followTouchMove = pick(options.tooltip.followTouchMove, true);
}
this.setDOMEvents();
},
/**
* Resolve the zoomType option, this is reset on all touch start and mouse
* down events.
*/
zoomOption: function(e) {
var chart = this.chart,
options = chart.options.chart,
zoomType = options.zoomType || '',
inverted = chart.inverted,
zoomX,
zoomY;
// Look for the pinchType option
if (/touch/.test(e.type)) {
zoomType = pick(options.pinchType, zoomType);
}
this.zoomX = zoomX = /x/.test(zoomType);
this.zoomY = zoomY = /y/.test(zoomType);
this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
this.hasZoom = zoomX || zoomY;
},
/**
* Add crossbrowser support for chartX and chartY
* @param {Object} e The event object in standard browsers
*/
normalize: function(e, chartPosition) {
var chartX,
chartY,
ePos;
// IE normalizing
e = e || win.event;
if (!e.target) {
e.target = e.srcElement;
}
// iOS (#2757)
ePos = e.touches ? (e.touches.length ? e.touches.item(0) : e.changedTouches[0]) : e;
// Get mouse position
if (!chartPosition) {
this.chartPosition = chartPosition = offset(this.chart.container);
}
// chartX and chartY
if (ePos.pageX === undefined) { // IE < 9. #886.
chartX = Math.max(e.x, e.clientX - chartPosition.left); // #2005, #2129: the second case is
// for IE10 quirks mode within framesets
chartY = e.y;
} else {
chartX = ePos.pageX - chartPosition.left;
chartY = ePos.pageY - chartPosition.top;
}
return extend(e, {
chartX: Math.round(chartX),
chartY: Math.round(chartY)
});
},
/**
* Get the click position in terms of axis values.
*
* @param {Object} e A pointer event
*/
getCoordinates: function(e) {
var coordinates = {
xAxis: [],
yAxis: []
};
each(this.chart.axes, function(axis) {
coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
axis: axis,
value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
});
});
return coordinates;
},
/**
* Collects the points closest to a mouseEvent
* @param {Array} series Array of series to gather points from
* @param {Boolean} shared True if shared tooltip, otherwise false
* @param {Object} e Mouse event which possess a position to compare against
* @return {Array} KDPoints sorted by distance
*/
getKDPoints: function(series, shared, e) {
var kdpoints = [],
noSharedTooltip,
directTouch,
kdpointT,
i;
// Find nearest points on all series
each(series, function(s) {
// Skip hidden series
noSharedTooltip = s.noSharedTooltip && shared;
directTouch = !shared && s.directTouch;
if (s.visible && !directTouch && pick(s.options.enableMouseTracking, true)) { // #3821
// #3828
kdpointT = s.searchPoint(
e, !noSharedTooltip && s.options.findNearestPointBy.indexOf('y') < 0
);
if (kdpointT && kdpointT.series) { // Point.series becomes null when reset and before redraw (#5197)
kdpoints.push(kdpointT);
}
}
});
// Sort kdpoints by distance to mouse pointer
kdpoints.sort(function(p1, p2) {
var isCloserX = p1.distX - p2.distX,
isCloser = p1.dist - p2.dist,
isAbove =
(p2.series.group && p2.series.group.zIndex) -
(p1.series.group && p1.series.group.zIndex),
result;
// We have two points which are not in the same place on xAxis and shared tooltip:
if (isCloserX !== 0 && shared) { // #5721
result = isCloserX;
// Points are not exactly in the same place on x/yAxis:
} else if (isCloser !== 0) {
result = isCloser;
// The same xAxis and yAxis position, sort by z-index:
} else if (isAbove !== 0) {
result = isAbove;
// The same zIndex, sort by array index:
} else {
result = p1.series.index > p2.series.index ? -1 : 1;
}
return result;
});
// Remove points with different x-positions, required for shared tooltip and crosshairs (#4645):
if (shared && kdpoints[0] && !kdpoints[0].series.noSharedTooltip) {
i = kdpoints.length;
while (i--) {
if (kdpoints[i].x !== kdpoints[0].x || kdpoints[i].series.noSharedTooltip) {
kdpoints.splice(i, 1);
}
}
}
return kdpoints;
},
getPointFromEvent: function(e) {
var target = e.target,
point;
while (target && !point) {
point = target.point;
target = target.parentNode;
}
return point;
},
getHoverData: function(existingHoverPoint, existingHoverSeries, series, isDirectTouch, shared, e) {
var hoverPoint = existingHoverPoint,
hoverSeries = existingHoverSeries,
searchSeries,
hoverPoints;
// If it has a hoverPoint and that series requires direct touch (like columns, #3899), or we're on
// a noSharedTooltip series among shared tooltip series (#4546), use the hoverPoint . Otherwise,
// search the k-d tree.
// Handle shared tooltip or cases where a series is not yet hovered
if (isDirectTouch) {
if (shared) {
hoverPoints = [];
each(series, function(s) {
// Skip hidden series
var noSharedTooltip = s.noSharedTooltip && shared,
directTouch = !shared && s.directTouch,
kdpointT;
if (s.visible && !noSharedTooltip && !directTouch && pick(s.options.enableMouseTracking, true)) { // #3821
kdpointT = s.searchKDTree({
clientX: hoverPoint.clientX,
plotY: hoverPoint.plotY
}, !noSharedTooltip && s.kdDimensions === 1);
if (kdpointT && kdpointT.series) { // Point.series becomes null when reset and before redraw (#5197)
hoverPoints.push(kdpointT);
}
}
});
// If kdTree is not built
if (hoverPoints.length === 0) {
hoverPoints = [hoverPoint];
}
} else {
hoverPoints = [hoverPoint];
}
// When the hovered series has stickyTracking false.
} else if (hoverSeries && !hoverSeries.stickyTracking) {
if (!shared) {
series = [hoverSeries];
}
hoverPoints = this.getKDPoints(series, shared, e);
hoverPoint = H.find(hoverPoints, function(p) {
return p.series === hoverSeries;
});
// When the hoverSeries has stickyTracking or there is no series hovered.
} else {
// Avoid series with stickyTracking
searchSeries = H.grep(series, function(s) {
return s.stickyTracking;
});
hoverPoints = this.getKDPoints(searchSeries, shared, e);
hoverPoint = hoverPoints[0];
hoverSeries = hoverPoint && hoverPoint.series;
// If
if (shared) {
hoverPoints = this.getKDPoints(series, shared, e);
}
}
// Keep the order of series in tooltip
// Must be done after assigning of hoverPoint
hoverPoints.sort(function(p1, p2) {
return p1.series.index - p2.series.index;
});
return {
hoverPoint: hoverPoint,
hoverSeries: hoverSeries,
hoverPoints: hoverPoints
};
},
/**
* With line type charts with a single tracker, get the point closest to the mouse.
* Run Point.onMouseOver and display tooltip for the point or points.
*/
runPointActions: function(e, p) {
var pointer = this,
chart = pointer.chart,
series = chart.series,
tooltip = chart.tooltip,
shared = tooltip ? tooltip.shared : false,
hoverPoint = p || chart.hoverPoint,
hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries,
// onMouseOver or already hovering a series with directTouch
isDirectTouch = !!p || (!shared && hoverSeries && hoverSeries.directTouch),
hoverData = this.getHoverData(hoverPoint, hoverSeries, series, isDirectTouch, shared, e),
useSharedTooltip,
followPointer,
anchor,
points;
// Update variables from hoverData.
hoverPoint = hoverData.hoverPoint;
hoverSeries = hoverData.hoverSeries;
followPointer = hoverSeries && hoverSeries.tooltipOptions.followPointer;
useSharedTooltip = shared && hoverPoint && !hoverPoint.series.noSharedTooltip;
points = (useSharedTooltip ?
hoverData.hoverPoints :
(hoverPoint ? [hoverPoint] : [])
);
// Refresh tooltip for kdpoint if new hover point or tooltip was hidden // #3926, #4200
if (
hoverPoint &&
// !(hoverSeries && hoverSeries.directTouch) &&
(hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))
) {
each(chart.hoverPoints || [], function(p) {
if (H.inArray(p, points) === -1) {
p.setState();
}
});
// Do mouseover on all points (#3919, #3985, #4410, #5622)
each(points || [], function(p) {
p.setState('hover');
});
// set normal state to previous series
if (chart.hoverSeries !== hoverSeries) {
hoverSeries.onMouseOver();
}
// If tracking is on series in stead of on each point,
// fire mouseOver on hover point.
if (hoverSeries && !hoverSeries.directTouch) { // #4448
if (chart.hoverPoint) {
chart.hoverPoint.firePointEvent('mouseOut');
}
hoverPoint.firePointEvent('mouseOver');
}
chart.hoverPoints = points;
chart.hoverPoint = hoverPoint;
// Draw tooltip if necessary
if (tooltip) {
tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
}
// Update positions (regardless of kdpoint or hoverPoint)
} else if (followPointer && tooltip && !tooltip.isHidden) {
anchor = tooltip.getAnchor([{}], e);
tooltip.updatePosition({
plotX: anchor[0],
plotY: anchor[1]
});
}
// Start the event listener to pick up the tooltip and crosshairs
if (!pointer.unDocMouseMove) {
pointer.unDocMouseMove = addEvent(doc, 'mousemove', function(e) {
var chart = charts[H.hoverChartIndex];
if (chart) {
chart.pointer.onDocumentMouseMove(e);
}
});
}
// Draw crosshairs (#4927, #5269 #5066, #5658)
each(chart.axes, function drawAxisCrosshair(axis) {
// Snap is true. For each hover point, loop over the axes and draw a
// crosshair if that point belongs to the axis.
// @todo Consider only one crosshair per axis.
if (pick(axis.crosshair.snap, true)) {
each(points, function(p) {
if (p.series[axis.coll] === axis) {
axis.drawCrosshair(e, p);
}
});
} else {
axis.drawCrosshair(e);
}
});
},
/**
* Reset the tracking by hiding the tooltip, the hover series state and the hover point
*
* @param allowMove {Boolean} Instead of destroying the tooltip altogether, allow moving it if possible
*/
reset: function(allowMove, delay) {
var pointer = this,
chart = pointer.chart,
hoverSeries = chart.hoverSeries,
hoverPoint = chart.hoverPoint,
hoverPoints = chart.hoverPoints,
tooltip = chart.tooltip,
tooltipPoints = tooltip && tooltip.shared ? hoverPoints : hoverPoint;
// Check if the points have moved outside the plot area (#1003, #4736, #5101)
if (allowMove && tooltipPoints) {
each(splat(tooltipPoints), function(point) {
if (point.series.isCartesian && point.plotX === undefined) {
allowMove = false;
}
});
}
// Just move the tooltip, #349
if (allowMove) {
if (tooltip && tooltipPoints) {
tooltip.refresh(tooltipPoints);
if (hoverPoint) { // #2500
hoverPoint.setState(hoverPoint.state, true);
each(chart.axes, function(axis) {
if (axis.crosshair) {
axis.drawCrosshair(null, hoverPoint);
}
});
}
}
// Full reset
} else {
if (hoverPoint) {
hoverPoint.onMouseOut();
}
if (hoverPoints) {
each(hoverPoints, function(point) {
point.setState();
});
}
if (hoverSeries) {
hoverSeries.onMouseOut();
}
if (tooltip) {
tooltip.hide(delay);
}
if (pointer.unDocMouseMove) {
pointer.unDocMouseMove = pointer.unDocMouseMove();
}
// Remove crosshairs
each(chart.axes, function(axis) {
axis.hideCrosshair();
});
pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
}
},
/**
* Scale series groups to a certain scale and translation
*/
scaleGroups: function(attribs, clip) {
var chart = this.chart,
seriesAttribs;
// Scale each series
each(chart.series, function(series) {
seriesAttribs = attribs || series.getPlotBox(); // #1701
if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
series.group.attr(seriesAttribs);
if (series.markerGroup) {
series.markerGroup.attr(seriesAttribs);
series.markerGroup.clip(clip ? chart.clipRect : null);
}
if (series.dataLabelsGroup) {
series.dataLabelsGroup.attr(seriesAttribs);
}
}
});
// Clip
chart.clipRect.attr(clip || chart.clipBox);
},
/**
* Start a drag operation
*/
dragStart: function(e) {
var chart = this.chart;
// Record the start position
chart.mouseIsDown = e.type;
chart.cancelClick = false;
chart.mouseDownX = this.mouseDownX = e.chartX;
chart.mouseDownY = this.mouseDownY = e.chartY;
},
/**
* Perform a drag operation in response to a mousemove event while the mouse is down
*/
drag: function(e) {
var chart = this.chart,
chartOptions = chart.options.chart,
chartX = e.chartX,
chartY = e.chartY,
zoomHor = this.zoomHor,
zoomVert = this.zoomVert,
plotLeft = chart.plotLeft,
plotTop = chart.plotTop,
plotWidth = chart.plotWidth,
plotHeight = chart.plotHeight,
clickedInside,
size,
selectionMarker = this.selectionMarker,
mouseDownX = this.mouseDownX,
mouseDownY = this.mouseDownY,
panKey = chartOptions.panKey && e[chartOptions.panKey + 'Key'];
// If the device supports both touch and mouse (like IE11), and we are touch-dragging
// inside the plot area, don't handle the mouse event. #4339.
if (selectionMarker && selectionMarker.touch) {
return;
}
// If the mouse is outside the plot area, adjust to cooordinates
// inside to prevent the selection marker from going outside
if (chartX < plotLeft) {
chartX = plotLeft;
} else if (chartX > plotLeft + plotWidth) {
chartX = plotLeft + plotWidth;
}
if (chartY < plotTop) {
chartY = plotTop;
} else if (chartY > plotTop + plotHeight) {
chartY = plotTop + plotHeight;
}
// determine if the mouse has moved more than 10px
this.hasDragged = Math.sqrt(
Math.pow(mouseDownX - chartX, 2) +
Math.pow(mouseDownY - chartY, 2)
);
if (this.hasDragged > 10) {
clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop);
// make a selection
if (chart.hasCartesianSeries && (this.zoomX || this.zoomY) && clickedInside && !panKey) {
if (!selectionMarker) {
this.selectionMarker = selectionMarker = chart.renderer.rect(
plotLeft,
plotTop,
zoomHor ? 1 : plotWidth,
zoomVert ? 1 : plotHeight,
0
)
.attr({
fill: chartOptions.selectionMarkerFill || color('#335cad').setOpacity(0.25).get(),
'class': 'highcharts-selection-marker',
'zIndex': 7
})
.add();
}
}
// adjust the width of the selection marker
if (selectionMarker && zoomHor) {
size = chartX - mouseDownX;
selectionMarker.attr({
width: Math.abs(size),
x: (size > 0 ? 0 : size) + mouseDownX
});
}
// adjust the height of the selection marker
if (selectionMarker && zoomVert) {
size = chartY - mouseDownY;
selectionMarker.attr({
height: Math.abs(size),
y: (size > 0 ? 0 : size) + mouseDownY
});
}
// panning
if (clickedInside && !selectionMarker && chartOptions.panning) {
chart.pan(e, chartOptions.panning);
}
}
},
/**
* On mouse up or touch end across the entire document, drop the selection.
*/
drop: function(e) {
var pointer = this,
chart = this.chart,
hasPinched = this.hasPinched;
if (this.selectionMarker) {
var selectionData = {
originalEvent: e, // #4890
xAxis: [],
yAxis: []
},
selectionBox = this.selectionMarker,
selectionLeft = selectionBox.attr ? selectionBox.attr('x') : selectionBox.x,
selectionTop = selectionBox.attr ? selectionBox.attr('y') : selectionBox.y,
selectionWidth = selectionBox.attr ? selectionBox.attr('width') : selectionBox.width,
selectionHeight = selectionBox.attr ? selectionBox.attr('height') : selectionBox.height,
runZoom;
// a selection has been made
if (this.hasDragged || hasPinched) {
// record each axis' min and max
each(chart.axes, function(axis) {
if (axis.zoomEnabled && defined(axis.min) && (hasPinched || pointer[{
xAxis: 'zoomX',
yAxis: 'zoomY'
}[axis.coll]])) { // #859, #3569
var horiz = axis.horiz,
minPixelPadding = e.type === 'touchend' ? axis.minPixelPadding : 0, // #1207, #3075
selectionMin = axis.toValue((horiz ? selectionLeft : selectionTop) + minPixelPadding),
selectionMax = axis.toValue((horiz ? selectionLeft + selectionWidth : selectionTop + selectionHeight) - minPixelPadding);
selectionData[axis.coll].push({
axis: axis,
min: Math.min(selectionMin, selectionMax), // for reversed axes
max: Math.max(selectionMin, selectionMax)
});
runZoom = true;
}
});
if (runZoom) {
fireEvent(chart, 'selection', selectionData, function(args) {
chart.zoom(extend(args, hasPinched ? {
animation: false
} : null));
});
}
}
this.selectionMarker = this.selectionMarker.destroy();
// Reset scaling preview
if (hasPinched) {
this.scaleGroups();
}
}
// Reset all
if (chart) { // it may be destroyed on mouse up - #877
css(chart.container, {
cursor: chart._cursor
});
chart.cancelClick = this.hasDragged > 10; // #370
chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
this.pinchDown = [];
}
},
onContainerMouseDown: function(e) {
e = this.normalize(e);
this.zoomOption(e);
// issue #295, dragging not always working in Firefox
if (e.preventDefault) {
e.preventDefault();
}
this.dragStart(e);
},
onDocumentMouseUp: function(e) {
if (charts[H.hoverChartIndex]) {
charts[H.hoverChartIndex].pointer.drop(e);
}
},
/**
* Special handler for mouse move that will hide the tooltip when the mouse leaves the plotarea.
* Issue #149 workaround. The mouseleave event does not always fire.
*/
onDocumentMouseMove: function(e) {
var chart = this.chart,
chartPosition = this.chartPosition;
e = this.normalize(e, chartPosition);
// If we're outside, hide the tooltip
if (chartPosition && !this.inClass(e.target, 'highcharts-tracker') &&
!chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
this.reset();
}
},
/**
* When mouse leaves the container, hide the tooltip.
*/
onContainerMouseLeave: function(e) {
var chart = charts[H.hoverChartIndex];
if (chart && (e.relatedTarget || e.toElement)) { // #4886, MS Touch end fires mouseleave but with no related target
chart.pointer.reset();
chart.pointer.chartPosition = null; // also reset the chart position, used in #149 fix
}
},
// The mousemove, touchmove and touchstart event handler
onContainerMouseMove: function(e) {
var chart = this.chart;
if (!defined(H.hoverChartIndex) || !charts[H.hoverChartIndex] || !charts[H.hoverChartIndex].mouseIsDown) {
H.hoverChartIndex = chart.index;
}
e = this.normalize(e);
e.returnValue = false; // #2251, #3224
if (chart.mouseIsDown === 'mousedown') {
this.drag(e);
}
// Show the tooltip and run mouse over events (#977)
if ((this.inClass(e.target, 'highcharts-tracker') ||
chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) && !chart.openMenu) {
this.runPointActions(e);
}
},
/**
* Utility to detect whether an element has, or has a parent with, a specific
* class name. Used on detection of tracker objects and on deciding whether
* hovering the tooltip should cause the active series to mouse out.
*/
inClass: function(element, className) {
var elemClassName;
while (element) {
elemClassName = attr(element, 'class');
if (elemClassName) {
if (elemClassName.indexOf(className) !== -1) {
return true;
}
if (elemClassName.indexOf('highcharts-container') !== -1) {
return false;
}
}
element = element.parentNode;
}
},
onTrackerMouseOut: function(e) {
var series = this.chart.hoverSeries,
relatedTarget = e.relatedTarget || e.toElement;
if (series && relatedTarget && !series.stickyTracking &&
!this.inClass(relatedTarget, 'highcharts-tooltip') &&
(!this.inClass(relatedTarget, 'highcharts-series-' + series.index) || // #2499, #4465
!this.inClass(relatedTarget, 'highcharts-tracker') // #5553
)
) {
series.onMouseOut();
}
},
onContainerClick: function(e) {
var chart = this.chart,
hoverPoint = chart.hoverPoint,
plotLeft = chart.plotLeft,
plotTop = chart.plotTop;
e = this.normalize(e);
if (!chart.cancelClick) {
// On tracker click, fire the series and point events. #783, #1583
if (hoverPoint && this.inClass(e.target, 'highcharts-tracker')) {
// the series click event
fireEvent(hoverPoint.series, 'click', extend(e, {
point: hoverPoint
}));
// the point click event
if (chart.hoverPoint) { // it may be destroyed (#1844)
hoverPoint.firePointEvent('click', e);
}
// When clicking outside a tracker, fire a chart event
} else {
extend(e, this.getCoordinates(e));
// fire a click event in the chart
if (chart.isInsidePlot(e.chartX - plotLeft, e.chartY - plotTop)) {
fireEvent(chart, 'click', e);
}
}
}
},
/**
* Set the JS DOM events on the container and document. This method should contain
* a one-to-one assignment between methods and their handlers. Any advanced logic should
* be moved to the handler reflecting the event's name.
*/
setDOMEvents: function() {
var pointer = this,
container = pointer.chart.container;
container.onmousedown = function(e) {
pointer.onContainerMouseDown(e);
};
container.onmousemove = function(e) {
pointer.onContainerMouseMove(e);
};
container.onclick = function(e) {
pointer.onContainerClick(e);
};
addEvent(container, 'mouseleave', pointer.onContainerMouseLeave);
if (H.chartCount === 1) {
addEvent(doc, 'mouseup', pointer.onDocumentMouseUp);
}
if (H.hasTouch) {
container.ontouchstart = function(e) {
pointer.onContainerTouchStart(e);
};
container.ontouchmove = function(e) {
pointer.onContainerTouchMove(e);
};
if (H.chartCount === 1) {
addEvent(doc, 'touchend', pointer.onDocumentTouchEnd);
}
}
},
/**
* Destroys the Pointer object and disconnects DOM events.
*/
destroy: function() {
var prop;
if (this.unDocMouseMove) {
this.unDocMouseMove();
}
removeEvent(
this.chart.container,
'mouseleave',
this.onContainerMouseLeave
);
if (!H.chartCount) {
removeEvent(doc, 'mouseup', this.onDocumentMouseUp);
removeEvent(doc, 'touchend', this.onDocumentTouchEnd);
}
// memory and CPU leak
clearInterval(this.tooltipTimeout);
for (prop in this) {
this[prop] = null;
}
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var charts = H.charts,
each = H.each,
extend = H.extend,
map = H.map,
noop = H.noop,
pick = H.pick,
Pointer = H.Pointer;
/* Support for touch devices */
extend(Pointer.prototype, /** @lends Pointer.prototype */ {
/**
* Run translation operations
*/
pinchTranslate: function(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
if (this.zoomHor) {
this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
}
if (this.zoomVert) {
this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
}
},
/**
* Run translation operations for each direction (horizontal and vertical) independently
*/
pinchTranslateDirection: function(horiz, pinchDown, touches, transform,
selectionMarker, clip, lastValidTouch, forcedScale) {
var chart = this.chart,
xy = horiz ? 'x' : 'y',
XY = horiz ? 'X' : 'Y',
sChartXY = 'chart' + XY,
wh = horiz ? 'width' : 'height',
plotLeftTop = chart['plot' + (horiz ? 'Left' : 'Top')],
selectionWH,
selectionXY,
clipXY,
scale = forcedScale || 1,
inverted = chart.inverted,
bounds = chart.bounds[horiz ? 'h' : 'v'],
singleTouch = pinchDown.length === 1,
touch0Start = pinchDown[0][sChartXY],
touch0Now = touches[0][sChartXY],
touch1Start = !singleTouch && pinchDown[1][sChartXY],
touch1Now = !singleTouch && touches[1][sChartXY],
outOfBounds,
transformScale,
scaleKey,
setScale = function() {
// Don't zoom if fingers are too close on this axis
if (!singleTouch && Math.abs(touch0Start - touch1Start) > 20) {
scale = forcedScale || Math.abs(touch0Now - touch1Now) / Math.abs(touch0Start - touch1Start);
}
clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale;
};
// Set the scale, first pass
setScale();
selectionXY = clipXY; // the clip position (x or y) is altered if out of bounds, the selection position is not
// Out of bounds
if (selectionXY < bounds.min) {
selectionXY = bounds.min;
outOfBounds = true;
} else if (selectionXY + selectionWH > bounds.max) {
selectionXY = bounds.max - selectionWH;
outOfBounds = true;
}
// Is the chart dragged off its bounds, determined by dataMin and dataMax?
if (outOfBounds) {
// Modify the touchNow position in order to create an elastic drag movement. This indicates
// to the user that the chart is responsive but can't be dragged further.
touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
if (!singleTouch) {
touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
}
// Set the scale, second pass to adapt to the modified touchNow positions
setScale();
} else {
lastValidTouch[xy] = [touch0Now, touch1Now];
}
// Set geometry for clipping, selection and transformation
if (!inverted) {
clip[xy] = clipXY - plotLeftTop;
clip[wh] = selectionWH;
}
scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
transformScale = inverted ? 1 / scale : scale;
selectionMarker[wh] = selectionWH;
selectionMarker[xy] = selectionXY;
transform[scaleKey] = scale;
transform['translate' + XY] = (transformScale * plotLeftTop) + (touch0Now - (transformScale * touch0Start));
},
/**
* Handle touch events with two touches
*/
pinch: function(e) {
var self = this,
chart = self.chart,
pinchDown = self.pinchDown,
touches = e.touches,
touchesLength = touches.length,
lastValidTouch = self.lastValidTouch,
hasZoom = self.hasZoom,
selectionMarker = self.selectionMarker,
transform = {},
fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, 'highcharts-tracker') &&
chart.runTrackerClick) || self.runChartClick),
clip = {};
// Don't initiate panning until the user has pinched. This prevents us from
// blocking page scrolling as users scroll down a long page (#4210).
if (touchesLength > 1) {
self.initiated = true;
}
// On touch devices, only proceed to trigger click if a handler is defined
if (hasZoom && self.initiated && !fireClickEvent) {
e.preventDefault();
}
// Normalize each touch
map(touches, function(e) {
return self.normalize(e);
});
// Register the touch start position
if (e.type === 'touchstart') {
each(touches, function(e, i) {
pinchDown[i] = {
chartX: e.chartX,
chartY: e.chartY
};
});
lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] && pinchDown[1].chartX];
lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] && pinchDown[1].chartY];
// Identify the data bounds in pixels
each(chart.axes, function(axis) {
if (axis.zoomEnabled) {
var bounds = chart.bounds[axis.horiz ? 'h' : 'v'],
minPixelPadding = axis.minPixelPadding,
min = axis.toPixels(pick(axis.options.min, axis.dataMin)),
max = axis.toPixels(pick(axis.options.max, axis.dataMax)),
absMin = Math.min(min, max),
absMax = Math.max(min, max);
// Store the bounds for use in the touchmove handler
bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
bounds.max = Math.max(axis.pos + axis.len, absMax + minPixelPadding);
}
});
self.res = true; // reset on next move
// Optionally move the tooltip on touchmove
} else if (self.followTouchMove && touchesLength === 1) {
this.runPointActions(self.normalize(e));
// Event type is touchmove, handle panning and pinching
} else if (pinchDown.length) { // can be 0 when releasing, if touchend fires first
// Set the marker
if (!selectionMarker) {
self.selectionMarker = selectionMarker = extend({
destroy: noop,
touch: true
}, chart.plotBox);
}
self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
self.hasPinched = hasZoom;
// Scale and translate the groups to provide visual feedback during pinching
self.scaleGroups(transform, clip);
if (self.res) {
self.res = false;
this.reset(false, 0);
}
}
},
/**
* General touch handler shared by touchstart and touchmove.
*/
touch: function(e, start) {
var chart = this.chart,
hasMoved,
pinchDown,
isInside;
if (chart.index !== H.hoverChartIndex) {
this.onContainerMouseLeave({
relatedTarget: true
});
}
H.hoverChartIndex = chart.index;
if (e.touches.length === 1) {
e = this.normalize(e);
isInside = chart.isInsidePlot(
e.chartX - chart.plotLeft,
e.chartY - chart.plotTop
);
if (isInside && !chart.openMenu) {
// Run mouse events and display tooltip etc
if (start) {
this.runPointActions(e);
}
// Android fires touchmove events after the touchstart even if the
// finger hasn't moved, or moved only a pixel or two. In iOS however,
// the touchmove doesn't fire unless the finger moves more than ~4px.
// So we emulate this behaviour in Android by checking how much it
// moved, and cancelling on small distances. #3450.
if (e.type === 'touchmove') {
pinchDown = this.pinchDown;
hasMoved = pinchDown[0] ? Math.sqrt( // #5266
Math.pow(pinchDown[0].chartX - e.chartX, 2) +
Math.pow(pinchDown[0].chartY - e.chartY, 2)
) >= 4 : false;
}
if (pick(hasMoved, true)) {
this.pinch(e);
}
} else if (start) {
// Hide the tooltip on touching outside the plot area (#1203)
this.reset();
}
} else if (e.touches.length === 2) {
this.pinch(e);
}
},
onContainerTouchStart: function(e) {
this.zoomOption(e);
this.touch(e, true);
},
onContainerTouchMove: function(e) {
this.touch(e);
},
onDocumentTouchEnd: function(e) {
if (charts[H.hoverChartIndex]) {
charts[H.hoverChartIndex].pointer.drop(e);
}
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
charts = H.charts,
css = H.css,
doc = H.doc,
extend = H.extend,
noop = H.noop,
Pointer = H.Pointer,
removeEvent = H.removeEvent,
win = H.win,
wrap = H.wrap;
if (win.PointerEvent || win.MSPointerEvent) {
// The touches object keeps track of the points being touched at all times
var touches = {},
hasPointerEvent = !!win.PointerEvent,
getWebkitTouches = function() {
var key,
fake = [];
fake.item = function(i) {
return this[i];
};
for (key in touches) {
if (touches.hasOwnProperty(key)) {
fake.push({
pageX: touches[key].pageX,
pageY: touches[key].pageY,
target: touches[key].target
});
}
}
return fake;
},
translateMSPointer = function(e, method, wktype, func) {
var p;
if ((e.pointerType === 'touch' || e.pointerType === e.MSPOINTER_TYPE_TOUCH) && charts[H.hoverChartIndex]) {
func(e);
p = charts[H.hoverChartIndex].pointer;
p[method]({
type: wktype,
target: e.currentTarget,
preventDefault: noop,
touches: getWebkitTouches()
});
}
};
/**
* Extend the Pointer prototype with methods for each event handler and more
*/
extend(Pointer.prototype, /** @lends Pointer.prototype */ {
onContainerPointerDown: function(e) {
translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function(e) {
touches[e.pointerId] = {
pageX: e.pageX,
pageY: e.pageY,
target: e.currentTarget
};
});
},
onContainerPointerMove: function(e) {
translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function(e) {
touches[e.pointerId] = {
pageX: e.pageX,
pageY: e.pageY
};
if (!touches[e.pointerId].target) {
touches[e.pointerId].target = e.currentTarget;
}
});
},
onDocumentPointerUp: function(e) {
translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function(e) {
delete touches[e.pointerId];
});
},
/**
* Add or remove the MS Pointer specific events
*/
batchMSEvents: function(fn) {
fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
}
});
// Disable default IE actions for pinch and such on chart element
wrap(Pointer.prototype, 'init', function(proceed, chart, options) {
proceed.call(this, chart, options);
if (this.hasZoom) { // #4014
css(chart.container, {
'-ms-touch-action': 'none',
'touch-action': 'none'
});
}
});
// Add IE specific touch events to chart
wrap(Pointer.prototype, 'setDOMEvents', function(proceed) {
proceed.apply(this);
if (this.hasZoom || this.followTouchMove) {
this.batchMSEvents(addEvent);
}
});
// Destroy MS events also
wrap(Pointer.prototype, 'destroy', function(proceed) {
this.batchMSEvents(removeEvent);
proceed.call(this);
});
}
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Legend,
addEvent = H.addEvent,
css = H.css,
discardElement = H.discardElement,
defined = H.defined,
each = H.each,
isFirefox = H.isFirefox,
marginNames = H.marginNames,
merge = H.merge,
pick = H.pick,
setAnimation = H.setAnimation,
stableSort = H.stableSort,
win = H.win,
wrap = H.wrap;
/**
* The overview of the chart's series.
* @class
*/
Legend = H.Legend = function(chart, options) {
this.init(chart, options);
};
Legend.prototype = {
/**
* Initialize the legend
*/
init: function(chart, options) {
this.chart = chart;
this.setOptions(options);
if (options.enabled) {
// Render it
this.render();
// move checkboxes
addEvent(this.chart, 'endResize', function() {
this.legend.positionCheckboxes();
});
}
},
setOptions: function(options) {
var padding = pick(options.padding, 8);
this.options = options;
this.itemStyle = options.itemStyle;
this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
this.itemMarginTop = options.itemMarginTop || 0;
this.padding = padding;
this.initialItemY = padding - 5; // 5 is pixels above the text
this.maxItemWidth = 0;
this.itemHeight = 0;
this.symbolWidth = pick(options.symbolWidth, 16);
this.pages = [];
},
/**
* Update the legend with new options. Equivalent to running chart.update
* with a legend configuration option.
* @param {Object} options Legend options
* @param {Boolean} redraw Whether to redraw the chart, defaults to true.
*/
update: function(options, redraw) {
var chart = this.chart;
this.setOptions(merge(true, this.options, options));
this.destroy();
chart.isDirtyLegend = chart.isDirtyBox = true;
if (pick(redraw, true)) {
chart.redraw();
}
},
/**
* Set the colors for the legend item
* @param {Object} item A Series or Point instance
* @param {Object} visible Dimmed or colored
*/
colorizeItem: function(item, visible) {
item.legendGroup[visible ? 'removeClass' : 'addClass'](
'highcharts-legend-item-hidden'
);
var legend = this,
options = legend.options,
legendItem = item.legendItem,
legendLine = item.legendLine,
legendSymbol = item.legendSymbol,
hiddenColor = legend.itemHiddenStyle.color,
textColor = visible ? options.itemStyle.color : hiddenColor,
symbolColor = visible ? (item.color || hiddenColor) : hiddenColor,
markerOptions = item.options && item.options.marker,
symbolAttr = {
fill: symbolColor
},
key;
if (legendItem) {
legendItem.css({
fill: textColor,
color: textColor // #1553, oldIE
});
}
if (legendLine) {
legendLine.attr({
stroke: symbolColor
});
}
if (legendSymbol) {
// Apply marker options
if (markerOptions && legendSymbol.isMarker) { // #585
//symbolAttr.stroke = symbolColor;
symbolAttr = item.pointAttribs();
if (!visible) {
for (key in symbolAttr) {
symbolAttr[key] = hiddenColor;
}
}
}
legendSymbol.attr(symbolAttr);
}
},
/**
* Position the legend item
* @param {Object} item A Series or Point instance
*/
positionItem: function(item) {
var legend = this,
options = legend.options,
symbolPadding = options.symbolPadding,
ltr = !options.rtl,
legendItemPos = item._legendItemPos,
itemX = legendItemPos[0],
itemY = legendItemPos[1],
checkbox = item.checkbox,
legendGroup = item.legendGroup;
if (legendGroup && legendGroup.element) {
legendGroup.translate(
ltr ?
itemX :
legend.legendWidth - itemX - 2 * symbolPadding - 4,
itemY
);
}
if (checkbox) {
checkbox.x = itemX;
checkbox.y = itemY;
}
},
/**
* Destroy a single legend item
* @param {Object} item The series or point
*/
destroyItem: function(item) {
var checkbox = item.checkbox;
// destroy SVG elements
each(
['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'],
function(key) {
if (item[key]) {
item[key] = item[key].destroy();
}
}
);
if (checkbox) {
discardElement(item.checkbox);
}
},
/**
* Destroys the legend.
*/
destroy: function() {
function destroyItems(key) {
if (this[key]) {
this[key] = this[key].destroy();
}
}
// Destroy items
each(this.getAllItems(), function(item) {
each(['legendItem', 'legendGroup'], destroyItems, item);
});
// Destroy legend elements
each([
'clipRect',
'up',
'down',
'pager',
'nav',
'box',
'title',
'group'
], destroyItems, this);
this.display = null; // Reset in .render on update.
},
/**
* Position the checkboxes after the width is determined
*/
positionCheckboxes: function(scrollOffset) {
var alignAttr = this.group && this.group.alignAttr,
translateY,
clipHeight = this.clipHeight || this.legendHeight,
titleHeight = this.titleHeight;
if (alignAttr) {
translateY = alignAttr.translateY;
each(this.allItems, function(item) {
var checkbox = item.checkbox,
top;
if (checkbox) {
top = translateY + titleHeight + checkbox.y +
(scrollOffset || 0) + 3;
css(checkbox, {
left: (alignAttr.translateX + item.checkboxOffset +
checkbox.x - 20) + 'px',
top: top + 'px',
display: top > translateY - 6 && top < translateY +
clipHeight - 6 ? '' : 'none'
});
}
});
}
},
/**
* Render the legend title on top of the legend
*/
renderTitle: function() {
var options = this.options,
padding = this.padding,
titleOptions = options.title,
titleHeight = 0,
bBox;
if (titleOptions.text) {
if (!this.title) {
this.title = this.chart.renderer.label(
titleOptions.text,
padding - 3,
padding - 4,
null,
null,
null,
null,
null,
'legend-title'
)
.attr({
zIndex: 1
})
.css(titleOptions.style)
.add(this.group);
}
bBox = this.title.getBBox();
titleHeight = bBox.height;
this.offsetWidth = bBox.width; // #1717
this.contentGroup.attr({
translateY: titleHeight
});
}
this.titleHeight = titleHeight;
},
/**
* Set the legend item text
*/
setText: function(item) {
var options = this.options;
item.legendItem.attr({
text: options.labelFormat ?
H.format(options.labelFormat, item) : options.labelFormatter.call(item)
});
},
/**
* Render a single specific legend item
* @param {Object} item A series or point
*/
renderItem: function(item) {
var legend = this,
chart = legend.chart,
renderer = chart.renderer,
options = legend.options,
horizontal = options.layout === 'horizontal',
symbolWidth = legend.symbolWidth,
symbolPadding = options.symbolPadding,
itemStyle = legend.itemStyle,
itemHiddenStyle = legend.itemHiddenStyle,
padding = legend.padding,
itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
ltr = !options.rtl,
itemHeight,
widthOption = options.width,
itemMarginBottom = options.itemMarginBottom || 0,
itemMarginTop = legend.itemMarginTop,
bBox,
itemWidth,
li = item.legendItem,
isSeries = !item.series,
series = !isSeries && item.series.drawLegendSymbol ?
item.series :
item,
seriesOptions = series.options,
showCheckbox = legend.createCheckboxForItem &&
seriesOptions &&
seriesOptions.showCheckbox,
useHTML = options.useHTML,
fontSize = 12,
itemClassName = item.options.className;
if (!li) { // generate it once, later move it
// Generate the group box, a group to hold the symbol and text. Text
// is to be appended in Legend class.
item.legendGroup = renderer.g('legend-item')
.addClass(
'highcharts-' + series.type + '-series ' +
'highcharts-color-' + item.colorIndex +
(itemClassName ? ' ' + itemClassName : '') +
(isSeries ? ' highcharts-series-' + item.index : '')
)
.attr({
zIndex: 1
})
.add(legend.scrollGroup);
// Generate the list item text and add it to the group
item.legendItem = li = renderer.text(
'',
ltr ? symbolWidth + symbolPadding : -symbolPadding,
legend.baseline || 0,
useHTML
)
// merge to prevent modifying original (#1021)
.css(merge(item.visible ? itemStyle : itemHiddenStyle))
.attr({
align: ltr ? 'left' : 'right',
zIndex: 2
})
.add(item.legendGroup);
// Get the baseline for the first item - the font size is equal for
// all
if (!legend.baseline) {
fontSize = itemStyle.fontSize;
legend.fontMetrics = renderer.fontMetrics(
fontSize,
li
);
legend.baseline = legend.fontMetrics.f + 3 + itemMarginTop;
li.attr('y', legend.baseline);
}
// Draw the legend symbol inside the group box
legend.symbolHeight = options.symbolHeight || legend.fontMetrics.f;
series.drawLegendSymbol(legend, item);
if (legend.setItemEvents) {
legend.setItemEvents(item, li, useHTML);
}
// add the HTML checkbox on top
if (showCheckbox) {
legend.createCheckboxForItem(item);
}
}
// Colorize the items
legend.colorizeItem(item, item.visible);
// Always update the text
legend.setText(item);
// calculate the positions for the next line
bBox = li.getBBox();
itemWidth = item.checkboxOffset =
options.itemWidth ||
item.legendItemWidth ||
symbolWidth + symbolPadding + bBox.width + itemDistance +
(showCheckbox ? 20 : 0);
legend.itemHeight = itemHeight = Math.round(
item.legendItemHeight || bBox.height || legend.symbolHeight
);
// If the item exceeds the width, start a new line
if (
horizontal &&
legend.itemX - padding + itemWidth > (
widthOption || (
chart.spacingBox.width - 2 * padding - options.x
)
)
) {
legend.itemX = padding;
legend.itemY += itemMarginTop + legend.lastLineHeight +
itemMarginBottom;
legend.lastLineHeight = 0; // reset for next line (#915, #3976)
}
// If the item exceeds the height, start a new column
/*if (!horizontal && legend.itemY + options.y +
itemHeight > chart.chartHeight - spacingTop - spacingBottom) {
legend.itemY = legend.initialItemY;
legend.itemX += legend.maxItemWidth;
legend.maxItemWidth = 0;
}*/
// Set the edge positions
legend.maxItemWidth = Math.max(legend.maxItemWidth, itemWidth);
legend.lastItemY = itemMarginTop + legend.itemY + itemMarginBottom;
legend.lastLineHeight = Math.max( // #915
itemHeight,
legend.lastLineHeight
);
// cache the position of the newly generated or reordered items
item._legendItemPos = [legend.itemX, legend.itemY];
// advance
if (horizontal) {
legend.itemX += itemWidth;
} else {
legend.itemY += itemMarginTop + itemHeight + itemMarginBottom;
legend.lastLineHeight = itemHeight;
}
// the width of the widest item
legend.offsetWidth = widthOption || Math.max(
(horizontal ? legend.itemX - padding - itemDistance : itemWidth) +
padding,
legend.offsetWidth
);
},
/**
* Get all items, which is one item per series for normal series and one
* item per point for pie series.
*/
getAllItems: function() {
var allItems = [];
each(this.chart.series, function(series) {
var seriesOptions = series && series.options;
// Handle showInLegend. If the series is linked to another series,
// defaults to false.
if (series && pick(
seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? undefined : false, true
)) {
// Use points or series for the legend item depending on
// legendType
allItems = allItems.concat(
series.legendItems ||
(
seriesOptions.legendType === 'point' ?
series.data :
series
)
);
}
});
return allItems;
},
/**
* Adjust the chart margins by reserving space for the legend on only one
* side of the chart. If the position is set to a corner, top or bottom is
* reserved for horizontal legends and left or right for vertical ones.
*/
adjustMargins: function(margin, spacing) {
var chart = this.chart,
options = this.options,
// Use the first letter of each alignment option in order to detect
// the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
alignment = options.align.charAt(0) +
options.verticalAlign.charAt(0) +
options.layout.charAt(0);
if (!options.floating) {
each([
/(lth|ct|rth)/,
/(rtv|rm|rbv)/,
/(rbh|cb|lbh)/,
/(lbv|lm|ltv)/
], function(alignments, side) {
if (alignments.test(alignment) && !defined(margin[side])) {
// Now we have detected on which side of the chart we should
// reserve space for the legend
chart[marginNames[side]] = Math.max(
chart[marginNames[side]],
(
chart.legend[
(side + 1) % 2 ? 'legendHeight' : 'legendWidth'
] + [1, -1, -1, 1][side] * options[
(side % 2) ? 'x' : 'y'
] +
pick(options.margin, 12) +
spacing[side]
)
);
}
});
}
},
/**
* Render the legend. This method can be called both before and after
* chart.render. If called after, it will only rearrange items instead
* of creating new ones.
*/
render: function() {
var legend = this,
chart = legend.chart,
renderer = chart.renderer,
legendGroup = legend.group,
allItems,
display,
legendWidth,
legendHeight,
box = legend.box,
options = legend.options,
padding = legend.padding;
legend.itemX = padding;
legend.itemY = legend.initialItemY;
legend.offsetWidth = 0;
legend.lastItemY = 0;
if (!legendGroup) {
legend.group = legendGroup = renderer.g('legend')
.attr({
zIndex: 7
})
.add();
legend.contentGroup = renderer.g()
.attr({
zIndex: 1
}) // above background
.add(legendGroup);
legend.scrollGroup = renderer.g()
.add(legend.contentGroup);
}
legend.renderTitle();
// add each series or point
allItems = legend.getAllItems();
// sort by legendIndex
stableSort(allItems, function(a, b) {
return ((a.options && a.options.legendIndex) || 0) -
((b.options && b.options.legendIndex) || 0);
});
// reversed legend
if (options.reversed) {
allItems.reverse();
}
legend.allItems = allItems;
legend.display = display = !!allItems.length;
// render the items
legend.lastLineHeight = 0;
each(allItems, function(item) {
legend.renderItem(item);
});
// Get the box
legendWidth = (options.width || legend.offsetWidth) + padding;
legendHeight = legend.lastItemY + legend.lastLineHeight +
legend.titleHeight;
legendHeight = legend.handleOverflow(legendHeight);
legendHeight += padding;
// Draw the border and/or background
if (!box) {
legend.box = box = renderer.rect()
.addClass('highcharts-legend-box')
.attr({
r: options.borderRadius
})
.add(legendGroup);
box.isNew = true;
}
// Presentational
box
.attr({
stroke: options.borderColor,
'stroke-width': options.borderWidth || 0,
fill: options.backgroundColor || 'none'
})
.shadow(options.shadow);
if (legendWidth > 0 && legendHeight > 0) {
box[box.isNew ? 'attr' : 'animate'](
box.crisp({
x: 0,
y: 0,
width: legendWidth,
height: legendHeight
}, box.strokeWidth())
);
box.isNew = false;
}
// hide the border if no items
box[display ? 'show' : 'hide']();
legend.legendWidth = legendWidth;
legend.legendHeight = legendHeight;
// Now that the legend width and height are established, put the items
// in the final position
each(allItems, function(item) {
legend.positionItem(item);
});
// 1.x compatibility: positioning based on style
/*var props = ['left', 'right', 'top', 'bottom'],
prop,
i = 4;
while (i--) {
prop = props[i];
if (options.style[prop] && options.style[prop] !== 'auto') {
options[i < 2 ? 'align' : 'verticalAlign'] = prop;
options[i < 2 ? 'x' : 'y'] =
pInt(options.style[prop]) * (i % 2 ? -1 : 1);
}
}*/
if (display) {
legendGroup.align(merge(options, {
width: legendWidth,
height: legendHeight
}), true, 'spacingBox');
}
if (!chart.isResizing) {
this.positionCheckboxes();
}
},
/**
* Set up the overflow handling by adding navigation with up and down arrows
* below the legend.
*/
handleOverflow: function(legendHeight) {
var legend = this,
chart = this.chart,
renderer = chart.renderer,
options = this.options,
optionsY = options.y,
alignTop = options.verticalAlign === 'top',
padding = this.padding,
spaceHeight = chart.spacingBox.height +
(alignTop ? -optionsY : optionsY) - padding,
maxHeight = options.maxHeight,
clipHeight,
clipRect = this.clipRect,
navOptions = options.navigation,
animation = pick(navOptions.animation, true),
arrowSize = navOptions.arrowSize || 12,
nav = this.nav,
pages = this.pages,
lastY,
allItems = this.allItems,
clipToHeight = function(height) {
if (height) {
clipRect.attr({
height: height
});
} else if (clipRect) { // Reset (#5912)
legend.clipRect = clipRect.destroy();
legend.contentGroup.clip();
}
// useHTML
if (legend.contentGroup.div) {
legend.contentGroup.div.style.clip = height ?
'rect(' + padding + 'px,9999px,' +
(padding + height) + 'px,0)' :
'auto';
}
};
// Adjust the height
if (
options.layout === 'horizontal' &&
options.verticalAlign !== 'middle' &&
!options.floating
) {
spaceHeight /= 2;
}
if (maxHeight) {
spaceHeight = Math.min(spaceHeight, maxHeight);
}
// Reset the legend height and adjust the clipping rectangle
pages.length = 0;
if (legendHeight > spaceHeight && navOptions.enabled !== false) {
this.clipHeight = clipHeight =
Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
this.currentPage = pick(this.currentPage, 1);
this.fullHeight = legendHeight;
// Fill pages with Y positions so that the top of each a legend item
// defines the scroll top for each page (#2098)
each(allItems, function(item, i) {
var y = item._legendItemPos[1],
h = Math.round(item.legendItem.getBBox().height),
len = pages.length;
if (!len || (y - pages[len - 1] > clipHeight &&
(lastY || y) !== pages[len - 1])) {
pages.push(lastY || y);
len++;
}
if (i === allItems.length - 1 &&
y + h - pages[len - 1] > clipHeight) {
pages.push(y);
}
if (y !== lastY) {
lastY = y;
}
});
// Only apply clipping if needed. Clipping causes blurred legend in
// PDF export (#1787)
if (!clipRect) {
clipRect = legend.clipRect =
renderer.clipRect(0, padding, 9999, 0);
legend.contentGroup.clip(clipRect);
}
clipToHeight(clipHeight);
// Add navigation elements
if (!nav) {
this.nav = nav = renderer.g()
.attr({
zIndex: 1
})
.add(this.group);
this.up = renderer
.symbol(
'triangle',
0,
0,
arrowSize,
arrowSize
)
.on('click', function() {
legend.scroll(-1, animation);
})
.add(nav);
this.pager = renderer.text('', 15, 10)
.addClass('highcharts-legend-navigation')
.css(navOptions.style)
.add(nav);
this.down = renderer
.symbol(
'triangle-down',
0,
0,
arrowSize,
arrowSize
)
.on('click', function() {
legend.scroll(1, animation);
})
.add(nav);
}
// Set initial position
legend.scroll(0);
legendHeight = spaceHeight;
// Reset
} else if (nav) {
clipToHeight();
this.nav = nav.destroy(); // #6322
this.scrollGroup.attr({
translateY: 1
});
this.clipHeight = 0; // #1379
}
return legendHeight;
},
/**
* Scroll the legend by a number of pages
* @param {Object} scrollBy
* @param {Object} animation
*/
scroll: function(scrollBy, animation) {
var pages = this.pages,
pageCount = pages.length,
currentPage = this.currentPage + scrollBy,
clipHeight = this.clipHeight,
navOptions = this.options.navigation,
pager = this.pager,
padding = this.padding,
scrollOffset;
// When resizing while looking at the last page
if (currentPage > pageCount) {
currentPage = pageCount;
}
if (currentPage > 0) {
if (animation !== undefined) {
setAnimation(animation, this.chart);
}
this.nav.attr({
translateX: padding,
translateY: clipHeight + this.padding + 7 + this.titleHeight,
visibility: 'visible'
});
this.up.attr({
'class': currentPage === 1 ?
'highcharts-legend-nav-inactive' : 'highcharts-legend-nav-active'
});
pager.attr({
text: currentPage + '/' + pageCount
});
this.down.attr({
'x': 18 + this.pager.getBBox().width, // adjust to text width
'class': currentPage === pageCount ?
'highcharts-legend-nav-inactive' : 'highcharts-legend-nav-active'
});
this.up
.attr({
fill: currentPage === 1 ?
navOptions.inactiveColor : navOptions.activeColor
})
.css({
cursor: currentPage === 1 ? 'default' : 'pointer'
});
this.down
.attr({
fill: currentPage === pageCount ?
navOptions.inactiveColor : navOptions.activeColor
})
.css({
cursor: currentPage === pageCount ? 'default' : 'pointer'
});
scrollOffset = -pages[currentPage - 1] + this.initialItemY;
this.scrollGroup.animate({
translateY: scrollOffset
});
this.currentPage = currentPage;
this.positionCheckboxes(scrollOffset);
}
}
};
/*
* LegendSymbolMixin
*/
H.LegendSymbolMixin = {
/**
* Get the series' symbol in the legend
*
* @param {Object} legend The legend object
* @param {Object} item The series (this) or point
*/
drawRectangle: function(legend, item) {
var options = legend.options,
symbolHeight = legend.symbolHeight,
square = options.squareSymbol,
symbolWidth = square ? symbolHeight : legend.symbolWidth;
item.legendSymbol = this.chart.renderer.rect(
square ? (legend.symbolWidth - symbolHeight) / 2 : 0,
legend.baseline - symbolHeight + 1, // #3988
symbolWidth,
symbolHeight,
pick(legend.options.symbolRadius, symbolHeight / 2)
)
.addClass('highcharts-point')
.attr({
zIndex: 3
}).add(item.legendGroup);
},
/**
* Get the series' symbol in the legend. This method should be overridable
* to create custom symbols through
* Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
*
* @param {Object} legend The legend object
*/
drawLineMarker: function(legend) {
var options = this.options,
markerOptions = options.marker,
radius,
legendSymbol,
symbolWidth = legend.symbolWidth,
symbolHeight = legend.symbolHeight,
generalRadius = symbolHeight / 2,
renderer = this.chart.renderer,
legendItemGroup = this.legendGroup,
verticalCenter = legend.baseline -
Math.round(legend.fontMetrics.b * 0.3),
attr = {};
// Draw the line
attr = {
'stroke-width': options.lineWidth || 0
};
if (options.dashStyle) {
attr.dashstyle = options.dashStyle;
}
this.legendLine = renderer.path([
'M',
0,
verticalCenter,
'L',
symbolWidth,
verticalCenter
])
.addClass('highcharts-graph')
.attr(attr)
.add(legendItemGroup);
// Draw the marker
if (markerOptions && markerOptions.enabled !== false) {
// Do not allow the marker to be larger than the symbolHeight
radius = Math.min(
pick(markerOptions.radius, generalRadius),
generalRadius
);
// Restrict symbol markers size
if (this.symbol.indexOf('url') === 0) {
markerOptions = merge(markerOptions, {
width: symbolHeight,
height: symbolHeight
});
radius = 0;
}
this.legendSymbol = legendSymbol = renderer.symbol(
this.symbol,
(symbolWidth / 2) - radius,
verticalCenter - radius,
2 * radius,
2 * radius,
markerOptions
)
.addClass('highcharts-point')
.add(legendItemGroup);
legendSymbol.isMarker = true;
}
}
};
// Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
// and for #2580, a similar drawing flaw in Firefox 26.
// Explore if there's a general cause for this. The problem may be related
// to nested group elements, as the legend item texts are within 4 group
// elements.
if (/Trident\/7\.0/.test(win.navigator.userAgent) || isFirefox) {
wrap(Legend.prototype, 'positionItem', function(proceed, item) {
var legend = this,
// If chart destroyed in sync, this is undefined (#2030)
runPositionItem = function() {
if (item._legendItemPos) {
proceed.call(legend, item);
}
};
// Do it now, for export and to get checkbox placement
runPositionItem();
// Do it after to work around the core issue
setTimeout(runPositionItem);
});
}
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animate = H.animate,
animObject = H.animObject,
attr = H.attr,
doc = H.doc,
Axis = H.Axis, // @todo add as requirement
createElement = H.createElement,
defaultOptions = H.defaultOptions,
discardElement = H.discardElement,
charts = H.charts,
css = H.css,
defined = H.defined,
each = H.each,
extend = H.extend,
find = H.find,
fireEvent = H.fireEvent,
getStyle = H.getStyle,
grep = H.grep,
isNumber = H.isNumber,
isObject = H.isObject,
isString = H.isString,
Legend = H.Legend, // @todo add as requirement
marginNames = H.marginNames,
merge = H.merge,
Pointer = H.Pointer, // @todo add as requirement
pick = H.pick,
pInt = H.pInt,
removeEvent = H.removeEvent,
seriesTypes = H.seriesTypes,
splat = H.splat,
svg = H.svg,
syncTimeout = H.syncTimeout,
win = H.win,
Renderer = H.Renderer;
/**
* The Chart class.
* @class Highcharts.Chart
* @memberOf Highcharts
* @param {String|HTMLDOMElement} renderTo - The DOM element to render to, or its
* id.
* @param {ChartOptions} options - The chart options structure.
* @param {Function} callback - Function to run when the chart has loaded.
*/
var Chart = H.Chart = function() {
this.getArgs.apply(this, arguments);
};
H.chart = function(a, b, c) {
return new Chart(a, b, c);
};
Chart.prototype = {
/**
* Hook for modules
*/
callbacks: [],
/**
* Handle the arguments passed to the constructor
* @returns {Array} Arguments without renderTo
*/
getArgs: function() {
var args = [].slice.call(arguments);
// Remove the optional first argument, renderTo, and
// set it on this.
if (isString(args[0]) || args[0].nodeName) {
this.renderTo = args.shift();
}
this.init(args[0], args[1]);
},
/**
* Initialize the chart
*/
init: function(userOptions, callback) {
// Handle regular options
var options,
seriesOptions = userOptions.series; // skip merging data points to increase performance
userOptions.series = null;
options = merge(defaultOptions, userOptions); // do the merge
options.series = userOptions.series = seriesOptions; // set back the series data
this.userOptions = userOptions;
var optionsChart = options.chart;
var chartEvents = optionsChart.events;
this.margin = [];
this.spacing = [];
//this.runChartClick = chartEvents && !!chartEvents.click;
this.bounds = {
h: {},
v: {}
}; // Pixel data bounds for touch zoom
this.callback = callback;
this.isResizing = 0;
this.options = options;
//chartTitleOptions = undefined;
//chartSubtitleOptions = undefined;
this.axes = [];
this.series = [];
this.hasCartesianSeries = optionsChart.showAxes;
//this.axisOffset = undefined;
//this.inverted = undefined;
//this.loadingShown = undefined;
//this.container = undefined;
//this.chartWidth = undefined;
//this.chartHeight = undefined;
//this.marginRight = undefined;
//this.marginBottom = undefined;
//this.containerWidth = undefined;
//this.containerHeight = undefined;
//this.oldChartWidth = undefined;
//this.oldChartHeight = undefined;
//this.renderTo = undefined;
//this.renderToClone = undefined;
//this.spacingBox = undefined
//this.legend = undefined;
// Elements
//this.chartBackground = undefined;
//this.plotBackground = undefined;
//this.plotBGImage = undefined;
//this.plotBorder = undefined;
//this.loadingDiv = undefined;
//this.loadingSpan = undefined;
var chart = this,
eventType;
// Add the chart to the global lookup
chart.index = charts.length;
charts.push(chart);
H.chartCount++;
// Chart event handlers
if (chartEvents) {
for (eventType in chartEvents) {
addEvent(chart, eventType, chartEvents[eventType]);
}
}
chart.xAxis = [];
chart.yAxis = [];
chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;
chart.firstRender();
},
/**
* Initialize an individual series, called internally before render time
*/
initSeries: function(options) {
var chart = this,
optionsChart = chart.options.chart,
type = options.type || optionsChart.type || optionsChart.defaultSeriesType,
series,
Constr = seriesTypes[type];
// No such series type
if (!Constr) {
H.error(17, true);
}
series = new Constr();
series.init(this, options);
return series;
},
/**
* Order all series above a given index. When series are added and ordered
* by configuration, only the last series is handled (#248, #1123, #2456,
* #6112). This function is called on series initialization and destroy.
*
* @param {number} fromIndex - If this is given, only the series above this
* index are handled.
*/
orderSeries: function(fromIndex) {
var series = this.series,
i = fromIndex || 0;
for (; i < series.length; i++) {
if (series[i]) {
series[i].index = i;
series[i].name = series[i].name ||
'Series ' + (series[i].index + 1);
}
}
},
/**
* Check whether a given point is within the plot area
*
* @param {Number} plotX Pixel x relative to the plot area
* @param {Number} plotY Pixel y relative to the plot area
* @param {Boolean} inverted Whether the chart is inverted
*/
isInsidePlot: function(plotX, plotY, inverted) {
var x = inverted ? plotY : plotX,
y = inverted ? plotX : plotY;
return x >= 0 &&
x <= this.plotWidth &&
y >= 0 &&
y <= this.plotHeight;
},
/**
* Redraw legend, axes or series based on updated data
*
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
redraw: function(animation) {
var chart = this,
axes = chart.axes,
series = chart.series,
pointer = chart.pointer,
legend = chart.legend,
redrawLegend = chart.isDirtyLegend,
hasStackedSeries,
hasDirtyStacks,
hasCartesianSeries = chart.hasCartesianSeries,
isDirtyBox = chart.isDirtyBox,
i,
serie,
renderer = chart.renderer,
isHiddenChart = renderer.isHidden(),
afterRedraw = [];
// Handle responsive rules, not only on resize (#6130)
if (chart.setResponsive) {
chart.setResponsive(false);
}
H.setAnimation(animation, chart);
if (isHiddenChart) {
chart.cloneRenderTo();
}
// Adjust title layout (reflow multiline text)
chart.layOutTitles();
// link stacked series
i = series.length;
while (i--) {
serie = series[i];
if (serie.options.stacking) {
hasStackedSeries = true;
if (serie.isDirty) {
hasDirtyStacks = true;
break;
}
}
}
if (hasDirtyStacks) { // mark others as dirty
i = series.length;
while (i--) {
serie = series[i];
if (serie.options.stacking) {
serie.isDirty = true;
}
}
}
// Handle updated data in the series
each(series, function(serie) {
if (serie.isDirty) {
if (serie.options.legendType === 'point') {
if (serie.updateTotals) {
serie.updateTotals();
}
redrawLegend = true;
}
}
if (serie.isDirtyData) {
fireEvent(serie, 'updatedData');
}
});
// handle added or removed series
if (redrawLegend && legend.options.enabled) { // series or pie points are added or removed
// draw legend graphics
legend.render();
chart.isDirtyLegend = false;
}
// reset stacks
if (hasStackedSeries) {
chart.getStacks();
}
if (hasCartesianSeries) {
// set axes scales
each(axes, function(axis) {
axis.updateNames();
axis.setScale();
});
}
chart.getMargins(); // #3098
if (hasCartesianSeries) {
// If one axis is dirty, all axes must be redrawn (#792, #2169)
each(axes, function(axis) {
if (axis.isDirty) {
isDirtyBox = true;
}
});
// redraw axes
each(axes, function(axis) {
// Fire 'afterSetExtremes' only if extremes are set
var key = axis.min + ',' + axis.max;
if (axis.extKey !== key) { // #821, #4452
axis.extKey = key;
afterRedraw.push(function() { // prevent a recursive call to chart.redraw() (#1119)
fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
delete axis.eventArgs;
});
}
if (isDirtyBox || hasStackedSeries) {
axis.redraw();
}
});
}
// the plot areas size has changed
if (isDirtyBox) {
chart.drawChartBox();
}
// Fire an event before redrawing series, used by the boost module to
// clear previous series renderings.
fireEvent(chart, 'predraw');
// redraw affected series
each(series, function(serie) {
if ((isDirtyBox || serie.isDirty) && serie.visible) {
serie.redraw();
}
// Set it here, otherwise we will have unlimited 'updatedData' calls
// for a hidden series after setData(). Fixes #6012
serie.isDirtyData = false;
});
// move tooltip or reset
if (pointer) {
pointer.reset(true);
}
// redraw if canvas
renderer.draw();
// Fire the events
fireEvent(chart, 'redraw');
fireEvent(chart, 'render');
if (isHiddenChart) {
chart.cloneRenderTo(true);
}
// Fire callbacks that are put on hold until after the redraw
each(afterRedraw, function(callback) {
callback.call();
});
},
/**
* Get an axis, series or point object by id.
* @param id {String} The id as given in the configuration options
*/
get: function(id) {
var ret,
series = this.series,
i;
function itemById(item) {
return item.id === id || (item.options && item.options.id === id);
}
ret =
// Search axes
find(this.axes, itemById) ||
// Search series
find(this.series, itemById);
// Search points
for (i = 0; !ret && i < series.length; i++) {
ret = find(series[i].points || [], itemById);
}
return ret;
},
/**
* Create the Axis instances based on the config options
*/
getAxes: function() {
var chart = this,
options = this.options,
xAxisOptions = options.xAxis = splat(options.xAxis || {}),
yAxisOptions = options.yAxis = splat(options.yAxis || {}),
optionsArray;
// make sure the options are arrays and add some members
each(xAxisOptions, function(axis, i) {
axis.index = i;
axis.isX = true;
});
each(yAxisOptions, function(axis, i) {
axis.index = i;
});
// concatenate all axis options into one array
optionsArray = xAxisOptions.concat(yAxisOptions);
each(optionsArray, function(axisOptions) {
new Axis(chart, axisOptions); // eslint-disable-line no-new
});
},
/**
* Get the currently selected points from all series
*/
getSelectedPoints: function() {
var points = [];
each(this.series, function(serie) {
points = points.concat(grep(serie.points || [], function(point) {
return point.selected;
}));
});
return points;
},
/**
* Get the currently selected series
*/
getSelectedSeries: function() {
return grep(this.series, function(serie) {
return serie.selected;
});
},
/**
* Show the title and subtitle of the chart
*
* @param titleOptions {Object} New title options
* @param subtitleOptions {Object} New subtitle options
*
*/
setTitle: function(titleOptions, subtitleOptions, redraw) {
var chart = this,
options = chart.options,
chartTitleOptions,
chartSubtitleOptions;
chartTitleOptions = options.title = merge(
// Default styles
{
style: {
color: '#333333',
fontSize: options.isStock ? '16px' : '18px' // #2944
}
},
options.title,
titleOptions
);
chartSubtitleOptions = options.subtitle = merge(
// Default styles
{
style: {
color: '#666666'
}
},
options.subtitle,
subtitleOptions
);
// add title and subtitle
each([
['title', titleOptions, chartTitleOptions],
['subtitle', subtitleOptions, chartSubtitleOptions]
], function(arr, i) {
var name = arr[0],
title = chart[name],
titleOptions = arr[1],
chartTitleOptions = arr[2];
if (title && titleOptions) {
chart[name] = title = title.destroy(); // remove old
}
if (chartTitleOptions && chartTitleOptions.text && !title) {
chart[name] = chart.renderer.text(
chartTitleOptions.text,
0,
0,
chartTitleOptions.useHTML
)
.attr({
align: chartTitleOptions.align,
'class': 'highcharts-' + name,
zIndex: chartTitleOptions.zIndex || 4
})
.add();
// Update methods, shortcut to Chart.setTitle
chart[name].update = function(o) {
chart.setTitle(!i && o, i && o);
};
// Presentational
chart[name].css(chartTitleOptions.style);
}
});
chart.layOutTitles(redraw);
},
/**
* Lay out the chart titles and cache the full offset height for use
* in getMargins
*/
layOutTitles: function(redraw) {
var titleOffset = 0,
requiresDirtyBox,
renderer = this.renderer,
spacingBox = this.spacingBox;
// Lay out the title and the subtitle respectively
each(['title', 'subtitle'], function(key) {
var title = this[key],
titleOptions = this.options[key],
titleSize;
if (title) {
titleSize = titleOptions.style.fontSize;
titleSize = renderer.fontMetrics(titleSize, title).b;
title
.css({
width: (titleOptions.width ||
spacingBox.width + titleOptions.widthAdjust) + 'px'
})
.align(extend({
y: titleOffset + titleSize + (key === 'title' ? -3 : 2)
}, titleOptions), false, 'spacingBox');
if (!titleOptions.floating && !titleOptions.verticalAlign) {
titleOffset = Math.ceil(
titleOffset +
// Skip the cache for HTML (#3481)
title.getBBox(titleOptions.useHTML).height
);
}
}
}, this);
requiresDirtyBox = this.titleOffset !== titleOffset;
this.titleOffset = titleOffset; // used in getMargins
if (!this.isDirtyBox && requiresDirtyBox) {
this.isDirtyBox = requiresDirtyBox;
// Redraw if necessary (#2719, #2744)
if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
this.redraw();
}
}
},
/**
* Get chart width and height according to options and container size
*/
getChartSize: function() {
var chart = this,
optionsChart = chart.options.chart,
widthOption = optionsChart.width,
heightOption = optionsChart.height,
renderTo = chart.renderToClone || chart.renderTo;
// Get inner width and height
if (!defined(widthOption)) {
chart.containerWidth = getStyle(renderTo, 'width');
}
if (!defined(heightOption)) {
chart.containerHeight = getStyle(renderTo, 'height');
}
chart.chartWidth = Math.max( // #1393
0,
widthOption || chart.containerWidth || 600 // #1460
);
chart.chartHeight = Math.max(
0,
H.relativeLength(
heightOption,
chart.chartWidth
) || chart.containerHeight || 400
);
},
/**
* Create a clone of the chart's renderTo div and place it outside the viewport to allow
* size computation on chart.render and chart.redraw
*/
cloneRenderTo: function(revert) {
var clone = this.renderToClone,
container = this.container;
// Destroy the clone and bring the container back to the real renderTo div
if (revert) {
if (clone) {
while (clone.childNodes.length) { // #5231
this.renderTo.appendChild(clone.firstChild);
}
discardElement(clone);
delete this.renderToClone;
}
// Set up the clone
} else {
if (container && container.parentNode === this.renderTo) {
this.renderTo.removeChild(container); // do not clone this
}
this.renderToClone = clone = this.renderTo.cloneNode(0);
css(clone, {
position: 'absolute',
top: '-9999px',
display: 'block' // #833
});
if (clone.style.setProperty) { // #2631
clone.style.setProperty('display', 'block', 'important');
}
doc.body.appendChild(clone);
if (container) {
clone.appendChild(container);
}
}
},
/**
* Setter for the chart class name
*/
setClassName: function(className) {
this.container.className = 'highcharts-container ' + (className || '');
},
/**
* Get the containing element, determine the size and create the inner container
* div to hold the chart
*/
getContainer: function() {
var chart = this,
container,
options = chart.options,
optionsChart = options.chart,
chartWidth,
chartHeight,
renderTo = chart.renderTo,
indexAttrName = 'data-highcharts-chart',
oldChartIndex,
Ren,
containerId = H.uniqueKey(),
containerStyle,
key;
if (!renderTo) {
chart.renderTo = renderTo = optionsChart.renderTo;
}
if (isString(renderTo)) {
chart.renderTo = renderTo = doc.getElementById(renderTo);
}
// Display an error if the renderTo is wrong
if (!renderTo) {
H.error(13, true);
}
// If the container already holds a chart, destroy it. The check for hasRendered is there
// because web pages that are saved to disk from the browser, will preserve the data-highcharts-chart
// attribute and the SVG contents, but not an interactive chart. So in this case,
// charts[oldChartIndex] will point to the wrong chart if any (#2609).
oldChartIndex = pInt(attr(renderTo, indexAttrName));
if (isNumber(oldChartIndex) && charts[oldChartIndex] && charts[oldChartIndex].hasRendered) {
charts[oldChartIndex].destroy();
}
// Make a reference to the chart from the div
attr(renderTo, indexAttrName, chart.index);
// remove previous chart
renderTo.innerHTML = '';
// If the container doesn't have an offsetWidth, it has or is a child of
// a node that has display:none. We need to temporarily move it out to a
// visible state to determine the size, else the legend and tooltips
// won't render properly. The skipClone option is used in sparklines as
// a micro optimization, saving about 1-2 ms each chart.
if (!optionsChart.skipClone && !renderTo.offsetWidth) {
chart.cloneRenderTo();
}
// get the width and height
chart.getChartSize();
chartWidth = chart.chartWidth;
chartHeight = chart.chartHeight;
// Create the inner container
containerStyle = extend({
position: 'relative',
overflow: 'hidden', // needed for context menu (avoid scrollbars) and
// content overflow in IE
width: chartWidth + 'px',
height: chartHeight + 'px',
textAlign: 'left',
lineHeight: 'normal', // #427
zIndex: 0, // #1072
'-webkit-tap-highlight-color': 'rgba(0,0,0,0)'
}, optionsChart.style);
chart.container = container = createElement(
'div', {
id: containerId
},
containerStyle,
chart.renderToClone || renderTo
);
// cache the cursor (#1650)
chart._cursor = container.style.cursor;
// Initialize the renderer
Ren = H[optionsChart.renderer] || Renderer;
chart.renderer = new Ren(
container,
chartWidth,
chartHeight,
null,
optionsChart.forExport,
options.exporting && options.exporting.allowHTML
);
chart.setClassName(optionsChart.className);
chart.renderer.setStyle(optionsChart.style);
// Add a reference to the charts index
chart.renderer.chartIndex = chart.index;
},
/**
* Calculate margins by rendering axis labels in a preliminary position. Title,
* subtitle and legend have already been rendered at this stage, but will be
* moved into their final positions
*/
getMargins: function(skipAxes) {
var chart = this,
spacing = chart.spacing,
margin = chart.margin,
titleOffset = chart.titleOffset;
chart.resetMargins();
// Adjust for title and subtitle
if (titleOffset && !defined(margin[0])) {
chart.plotTop = Math.max(chart.plotTop, titleOffset + chart.options.title.margin + spacing[0]);
}
// Adjust for legend
if (chart.legend.display) {
chart.legend.adjustMargins(margin, spacing);
}
// adjust for scroller
if (chart.extraMargin) {
chart[chart.extraMargin.type] = (chart[chart.extraMargin.type] || 0) + chart.extraMargin.value;
}
if (chart.extraTopMargin) {
chart.plotTop += chart.extraTopMargin;
}
if (!skipAxes) {
this.getAxisMargins();
}
},
getAxisMargins: function() {
var chart = this,
axisOffset = chart.axisOffset = [0, 0, 0, 0], // top, right, bottom, left
margin = chart.margin;
// pre-render axes to get labels offset width
if (chart.hasCartesianSeries) {
each(chart.axes, function(axis) {
if (axis.visible) {
axis.getOffset();
}
});
}
// Add the axis offsets
each(marginNames, function(m, side) {
if (!defined(margin[side])) {
chart[m] += axisOffset[side];
}
});
chart.setChartSize();
},
/**
* Resize the chart to its container if size is not explicitly set
*/
reflow: function(e) {
var chart = this,
optionsChart = chart.options.chart,
renderTo = chart.renderTo,
hasUserWidth = defined(optionsChart.width),
width = optionsChart.width || getStyle(renderTo, 'width'),
height = optionsChart.height || getStyle(renderTo, 'height'),
target = e ? e.target : win;
// Width and height checks for display:none. Target is doc in IE8 and Opera,
// win in Firefox, Chrome and IE9.
if (!hasUserWidth && !chart.isPrinting && width && height && (target === win || target === doc)) { // #1093
if (width !== chart.containerWidth || height !== chart.containerHeight) {
clearTimeout(chart.reflowTimeout);
// When called from window.resize, e is set, else it's called directly (#2224)
chart.reflowTimeout = syncTimeout(function() {
if (chart.container) { // It may have been destroyed in the meantime (#1257)
chart.setSize(undefined, undefined, false);
}
}, e ? 100 : 0);
}
chart.containerWidth = width;
chart.containerHeight = height;
}
},
/**
* Add the event handlers necessary for auto resizing
*/
initReflow: function() {
var chart = this,
unbind;
unbind = addEvent(win, 'resize', function(e) {
chart.reflow(e);
});
addEvent(chart, 'destroy', unbind);
// The following will add listeners to re-fit the chart before and after
// printing (#2284). However it only works in WebKit. Should have worked
// in Firefox, but not supported in IE.
/*
if (win.matchMedia) {
win.matchMedia('print').addListener(function reflow() {
chart.reflow();
});
}
*/
},
/**
* Resize the chart to a given width and height
* @param {Number} width
* @param {Number} height
* @param {Object|Boolean} animation
*/
setSize: function(width, height, animation) {
var chart = this,
renderer = chart.renderer,
globalAnimation;
// Handle the isResizing counter
chart.isResizing += 1;
// set the animation for the current process
H.setAnimation(animation, chart);
chart.oldChartHeight = chart.chartHeight;
chart.oldChartWidth = chart.chartWidth;
if (width !== undefined) {
chart.options.chart.width = width;
}
if (height !== undefined) {
chart.options.chart.height = height;
}
chart.getChartSize();
// Resize the container with the global animation applied if enabled (#2503)
globalAnimation = renderer.globalAnimation;
(globalAnimation ? animate : css)(chart.container, {
width: chart.chartWidth + 'px',
height: chart.chartHeight + 'px'
}, globalAnimation);
chart.setChartSize(true);
renderer.setSize(chart.chartWidth, chart.chartHeight, animation);
// handle axes
each(chart.axes, function(axis) {
axis.isDirty = true;
axis.setScale();
});
chart.isDirtyLegend = true; // force legend redraw
chart.isDirtyBox = true; // force redraw of plot and chart border
chart.layOutTitles(); // #2857
chart.getMargins();
chart.redraw(animation);
chart.oldChartHeight = null;
fireEvent(chart, 'resize');
// Fire endResize and set isResizing back. If animation is disabled, fire without delay
syncTimeout(function() {
if (chart) {
fireEvent(chart, 'endResize', null, function() {
chart.isResizing -= 1;
});
}
}, animObject(globalAnimation).duration);
},
/**
* Set the public chart properties. This is done before and after the pre-render
* to determine margin sizes
*/
setChartSize: function(skipAxes) {
var chart = this,
inverted = chart.inverted,
renderer = chart.renderer,
chartWidth = chart.chartWidth,
chartHeight = chart.chartHeight,
optionsChart = chart.options.chart,
spacing = chart.spacing,
clipOffset = chart.clipOffset,
clipX,
clipY,
plotLeft,
plotTop,
plotWidth,
plotHeight,
plotBorderWidth;
chart.plotLeft = plotLeft = Math.round(chart.plotLeft);
chart.plotTop = plotTop = Math.round(chart.plotTop);
chart.plotWidth = plotWidth = Math.max(0, Math.round(chartWidth - plotLeft - chart.marginRight));
chart.plotHeight = plotHeight = Math.max(0, Math.round(chartHeight - plotTop - chart.marginBottom));
chart.plotSizeX = inverted ? plotHeight : plotWidth;
chart.plotSizeY = inverted ? plotWidth : plotHeight;
chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;
// Set boxes used for alignment
chart.spacingBox = renderer.spacingBox = {
x: spacing[3],
y: spacing[0],
width: chartWidth - spacing[3] - spacing[1],
height: chartHeight - spacing[0] - spacing[2]
};
chart.plotBox = renderer.plotBox = {
x: plotLeft,
y: plotTop,
width: plotWidth,
height: plotHeight
};
plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2);
clipX = Math.ceil(Math.max(plotBorderWidth, clipOffset[3]) / 2);
clipY = Math.ceil(Math.max(plotBorderWidth, clipOffset[0]) / 2);
chart.clipBox = {
x: clipX,
y: clipY,
width: Math.floor(chart.plotSizeX - Math.max(plotBorderWidth, clipOffset[1]) / 2 - clipX),
height: Math.max(0, Math.floor(chart.plotSizeY - Math.max(plotBorderWidth, clipOffset[2]) / 2 - clipY))
};
if (!skipAxes) {
each(chart.axes, function(axis) {
axis.setAxisSize();
axis.setAxisTranslation();
});
}
},
/**
* Initial margins before auto size margins are applied
*/
resetMargins: function() {
var chart = this,
chartOptions = chart.options.chart;
// Create margin and spacing array
each(['margin', 'spacing'], function splashArrays(target) {
var value = chartOptions[target],
values = isObject(value) ? value : [value, value, value, value];
each(['Top', 'Right', 'Bottom', 'Left'], function(sideName, side) {
chart[target][side] = pick(chartOptions[target + sideName], values[side]);
});
});
// Set margin names like chart.plotTop, chart.plotLeft, chart.marginRight, chart.marginBottom.
each(marginNames, function(m, side) {
chart[m] = pick(chart.margin[side], chart.spacing[side]);
});
chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
chart.clipOffset = [0, 0, 0, 0];
},
/**
* Draw the borders and backgrounds for chart and plot area
*/
drawChartBox: function() {
var chart = this,
optionsChart = chart.options.chart,
renderer = chart.renderer,
chartWidth = chart.chartWidth,
chartHeight = chart.chartHeight,
chartBackground = chart.chartBackground,
plotBackground = chart.plotBackground,
plotBorder = chart.plotBorder,
chartBorderWidth,
plotBGImage = chart.plotBGImage,
chartBackgroundColor = optionsChart.backgroundColor,
plotBackgroundColor = optionsChart.plotBackgroundColor,
plotBackgroundImage = optionsChart.plotBackgroundImage,
mgn,
bgAttr,
plotLeft = chart.plotLeft,
plotTop = chart.plotTop,
plotWidth = chart.plotWidth,
plotHeight = chart.plotHeight,
plotBox = chart.plotBox,
clipRect = chart.clipRect,
clipBox = chart.clipBox,
verb = 'animate';
// Chart area
if (!chartBackground) {
chart.chartBackground = chartBackground = renderer.rect()
.addClass('highcharts-background')
.add();
verb = 'attr';
}
// Presentational
chartBorderWidth = optionsChart.borderWidth || 0;
mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
bgAttr = {
fill: chartBackgroundColor || 'none'
};
if (chartBorderWidth || chartBackground['stroke-width']) { // #980
bgAttr.stroke = optionsChart.borderColor;
bgAttr['stroke-width'] = chartBorderWidth;
}
chartBackground
.attr(bgAttr)
.shadow(optionsChart.shadow);
chartBackground[verb]({
x: mgn / 2,
y: mgn / 2,
width: chartWidth - mgn - chartBorderWidth % 2,
height: chartHeight - mgn - chartBorderWidth % 2,
r: optionsChart.borderRadius
});
// Plot background
verb = 'animate';
if (!plotBackground) {
verb = 'attr';
chart.plotBackground = plotBackground = renderer.rect()
.addClass('highcharts-plot-background')
.add();
}
plotBackground[verb](plotBox);
// Presentational attributes for the background
plotBackground
.attr({
fill: plotBackgroundColor || 'none'
})
.shadow(optionsChart.plotShadow);
// Create the background image
if (plotBackgroundImage) {
if (!plotBGImage) {
chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight)
.add();
} else {
plotBGImage.animate(plotBox);
}
}
// Plot clip
if (!clipRect) {
chart.clipRect = renderer.clipRect(clipBox);
} else {
clipRect.animate({
width: clipBox.width,
height: clipBox.height
});
}
// Plot area border
verb = 'animate';
if (!plotBorder) {
verb = 'attr';
chart.plotBorder = plotBorder = renderer.rect()
.addClass('highcharts-plot-border')
.attr({
zIndex: 1 // Above the grid
})
.add();
}
// Presentational
plotBorder.attr({
stroke: optionsChart.plotBorderColor,
'stroke-width': optionsChart.plotBorderWidth || 0,
fill: 'none'
});
plotBorder[verb](plotBorder.crisp({
x: plotLeft,
y: plotTop,
width: plotWidth,
height: plotHeight
}, -plotBorder.strokeWidth())); //#3282 plotBorder should be negative;
// reset
chart.isDirtyBox = false;
},
/**
* Detect whether a certain chart property is needed based on inspecting its options
* and series. This mainly applies to the chart.inverted property, and in extensions to
* the chart.angular and chart.polar properties.
*/
propFromSeries: function() {
var chart = this,
optionsChart = chart.options.chart,
klass,
seriesOptions = chart.options.series,
i,
value;
each(['inverted', 'angular', 'polar'], function(key) {
// The default series type's class
klass = seriesTypes[optionsChart.type || optionsChart.defaultSeriesType];
// Get the value from available chart-wide properties
value =
optionsChart[key] || // It is set in the options
(klass && klass.prototype[key]); // The default series class requires it
// 4. Check if any the chart's series require it
i = seriesOptions && seriesOptions.length;
while (!value && i--) {
klass = seriesTypes[seriesOptions[i].type];
if (klass && klass.prototype[key]) {
value = true;
}
}
// Set the chart property
chart[key] = value;
});
},
/**
* Link two or more series together. This is done initially from Chart.render,
* and after Chart.addSeries and Series.remove.
*/
linkSeries: function() {
var chart = this,
chartSeries = chart.series;
// Reset links
each(chartSeries, function(series) {
series.linkedSeries.length = 0;
});
// Apply new links
each(chartSeries, function(series) {
var linkedTo = series.options.linkedTo;
if (isString(linkedTo)) {
if (linkedTo === ':previous') {
linkedTo = chart.series[series.index - 1];
} else {
linkedTo = chart.get(linkedTo);
}
if (linkedTo && linkedTo.linkedParent !== series) { // #3341 avoid mutual linking
linkedTo.linkedSeries.push(series);
series.linkedParent = linkedTo;
series.visible = pick(series.options.visible, linkedTo.options.visible, series.visible); // #3879
}
}
});
},
/**
* Render series for the chart
*/
renderSeries: function() {
each(this.series, function(serie) {
serie.translate();
serie.render();
});
},
/**
* Render labels for the chart
*/
renderLabels: function() {
var chart = this,
labels = chart.options.labels;
if (labels.items) {
each(labels.items, function(label) {
var style = extend(labels.style, label.style),
x = pInt(style.left) + chart.plotLeft,
y = pInt(style.top) + chart.plotTop + 12;
// delete to prevent rewriting in IE
delete style.left;
delete style.top;
chart.renderer.text(
label.html,
x,
y
)
.attr({
zIndex: 2
})
.css(style)
.add();
});
}
},
/**
* Render all graphics for the chart
*/
render: function() {
var chart = this,
axes = chart.axes,
renderer = chart.renderer,
options = chart.options,
tempWidth,
tempHeight,
redoHorizontal,
redoVertical;
// Title
chart.setTitle();
// Legend
chart.legend = new Legend(chart, options.legend);
// Get stacks
if (chart.getStacks) {
chart.getStacks();
}
// Get chart margins
chart.getMargins(true);
chart.setChartSize();
// Record preliminary dimensions for later comparison
tempWidth = chart.plotWidth;
tempHeight = chart.plotHeight = chart.plotHeight - 21; // 21 is the most common correction for X axis labels
// Get margins by pre-rendering axes
each(axes, function(axis) {
axis.setScale();
});
chart.getAxisMargins();
// If the plot area size has changed significantly, calculate tick positions again
redoHorizontal = tempWidth / chart.plotWidth > 1.1;
redoVertical = tempHeight / chart.plotHeight > 1.05; // Height is more sensitive
if (redoHorizontal || redoVertical) {
each(axes, function(axis) {
if ((axis.horiz && redoHorizontal) || (!axis.horiz && redoVertical)) {
axis.setTickInterval(true); // update to reflect the new margins
}
});
chart.getMargins(); // second pass to check for new labels
}
// Draw the borders and backgrounds
chart.drawChartBox();
// Axes
if (chart.hasCartesianSeries) {
each(axes, function(axis) {
if (axis.visible) {
axis.render();
}
});
}
// The series
if (!chart.seriesGroup) {
chart.seriesGroup = renderer.g('series-group')
.attr({
zIndex: 3
})
.add();
}
chart.renderSeries();
// Labels
chart.renderLabels();
// Credits
chart.addCredits();
// Handle responsiveness
if (chart.setResponsive) {
chart.setResponsive();
}
// Set flag
chart.hasRendered = true;
},
/**
* Show chart credits based on config options
*/
addCredits: function(credits) {
var chart = this;
credits = merge(true, this.options.credits, credits);
if (credits.enabled && !this.credits) {
this.credits = this.renderer.text(
credits.text + (this.mapCredits || ''),
0,
0
)
.addClass('highcharts-credits')
.on('click', function() {
if (credits.href) {
win.location.href = credits.href;
}
})
.attr({
align: credits.position.align,
zIndex: 8
})
.css(credits.style)
.add()
.align(credits.position);
// Dynamically update
this.credits.update = function(options) {
chart.credits = chart.credits.destroy();
chart.addCredits(options);
};
}
},
/**
* Clean up memory usage
*/
destroy: function() {
var chart = this,
axes = chart.axes,
series = chart.series,
container = chart.container,
i,
parentNode = container && container.parentNode;
// fire the chart.destoy event
fireEvent(chart, 'destroy');
// Delete the chart from charts lookup array
charts[chart.index] = undefined;
H.chartCount--;
chart.renderTo.removeAttribute('data-highcharts-chart');
// remove events
removeEvent(chart);
// ==== Destroy collections:
// Destroy axes
i = axes.length;
while (i--) {
axes[i] = axes[i].destroy();
}
// Destroy scroller & scroller series before destroying base series
if (this.scroller && this.scroller.destroy) {
this.scroller.destroy();
}
// Destroy each series
i = series.length;
while (i--) {
series[i] = series[i].destroy();
}
// ==== Destroy chart properties:
each([
'title', 'subtitle', 'chartBackground', 'plotBackground',
'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
'renderer'
], function(name) {
var prop = chart[name];
if (prop && prop.destroy) {
chart[name] = prop.destroy();
}
});
// remove container and all SVG
if (container) { // can break in IE when destroyed before finished loading
container.innerHTML = '';
removeEvent(container);
if (parentNode) {
discardElement(container);
}
}
// clean it all up
for (i in chart) {
delete chart[i];
}
},
/**
* VML namespaces can't be added until after complete. Listening
* for Perini's doScroll hack is not enough.
*/
isReadyToRender: function() {
var chart = this;
// Note: win == win.top is required
if ((!svg && (win == win.top && doc.readyState !== 'complete'))) { // eslint-disable-line eqeqeq
doc.attachEvent('onreadystatechange', function() {
doc.detachEvent('onreadystatechange', chart.firstRender);
if (doc.readyState === 'complete') {
chart.firstRender();
}
});
return false;
}
return true;
},
/**
* Prepare for first rendering after all data are loaded
*/
firstRender: function() {
var chart = this,
options = chart.options;
// Check whether the chart is ready to render
if (!chart.isReadyToRender()) {
return;
}
// Create the container
chart.getContainer();
// Run an early event after the container and renderer are established
fireEvent(chart, 'init');
chart.resetMargins();
chart.setChartSize();
// Set the common chart properties (mainly invert) from the given series
chart.propFromSeries();
// get axes
chart.getAxes();
// Initialize the series
each(options.series || [], function(serieOptions) {
chart.initSeries(serieOptions);
});
chart.linkSeries();
// Run an event after axes and series are initialized, but before render. At this stage,
// the series data is indexed and cached in the xData and yData arrays, so we can access
// those before rendering. Used in Highstock.
fireEvent(chart, 'beforeRender');
// depends on inverted and on margins being set
if (Pointer) {
chart.pointer = new Pointer(chart, options);
}
chart.render();
// Fire the load event if there are no external images
if (!chart.renderer.imgCount && chart.onload) {
chart.onload();
}
// If the chart was rendered outside the top container, put it back in (#3679)
chart.cloneRenderTo(true);
},
/**
* On chart load
*/
onload: function() {
// Run callbacks
each([this.callback].concat(this.callbacks), function(fn) {
if (fn && this.index !== undefined) { // Chart destroyed in its own callback (#3600)
fn.apply(this, [this]);
}
}, this);
fireEvent(this, 'load');
fireEvent(this, 'render');
// Set up auto resize, check for not destroyed (#6068)
if (defined(this.index) && this.options.chart.reflow !== false) {
this.initReflow();
}
// Don't run again
this.onload = null;
}
}; // end Chart
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Point,
each = H.each,
extend = H.extend,
erase = H.erase,
fireEvent = H.fireEvent,
format = H.format,
isArray = H.isArray,
isNumber = H.isNumber,
pick = H.pick,
removeEvent = H.removeEvent;
/**
* The Point object. The point objects are generated from the series.data
* configuration objects or raw numbers. They can be accessed from the
* Series.points array.
* @constructor Point
*/
Point = H.Point = function() {};
Point.prototype = {
/**
* Initialize the point. Called internally based on the series.data option.
* @function #init
* @memberOf Point
* @param {Object} series The series object containing this point.
* @param {Object} options The data in either number, array or object
* format.
* @param {Number} x Optionally, the X value of the.
* @returns {Object} The Point instance.
*/
init: function(series, options, x) {
var point = this,
colors,
colorCount = series.chart.options.chart.colorCount,
colorIndex;
point.series = series;
point.color = series.color; // #3445
point.applyOptions(options, x);
if (series.options.colorByPoint) {
colors = series.options.colors || series.chart.options.colors;
point.color = point.color || colors[series.colorCounter];
colorCount = colors.length;
colorIndex = series.colorCounter;
series.colorCounter++;
// loop back to zero
if (series.colorCounter === colorCount) {
series.colorCounter = 0;
}
} else {
colorIndex = series.colorIndex;
}
point.colorIndex = pick(point.colorIndex, colorIndex);
series.chart.pointCount++;
return point;
},
/**
* Apply the options containing the x and y data and possible some extra
* properties. Called on point init or from point.update.
*
* @function #applyOptions
* @memberOf Point
* @param {Object} options The point options as defined in series.data.
* @param {Number} x Optionally, the X value.
* @returns {Object} The Point instance.
*/
applyOptions: function(options, x) {
var point = this,
series = point.series,
pointValKey = series.options.pointValKey || series.pointValKey;
options = Point.prototype.optionsToObject.call(this, options);
// copy options directly to point
extend(point, options);
point.options = point.options ? extend(point.options, options) : options;
// Since options are copied into the Point instance, some accidental options must be shielded (#5681)
if (options.group) {
delete point.group;
}
// For higher dimension series types. For instance, for ranges, point.y is mapped to point.low.
if (pointValKey) {
point.y = point[pointValKey];
}
point.isNull = pick(
point.isValid && !point.isValid(),
point.x === null || !isNumber(point.y, true)
); // #3571, check for NaN
// The point is initially selected by options (#5777)
if (point.selected) {
point.state = 'select';
}
// If no x is set by now, get auto incremented value. All points must have an
// x value, however the y value can be null to create a gap in the series
if ('name' in point && x === undefined && series.xAxis && series.xAxis.hasNames) {
point.x = series.xAxis.nameToX(point);
}
if (point.x === undefined && series) {
if (x === undefined) {
point.x = series.autoIncrement(point);
} else {
point.x = x;
}
}
return point;
},
/**
* Transform number or array configs into objects
*/
optionsToObject: function(options) {
var ret = {},
series = this.series,
keys = series.options.keys,
pointArrayMap = keys || series.pointArrayMap || ['y'],
valueCount = pointArrayMap.length,
firstItemType,
i = 0,
j = 0;
if (isNumber(options) || options === null) {
ret[pointArrayMap[0]] = options;
} else if (isArray(options)) {
// with leading x value
if (!keys && options.length > valueCount) {
firstItemType = typeof options[0];
if (firstItemType === 'string') {
ret.name = options[0];
} else if (firstItemType === 'number') {
ret.x = options[0];
}
i++;
}
while (j < valueCount) {
if (!keys || options[i] !== undefined) { // Skip undefined positions for keys
ret[pointArrayMap[j]] = options[i];
}
i++;
j++;
}
} else if (typeof options === 'object') {
ret = options;
// This is the fastest way to detect if there are individual point dataLabels that need
// to be considered in drawDataLabels. These can only occur in object configs.
if (options.dataLabels) {
series._hasPointLabels = true;
}
// Same approach as above for markers
if (options.marker) {
series._hasPointMarkers = true;
}
}
return ret;
},
/**
* Get the CSS class names for individual points
* @returns {String} The class name
*/
getClassName: function() {
return 'highcharts-point' +
(this.selected ? ' highcharts-point-select' : '') +
(this.negative ? ' highcharts-negative' : '') +
(this.isNull ? ' highcharts-null-point' : '') +
(this.colorIndex !== undefined ? ' highcharts-color-' +
this.colorIndex : '') +
(this.options.className ? ' ' + this.options.className : '') +
(this.zone && this.zone.className ? ' ' +
this.zone.className.replace('highcharts-negative', '') : '');
},
/**
* Return the zone that the point belongs to
*/
getZone: function() {
var series = this.series,
zones = series.zones,
zoneAxis = series.zoneAxis || 'y',
i = 0,
zone;
zone = zones[i];
while (this[zoneAxis] >= zone.value) {
zone = zones[++i];
}
if (zone && zone.color && !this.options.color) {
this.color = zone.color;
}
return zone;
},
/**
* Destroy a point to clear memory. Its reference still stays in series.data.
*/
destroy: function() {
var point = this,
series = point.series,
chart = series.chart,
hoverPoints = chart.hoverPoints,
prop;
chart.pointCount--;
if (hoverPoints) {
point.setState();
erase(hoverPoints, point);
if (!hoverPoints.length) {
chart.hoverPoints = null;
}
}
if (point === chart.hoverPoint) {
point.onMouseOut();
}
// remove all events
if (point.graphic || point.dataLabel) { // removeEvent and destroyElements are performance expensive
removeEvent(point);
point.destroyElements();
}
if (point.legendItem) { // pies have legend items
chart.legend.destroyItem(point);
}
for (prop in point) {
point[prop] = null;
}
},
/**
* Destroy SVG elements associated with the point
*/
destroyElements: function() {
var point = this,
props = ['graphic', 'dataLabel', 'dataLabelUpper', 'connector', 'shadowGroup'],
prop,
i = 6;
while (i--) {
prop = props[i];
if (point[prop]) {
point[prop] = point[prop].destroy();
}
}
},
/**
* Return the configuration hash needed for the data label and tooltip formatters
*/
getLabelConfig: function() {
return {
x: this.category,
y: this.y,
color: this.color,
colorIndex: this.colorIndex,
key: this.name || this.category,
series: this.series,
point: this,
percentage: this.percentage,
total: this.total || this.stackTotal
};
},
/**
* Extendable method for formatting each point's tooltip line
*
* @return {String} A string to be concatenated in to the common tooltip text
*/
tooltipFormatter: function(pointFormat) {
// Insert options for valueDecimals, valuePrefix, and valueSuffix
var series = this.series,
seriesTooltipOptions = series.tooltipOptions,
valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''),
valuePrefix = seriesTooltipOptions.valuePrefix || '',
valueSuffix = seriesTooltipOptions.valueSuffix || '';
// Loop over the point array map and replace unformatted values with sprintf formatting markup
each(series.pointArrayMap || ['y'], function(key) {
key = '{point.' + key; // without the closing bracket
if (valuePrefix || valueSuffix) {
pointFormat = pointFormat.replace(key + '}', valuePrefix + key + '}' + valueSuffix);
}
pointFormat = pointFormat.replace(key + '}', key + ':,.' + valueDecimals + 'f}');
});
return format(pointFormat, {
point: this,
series: this.series
});
},
/**
* Fire an event on the Point object.
* @param {String} eventType
* @param {Object} eventArgs Additional event arguments
* @param {Function} defaultFunction Default event handler
*/
firePointEvent: function(eventType, eventArgs, defaultFunction) {
var point = this,
series = this.series,
seriesOptions = series.options;
// load event handlers on demand to save time on mouseover/out
if (seriesOptions.point.events[eventType] || (point.options && point.options.events && point.options.events[eventType])) {
this.importEvents();
}
// add default handler if in selection mode
if (eventType === 'click' && seriesOptions.allowPointSelect) {
defaultFunction = function(event) {
// Control key is for Windows, meta (= Cmd key) for Mac, Shift for Opera
if (point.select) { // Could be destroyed by prior event handlers (#2911)
point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
}
};
}
fireEvent(this, eventType, eventArgs, defaultFunction);
},
visible: true
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animObject = H.animObject,
arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
correctFloat = H.correctFloat,
Date = H.Date,
defaultOptions = H.defaultOptions,
defaultPlotOptions = H.defaultPlotOptions,
defined = H.defined,
each = H.each,
erase = H.erase,
extend = H.extend,
fireEvent = H.fireEvent,
grep = H.grep,
isArray = H.isArray,
isNumber = H.isNumber,
isString = H.isString,
LegendSymbolMixin = H.LegendSymbolMixin, // @todo add as a requirement
merge = H.merge,
pick = H.pick,
Point = H.Point, // @todo add as a requirement
removeEvent = H.removeEvent,
splat = H.splat,
SVGElement = H.SVGElement,
syncTimeout = H.syncTimeout,
win = H.win;
/**
* The base function which all other series types inherit from. The data in the series is stored
* in various arrays.
*
* - First, series.options.data contains all the original config options for
* each point whether added by options or methods like series.addPoint.
* - Next, series.data contains those values converted to points, but in case the series data length
* exceeds the cropThreshold, or if the data is grouped, series.data doesn't contain all the points. It
* only contains the points that have been created on demand.
* - Then there's series.points that contains all currently visible point objects. In case of cropping,
* the cropped-away points are not part of this array. The series.points array starts at series.cropStart
* compared to series.data and series.options.data. If however the series data is grouped, these can't
* be correlated one to one.
* - series.xData and series.processedXData contain clean x values, equivalent to series.data and series.points.
* - series.yData and series.processedYData contain clean y values, equivalent to series.data and series.points.
*
* @constructor Series
* @param {Object} chart - The chart instance.
* @param {Object} options - The series options.
*/
H.Series = H.seriesType('line', null, { // base series options
//cursor: 'default',
//dashStyle: null,
//linecap: 'round',
lineWidth: 2,
//shadow: false,
allowPointSelect: false,
showCheckbox: false,
animation: {
duration: 1000
},
//clip: true,
//connectNulls: false,
//enableMouseTracking: true,
events: {},
//legendIndex: 0,
// stacking: null,
marker: {
lineWidth: 0,
lineColor: '#ffffff',
//fillColor: null,
//enabled: true,
//symbol: null,
radius: 4,
states: { // states for a single point
hover: {
animation: {
duration: 50
},
enabled: true,
radiusPlus: 2,
lineWidthPlus: 1
},
select: {
fillColor: '#cccccc',
lineColor: '#000000',
lineWidth: 2
}
}
},
point: {
events: {}
},
dataLabels: {
align: 'center',
// defer: true,
// enabled: false,
formatter: function() {
return this.y === null ? '' : H.numberFormat(this.y, -1);
},
style: {
fontSize: '11px',
fontWeight: 'bold',
color: 'contrast',
textOutline: '1px contrast'
},
// backgroundColor: undefined,
// borderColor: undefined,
// borderWidth: undefined,
// shadow: false
verticalAlign: 'bottom', // above singular point
x: 0,
y: 0,
// borderRadius: undefined,
padding: 5
},
cropThreshold: 300, // draw points outside the plot area when the number of points is less than this
pointRange: 0,
//pointStart: 0,
//pointInterval: 1,
//showInLegend: null, // auto: true for standalone series, false for linked series
softThreshold: true,
states: { // states for the entire series
hover: {
//enabled: false,
animation: {
duration: 50
},
lineWidthPlus: 1,
marker: {
// lineWidth: base + 1,
// radius: base + 1
},
halo: {
size: 10,
opacity: 0.25
}
},
select: {
marker: {}
}
},
stickyTracking: true,
//tooltip: {
//pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b>'
//valueDecimals: null,
//xDateFormat: '%A, %b %e, %Y',
//valuePrefix: '',
//ySuffix: ''
//}
turboThreshold: 1000,
// zIndex: null
findNearestPointBy: 'x'
}, /** @lends Series.prototype */ {
isCartesian: true,
pointClass: Point,
sorted: true, // requires the data to be sorted
requireSorting: true,
directTouch: false,
axisTypes: ['xAxis', 'yAxis'],
colorCounter: 0,
parallelArrays: ['x', 'y'], // each point's x and y values are stored in this.xData and this.yData
coll: 'series',
init: function(chart, options) {
var series = this,
eventType,
events,
chartSeries = chart.series,
lastSeries;
series.chart = chart;
series.options = options = series.setOptions(options); // merge with plotOptions
series.linkedSeries = [];
// bind the axes
series.bindAxes();
// set some variables
extend(series, {
name: options.name,
state: '',
visible: options.visible !== false, // true by default
selected: options.selected === true // false by default
});
// register event listeners
events = options.events;
for (eventType in events) {
addEvent(series, eventType, events[eventType]);
}
if (
(events && events.click) ||
(options.point && options.point.events && options.point.events.click) ||
options.allowPointSelect
) {
chart.runTrackerClick = true;
}
series.getColor();
series.getSymbol();
// Set the data
each(series.parallelArrays, function(key) {
series[key + 'Data'] = [];
});
series.setData(options.data, false);
// Mark cartesian
if (series.isCartesian) {
chart.hasCartesianSeries = true;
}
// Get the index and register the series in the chart. The index is one
// more than the current latest series index (#5960).
if (chartSeries.length) {
lastSeries = chartSeries[chartSeries.length - 1];
}
series._i = pick(lastSeries && lastSeries._i, -1) + 1;
// Insert the series and re-order all series above the insertion point.
chart.orderSeries(this.insert(chartSeries));
},
/**
* Insert the series in a collection with other series, either the chart
* series or yAxis series, in the correct order according to the index
* option.
* @param {Array} collection A collection of series.
* @returns {Number} The index of the series in the collection.
*/
insert: function(collection) {
var indexOption = this.options.index,
i;
// Insert by index option
if (isNumber(indexOption)) {
i = collection.length;
while (i--) {
// Loop down until the interted element has higher index
if (indexOption >=
pick(collection[i].options.index, collection[i]._i)) {
collection.splice(i + 1, 0, this);
break;
}
}
if (i === -1) {
collection.unshift(this);
}
i = i + 1;
// Or just push it to the end
} else {
collection.push(this);
}
return pick(i, collection.length - 1);
},
/**
* Set the xAxis and yAxis properties of cartesian series, and register the
* series in the `axis.series` array.
*
* @function #bindAxes
* @memberOf Series
* @returns {void}
*/
bindAxes: function() {
var series = this,
seriesOptions = series.options,
chart = series.chart,
axisOptions;
each(series.axisTypes || [], function(AXIS) { // repeat for xAxis and yAxis
each(chart[AXIS], function(axis) { // loop through the chart's axis objects
axisOptions = axis.options;
// apply if the series xAxis or yAxis option mathches the number of the
// axis, or if undefined, use the first axis
if ((seriesOptions[AXIS] === axisOptions.index) ||
(seriesOptions[AXIS] !== undefined && seriesOptions[AXIS] === axisOptions.id) ||
(seriesOptions[AXIS] === undefined && axisOptions.index === 0)) {
// register this series in the axis.series lookup
series.insert(axis.series);
// set this series.xAxis or series.yAxis reference
series[AXIS] = axis;
// mark dirty for redraw
axis.isDirty = true;
}
});
// The series needs an X and an Y axis
if (!series[AXIS] && series.optionalAxis !== AXIS) {
H.error(18, true);
}
});
},
/**
* For simple series types like line and column, the data values are held in arrays like
* xData and yData for quick lookup to find extremes and more. For multidimensional series
* like bubble and map, this can be extended with arrays like zData and valueData by
* adding to the series.parallelArrays array.
*/
updateParallelArrays: function(point, i) {
var series = point.series,
args = arguments,
fn = isNumber(i) ?
// Insert the value in the given position
function(key) {
var val = key === 'y' && series.toYData ? series.toYData(point) : point[key];
series[key + 'Data'][i] = val;
} :
// Apply the method specified in i with the following arguments as arguments
function(key) {
Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
};
each(series.parallelArrays, fn);
},
/**
* Return an auto incremented x value based on the pointStart and pointInterval options.
* This is only used if an x value is not given for the point that calls autoIncrement.
*/
autoIncrement: function() {
var options = this.options,
xIncrement = this.xIncrement,
date,
pointInterval,
pointIntervalUnit = options.pointIntervalUnit;
xIncrement = pick(xIncrement, options.pointStart, 0);
this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
// Added code for pointInterval strings
if (pointIntervalUnit) {
date = new Date(xIncrement);
if (pointIntervalUnit === 'day') {
date = +date[Date.hcSetDate](date[Date.hcGetDate]() + pointInterval);
} else if (pointIntervalUnit === 'month') {
date = +date[Date.hcSetMonth](date[Date.hcGetMonth]() + pointInterval);
} else if (pointIntervalUnit === 'year') {
date = +date[Date.hcSetFullYear](date[Date.hcGetFullYear]() + pointInterval);
}
pointInterval = date - xIncrement;
}
this.xIncrement = xIncrement + pointInterval;
return xIncrement;
},
/**
* Set the series options by merging from the options tree
* @param {Object} itemOptions
*/
setOptions: function(itemOptions) {
var chart = this.chart,
chartOptions = chart.options,
plotOptions = chartOptions.plotOptions,
userOptions = chart.userOptions || {},
userPlotOptions = userOptions.plotOptions || {},
typeOptions = plotOptions[this.type],
options,
zones;
this.userOptions = itemOptions;
// General series options take precedence over type options because otherwise, default
// type options like column.animation would be overwritten by the general option.
// But issues have been raised here (#3881), and the solution may be to distinguish
// between default option and userOptions like in the tooltip below.
options = merge(
typeOptions,
plotOptions.series,
itemOptions
);
// The tooltip options are merged between global and series specific options
this.tooltipOptions = merge(
defaultOptions.tooltip,
defaultOptions.plotOptions[this.type].tooltip,
userOptions.tooltip,
userPlotOptions.series && userPlotOptions.series.tooltip,
userPlotOptions[this.type] && userPlotOptions[this.type].tooltip,
itemOptions.tooltip
);
// When shared tooltip, stickyTracking is true by default,
// unless user says otherwise.
this.stickyTracking = pick(
itemOptions.stickyTracking,
userPlotOptions[this.type] && userPlotOptions[this.type].stickyTracking,
userPlotOptions.series && userPlotOptions.series.stickyTracking,
(
this.tooltipOptions.shared && !this.noSharedTooltip ?
true :
options.stickyTracking
)
);
// Delete marker object if not allowed (#1125)
if (typeOptions.marker === null) {
delete options.marker;
}
// Handle color zones
this.zoneAxis = options.zoneAxis;
zones = this.zones = (options.zones || []).slice();
if ((options.negativeColor || options.negativeFillColor) && !options.zones) {
zones.push({
value: options[this.zoneAxis + 'Threshold'] || options.threshold || 0,
className: 'highcharts-negative',
color: options.negativeColor,
fillColor: options.negativeFillColor
});
}
if (zones.length) { // Push one extra zone for the rest
if (defined(zones[zones.length - 1].value)) {
zones.push({
color: this.color,
fillColor: this.fillColor
});
}
}
return options;
},
getCyclic: function(prop, value, defaults) {
var i,
chart = this.chart,
userOptions = this.userOptions,
indexName = prop + 'Index',
counterName = prop + 'Counter',
len = defaults ? defaults.length : pick(
chart.options.chart[prop + 'Count'],
chart[prop + 'Count']
),
setting;
if (!value) {
// Pick up either the colorIndex option, or the _colorIndex after Series.update()
setting = pick(userOptions[indexName], userOptions['_' + indexName]);
if (defined(setting)) { // after Series.update()
i = setting;
} else {
// #6138
if (!chart.series.length) {
chart[counterName] = 0;
}
userOptions['_' + indexName] = i = chart[counterName] % len;
chart[counterName] += 1;
}
if (defaults) {
value = defaults[i];
}
}
// Set the colorIndex
if (i !== undefined) {
this[indexName] = i;
}
this[prop] = value;
},
/**
* Get the series' color
*/
getColor: function() {
if (this.options.colorByPoint) {
this.options.color = null; // #4359, selected slice got series.color even when colorByPoint was set.
} else {
this.getCyclic('color', this.options.color || defaultPlotOptions[this.type].color, this.chart.options.colors);
}
},
/**
* Get the series' symbol
*/
getSymbol: function() {
var seriesMarkerOption = this.options.marker;
this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
},
drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
/**
* Replace the series data with a new set of data
* @param {Object} data
* @param {Object} redraw
*/
setData: function(data, redraw, animation, updatePoints) {
var series = this,
oldData = series.points,
oldDataLength = (oldData && oldData.length) || 0,
dataLength,
options = series.options,
chart = series.chart,
firstPoint = null,
xAxis = series.xAxis,
i,
turboThreshold = options.turboThreshold,
pt,
xData = this.xData,
yData = this.yData,
pointArrayMap = series.pointArrayMap,
valueCount = pointArrayMap && pointArrayMap.length;
data = data || [];
dataLength = data.length;
redraw = pick(redraw, true);
// If the point count is the same as is was, just run Point.update which is
// cheaper, allows animation, and keeps references to points.
if (updatePoints !== false && dataLength && oldDataLength === dataLength && !series.cropped && !series.hasGroupedData && series.visible) {
each(data, function(point, i) {
// .update doesn't exist on a linked, hidden series (#3709)
if (oldData[i].update && point !== options.data[i]) {
oldData[i].update(point, false, null, false);
}
});
} else {
// Reset properties
series.xIncrement = null;
series.colorCounter = 0; // for series with colorByPoint (#1547)
// Update parallel arrays
each(this.parallelArrays, function(key) {
series[key + 'Data'].length = 0;
});
// In turbo mode, only one- or twodimensional arrays of numbers are allowed. The
// first value is tested, and we assume that all the rest are defined the same
// way. Although the 'for' loops are similar, they are repeated inside each
// if-else conditional for max performance.
if (turboThreshold && dataLength > turboThreshold) {
// find the first non-null point
i = 0;
while (firstPoint === null && i < dataLength) {
firstPoint = data[i];
i++;
}
if (isNumber(firstPoint)) { // assume all points are numbers
for (i = 0; i < dataLength; i++) {
xData[i] = this.autoIncrement();
yData[i] = data[i];
}
} else if (isArray(firstPoint)) { // assume all points are arrays
if (valueCount) { // [x, low, high] or [x, o, h, l, c]
for (i = 0; i < dataLength; i++) {
pt = data[i];
xData[i] = pt[0];
yData[i] = pt.slice(1, valueCount + 1);
}
} else { // [x, y]
for (i = 0; i < dataLength; i++) {
pt = data[i];
xData[i] = pt[0];
yData[i] = pt[1];
}
}
} else {
H.error(12); // Highcharts expects configs to be numbers or arrays in turbo mode
}
} else {
for (i = 0; i < dataLength; i++) {
if (data[i] !== undefined) { // stray commas in oldIE
pt = {
series: series
};
series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
series.updateParallelArrays(pt, i);
}
}
}
// Forgetting to cast strings to numbers is a common caveat when handling CSV or JSON
if (isString(yData[0])) {
H.error(14, true);
}
series.data = [];
series.options.data = series.userOptions.data = data;
// destroy old points
i = oldDataLength;
while (i--) {
if (oldData[i] && oldData[i].destroy) {
oldData[i].destroy();
}
}
// reset minRange (#878)
if (xAxis) {
xAxis.minRange = xAxis.userMinRange;
}
// redraw
series.isDirty = chart.isDirtyBox = true;
series.isDirtyData = !!oldData;
animation = false;
}
// Typically for pie series, points need to be processed and generated
// prior to rendering the legend
if (options.legendType === 'point') {
this.processData();
this.generatePoints();
}
if (redraw) {
chart.redraw(animation);
}
},
/**
* Process the data by cropping away unused data points if the series is longer
* than the crop threshold. This saves computing time for large series.
*/
processData: function(force) {
var series = this,
processedXData = series.xData, // copied during slice operation below
processedYData = series.yData,
dataLength = processedXData.length,
croppedData,
cropStart = 0,
cropped,
distance,
closestPointRange,
xAxis = series.xAxis,
i, // loop variable
options = series.options,
cropThreshold = options.cropThreshold,
getExtremesFromAll = series.getExtremesFromAll || options.getExtremesFromAll, // #4599
isCartesian = series.isCartesian,
xExtremes,
val2lin = xAxis && xAxis.val2lin,
isLog = xAxis && xAxis.isLog,
min,
max;
// If the series data or axes haven't changed, don't go through this. Return false to pass
// the message on to override methods like in data grouping.
if (isCartesian && !series.isDirty && !xAxis.isDirty && !series.yAxis.isDirty && !force) {
return false;
}
if (xAxis) {
xExtremes = xAxis.getExtremes(); // corrected for log axis (#3053)
min = xExtremes.min;
max = xExtremes.max;
}
// optionally filter out points outside the plot area
if (isCartesian && series.sorted && !getExtremesFromAll && (!cropThreshold || dataLength > cropThreshold || series.forceCrop)) {
// it's outside current extremes
if (processedXData[dataLength - 1] < min || processedXData[0] > max) {
processedXData = [];
processedYData = [];
// only crop if it's actually spilling out
} else if (processedXData[0] < min || processedXData[dataLength - 1] > max) {
croppedData = this.cropData(series.xData, series.yData, min, max);
processedXData = croppedData.xData;
processedYData = croppedData.yData;
cropStart = croppedData.start;
cropped = true;
}
}
// Find the closest distance between processed points
i = processedXData.length || 1;
while (--i) {
distance = isLog ?
val2lin(processedXData[i]) - val2lin(processedXData[i - 1]) :
processedXData[i] - processedXData[i - 1];
if (distance > 0 && (closestPointRange === undefined || distance < closestPointRange)) {
closestPointRange = distance;
// Unsorted data is not supported by the line tooltip, as well as data grouping and
// navigation in Stock charts (#725) and width calculation of columns (#1900)
} else if (distance < 0 && series.requireSorting) {
H.error(15);
}
}
// Record the properties
series.cropped = cropped; // undefined or true
series.cropStart = cropStart;
series.processedXData = processedXData;
series.processedYData = processedYData;
series.closestPointRange = closestPointRange;
},
/**
* Iterate over xData and crop values between min and max. Returns object containing crop start/end
* cropped xData with corresponding part of yData, dataMin and dataMax within the cropped range
*/
cropData: function(xData, yData, min, max) {
var dataLength = xData.length,
cropStart = 0,
cropEnd = dataLength,
cropShoulder = pick(this.cropShoulder, 1), // line-type series need one point outside
i,
j;
// iterate up to find slice start
for (i = 0; i < dataLength; i++) {
if (xData[i] >= min) {
cropStart = Math.max(0, i - cropShoulder);
break;
}
}
// proceed to find slice end
for (j = i; j < dataLength; j++) {
if (xData[j] > max) {
cropEnd = j + cropShoulder;
break;
}
}
return {
xData: xData.slice(cropStart, cropEnd),
yData: yData.slice(cropStart, cropEnd),
start: cropStart,
end: cropEnd
};
},
/**
* Generate the data point after the data has been processed by cropping away
* unused points and optionally grouped in Highcharts Stock.
*/
generatePoints: function() {
var series = this,
options = series.options,
dataOptions = options.data,
data = series.data,
dataLength,
processedXData = series.processedXData,
processedYData = series.processedYData,
PointClass = series.pointClass,
processedDataLength = processedXData.length,
cropStart = series.cropStart || 0,
cursor,
hasGroupedData = series.hasGroupedData,
point,
points = [],
i;
if (!data && !hasGroupedData) {
var arr = [];
arr.length = dataOptions.length;
data = series.data = arr;
}
for (i = 0; i < processedDataLength; i++) {
cursor = cropStart + i;
if (!hasGroupedData) {
point = data[cursor];
if (!point && dataOptions[cursor] !== undefined) { // #970
data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
}
} else {
// splat the y data in case of ohlc data array
point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
point.dataGroup = series.groupMap[i];
}
if (point) { // #6279
point.index = cursor; // For faster access in Point.update
points[i] = point;
}
}
// Hide cropped-away points - this only runs when the number of points is above cropThreshold, or when
// swithching view from non-grouped data to grouped data (#637)
if (data && (processedDataLength !== (dataLength = data.length) || hasGroupedData)) {
for (i = 0; i < dataLength; i++) {
if (i === cropStart && !hasGroupedData) { // when has grouped data, clear all points
i += processedDataLength;
}
if (data[i]) {
data[i].destroyElements();
data[i].plotX = undefined; // #1003
}
}
}
series.data = data;
series.points = points;
},
/**
* Calculate Y extremes for visible data
*/
getExtremes: function(yData) {
var xAxis = this.xAxis,
yAxis = this.yAxis,
xData = this.processedXData,
yDataLength,
activeYData = [],
activeCounter = 0,
xExtremes = xAxis.getExtremes(), // #2117, need to compensate for log X axis
xMin = xExtremes.min,
xMax = xExtremes.max,
validValue,
withinRange,
x,
y,
i,
j;
yData = yData || this.stackedYData || this.processedYData || [];
yDataLength = yData.length;
for (i = 0; i < yDataLength; i++) {
x = xData[i];
y = yData[i];
// For points within the visible range, including the first point outside the
// visible range, consider y extremes
validValue = (isNumber(y, true) || isArray(y)) && (!yAxis.positiveValuesOnly || (y.length || y > 0));
withinRange = this.getExtremesFromAll || this.options.getExtremesFromAll || this.cropped ||
((xData[i] || x) >= xMin && (xData[i] || x) <= xMax);
if (validValue && withinRange) {
j = y.length;
if (j) { // array, like ohlc or range data
while (j--) {
if (y[j] !== null) {
activeYData[activeCounter++] = y[j];
}
}
} else {
activeYData[activeCounter++] = y;
}
}
}
this.dataMin = arrayMin(activeYData);
this.dataMax = arrayMax(activeYData);
},
/**
* Translate data points from raw data values to chart specific positioning
* data needed later in drawPoints, drawGraph and drawTracker.
*
* @function #translate
* @memberOf Series
* @returns {void}
*/
translate: function() {
if (!this.processedXData) { // hidden series
this.processData();
}
this.generatePoints();
var series = this,
options = series.options,
stacking = options.stacking,
xAxis = series.xAxis,
categories = xAxis.categories,
yAxis = series.yAxis,
points = series.points,
dataLength = points.length,
hasModifyValue = !!series.modifyValue,
i,
pointPlacement = options.pointPlacement,
dynamicallyPlaced = pointPlacement === 'between' || isNumber(pointPlacement),
threshold = options.threshold,
stackThreshold = options.startFromThreshold ? threshold : 0,
plotX,
plotY,
lastPlotX,
stackIndicator,
closestPointRangePx = Number.MAX_VALUE;
// Point placement is relative to each series pointRange (#5889)
if (pointPlacement === 'between') {
pointPlacement = 0.5;
}
if (isNumber(pointPlacement)) {
pointPlacement *= pick(options.pointRange || xAxis.pointRange);
}
// Translate each point
for (i = 0; i < dataLength; i++) {
var point = points[i],
xValue = point.x,
yValue = point.y,
yBottom = point.low,
stack = stacking && yAxis.stacks[(series.negStacks && yValue < (stackThreshold ? 0 : threshold) ? '-' : '') + series.stackKey],
pointStack,
stackValues;
// Discard disallowed y values for log axes (#3434)
if (yAxis.positiveValuesOnly && yValue !== null && yValue <= 0) {
point.isNull = true;
}
// Get the plotX translation
point.plotX = plotX = correctFloat( // #5236
Math.min(Math.max(-1e5, xAxis.translate(
xValue,
0,
0,
0,
1,
pointPlacement,
this.type === 'flags'
)), 1e5) // #3923
);
// Calculate the bottom y value for stacked series
if (stacking && series.visible && !point.isNull && stack && stack[xValue]) {
stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
pointStack = stack[xValue];
stackValues = pointStack.points[stackIndicator.key];
yBottom = stackValues[0];
yValue = stackValues[1];
if (yBottom === stackThreshold && stackIndicator.key === stack[xValue].base) {
yBottom = pick(threshold, yAxis.min);
}
if (yAxis.positiveValuesOnly && yBottom <= 0) { // #1200, #1232
yBottom = null;
}
point.total = point.stackTotal = pointStack.total;
point.percentage = pointStack.total && (point.y / pointStack.total * 100);
point.stackY = yValue;
// Place the stack label
pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
}
// Set translated yBottom or remove it
point.yBottom = defined(yBottom) ?
yAxis.translate(yBottom, 0, 1, 0, 1) :
null;
// general hook, used for Highstock compare mode
if (hasModifyValue) {
yValue = series.modifyValue(yValue, point);
}
// Set the the plotY value, reset it for redraws
point.plotY = plotY = (typeof yValue === 'number' && yValue !== Infinity) ?
Math.min(Math.max(-1e5, yAxis.translate(yValue, 0, 1, 0, 1)), 1e5) : // #3201
undefined;
point.isInside = plotY !== undefined && plotY >= 0 && plotY <= yAxis.len && // #3519
plotX >= 0 && plotX <= xAxis.len;
// Set client related positions for mouse tracking
point.clientX = dynamicallyPlaced ? correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) : plotX; // #1514, #5383, #5518
point.negative = point.y < (threshold || 0);
// some API data
point.category = categories && categories[point.x] !== undefined ?
categories[point.x] : point.x;
// Determine auto enabling of markers (#3635, #5099)
if (!point.isNull) {
if (lastPlotX !== undefined) {
closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
}
lastPlotX = plotX;
}
// Find point zone
point.zone = this.zones.length && point.getZone();
}
series.closestPointRangePx = closestPointRangePx;
},
/**
* Return the series points with null points filtered out
*/
getValidPoints: function(points, insideOnly) {
var chart = this.chart;
return grep(points || this.points || [], function isValidPoint(point) { // #3916, #5029
if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, chart.inverted)) { // #5085
return false;
}
return !point.isNull;
});
},
/**
* Set the clipping for the series. For animated series it is called twice, first to initiate
* animating the clip then the second time without the animation to set the final clip.
*/
setClip: function(animation) {
var chart = this.chart,
options = this.options,
renderer = chart.renderer,
inverted = chart.inverted,
seriesClipBox = this.clipBox,
clipBox = seriesClipBox || chart.clipBox,
sharedClipKey = this.sharedClipKey || ['_sharedClip', animation && animation.duration, animation && animation.easing, clipBox.height, options.xAxis, options.yAxis].join(','), // #4526
clipRect = chart[sharedClipKey],
markerClipRect = chart[sharedClipKey + 'm'];
// If a clipping rectangle with the same properties is currently present in the chart, use that.
if (!clipRect) {
// When animation is set, prepare the initial positions
if (animation) {
clipBox.width = 0;
chart[sharedClipKey + 'm'] = markerClipRect = renderer.clipRect(-99, // include the width of the first marker
inverted ? -chart.plotLeft : -chart.plotTop,
99,
inverted ? chart.chartWidth : chart.chartHeight
);
}
chart[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
// Create hashmap for series indexes
clipRect.count = {
length: 0
};
}
if (animation) {
if (!clipRect.count[this.index]) {
clipRect.count[this.index] = true;
clipRect.count.length += 1;
}
}
if (options.clip !== false) {
this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
this.markerGroup.clip(markerClipRect);
this.sharedClipKey = sharedClipKey;
}
// Remove the shared clipping rectangle when all series are shown
if (!animation) {
if (clipRect.count[this.index]) {
delete clipRect.count[this.index];
clipRect.count.length -= 1;
}
if (clipRect.count.length === 0 && sharedClipKey && chart[sharedClipKey]) {
if (!seriesClipBox) {
chart[sharedClipKey] = chart[sharedClipKey].destroy();
}
if (chart[sharedClipKey + 'm']) {
chart[sharedClipKey + 'm'] = chart[sharedClipKey + 'm'].destroy();
}
}
}
},
/**
* Animate in the series
*/
animate: function(init) {
var series = this,
chart = series.chart,
clipRect,
animation = animObject(series.options.animation),
sharedClipKey;
// Initialize the animation. Set up the clipping rectangle.
if (init) {
series.setClip(animation);
// Run the animation
} else {
sharedClipKey = this.sharedClipKey;
clipRect = chart[sharedClipKey];
if (clipRect) {
clipRect.animate({
width: chart.plotSizeX
}, animation);
}
if (chart[sharedClipKey + 'm']) {
chart[sharedClipKey + 'm'].animate({
width: chart.plotSizeX + 99
}, animation);
}
// Delete this function to allow it only once
series.animate = null;
}
},
/**
* This runs after animation to land on the final plot clipping
*/
afterAnimate: function() {
this.setClip();
fireEvent(this, 'afterAnimate');
},
/**
* Draw the markers.
*
* @function #drawPoints
* @memberOf Series
* @returns {void}
*/
drawPoints: function() {
var series = this,
points = series.points,
chart = series.chart,
plotY,
i,
point,
symbol,
graphic,
options = series.options,
seriesMarkerOptions = options.marker,
pointMarkerOptions,
hasPointMarker,
enabled,
isInside,
markerGroup = series.markerGroup,
xAxis = series.xAxis,
markerAttribs,
globallyEnabled = pick(
seriesMarkerOptions.enabled,
xAxis.isRadial ? true : null,
// Use larger or equal as radius is null in bubbles (#6321)
series.closestPointRangePx >= 2 * seriesMarkerOptions.radius
);
if (seriesMarkerOptions.enabled !== false || series._hasPointMarkers) {
for (i = 0; i < points.length; i++) {
point = points[i];
plotY = point.plotY;
graphic = point.graphic;
pointMarkerOptions = point.marker || {};
hasPointMarker = !!point.marker;
enabled = (globallyEnabled && pointMarkerOptions.enabled === undefined) || pointMarkerOptions.enabled;
isInside = point.isInside;
// only draw the point if y is defined
if (enabled && isNumber(plotY) && point.y !== null) {
// Shortcuts
symbol = pick(pointMarkerOptions.symbol, series.symbol);
point.hasImage = symbol.indexOf('url') === 0;
markerAttribs = series.markerAttribs(
point,
point.selected && 'select'
);
if (graphic) { // update
graphic[isInside ? 'show' : 'hide'](true) // Since the marker group isn't clipped, each individual marker must be toggled
.animate(markerAttribs);
} else if (isInside && (markerAttribs.width > 0 || point.hasImage)) {
point.graphic = graphic = chart.renderer.symbol(
symbol,
markerAttribs.x,
markerAttribs.y,
markerAttribs.width,
markerAttribs.height,
hasPointMarker ? pointMarkerOptions : seriesMarkerOptions
)
.add(markerGroup);
}
// Presentational attributes
if (graphic) {
graphic.attr(series.pointAttribs(point, point.selected && 'select'));
}
if (graphic) {
graphic.addClass(point.getClassName(), true);
}
} else if (graphic) {
point.graphic = graphic.destroy(); // #1269
}
}
}
},
/**
* Get non-presentational attributes for the point.
*/
markerAttribs: function(point, state) {
var seriesMarkerOptions = this.options.marker,
seriesStateOptions,
pointMarkerOptions = point.marker || {},
pointStateOptions,
radius = pick(
pointMarkerOptions.radius,
seriesMarkerOptions.radius
),
attribs;
// Handle hover and select states
if (state) {
seriesStateOptions = seriesMarkerOptions.states[state];
pointStateOptions = pointMarkerOptions.states &&
pointMarkerOptions.states[state];
radius = pick(
pointStateOptions && pointStateOptions.radius,
seriesStateOptions && seriesStateOptions.radius,
radius + (seriesStateOptions && seriesStateOptions.radiusPlus || 0)
);
}
if (point.hasImage) {
radius = 0; // and subsequently width and height is not set
}
attribs = {
x: Math.floor(point.plotX) - radius, // Math.floor for #1843
y: point.plotY - radius
};
if (radius) {
attribs.width = attribs.height = 2 * radius;
}
return attribs;
},
/**
* Get presentational attributes for marker-based series (line, spline, scatter, bubble, mappoint...)
*/
pointAttribs: function(point, state) {
var seriesMarkerOptions = this.options.marker,
seriesStateOptions,
pointOptions = point && point.options,
pointMarkerOptions = (pointOptions && pointOptions.marker) || {},
pointStateOptions,
color = this.color,
pointColorOption = pointOptions && pointOptions.color,
pointColor = point && point.color,
strokeWidth = pick(
pointMarkerOptions.lineWidth,
seriesMarkerOptions.lineWidth
),
zoneColor = point && point.zone && point.zone.color,
fill,
stroke;
color = pointColorOption || zoneColor || pointColor || color;
fill = pointMarkerOptions.fillColor || seriesMarkerOptions.fillColor || color;
stroke = pointMarkerOptions.lineColor || seriesMarkerOptions.lineColor || color;
// Handle hover and select states
if (state) {
seriesStateOptions = seriesMarkerOptions.states[state];
pointStateOptions = (pointMarkerOptions.states && pointMarkerOptions.states[state]) || {};
strokeWidth = pick(
pointStateOptions.lineWidth,
seriesStateOptions.lineWidth,
strokeWidth + pick(
pointStateOptions.lineWidthPlus,
seriesStateOptions.lineWidthPlus,
0
)
);
fill = pointStateOptions.fillColor || seriesStateOptions.fillColor || fill;
stroke = pointStateOptions.lineColor || seriesStateOptions.lineColor || stroke;
}
return {
'stroke': stroke,
'stroke-width': strokeWidth,
'fill': fill
};
},
/**
* Clear DOM objects and free up memory
*/
destroy: function() {
var series = this,
chart = series.chart,
issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent),
destroy,
i,
data = series.data || [],
point,
prop,
axis;
// add event hook
fireEvent(series, 'destroy');
// remove all events
removeEvent(series);
// erase from axes
each(series.axisTypes || [], function(AXIS) {
axis = series[AXIS];
if (axis && axis.series) {
erase(axis.series, series);
axis.isDirty = axis.forceRedraw = true;
}
});
// remove legend items
if (series.legendItem) {
series.chart.legend.destroyItem(series);
}
// destroy all points with their elements
i = data.length;
while (i--) {
point = data[i];
if (point && point.destroy) {
point.destroy();
}
}
series.points = null;
// Clear the animation timeout if we are destroying the series during initial animation
clearTimeout(series.animationTimeout);
// Destroy all SVGElements associated to the series
for (prop in series) {
if (series[prop] instanceof SVGElement && !series[prop].survive) { // Survive provides a hook for not destroying
// issue 134 workaround
destroy = issue134 && prop === 'group' ?
'hide' :
'destroy';
series[prop][destroy]();
}
}
// remove from hoverSeries
if (chart.hoverSeries === series) {
chart.hoverSeries = null;
}
erase(chart.series, series);
chart.orderSeries();
// clear all members
for (prop in series) {
delete series[prop];
}
},
/**
* Get the graph path
*/
getGraphPath: function(points, nullsAsZeroes, connectCliffs) {
var series = this,
options = series.options,
step = options.step,
reversed,
graphPath = [],
xMap = [],
gap;
points = points || series.points;
// Bottom of a stack is reversed
reversed = points.reversed;
if (reversed) {
points.reverse();
}
// Reverse the steps (#5004)
step = {
right: 1,
center: 2
}[step] || (step && 3);
if (step && reversed) {
step = 4 - step;
}
// Remove invalid points, especially in spline (#5015)
if (options.connectNulls && !nullsAsZeroes && !connectCliffs) {
points = this.getValidPoints(points);
}
// Build the line
each(points, function(point, i) {
var plotX = point.plotX,
plotY = point.plotY,
lastPoint = points[i - 1],
pathToPoint; // the path to this point from the previous
if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) && !connectCliffs) {
gap = true; // ... and continue
}
// Line series, nullsAsZeroes is not handled
if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
gap = !options.connectNulls;
// Area series, nullsAsZeroes is set
} else if (point.isNull && !nullsAsZeroes) {
gap = true;
} else {
if (i === 0 || gap) {
pathToPoint = ['M', point.plotX, point.plotY];
} else if (series.getPointSpline) { // generate the spline as defined in the SplineSeries object
pathToPoint = series.getPointSpline(points, point, i);
} else if (step) {
if (step === 1) { // right
pathToPoint = [
'L',
lastPoint.plotX,
plotY
];
} else if (step === 2) { // center
pathToPoint = [
'L',
(lastPoint.plotX + plotX) / 2,
lastPoint.plotY,
'L',
(lastPoint.plotX + plotX) / 2,
plotY
];
} else {
pathToPoint = [
'L',
plotX,
lastPoint.plotY
];
}
pathToPoint.push('L', plotX, plotY);
} else {
// normal line to next point
pathToPoint = [
'L',
plotX,
plotY
];
}
// Prepare for animation. When step is enabled, there are two path nodes for each x value.
xMap.push(point.x);
if (step) {
xMap.push(point.x);
}
graphPath.push.apply(graphPath, pathToPoint);
gap = false;
}
});
graphPath.xMap = xMap;
series.graphPath = graphPath;
return graphPath;
},
/**
* Draw the actual graph
*/
drawGraph: function() {
var series = this,
options = this.options,
graphPath = (this.gappedPath || this.getGraphPath).call(this),
props = [
[
'graph',
'highcharts-graph',
options.lineColor || this.color,
options.dashStyle
]
];
// Add the zone properties if any
each(this.zones, function(zone, i) {
props.push([
'zone-graph-' + i,
'highcharts-graph highcharts-zone-graph-' + i + ' ' + (zone.className || ''),
zone.color || series.color,
zone.dashStyle || options.dashStyle
]);
});
// Draw the graph
each(props, function(prop, i) {
var graphKey = prop[0],
graph = series[graphKey],
attribs;
if (graph) {
graph.endX = graphPath.xMap;
graph.animate({
d: graphPath
});
} else if (graphPath.length) { // #1487
series[graphKey] = series.chart.renderer.path(graphPath)
.addClass(prop[1])
.attr({
zIndex: 1
}) // #1069
.add(series.group);
attribs = {
'stroke': prop[2],
'stroke-width': options.lineWidth,
'fill': (series.fillGraph && series.color) || 'none' // Polygon series use filled graph
};
if (prop[3]) {
attribs.dashstyle = prop[3];
} else if (options.linecap !== 'square') {
attribs['stroke-linecap'] = attribs['stroke-linejoin'] = 'round';
}
graph = series[graphKey]
.attr(attribs)
.shadow((i < 2) && options.shadow); // add shadow to normal series (0) or to first zone (1) #3932
}
// Helpers for animation
if (graph) {
graph.startX = graphPath.xMap;
//graph.shiftUnit = options.step ? 2 : 1;
graph.isArea = graphPath.isArea; // For arearange animation
}
});
},
/**
* Clip the graphs into the positive and negative coloured graphs
*/
applyZones: function() {
var series = this,
chart = this.chart,
renderer = chart.renderer,
zones = this.zones,
translatedFrom,
translatedTo,
clips = this.clips || [],
clipAttr,
graph = this.graph,
area = this.area,
chartSizeMax = Math.max(chart.chartWidth, chart.chartHeight),
axis = this[(this.zoneAxis || 'y') + 'Axis'],
extremes,
reversed,
inverted = chart.inverted,
horiz,
pxRange,
pxPosMin,
pxPosMax,
ignoreZones = false;
if (zones.length && (graph || area) && axis && axis.min !== undefined) {
reversed = axis.reversed;
horiz = axis.horiz;
// The use of the Color Threshold assumes there are no gaps
// so it is safe to hide the original graph and area
if (graph) {
graph.hide();
}
if (area) {
area.hide();
}
// Create the clips
extremes = axis.getExtremes();
each(zones, function(threshold, i) {
translatedFrom = reversed ?
(horiz ? chart.plotWidth : 0) :
(horiz ? 0 : axis.toPixels(extremes.min));
translatedFrom = Math.min(Math.max(pick(translatedTo, translatedFrom), 0), chartSizeMax);
translatedTo = Math.min(Math.max(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true)), 0), chartSizeMax);
if (ignoreZones) {
translatedFrom = translatedTo = axis.toPixels(extremes.max);
}
pxRange = Math.abs(translatedFrom - translatedTo);
pxPosMin = Math.min(translatedFrom, translatedTo);
pxPosMax = Math.max(translatedFrom, translatedTo);
if (axis.isXAxis) {
clipAttr = {
x: inverted ? pxPosMax : pxPosMin,
y: 0,
width: pxRange,
height: chartSizeMax
};
if (!horiz) {
clipAttr.x = chart.plotHeight - clipAttr.x;
}
} else {
clipAttr = {
x: 0,
y: inverted ? pxPosMax : pxPosMin,
width: chartSizeMax,
height: pxRange
};
if (horiz) {
clipAttr.y = chart.plotWidth - clipAttr.y;
}
}
/// VML SUPPPORT
if (inverted && renderer.isVML) {
if (axis.isXAxis) {
clipAttr = {
x: 0,
y: reversed ? pxPosMin : pxPosMax,
height: clipAttr.width,
width: chart.chartWidth
};
} else {
clipAttr = {
x: clipAttr.y - chart.plotLeft - chart.spacingBox.x,
y: 0,
width: clipAttr.height,
height: chart.chartHeight
};
}
}
/// END OF VML SUPPORT
if (clips[i]) {
clips[i].animate(clipAttr);
} else {
clips[i] = renderer.clipRect(clipAttr);
if (graph) {
series['zone-graph-' + i].clip(clips[i]);
}
if (area) {
series['zone-area-' + i].clip(clips[i]);
}
}
// if this zone extends out of the axis, ignore the others
ignoreZones = threshold.value > extremes.max;
});
this.clips = clips;
}
},
/**
* Initialize and perform group inversion on series.group and series.markerGroup
*/
invertGroups: function(inverted) {
var series = this,
chart = series.chart,
remover;
function setInvert() {
each(['group', 'markerGroup'], function(groupName) {
if (series[groupName]) {
// VML/HTML needs explicit attributes for flipping
if (chart.renderer.isVML) {
series[groupName].attr({
width: series.yAxis.len,
height: series.xAxis.len
});
}
series[groupName].width = series.yAxis.len;
series[groupName].height = series.xAxis.len;
series[groupName].invert(inverted);
}
});
}
// Pie, go away (#1736)
if (!series.xAxis) {
return;
}
// A fixed size is needed for inversion to work
remover = addEvent(chart, 'resize', setInvert);
addEvent(series, 'destroy', remover);
// Do it now
setInvert(inverted); // do it now
// On subsequent render and redraw, just do setInvert without setting up events again
series.invertGroups = setInvert;
},
/**
* General abstraction for creating plot groups like series.group, series.dataLabelsGroup and
* series.markerGroup. On subsequent calls, the group will only be adjusted to the updated plot size.
*/
plotGroup: function(prop, name, visibility, zIndex, parent) {
var group = this[prop],
isNew = !group;
// Generate it on first call
if (isNew) {
this[prop] = group = this.chart.renderer.g(name)
.attr({
zIndex: zIndex || 0.1 // IE8 and pointer logic use this
})
.add(parent);
group.addClass('highcharts-series-' + this.index + ' highcharts-' + this.type + '-series highcharts-color-' + this.colorIndex +
' ' + (this.options.className || ''));
}
// Place it on first and subsequent (redraw) calls
group.attr({
visibility: visibility
})[isNew ? 'attr' : 'animate'](this.getPlotBox());
return group;
},
/**
* Get the translation and scale for the plot area of this series
*/
getPlotBox: function() {
var chart = this.chart,
xAxis = this.xAxis,
yAxis = this.yAxis;
// Swap axes for inverted (#2339)
if (chart.inverted) {
xAxis = yAxis;
yAxis = this.xAxis;
}
return {
translateX: xAxis ? xAxis.left : chart.plotLeft,
translateY: yAxis ? yAxis.top : chart.plotTop,
scaleX: 1, // #1623
scaleY: 1
};
},
/**
* Render the graph and markers
*/
render: function() {
var series = this,
chart = series.chart,
group,
options = series.options,
// Animation doesn't work in IE8 quirks when the group div is hidden,
// and looks bad in other oldIE
animDuration = !!series.animate && chart.renderer.isSVG && animObject(options.animation).duration,
visibility = series.visible ? 'inherit' : 'hidden', // #2597
zIndex = options.zIndex,
hasRendered = series.hasRendered,
chartSeriesGroup = chart.seriesGroup,
inverted = chart.inverted;
// the group
group = series.plotGroup(
'group',
'series',
visibility,
zIndex,
chartSeriesGroup
);
series.markerGroup = series.plotGroup(
'markerGroup',
'markers',
visibility,
zIndex,
chartSeriesGroup
);
// initiate the animation
if (animDuration) {
series.animate(true);
}
// SVGRenderer needs to know this before drawing elements (#1089, #1795)
group.inverted = series.isCartesian ? inverted : false;
// draw the graph if any
if (series.drawGraph) {
series.drawGraph();
series.applyZones();
}
/* each(series.points, function (point) {
if (point.redraw) {
point.redraw();
}
});*/
// draw the data labels (inn pies they go before the points)
if (series.drawDataLabels) {
series.drawDataLabels();
}
// draw the points
if (series.visible) {
series.drawPoints();
}
// draw the mouse tracking area
if (series.drawTracker && series.options.enableMouseTracking !== false) {
series.drawTracker();
}
// Handle inverted series and tracker groups
series.invertGroups(inverted);
// Initial clipping, must be defined after inverting groups for VML. Applies to columns etc. (#3839).
if (options.clip !== false && !series.sharedClipKey && !hasRendered) {
group.clip(chart.clipRect);
}
// Run the animation
if (animDuration) {
series.animate();
}
// Call the afterAnimate function on animation complete (but don't overwrite the animation.complete option
// which should be available to the user).
if (!hasRendered) {
series.animationTimeout = syncTimeout(function() {
series.afterAnimate();
}, animDuration);
}
series.isDirty = false; // means data is in accordance with what you see
// (See #322) series.isDirty = series.isDirtyData = false; // means data is in accordance with what you see
series.hasRendered = true;
},
/**
* Redraw the series after an update in the axes.
*/
redraw: function() {
var series = this,
chart = series.chart,
wasDirty = series.isDirty || series.isDirtyData, // cache it here as it is set to false in render, but used after
group = series.group,
xAxis = series.xAxis,
yAxis = series.yAxis;
// reposition on resize
if (group) {
if (chart.inverted) {
group.attr({
width: chart.plotWidth,
height: chart.plotHeight
});
}
group.animate({
translateX: pick(xAxis && xAxis.left, chart.plotLeft),
translateY: pick(yAxis && yAxis.top, chart.plotTop)
});
}
series.translate();
series.render();
if (wasDirty) { // #3868, #3945
delete this.kdTree;
}
},
/**
* KD Tree && PointSearching Implementation
*/
kdAxisArray: ['clientX', 'plotY'],
searchPoint: function(e, compareX) {
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis,
inverted = series.chart.inverted;
return this.searchKDTree({
clientX: inverted ? xAxis.len - e.chartY + xAxis.pos : e.chartX - xAxis.pos,
plotY: inverted ? yAxis.len - e.chartX + yAxis.pos : e.chartY - yAxis.pos
}, compareX);
},
/**
* Build the k-d-tree that is used by mouse and touch interaction to get the
* closest point. Line-like series typically have a one-dimensional tree
* where points are searched along the X axis, while scatter-like series
* typically search in two dimensions, X and Y.
*/
buildKDTree: function() {
// Prevent multiple k-d-trees from being built simultaneously (#6235)
this.buildingKdTree = true;
var series = this,
dimensions = series.options.findNearestPointBy.indexOf('y') > -1 ?
2 : 1;
// Internal function
function _kdtree(points, depth, dimensions) {
var axis,
median,
length = points && points.length;
if (length) {
// alternate between the axis
axis = series.kdAxisArray[depth % dimensions];
// sort point array
points.sort(function(a, b) {
return a[axis] - b[axis];
});
median = Math.floor(length / 2);
// build and return nod
return {
point: points[median],
left: _kdtree(points.slice(0, median), depth + 1, dimensions),
right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
};
}
}
// Start the recursive build process with a clone of the points array and null points filtered out (#3873)
function startRecursive() {
series.kdTree = _kdtree(
series.getValidPoints(
null, !series.directTouch // For line-type series restrict to plot area, but column-type series not (#3916, #4511)
),
dimensions,
dimensions
);
series.buildingKdTree = false;
}
delete series.kdTree;
// For testing tooltips, don't build async
syncTimeout(startRecursive, series.options.kdNow ? 0 : 1);
},
searchKDTree: function(point, compareX) {
var series = this,
kdX = this.kdAxisArray[0],
kdY = this.kdAxisArray[1],
kdComparer = compareX ? 'distX' : 'dist',
kdDimensions = series.options.findNearestPointBy.indexOf('y') > -1 ?
2 : 1;
// Set the one and two dimensional distance on the point object
function setDistance(p1, p2) {
var x = (defined(p1[kdX]) && defined(p2[kdX])) ? Math.pow(p1[kdX] - p2[kdX], 2) : null,
y = (defined(p1[kdY]) && defined(p2[kdY])) ? Math.pow(p1[kdY] - p2[kdY], 2) : null,
r = (x || 0) + (y || 0);
p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
}
function _search(search, tree, depth, dimensions) {
var point = tree.point,
axis = series.kdAxisArray[depth % dimensions],
tdist,
sideA,
sideB,
ret = point,
nPoint1,
nPoint2;
setDistance(search, point);
// Pick side based on distance to splitting point
tdist = search[axis] - point[axis];
sideA = tdist < 0 ? 'left' : 'right';
sideB = tdist < 0 ? 'right' : 'left';
// End of tree
if (tree[sideA]) {
nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
ret = (nPoint1[kdComparer] < ret[kdComparer] ? nPoint1 : point);
}
if (tree[sideB]) {
// compare distance to current best to splitting point to decide wether to check side B or not
if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
ret = (nPoint2[kdComparer] < ret[kdComparer] ? nPoint2 : ret);
}
}
return ret;
}
if (!this.kdTree && !this.buildingKdTree) {
this.buildKDTree();
}
if (this.kdTree) {
return _search(point, this.kdTree, kdDimensions, kdDimensions);
}
}
}); // end Series prototype
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
Chart = H.Chart,
correctFloat = H.correctFloat,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
each = H.each,
format = H.format,
pick = H.pick,
Series = H.Series;
/**
* The class for stacks. Each stack, on a specific X value and either negative
* or positive, has its own stack item.
*
* @class
*/
function StackItem(axis, options, isNegative, x, stackOption) {
var inverted = axis.chart.inverted;
this.axis = axis;
// Tells if the stack is negative
this.isNegative = isNegative;
// Save the options to be able to style the label
this.options = options;
// Save the x value to be able to position the label later
this.x = x;
// Initialize total value
this.total = null;
// This will keep each points' extremes stored by series.index and point
// index
this.points = {};
// Save the stack option on the series configuration object, and whether to
// treat it as percent
this.stack = stackOption;
this.leftCliff = 0;
this.rightCliff = 0;
// The align options and text align varies on whether the stack is negative
// and if the chart is inverted or not.
// First test the user supplied value, then use the dynamic.
this.alignOptions = {
align: options.align ||
(inverted ? (isNegative ? 'left' : 'right') : 'center'),
verticalAlign: options.verticalAlign ||
(inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
y: pick(options.y, inverted ? 4 : (isNegative ? 14 : -6)),
x: pick(options.x, inverted ? (isNegative ? -6 : 6) : 0)
};
this.textAlign = options.textAlign ||
(inverted ? (isNegative ? 'right' : 'left') : 'center');
}
StackItem.prototype = {
destroy: function() {
destroyObjectProperties(this, this.axis);
},
/**
* Renders the stack total label and adds it to the stack label group.
*/
render: function(group) {
var options = this.options,
formatOption = options.format,
str = formatOption ?
format(formatOption, this) :
options.formatter.call(this); // format the text in the label
// Change the text to reflect the new total and set visibility to hidden
// in case the serie is hidden
if (this.label) {
this.label.attr({
text: str,
visibility: 'hidden'
});
// Create new label
} else {
this.label =
this.axis.chart.renderer.text(str, null, null, options.useHTML)
.css(options.style)
.attr({
align: this.textAlign,
rotation: options.rotation,
visibility: 'hidden' // hidden until setOffset is called
})
.add(group); // add to the labels-group
}
},
/**
* Sets the offset that the stack has from the x value and repositions the
* label.
*/
setOffset: function(xOffset, xWidth) {
var stackItem = this,
axis = stackItem.axis,
chart = axis.chart,
inverted = chart.inverted,
reversed = axis.reversed,
neg = (this.isNegative && !reversed) ||
(!this.isNegative && reversed), // #4056
// stack value translated mapped to chart coordinates
y = axis.translate(
axis.usePercentage ? 100 : this.total,
0,
0,
0,
1
),
yZero = axis.translate(0), // stack origin
h = Math.abs(y - yZero), // stack height
x = chart.xAxis[0].translate(this.x) + xOffset, // stack x position
plotHeight = chart.plotHeight,
stackBox = { // this is the box for the complete stack
x: inverted ? (neg ? y : y - h) : x,
y: inverted ?
plotHeight - x - xWidth : (neg ? (plotHeight - y - h) :
plotHeight - y),
width: inverted ? h : xWidth,
height: inverted ? xWidth : h
},
label = this.label,
alignAttr;
if (label) {
// Align the label to the box
label.align(this.alignOptions, null, stackBox);
// Set visibility (#678)
alignAttr = label.alignAttr;
label[
this.options.crop === false || chart.isInsidePlot(
alignAttr.x,
alignAttr.y
) ? 'show' : 'hide'](true);
}
}
};
/**
* Generate stacks for each series and calculate stacks total values
*/
Chart.prototype.getStacks = function() {
var chart = this;
// reset stacks for each yAxis
each(chart.yAxis, function(axis) {
if (axis.stacks && axis.hasVisibleSeries) {
axis.oldStacks = axis.stacks;
}
});
each(chart.series, function(series) {
if (series.options.stacking && (series.visible === true ||
chart.options.chart.ignoreHiddenSeries === false)) {
series.stackKey = series.type + pick(series.options.stack, '');
}
});
};
// Stacking methods defined on the Axis prototype
/**
* Build the stacks from top down
*/
Axis.prototype.buildStacks = function() {
var axisSeries = this.series,
series,
reversedStacks = pick(this.options.reversedStacks, true),
len = axisSeries.length,
i;
if (!this.isXAxis) {
this.usePercentage = false;
i = len;
while (i--) {
axisSeries[reversedStacks ? i : len - i - 1].setStackedPoints();
}
i = len;
while (i--) {
series = axisSeries[reversedStacks ? i : len - i - 1];
if (series.setStackCliffs) {
series.setStackCliffs();
}
}
// Loop up again to compute percent stack
if (this.usePercentage) {
for (i = 0; i < len; i++) {
axisSeries[i].setPercentStacks();
}
}
}
};
Axis.prototype.renderStackTotals = function() {
var axis = this,
chart = axis.chart,
renderer = chart.renderer,
stacks = axis.stacks,
stackKey,
oneStack,
stackCategory,
stackTotalGroup = axis.stackTotalGroup;
// Create a separate group for the stack total labels
if (!stackTotalGroup) {
axis.stackTotalGroup = stackTotalGroup =
renderer.g('stack-labels')
.attr({
visibility: 'visible',
zIndex: 6
})
.add();
}
// plotLeft/Top will change when y axis gets wider so we need to translate
// the stackTotalGroup at every render call. See bug #506 and #516
stackTotalGroup.translate(chart.plotLeft, chart.plotTop);
// Render each stack total
for (stackKey in stacks) {
oneStack = stacks[stackKey];
for (stackCategory in oneStack) {
oneStack[stackCategory].render(stackTotalGroup);
}
}
};
/**
* Set all the stacks to initial states and destroy unused ones.
*/
Axis.prototype.resetStacks = function() {
var stacks = this.stacks,
type,
i;
if (!this.isXAxis) {
for (type in stacks) {
for (i in stacks[type]) {
// Clean up memory after point deletion (#1044, #4320)
if (stacks[type][i].touched < this.stacksTouched) {
stacks[type][i].destroy();
delete stacks[type][i];
// Reset stacks
} else {
stacks[type][i].total = null;
stacks[type][i].cum = null;
}
}
}
}
};
Axis.prototype.cleanStacks = function() {
var stacks, type, i;
if (!this.isXAxis) {
if (this.oldStacks) {
stacks = this.stacks = this.oldStacks;
}
// reset stacks
for (type in stacks) {
for (i in stacks[type]) {
stacks[type][i].cum = stacks[type][i].total;
}
}
}
};
// Stacking methods defnied for Series prototype
/**
* Adds series' points value to corresponding stack
*/
Series.prototype.setStackedPoints = function() {
if (!this.options.stacking || (this.visible !== true &&
this.chart.options.chart.ignoreHiddenSeries !== false)) {
return;
}
var series = this,
xData = series.processedXData,
yData = series.processedYData,
stackedYData = [],
yDataLength = yData.length,
seriesOptions = series.options,
threshold = seriesOptions.threshold,
stackThreshold = seriesOptions.startFromThreshold ? threshold : 0,
stackOption = seriesOptions.stack,
stacking = seriesOptions.stacking,
stackKey = series.stackKey,
negKey = '-' + stackKey,
negStacks = series.negStacks,
yAxis = series.yAxis,
stacks = yAxis.stacks,
oldStacks = yAxis.oldStacks,
stackIndicator,
isNegative,
stack,
other,
key,
pointKey,
i,
x,
y;
yAxis.stacksTouched += 1;
// loop over the non-null y values and read them into a local array
for (i = 0; i < yDataLength; i++) {
x = xData[i];
y = yData[i];
stackIndicator = series.getStackIndicator(
stackIndicator,
x,
series.index
);
pointKey = stackIndicator.key;
// Read stacked values into a stack based on the x value,
// the sign of y and the stack key. Stacking is also handled for null
// values (#739)
isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
key = isNegative ? negKey : stackKey;
// Create empty object for this stack if it doesn't exist yet
if (!stacks[key]) {
stacks[key] = {};
}
// Initialize StackItem for this x
if (!stacks[key][x]) {
if (oldStacks[key] && oldStacks[key][x]) {
stacks[key][x] = oldStacks[key][x];
stacks[key][x].total = null;
} else {
stacks[key][x] = new StackItem(
yAxis,
yAxis.options.stackLabels,
isNegative,
x,
stackOption
);
}
}
// If the StackItem doesn't exist, create it first
stack = stacks[key][x];
if (y !== null) {
stack.points[pointKey] = stack.points[series.index] = [pick(stack.cum, stackThreshold)];
// Record the base of the stack
if (!defined(stack.cum)) {
stack.base = pointKey;
}
stack.touched = yAxis.stacksTouched;
// In area charts, if there are multiple points on the same X value,
// let the area fill the full span of those points
if (stackIndicator.index > 0 && series.singleStacks === false) {
stack.points[pointKey][0] =
stack.points[series.index + ',' + x + ',0'][0];
}
}
// Add value to the stack total
if (stacking === 'percent') {
// Percent stacked column, totals are the same for the positive and
// negative stacks
other = isNegative ? stackKey : negKey;
if (negStacks && stacks[other] && stacks[other][x]) {
other = stacks[other][x];
stack.total = other.total =
Math.max(other.total, stack.total) + Math.abs(y) || 0;
// Percent stacked areas
} else {
stack.total = correctFloat(stack.total + (Math.abs(y) || 0));
}
} else {
stack.total = correctFloat(stack.total + (y || 0));
}
stack.cum = pick(stack.cum, stackThreshold) + (y || 0);
if (y !== null) {
stack.points[pointKey].push(stack.cum);
stackedYData[i] = stack.cum;
}
}
if (stacking === 'percent') {
yAxis.usePercentage = true;
}
this.stackedYData = stackedYData; // To be used in getExtremes
// Reset old stacks
yAxis.oldStacks = {};
};
/**
* Iterate over all stacks and compute the absolute values to percent
*/
Series.prototype.setPercentStacks = function() {
var series = this,
stackKey = series.stackKey,
stacks = series.yAxis.stacks,
processedXData = series.processedXData,
stackIndicator;
each([stackKey, '-' + stackKey], function(key) {
var i = processedXData.length,
x,
stack,
pointExtremes,
totalFactor;
while (i--) {
x = processedXData[i];
stackIndicator = series.getStackIndicator(
stackIndicator,
x,
series.index,
key
);
stack = stacks[key] && stacks[key][x];
pointExtremes = stack && stack.points[stackIndicator.key];
if (pointExtremes) {
totalFactor = stack.total ? 100 / stack.total : 0;
// Y bottom value
pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor);
// Y value
pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor);
series.stackedYData[i] = pointExtremes[1];
}
}
});
};
/**
* Get stack indicator, according to it's x-value, to determine points with the
* same x-value
*/
Series.prototype.getStackIndicator = function(stackIndicator, x, index, key) {
// Update stack indicator, when:
// first point in a stack || x changed || stack type (negative vs positive)
// changed:
if (!defined(stackIndicator) || stackIndicator.x !== x ||
(key && stackIndicator.key !== key)) {
stackIndicator = {
x: x,
index: 0,
key: key
};
} else {
stackIndicator.index++;
}
stackIndicator.key = [index, x, stackIndicator.index].join(',');
return stackIndicator;
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animate = H.animate,
Axis = H.Axis,
Chart = H.Chart,
createElement = H.createElement,
css = H.css,
defined = H.defined,
each = H.each,
erase = H.erase,
extend = H.extend,
fireEvent = H.fireEvent,
inArray = H.inArray,
isNumber = H.isNumber,
isObject = H.isObject,
merge = H.merge,
pick = H.pick,
Point = H.Point,
Series = H.Series,
seriesTypes = H.seriesTypes,
setAnimation = H.setAnimation,
splat = H.splat;
// Extend the Chart prototype for dynamic methods
extend(Chart.prototype, /** @lends Highcharts.Chart.prototype */ {
/**
* Add a series dynamically after time
*
* @param {Object} options The config options
* @param {Boolean} redraw Whether to redraw the chart after adding. Defaults to true.
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*
* @return {Object} series The newly created series object
*/
addSeries: function(options, redraw, animation) {
var series,
chart = this;
if (options) {
redraw = pick(redraw, true); // defaults to true
fireEvent(chart, 'addSeries', {
options: options
}, function() {
series = chart.initSeries(options);
chart.isDirtyLegend = true; // the series array is out of sync with the display
chart.linkSeries();
if (redraw) {
chart.redraw(animation);
}
});
}
return series;
},
/**
* Add an axis to the chart
* @param {Object} options The axis option
* @param {Boolean} isX Whether it is an X axis or a value axis
*/
addAxis: function(options, isX, redraw, animation) {
var key = isX ? 'xAxis' : 'yAxis',
chartOptions = this.options,
userOptions = merge(options, {
index: this[key].length,
isX: isX
});
new Axis(this, userOptions); // eslint-disable-line no-new
// Push the new axis options to the chart options
chartOptions[key] = splat(chartOptions[key] || {});
chartOptions[key].push(userOptions);
if (pick(redraw, true)) {
this.redraw(animation);
}
},
/**
* Dim the chart and show a loading text or symbol
* @param {String} str An optional text to show in the loading label instead of the default one
*/
showLoading: function(str) {
var chart = this,
options = chart.options,
loadingDiv = chart.loadingDiv,
loadingOptions = options.loading,
setLoadingSize = function() {
if (loadingDiv) {
css(loadingDiv, {
left: chart.plotLeft + 'px',
top: chart.plotTop + 'px',
width: chart.plotWidth + 'px',
height: chart.plotHeight + 'px'
});
}
};
// create the layer at the first call
if (!loadingDiv) {
chart.loadingDiv = loadingDiv = createElement('div', {
className: 'highcharts-loading highcharts-loading-hidden'
}, null, chart.container);
chart.loadingSpan = createElement(
'span', {
className: 'highcharts-loading-inner'
},
null,
loadingDiv
);
addEvent(chart, 'redraw', setLoadingSize); // #1080
}
loadingDiv.className = 'highcharts-loading';
// Update text
chart.loadingSpan.innerHTML = str || options.lang.loading;
// Update visuals
css(loadingDiv, extend(loadingOptions.style, {
zIndex: 10
}));
css(chart.loadingSpan, loadingOptions.labelStyle);
// Show it
if (!chart.loadingShown) {
css(loadingDiv, {
opacity: 0,
display: ''
});
animate(loadingDiv, {
opacity: loadingOptions.style.opacity || 0.5
}, {
duration: loadingOptions.showDuration || 0
});
}
chart.loadingShown = true;
setLoadingSize();
},
/**
* Hide the loading layer
*/
hideLoading: function() {
var options = this.options,
loadingDiv = this.loadingDiv;
if (loadingDiv) {
loadingDiv.className = 'highcharts-loading highcharts-loading-hidden';
animate(loadingDiv, {
opacity: 0
}, {
duration: options.loading.hideDuration || 100,
complete: function() {
css(loadingDiv, {
display: 'none'
});
}
});
}
this.loadingShown = false;
},
/**
* These properties cause isDirtyBox to be set to true when updating. Can be extended from plugins.
*/
propsRequireDirtyBox: ['backgroundColor', 'borderColor', 'borderWidth', 'margin', 'marginTop', 'marginRight',
'marginBottom', 'marginLeft', 'spacing', 'spacingTop', 'spacingRight', 'spacingBottom', 'spacingLeft',
'borderRadius', 'plotBackgroundColor', 'plotBackgroundImage', 'plotBorderColor', 'plotBorderWidth',
'plotShadow', 'shadow'
],
/**
* These properties cause all series to be updated when updating. Can be
* extended from plugins.
*/
propsRequireUpdateSeries: ['chart.inverted', 'chart.polar',
'chart.ignoreHiddenSeries', 'chart.type', 'colors', 'plotOptions'
],
/**
* Chart.update function that takes the whole options stucture.
*/
update: function(options, redraw) {
var key,
adders = {
credits: 'addCredits',
title: 'setTitle',
subtitle: 'setSubtitle'
},
optionsChart = options.chart,
updateAllAxes,
updateAllSeries,
newWidth,
newHeight;
// If the top-level chart option is present, some special updates are required
if (optionsChart) {
merge(true, this.options.chart, optionsChart);
// Setter function
if ('className' in optionsChart) {
this.setClassName(optionsChart.className);
}
if ('inverted' in optionsChart || 'polar' in optionsChart) {
// Parse options.chart.inverted and options.chart.polar together
// with the available series.
this.propFromSeries();
updateAllAxes = true;
}
if ('alignTicks' in optionsChart) { // #6452
updateAllAxes = true;
}
for (key in optionsChart) {
if (optionsChart.hasOwnProperty(key)) {
if (inArray('chart.' + key, this.propsRequireUpdateSeries) !== -1) {
updateAllSeries = true;
}
// Only dirty box
if (inArray(key, this.propsRequireDirtyBox) !== -1) {
this.isDirtyBox = true;
}
}
}
if ('style' in optionsChart) {
this.renderer.setStyle(optionsChart.style);
}
}
// Some option stuctures correspond one-to-one to chart objects that have
// update methods, for example
// options.credits => chart.credits
// options.legend => chart.legend
// options.title => chart.title
// options.tooltip => chart.tooltip
// options.subtitle => chart.subtitle
// options.mapNavigation => chart.mapNavigation
// options.navigator => chart.navigator
// options.scrollbar => chart.scrollbar
for (key in options) {
if (this[key] && typeof this[key].update === 'function') {
this[key].update(options[key], false);
// If a one-to-one object does not exist, look for an adder function
} else if (typeof this[adders[key]] === 'function') {
this[adders[key]](options[key]);
}
if (key !== 'chart' && inArray(key, this.propsRequireUpdateSeries) !== -1) {
updateAllSeries = true;
}
}
if (options.colors) {
this.options.colors = options.colors;
}
if (options.plotOptions) {
merge(true, this.options.plotOptions, options.plotOptions);
}
// Setters for collections. For axes and series, each item is referred
// by an id. If the id is not found, it defaults to the corresponding
// item in the collection, so setting one series without an id, will
// update the first series in the chart. Setting two series without
// an id will update the first and the second respectively (#6019)
// chart.update and responsive.
each(['xAxis', 'yAxis', 'series', 'colorAxis', 'pane'], function(coll) {
if (options[coll]) {
each(splat(options[coll]), function(newOptions, i) {
var item = (
defined(newOptions.id) &&
this.get(newOptions.id)
) || this[coll][i];
if (item && item.coll === coll) {
item.update(newOptions, false);
}
}, this);
}
}, this);
if (updateAllAxes) {
each(this.axes, function(axis) {
axis.update({}, false);
});
}
// Certain options require the whole series structure to be thrown away
// and rebuilt
if (updateAllSeries) {
each(this.series, function(series) {
series.update({}, false);
});
}
// For loading, just update the options, do not redraw
if (options.loading) {
merge(true, this.options.loading, options.loading);
}
// Update size. Redraw is forced.
newWidth = optionsChart && optionsChart.width;
newHeight = optionsChart && optionsChart.height;
if ((isNumber(newWidth) && newWidth !== this.chartWidth) ||
(isNumber(newHeight) && newHeight !== this.chartHeight)) {
this.setSize(newWidth, newHeight);
} else if (pick(redraw, true)) {
this.redraw();
}
},
/**
* Setter function to allow use from chart.update
*/
setSubtitle: function(options) {
this.setTitle(undefined, options);
}
});
// extend the Point prototype for dynamic methods
extend(Point.prototype, /** @lends Point.prototype */ {
/**
* Point.update with new options (typically x/y data) and optionally redraw the series.
*
* @param {Object} options Point options as defined in the series.data array
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
update: function(options, redraw, animation, runEvent) {
var point = this,
series = point.series,
graphic = point.graphic,
i,
chart = series.chart,
seriesOptions = series.options;
redraw = pick(redraw, true);
function update() {
point.applyOptions(options);
// Update visuals
if (point.y === null && graphic) { // #4146
point.graphic = graphic.destroy();
}
if (isObject(options, true)) {
// Destroy so we can get new elements
if (graphic && graphic.element) {
if (options && options.marker && options.marker.symbol) {
point.graphic = graphic.destroy();
}
}
if (options && options.dataLabels && point.dataLabel) { // #2468
point.dataLabel = point.dataLabel.destroy();
}
}
// record changes in the parallel arrays
i = point.index;
series.updateParallelArrays(point, i);
// Record the options to options.data. If the old or the new config
// is an object, use point options, otherwise use raw options
// (#4701, #4916).
seriesOptions.data[i] = (
isObject(seriesOptions.data[i], true) ||
isObject(options, true)
) ?
point.options :
options;
// redraw
series.isDirty = series.isDirtyData = true;
if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
chart.isDirtyBox = true;
}
if (seriesOptions.legendType === 'point') { // #1831, #1885
chart.isDirtyLegend = true;
}
if (redraw) {
chart.redraw(animation);
}
}
// Fire the event with a default handler of doing the update
if (runEvent === false) { // When called from setData
update();
} else {
point.firePointEvent('update', {
options: options
}, update);
}
},
/**
* Remove a point and optionally redraw the series and if necessary the axes
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
remove: function(redraw, animation) {
this.series.removePoint(inArray(this, this.series.data), redraw, animation);
}
});
// Extend the series prototype for dynamic methods
extend(Series.prototype, /** @lends Series.prototype */ {
/**
* Add a point dynamically after chart load time
* @param {Object} options Point options as given in series.data
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean} shift If shift is true, a point is shifted off the start
* of the series as one is appended to the end.
* @param {Boolean|AnimationOptions} animation Whether to apply animation, and optionally animation
* configuration
*/
addPoint: function(options, redraw, shift, animation) {
var series = this,
seriesOptions = series.options,
data = series.data,
chart = series.chart,
xAxis = series.xAxis,
names = xAxis && xAxis.hasNames && xAxis.names,
dataOptions = seriesOptions.data,
point,
isInTheMiddle,
xData = series.xData,
i,
x;
// Optional redraw, defaults to true
redraw = pick(redraw, true);
// Get options and push the point to xData, yData and series.options. In series.generatePoints
// the Point instance will be created on demand and pushed to the series.data array.
point = {
series: series
};
series.pointClass.prototype.applyOptions.apply(point, [options]);
x = point.x;
// Get the insertion point
i = xData.length;
if (series.requireSorting && x < xData[i - 1]) {
isInTheMiddle = true;
while (i && xData[i - 1] > x) {
i--;
}
}
series.updateParallelArrays(point, 'splice', i, 0, 0); // insert undefined item
series.updateParallelArrays(point, i); // update it
if (names && point.name) {
names[x] = point.name;
}
dataOptions.splice(i, 0, options);
if (isInTheMiddle) {
series.data.splice(i, 0, null);
series.processData();
}
// Generate points to be added to the legend (#1329)
if (seriesOptions.legendType === 'point') {
series.generatePoints();
}
// Shift the first point off the parallel arrays
if (shift) {
if (data[0] && data[0].remove) {
data[0].remove(false);
} else {
data.shift();
series.updateParallelArrays(point, 'shift');
dataOptions.shift();
}
}
// redraw
series.isDirty = true;
series.isDirtyData = true;
if (redraw) {
chart.redraw(animation); // Animation is set anyway on redraw, #5665
}
},
/**
* Remove a point (rendered or not), by index
*/
removePoint: function(i, redraw, animation) {
var series = this,
data = series.data,
point = data[i],
points = series.points,
chart = series.chart,
remove = function() {
if (points && points.length === data.length) { // #4935
points.splice(i, 1);
}
data.splice(i, 1);
series.options.data.splice(i, 1);
series.updateParallelArrays(point || {
series: series
}, 'splice', i, 1);
if (point) {
point.destroy();
}
// redraw
series.isDirty = true;
series.isDirtyData = true;
if (redraw) {
chart.redraw();
}
};
setAnimation(animation, chart);
redraw = pick(redraw, true);
// Fire the event with a default handler of removing the point
if (point) {
point.firePointEvent('remove', null, remove);
} else {
remove();
}
},
/**
* Remove a series and optionally redraw the chart
*
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
remove: function(redraw, animation, withEvent) {
var series = this,
chart = series.chart;
function remove() {
// Destroy elements
series.destroy();
// Redraw
chart.isDirtyLegend = chart.isDirtyBox = true;
chart.linkSeries();
if (pick(redraw, true)) {
chart.redraw(animation);
}
}
// Fire the event with a default handler of removing the point
if (withEvent !== false) {
fireEvent(series, 'remove', null, remove);
} else {
remove();
}
},
/**
* Series.update with a new set of options
*/
update: function(newOptions, redraw) {
var series = this,
chart = this.chart,
// must use user options when changing type because this.options is merged
// in with type specific plotOptions
oldOptions = this.userOptions,
oldType = this.oldType || this.type,
newType = newOptions.type || oldOptions.type || chart.options.chart.type,
proto = seriesTypes[oldType].prototype,
preserve = ['group', 'markerGroup', 'dataLabelsGroup'],
n;
// If we're changing type or zIndex, create new groups (#3380, #3404)
if ((newType && newType !== oldType) || newOptions.zIndex !== undefined) {
preserve.length = 0;
}
// Make sure groups are not destroyed (#3094)
each(preserve, function(prop) {
preserve[prop] = series[prop];
delete series[prop];
});
// Do the merge, with some forced options
newOptions = merge(oldOptions, {
animation: false,
index: this.index,
pointStart: this.xData[0] // when updating after addPoint
}, {
data: this.options.data
}, newOptions);
// Destroy the series and delete all properties. Reinsert all methods
// and properties from the new type prototype (#2270, #3719)
this.remove(false, null, false);
for (n in proto) {
this[n] = undefined;
}
extend(this, seriesTypes[newType || oldType].prototype);
// Re-register groups (#3094)
each(preserve, function(prop) {
series[prop] = preserve[prop];
});
this.init(chart, newOptions);
this.oldType = oldType;
chart.linkSeries(); // Links are lost in this.remove (#3028)
if (pick(redraw, true)) {
chart.redraw(false);
}
}
});
// Extend the Axis.prototype for dynamic methods
extend(Axis.prototype, /** @lends Axis.prototype */ {
/**
* Axis.update with a new options structure
*/
update: function(newOptions, redraw) {
var chart = this.chart;
newOptions = chart.options[this.coll][this.options.index] = merge(this.userOptions, newOptions);
this.destroy(true);
this.init(chart, extend(newOptions, {
events: undefined
}));
chart.isDirtyBox = true;
if (pick(redraw, true)) {
chart.redraw();
}
},
/**
* Remove the axis from the chart
*/
remove: function(redraw) {
var chart = this.chart,
key = this.coll, // xAxis or yAxis
axisSeries = this.series,
i = axisSeries.length;
// Remove associated series (#2687)
while (i--) {
if (axisSeries[i]) {
axisSeries[i].remove(false);
}
}
// Remove the axis
erase(chart.axes, this);
erase(chart[key], this);
chart.options[key].splice(this.options.index, 1);
each(chart[key], function(axis, i) { // Re-index, #1706
axis.options.index = i;
});
this.destroy();
chart.isDirtyBox = true;
if (pick(redraw, true)) {
chart.redraw();
}
},
/**
* Update the axis title by options
*/
setTitle: function(newTitleOptions, redraw) {
this.update({
title: newTitleOptions
}, redraw);
},
/**
* Set new axis categories and optionally redraw
* @param {Array} categories
* @param {Boolean} redraw
*/
setCategories: function(categories, redraw) {
this.update({
categories: categories
}, redraw);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var color = H.color,
each = H.each,
LegendSymbolMixin = H.LegendSymbolMixin,
map = H.map,
pick = H.pick,
Series = H.Series,
seriesType = H.seriesType;
/**
* Area series type.
* @constructor seriesTypes.area
* @extends {Series}
*/
seriesType('area', 'line', {
softThreshold: false,
threshold: 0
// trackByArea: false,
// lineColor: null, // overrides color, but lets fillColor be unaltered
// fillOpacity: 0.75,
// fillColor: null
}, /** @lends seriesTypes.area.prototype */ {
singleStacks: false,
/**
* Return an array of stacked points, where null and missing points are replaced by
* dummy points in order for gaps to be drawn correctly in stacks.
*/
getStackPoints: function() {
var series = this,
segment = [],
keys = [],
xAxis = this.xAxis,
yAxis = this.yAxis,
stack = yAxis.stacks[this.stackKey],
pointMap = {},
points = this.points,
seriesIndex = series.index,
yAxisSeries = yAxis.series,
seriesLength = yAxisSeries.length,
visibleSeries,
upOrDown = pick(yAxis.options.reversedStacks, true) ? 1 : -1,
i,
x;
if (this.options.stacking) {
// Create a map where we can quickly look up the points by their X value.
for (i = 0; i < points.length; i++) {
pointMap[points[i].x] = points[i];
}
// Sort the keys (#1651)
for (x in stack) {
if (stack[x].total !== null) { // nulled after switching between grouping and not (#1651, #2336)
keys.push(x);
}
}
keys.sort(function(a, b) {
return a - b;
});
visibleSeries = map(yAxisSeries, function() {
return this.visible;
});
each(keys, function(x, idx) {
var y = 0,
stackPoint,
stackedValues;
if (pointMap[x] && !pointMap[x].isNull) {
segment.push(pointMap[x]);
// Find left and right cliff. -1 goes left, 1 goes right.
each([-1, 1], function(direction) {
var nullName = direction === 1 ? 'rightNull' : 'leftNull',
cliffName = direction === 1 ? 'rightCliff' : 'leftCliff',
cliff = 0,
otherStack = stack[keys[idx + direction]];
// If there is a stack next to this one, to the left or to the right...
if (otherStack) {
i = seriesIndex;
while (i >= 0 && i < seriesLength) { // Can go either up or down, depending on reversedStacks
stackPoint = otherStack.points[i];
if (!stackPoint) {
// If the next point in this series is missing, mark the point
// with point.leftNull or point.rightNull = true.
if (i === seriesIndex) {
pointMap[x][nullName] = true;
// If there are missing points in the next stack in any of the
// series below this one, we need to substract the missing values
// and add a hiatus to the left or right.
} else if (visibleSeries[i]) {
stackedValues = stack[x].points[i];
if (stackedValues) {
cliff -= stackedValues[1] - stackedValues[0];
}
}
}
// When reversedStacks is true, loop up, else loop down
i += upOrDown;
}
}
pointMap[x][cliffName] = cliff;
});
// There is no point for this X value in this series, so we
// insert a dummy point in order for the areas to be drawn
// correctly.
} else {
// Loop down the stack to find the series below this one that has
// a value (#1991)
i = seriesIndex;
while (i >= 0 && i < seriesLength) {
stackPoint = stack[x].points[i];
if (stackPoint) {
y = stackPoint[1];
break;
}
// When reversedStacks is true, loop up, else loop down
i += upOrDown;
}
y = yAxis.translate(y, 0, 1, 0, 1); // #6272
segment.push({
isNull: true,
plotX: xAxis.translate(x, 0, 0, 0, 1), // #6272
x: x,
plotY: y,
yBottom: y
});
}
});
}
return segment;
},
getGraphPath: function(points) {
var getGraphPath = Series.prototype.getGraphPath,
graphPath,
options = this.options,
stacking = options.stacking,
yAxis = this.yAxis,
topPath,
//topPoints = [],
bottomPath,
bottomPoints = [],
graphPoints = [],
seriesIndex = this.index,
i,
areaPath,
plotX,
stacks = yAxis.stacks[this.stackKey],
threshold = options.threshold,
translatedThreshold = yAxis.getThreshold(options.threshold),
isNull,
yBottom,
connectNulls = options.connectNulls || stacking === 'percent',
/**
* To display null points in underlying stacked series, this series graph must be
* broken, and the area also fall down to fill the gap left by the null point. #2069
*/
addDummyPoints = function(i, otherI, side) {
var point = points[i],
stackedValues = stacking && stacks[point.x].points[seriesIndex],
nullVal = point[side + 'Null'] || 0,
cliffVal = point[side + 'Cliff'] || 0,
top,
bottom,
isNull = true;
if (cliffVal || nullVal) {
top = (nullVal ? stackedValues[0] : stackedValues[1]) + cliffVal;
bottom = stackedValues[0] + cliffVal;
isNull = !!nullVal;
} else if (!stacking && points[otherI] && points[otherI].isNull) {
top = bottom = threshold;
}
// Add to the top and bottom line of the area
if (top !== undefined) {
graphPoints.push({
plotX: plotX,
plotY: top === null ? translatedThreshold : yAxis.getThreshold(top),
isNull: isNull,
isCliff: true
});
bottomPoints.push({
plotX: plotX,
plotY: bottom === null ? translatedThreshold : yAxis.getThreshold(bottom),
doCurve: false // #1041, gaps in areaspline areas
});
}
};
// Find what points to use
points = points || this.points;
// Fill in missing points
if (stacking) {
points = this.getStackPoints();
}
for (i = 0; i < points.length; i++) {
isNull = points[i].isNull;
plotX = pick(points[i].rectPlotX, points[i].plotX);
yBottom = pick(points[i].yBottom, translatedThreshold);
if (!isNull || connectNulls) {
if (!connectNulls) {
addDummyPoints(i, i - 1, 'left');
}
if (!(isNull && !stacking && connectNulls)) { // Skip null point when stacking is false and connectNulls true
graphPoints.push(points[i]);
bottomPoints.push({
x: i,
plotX: plotX,
plotY: yBottom
});
}
if (!connectNulls) {
addDummyPoints(i, i + 1, 'right');
}
}
}
topPath = getGraphPath.call(this, graphPoints, true, true);
bottomPoints.reversed = true;
bottomPath = getGraphPath.call(this, bottomPoints, true, true);
if (bottomPath.length) {
bottomPath[0] = 'L';
}
areaPath = topPath.concat(bottomPath);
graphPath = getGraphPath.call(this, graphPoints, false, connectNulls); // TODO: don't set leftCliff and rightCliff when connectNulls?
areaPath.xMap = topPath.xMap;
this.areaPath = areaPath;
return graphPath;
},
/**
* Draw the graph and the underlying area. This method calls the Series base
* function and adds the area. The areaPath is calculated in the getSegmentPath
* method called from Series.prototype.drawGraph.
*/
drawGraph: function() {
// Define or reset areaPath
this.areaPath = [];
// Call the base method
Series.prototype.drawGraph.apply(this);
// Define local variables
var series = this,
areaPath = this.areaPath,
options = this.options,
zones = this.zones,
props = [
[
'area',
'highcharts-area',
this.color,
options.fillColor
]
]; // area name, main color, fill color
each(zones, function(zone, i) {
props.push([
'zone-area-' + i,
'highcharts-area highcharts-zone-area-' + i + ' ' + zone.className,
zone.color || series.color,
zone.fillColor || options.fillColor
]);
});
each(props, function(prop) {
var areaKey = prop[0],
area = series[areaKey];
// Create or update the area
if (area) { // update
area.endX = areaPath.xMap;
area.animate({
d: areaPath
});
} else { // create
area = series[areaKey] = series.chart.renderer.path(areaPath)
.addClass(prop[1])
.attr({
fill: pick(
prop[3],
color(prop[2]).setOpacity(pick(options.fillOpacity, 0.75)).get()
),
zIndex: 0 // #1069
}).add(series.group);
area.isArea = true;
}
area.startX = areaPath.xMap;
area.shiftUnit = options.step ? 2 : 1;
});
},
drawLegendSymbol: LegendSymbolMixin.drawRectangle
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var pick = H.pick,
seriesType = H.seriesType;
/**
* Spline series type.
* @constructor seriesTypes.spline
* @extends {Series}
*/
seriesType('spline', 'line', {}, /** @lends seriesTypes.spline.prototype */ {
/**
* Get the spline segment from a given point's previous neighbour to the given point
*/
getPointSpline: function(points, point, i) {
var smoothing = 1.5, // 1 means control points midway between points, 2 means 1/3 from the point, 3 is 1/4 etc
denom = smoothing + 1,
plotX = point.plotX,
plotY = point.plotY,
lastPoint = points[i - 1],
nextPoint = points[i + 1],
leftContX,
leftContY,
rightContX,
rightContY,
ret;
function doCurve(otherPoint) {
return otherPoint &&
!otherPoint.isNull &&
otherPoint.doCurve !== false &&
!point.isCliff; // #6387, area splines next to null
}
// Find control points
if (doCurve(lastPoint) && doCurve(nextPoint)) {
var lastX = lastPoint.plotX,
lastY = lastPoint.plotY,
nextX = nextPoint.plotX,
nextY = nextPoint.plotY,
correction = 0;
leftContX = (smoothing * plotX + lastX) / denom;
leftContY = (smoothing * plotY + lastY) / denom;
rightContX = (smoothing * plotX + nextX) / denom;
rightContY = (smoothing * plotY + nextY) / denom;
// Have the two control points make a straight line through main point
if (rightContX !== leftContX) { // #5016, division by zero
correction = ((rightContY - leftContY) * (rightContX - plotX)) /
(rightContX - leftContX) + plotY - rightContY;
}
leftContY += correction;
rightContY += correction;
// to prevent false extremes, check that control points are between
// neighbouring points' y values
if (leftContY > lastY && leftContY > plotY) {
leftContY = Math.max(lastY, plotY);
rightContY = 2 * plotY - leftContY; // mirror of left control point
} else if (leftContY < lastY && leftContY < plotY) {
leftContY = Math.min(lastY, plotY);
rightContY = 2 * plotY - leftContY;
}
if (rightContY > nextY && rightContY > plotY) {
rightContY = Math.max(nextY, plotY);
leftContY = 2 * plotY - rightContY;
} else if (rightContY < nextY && rightContY < plotY) {
rightContY = Math.min(nextY, plotY);
leftContY = 2 * plotY - rightContY;
}
// record for drawing in next point
point.rightContX = rightContX;
point.rightContY = rightContY;
}
// Visualize control points for debugging
/*
if (leftContX) {
this.chart.renderer.circle(leftContX + this.chart.plotLeft, leftContY + this.chart.plotTop, 2)
.attr({
stroke: 'red',
'stroke-width': 2,
fill: 'none',
zIndex: 9
})
.add();
this.chart.renderer.path(['M', leftContX + this.chart.plotLeft, leftContY + this.chart.plotTop,
'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
.attr({
stroke: 'red',
'stroke-width': 2,
zIndex: 9
})
.add();
}
if (rightContX) {
this.chart.renderer.circle(rightContX + this.chart.plotLeft, rightContY + this.chart.plotTop, 2)
.attr({
stroke: 'green',
'stroke-width': 2,
fill: 'none',
zIndex: 9
})
.add();
this.chart.renderer.path(['M', rightContX + this.chart.plotLeft, rightContY + this.chart.plotTop,
'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
.attr({
stroke: 'green',
'stroke-width': 2,
zIndex: 9
})
.add();
}
// */
ret = [
'C',
pick(lastPoint.rightContX, lastPoint.plotX),
pick(lastPoint.rightContY, lastPoint.plotY),
pick(leftContX, plotX),
pick(leftContY, plotY),
plotX,
plotY
];
lastPoint.rightContX = lastPoint.rightContY = null; // reset for updating series later
return ret;
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var areaProto = H.seriesTypes.area.prototype,
defaultPlotOptions = H.defaultPlotOptions,
LegendSymbolMixin = H.LegendSymbolMixin,
seriesType = H.seriesType;
/**
* AreaSplineSeries object
*/
seriesType('areaspline', 'spline', defaultPlotOptions.area, {
getStackPoints: areaProto.getStackPoints,
getGraphPath: areaProto.getGraphPath,
setStackCliffs: areaProto.setStackCliffs,
drawGraph: areaProto.drawGraph,
drawLegendSymbol: LegendSymbolMixin.drawRectangle
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var animObject = H.animObject,
color = H.color,
each = H.each,
extend = H.extend,
isNumber = H.isNumber,
LegendSymbolMixin = H.LegendSymbolMixin,
merge = H.merge,
noop = H.noop,
pick = H.pick,
Series = H.Series,
seriesType = H.seriesType,
svg = H.svg;
/**
* The column series type.
*
* @constructor seriesTypes.column
* @augments Series
*/
seriesType('column', 'line', {
borderRadius: 0,
//colorByPoint: undefined,
crisp: true,
groupPadding: 0.2,
//grouping: true,
marker: null, // point options are specified in the base options
pointPadding: 0.1,
//pointWidth: null,
minPointLength: 0,
cropThreshold: 50, // when there are more points, they will not animate out of the chart on xAxis.setExtremes
pointRange: null, // null means auto, meaning 1 in a categorized axis and least distance between points if not categories
states: {
hover: {
halo: false,
brightness: 0.1,
shadow: false
},
select: {
color: '#cccccc',
borderColor: '#000000',
shadow: false
}
},
dataLabels: {
align: null, // auto
verticalAlign: null, // auto
y: null
},
softThreshold: false,
startFromThreshold: true, // false doesn't work well: http://jsfiddle.net/highcharts/hz8fopan/14/
stickyTracking: false,
tooltip: {
distance: 6
},
threshold: 0,
borderColor: '#ffffff'
// borderWidth: 1
}, /** @lends seriesTypes.column.prototype */ {
cropShoulder: 0,
directTouch: true, // When tooltip is not shared, this series (and derivatives) requires direct touch/hover. KD-tree does not apply.
trackerGroups: ['group', 'dataLabelsGroup'],
negStacks: true, // use separate negative stacks, unlike area stacks where a negative
// point is substracted from previous (#1910)
/**
* Initialize the series. Extends the basic Series.init method by
* marking other series of the same type as dirty.
*
* @function #init
* @memberOf seriesTypes.column
* @returns {void}
*/
init: function() {
Series.prototype.init.apply(this, arguments);
var series = this,
chart = series.chart;
// if the series is added dynamically, force redraw of other
// series affected by a new column
if (chart.hasRendered) {
each(chart.series, function(otherSeries) {
if (otherSeries.type === series.type) {
otherSeries.isDirty = true;
}
});
}
},
/**
* Return the width and x offset of the columns adjusted for grouping, groupPadding, pointPadding,
* pointWidth etc.
*/
getColumnMetrics: function() {
var series = this,
options = series.options,
xAxis = series.xAxis,
yAxis = series.yAxis,
reversedXAxis = xAxis.reversed,
stackKey,
stackGroups = {},
columnCount = 0;
// Get the total number of column type series.
// This is called on every series. Consider moving this logic to a
// chart.orderStacks() function and call it on init, addSeries and removeSeries
if (options.grouping === false) {
columnCount = 1;
} else {
each(series.chart.series, function(otherSeries) {
var otherOptions = otherSeries.options,
otherYAxis = otherSeries.yAxis,
columnIndex;
if (otherSeries.type === series.type && otherSeries.visible &&
yAxis.len === otherYAxis.len && yAxis.pos === otherYAxis.pos) { // #642, #2086
if (otherOptions.stacking) {
stackKey = otherSeries.stackKey;
if (stackGroups[stackKey] === undefined) {
stackGroups[stackKey] = columnCount++;
}
columnIndex = stackGroups[stackKey];
} else if (otherOptions.grouping !== false) { // #1162
columnIndex = columnCount++;
}
otherSeries.columnIndex = columnIndex;
}
});
}
var categoryWidth = Math.min(
Math.abs(xAxis.transA) * (xAxis.ordinalSlope || options.pointRange || xAxis.closestPointRange || xAxis.tickInterval || 1), // #2610
xAxis.len // #1535
),
groupPadding = categoryWidth * options.groupPadding,
groupWidth = categoryWidth - 2 * groupPadding,
pointOffsetWidth = groupWidth / (columnCount || 1),
pointWidth = Math.min(
options.maxPointWidth || xAxis.len,
pick(options.pointWidth, pointOffsetWidth * (1 - 2 * options.pointPadding))
),
pointPadding = (pointOffsetWidth - pointWidth) / 2,
colIndex = (series.columnIndex || 0) + (reversedXAxis ? 1 : 0), // #1251, #3737
pointXOffset = pointPadding + (groupPadding + colIndex *
pointOffsetWidth - (categoryWidth / 2)) *
(reversedXAxis ? -1 : 1);
// Save it for reading in linked series (Error bars particularly)
series.columnMetrics = {
width: pointWidth,
offset: pointXOffset
};
return series.columnMetrics;
},
/**
* Make the columns crisp. The edges are rounded to the nearest full pixel.
*/
crispCol: function(x, y, w, h) {
var chart = this.chart,
borderWidth = this.borderWidth,
xCrisp = -(borderWidth % 2 ? 0.5 : 0),
yCrisp = borderWidth % 2 ? 0.5 : 1,
right,
bottom,
fromTop;
if (chart.inverted && chart.renderer.isVML) {
yCrisp += 1;
}
// Horizontal. We need to first compute the exact right edge, then round it
// and compute the width from there.
if (this.options.crisp) {
right = Math.round(x + w) + xCrisp;
x = Math.round(x) + xCrisp;
w = right - x;
}
// Vertical
bottom = Math.round(y + h) + yCrisp;
fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
y = Math.round(y) + yCrisp;
h = bottom - y;
// Top edges are exceptions
if (fromTop && h) { // #5146
y -= 1;
h += 1;
}
return {
x: x,
y: y,
width: w,
height: h
};
},
/**
* Translate each point to the plot area coordinate system and find shape positions
*/
translate: function() {
var series = this,
chart = series.chart,
options = series.options,
dense = series.dense = series.closestPointRange * series.xAxis.transA < 2,
borderWidth = series.borderWidth = pick(
options.borderWidth,
dense ? 0 : 1 // #3635
),
yAxis = series.yAxis,
threshold = options.threshold,
translatedThreshold = series.translatedThreshold = yAxis.getThreshold(threshold),
minPointLength = pick(options.minPointLength, 5),
metrics = series.getColumnMetrics(),
pointWidth = metrics.width,
seriesBarW = series.barW = Math.max(pointWidth, 1 + 2 * borderWidth), // postprocessed for border width
pointXOffset = series.pointXOffset = metrics.offset;
if (chart.inverted) {
translatedThreshold -= 0.5; // #3355
}
// When the pointPadding is 0, we want the columns to be packed tightly, so we allow individual
// columns to have individual sizes. When pointPadding is greater, we strive for equal-width
// columns (#2694).
if (options.pointPadding) {
seriesBarW = Math.ceil(seriesBarW);
}
Series.prototype.translate.apply(series);
// Record the new values
each(series.points, function(point) {
var yBottom = pick(point.yBottom, translatedThreshold),
safeDistance = 999 + Math.abs(yBottom),
plotY = Math.min(Math.max(-safeDistance, point.plotY), yAxis.len + safeDistance), // Don't draw too far outside plot area (#1303, #2241, #4264)
barX = point.plotX + pointXOffset,
barW = seriesBarW,
barY = Math.min(plotY, yBottom),
up,
barH = Math.max(plotY, yBottom) - barY;
// Handle options.minPointLength
if (Math.abs(barH) < minPointLength) {
if (minPointLength) {
barH = minPointLength;
up = (!yAxis.reversed && !point.negative) || (yAxis.reversed && point.negative);
barY = Math.abs(barY - translatedThreshold) > minPointLength ? // stacked
yBottom - minPointLength : // keep position
translatedThreshold - (up ? minPointLength : 0); // #1485, #4051
}
}
// Cache for access in polar
point.barX = barX;
point.pointWidth = pointWidth;
// Fix the tooltip on center of grouped columns (#1216, #424, #3648)
point.tooltipPos = chart.inverted ? [yAxis.len + yAxis.pos - chart.plotLeft - plotY, series.xAxis.len - barX - barW / 2, barH] : [barX + barW / 2, plotY + yAxis.pos - chart.plotTop, barH];
// Register shape type and arguments to be used in drawPoints
point.shapeType = 'rect';
point.shapeArgs = series.crispCol.apply(
series,
point.isNull ? [point.plotX, yAxis.len / 2, 0, 0] : // #3169, drilldown from null must have a position to work from
[barX, barY, barW, barH]
);
});
},
getSymbol: noop,
/**
* Use a solid rectangle like the area series types
*/
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
/**
* Columns have no graph
*/
drawGraph: function() {
this.group[this.dense ? 'addClass' : 'removeClass']('highcharts-dense-data');
},
/**
* Get presentational attributes
*/
pointAttribs: function(point, state) {
var options = this.options,
stateOptions,
ret,
p2o = this.pointAttrToOptions || {},
strokeOption = p2o.stroke || 'borderColor',
strokeWidthOption = p2o['stroke-width'] || 'borderWidth',
fill = (point && point.color) || this.color,
stroke = point[strokeOption] || options[strokeOption] ||
this.color || fill, // set to fill when borderColor null
strokeWidth = point[strokeWidthOption] ||
options[strokeWidthOption] || this[strokeWidthOption] || 0,
dashstyle = options.dashStyle,
zone,
brightness;
// Handle zone colors
if (point && this.zones.length) {
zone = point.getZone();
fill = (zone && zone.color) || point.options.color || this.color; // When zones are present, don't use point.color (#4267)
}
// Select or hover states
if (state) {
stateOptions = merge(
options.states[state],
point.options.states && point.options.states[state] || {} // #6401
);
brightness = stateOptions.brightness;
fill = stateOptions.color ||
(brightness !== undefined && color(fill).brighten(stateOptions.brightness).get()) ||
fill;
stroke = stateOptions[strokeOption] || stroke;
strokeWidth = stateOptions[strokeWidthOption] || strokeWidth;
dashstyle = stateOptions.dashStyle || dashstyle;
}
ret = {
'fill': fill,
'stroke': stroke,
'stroke-width': strokeWidth
};
if (options.borderRadius) {
ret.r = options.borderRadius;
}
if (dashstyle) {
ret.dashstyle = dashstyle;
}
return ret;
},
/**
* Draw the columns. For bars, the series.group is rotated, so the same coordinates
* apply for columns and bars. This method is inherited by scatter series.
*
*/
drawPoints: function() {
var series = this,
chart = this.chart,
options = series.options,
renderer = chart.renderer,
animationLimit = options.animationLimit || 250,
shapeArgs;
// draw the columns
each(series.points, function(point) {
var plotY = point.plotY,
graphic = point.graphic;
if (isNumber(plotY) && point.y !== null) {
shapeArgs = point.shapeArgs;
if (graphic) { // update
graphic[chart.pointCount < animationLimit ? 'animate' : 'attr'](
merge(shapeArgs)
);
} else {
point.graphic = graphic = renderer[point.shapeType](shapeArgs)
.add(point.group || series.group);
}
// Presentational
graphic
.attr(series.pointAttribs(point, point.selected && 'select'))
.shadow(options.shadow, null, options.stacking && !options.borderRadius);
graphic.addClass(point.getClassName(), true);
} else if (graphic) {
point.graphic = graphic.destroy(); // #1269
}
});
},
/**
* Animate the column heights one by one from zero
* @param {Boolean} init Whether to initialize the animation or run it
*/
animate: function(init) {
var series = this,
yAxis = this.yAxis,
options = series.options,
inverted = this.chart.inverted,
attr = {},
translatedThreshold;
if (svg) { // VML is too slow anyway
if (init) {
attr.scaleY = 0.001;
translatedThreshold = Math.min(yAxis.pos + yAxis.len, Math.max(yAxis.pos, yAxis.toPixels(options.threshold)));
if (inverted) {
attr.translateX = translatedThreshold - yAxis.len;
} else {
attr.translateY = translatedThreshold;
}
series.group.attr(attr);
} else { // run the animation
attr[inverted ? 'translateX' : 'translateY'] = yAxis.pos;
series.group.animate(attr, extend(animObject(series.options.animation), {
// Do the scale synchronously to ensure smooth updating (#5030)
step: function(val, fx) {
series.group.attr({
scaleY: Math.max(0.001, fx.pos) // #5250
});
}
}));
// delete this function to allow it only once
series.animate = null;
}
}
},
/**
* Remove this series from the chart
*/
remove: function() {
var series = this,
chart = series.chart;
// column and bar series affects other series of the same type
// as they are either stacked or grouped
if (chart.hasRendered) {
each(chart.series, function(otherSeries) {
if (otherSeries.type === series.type) {
otherSeries.isDirty = true;
}
});
}
Series.prototype.remove.apply(series, arguments);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var seriesType = H.seriesType;
/**
* The Bar series class
*/
seriesType('bar', 'column', null, {
inverted: true
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Series = H.Series,
seriesType = H.seriesType;
/**
* The scatter series type
*/
seriesType('scatter', 'line', {
lineWidth: 0,
findNearestPointBy: 'xy',
marker: {
enabled: true // Overrides auto-enabling in line series (#3647)
},
tooltip: {
headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
'<span style="font-size: 0.85em"> {series.name}</span><br/>',
pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
}
// Prototype members
}, {
sorted: false,
requireSorting: false,
noSharedTooltip: true,
trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
takeOrdinalPosition: false, // #2342
drawGraph: function() {
if (this.options.lineWidth) {
Series.prototype.drawGraph.call(this);
}
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var pick = H.pick,
relativeLength = H.relativeLength;
H.CenteredSeriesMixin = {
/**
* Get the center of the pie based on the size and center options relative to the
* plot area. Borrowed by the polar and gauge series types.
*/
getCenter: function() {
var options = this.options,
chart = this.chart,
slicingRoom = 2 * (options.slicedOffset || 0),
handleSlicingRoom,
plotWidth = chart.plotWidth - 2 * slicingRoom,
plotHeight = chart.plotHeight - 2 * slicingRoom,
centerOption = options.center,
positions = [pick(centerOption[0], '50%'), pick(centerOption[1], '50%'), options.size || '100%', options.innerSize || 0],
smallestSize = Math.min(plotWidth, plotHeight),
i,
value;
for (i = 0; i < 4; ++i) {
value = positions[i];
handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value));
// i == 0: centerX, relative to width
// i == 1: centerY, relative to height
// i == 2: size, relative to smallestSize
// i == 3: innerSize, relative to size
positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) +
(handleSlicingRoom ? slicingRoom : 0);
}
// innerSize cannot be larger than size (#3632)
if (positions[3] > positions[2]) {
positions[3] = positions[2];
}
return positions;
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
CenteredSeriesMixin = H.CenteredSeriesMixin,
defined = H.defined,
each = H.each,
extend = H.extend,
inArray = H.inArray,
LegendSymbolMixin = H.LegendSymbolMixin,
noop = H.noop,
pick = H.pick,
Point = H.Point,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes,
setAnimation = H.setAnimation;
/**
* The pie series type.
*
* @constructor seriesTypes.pie
* @augments Series
*/
seriesType('pie', 'line', {
center: [null, null],
clip: false,
colorByPoint: true, // always true for pies
dataLabels: {
// align: null,
// connectorWidth: 1,
// connectorColor: point.color,
// connectorPadding: 5,
distance: 30,
enabled: true,
formatter: function() { // #2945
return this.y === null ? undefined : this.point.name;
},
// softConnector: true,
x: 0
// y: 0
},
ignoreHiddenPoint: true,
//innerSize: 0,
legendType: 'point',
marker: null, // point options are specified in the base options
size: null,
showInLegend: false,
slicedOffset: 10,
stickyTracking: false,
tooltip: {
followPointer: true
},
borderColor: '#ffffff',
borderWidth: 1,
states: {
hover: {
brightness: 0.1,
shadow: false
}
}
}, /** @lends seriesTypes.pie.prototype */ {
isCartesian: false,
requireSorting: false,
directTouch: true,
noSharedTooltip: true,
trackerGroups: ['group', 'dataLabelsGroup'],
axisTypes: [],
pointAttribs: seriesTypes.column.prototype.pointAttribs,
/**
* Animate the pies in
*/
animate: function(init) {
var series = this,
points = series.points,
startAngleRad = series.startAngleRad;
if (!init) {
each(points, function(point) {
var graphic = point.graphic,
args = point.shapeArgs;
if (graphic) {
// start values
graphic.attr({
r: point.startR || (series.center[3] / 2), // animate from inner radius (#779)
start: startAngleRad,
end: startAngleRad
});
// animate
graphic.animate({
r: args.r,
start: args.start,
end: args.end
}, series.options.animation);
}
});
// delete this function to allow it only once
series.animate = null;
}
},
/**
* Recompute total chart sum and update percentages of points.
*/
updateTotals: function() {
var i,
total = 0,
points = this.points,
len = points.length,
point,
ignoreHiddenPoint = this.options.ignoreHiddenPoint;
// Get the total sum
for (i = 0; i < len; i++) {
point = points[i];
// Disallow negative values (#1530, #3623, #5322)
if (point.y < 0) {
point.y = null;
}
total += (ignoreHiddenPoint && !point.visible) ? 0 : point.y;
}
this.total = total;
// Set each point's properties
for (i = 0; i < len; i++) {
point = points[i];
point.percentage = (total > 0 && (point.visible || !ignoreHiddenPoint)) ? point.y / total * 100 : 0;
point.total = total;
}
},
/**
* Extend the generatePoints method by adding total and percentage properties to each point
*/
generatePoints: function() {
Series.prototype.generatePoints.call(this);
this.updateTotals();
},
/**
* Do translation for pie slices
*/
translate: function(positions) {
this.generatePoints();
var series = this,
cumulative = 0,
precision = 1000, // issue #172
options = series.options,
slicedOffset = options.slicedOffset,
connectorOffset = slicedOffset + (options.borderWidth || 0),
start,
end,
angle,
startAngle = options.startAngle || 0,
startAngleRad = series.startAngleRad = Math.PI / 180 * (startAngle - 90),
endAngleRad = series.endAngleRad = Math.PI / 180 * ((pick(options.endAngle, startAngle + 360)) - 90),
circ = endAngleRad - startAngleRad, //2 * Math.PI,
points = series.points,
radiusX, // the x component of the radius vector for a given point
radiusY,
labelDistance = options.dataLabels.distance,
ignoreHiddenPoint = options.ignoreHiddenPoint,
i,
len = points.length,
point;
// Get positions - either an integer or a percentage string must be given.
// If positions are passed as a parameter, we're in a recursive loop for adjusting
// space for data labels.
if (!positions) {
series.center = positions = series.getCenter();
}
// utility for getting the x value from a given y, used for anticollision logic in data labels
series.getX = function(y, left) {
angle = Math.asin(Math.min((y - positions[1]) / (positions[2] / 2 + labelDistance), 1));
return positions[0] +
(left ? -1 : 1) *
(Math.cos(angle) * (positions[2] / 2 + labelDistance));
};
// Calculate the geometry for each point
for (i = 0; i < len; i++) {
point = points[i];
// set start and end angle
start = startAngleRad + (cumulative * circ);
if (!ignoreHiddenPoint || point.visible) {
cumulative += point.percentage / 100;
}
end = startAngleRad + (cumulative * circ);
// set the shape
point.shapeType = 'arc';
point.shapeArgs = {
x: positions[0],
y: positions[1],
r: positions[2] / 2,
innerR: positions[3] / 2,
start: Math.round(start * precision) / precision,
end: Math.round(end * precision) / precision
};
// The angle must stay within -90 and 270 (#2645)
angle = (end + start) / 2;
if (angle > 1.5 * Math.PI) {
angle -= 2 * Math.PI;
} else if (angle < -Math.PI / 2) {
angle += 2 * Math.PI;
}
// Center for the sliced out slice
point.slicedTranslation = {
translateX: Math.round(Math.cos(angle) * slicedOffset),
translateY: Math.round(Math.sin(angle) * slicedOffset)
};
// set the anchor point for tooltips
radiusX = Math.cos(angle) * positions[2] / 2;
radiusY = Math.sin(angle) * positions[2] / 2;
point.tooltipPos = [
positions[0] + radiusX * 0.7,
positions[1] + radiusY * 0.7
];
point.half = angle < -Math.PI / 2 || angle > Math.PI / 2 ? 1 : 0;
point.angle = angle;
// set the anchor point for data labels
connectorOffset = Math.min(connectorOffset, labelDistance / 5); // #1678
point.labelPos = [
positions[0] + radiusX + Math.cos(angle) * labelDistance, // first break of connector
positions[1] + radiusY + Math.sin(angle) * labelDistance, // a/a
positions[0] + radiusX + Math.cos(angle) * connectorOffset, // second break, right outside pie
positions[1] + radiusY + Math.sin(angle) * connectorOffset, // a/a
positions[0] + radiusX, // landing point for connector
positions[1] + radiusY, // a/a
labelDistance < 0 ? // alignment
'center' :
point.half ? 'right' : 'left', // alignment
angle // center angle
];
}
},
drawGraph: null,
/**
* Draw the data points
*/
drawPoints: function() {
var series = this,
chart = series.chart,
renderer = chart.renderer,
groupTranslation,
//center,
graphic,
//group,
pointAttr,
shapeArgs;
var shadow = series.options.shadow;
if (shadow && !series.shadowGroup) {
series.shadowGroup = renderer.g('shadow')
.add(series.group);
}
// draw the slices
each(series.points, function(point) {
if (point.y !== null) {
graphic = point.graphic;
shapeArgs = point.shapeArgs;
// If the point is sliced, use special translation, else use
// plot area traslation
groupTranslation = point.getTranslate();
// Put the shadow behind all points
var shadowGroup = point.shadowGroup;
if (shadow && !shadowGroup) {
shadowGroup = point.shadowGroup = renderer.g('shadow')
.add(series.shadowGroup);
}
if (shadowGroup) {
shadowGroup.attr(groupTranslation);
}
pointAttr = series.pointAttribs(point, point.selected && 'select');
// Draw the slice
if (graphic) {
graphic
.setRadialReference(series.center)
.attr(pointAttr)
.animate(extend(shapeArgs, groupTranslation));
} else {
point.graphic = graphic = renderer[point.shapeType](shapeArgs)
.setRadialReference(series.center)
.attr(groupTranslation)
.add(series.group);
if (!point.visible) {
graphic.attr({
visibility: 'hidden'
});
}
graphic
.attr(pointAttr)
.attr({
'stroke-linejoin': 'round'
})
.shadow(shadow, shadowGroup);
}
graphic.addClass(point.getClassName());
}
});
},
searchPoint: noop,
/**
* Utility for sorting data labels
*/
sortByAngle: function(points, sign) {
points.sort(function(a, b) {
return a.angle !== undefined && (b.angle - a.angle) * sign;
});
},
/**
* Use a simple symbol from LegendSymbolMixin
*/
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
/**
* Use the getCenter method from drawLegendSymbol
*/
getCenter: CenteredSeriesMixin.getCenter,
/**
* Pies don't have point marker symbols
*/
getSymbol: noop
/**
* @constructor seriesTypes.pie.prototype.pointClass
* @extends {Point}
*/
}, /** @lends seriesTypes.pie.prototype.pointClass.prototype */ {
/**
* Initiate the pie slice
*/
init: function() {
Point.prototype.init.apply(this, arguments);
var point = this,
toggleSlice;
point.name = pick(point.name, 'Slice');
// add event listener for select
toggleSlice = function(e) {
point.slice(e.type === 'select');
};
addEvent(point, 'select', toggleSlice);
addEvent(point, 'unselect', toggleSlice);
return point;
},
/**
* Toggle the visibility of the pie slice
* @param {Boolean} vis Whether to show the slice or not. If undefined, the
* visibility is toggled
*/
setVisible: function(vis, redraw) {
var point = this,
series = point.series,
chart = series.chart,
ignoreHiddenPoint = series.options.ignoreHiddenPoint;
redraw = pick(redraw, ignoreHiddenPoint);
if (vis !== point.visible) {
// If called without an argument, toggle visibility
point.visible = point.options.visible = vis = vis === undefined ? !point.visible : vis;
series.options.data[inArray(point, series.data)] = point.options; // update userOptions.data
// Show and hide associated elements. This is performed regardless of redraw or not,
// because chart.redraw only handles full series.
each(['graphic', 'dataLabel', 'connector', 'shadowGroup'], function(key) {
if (point[key]) {
point[key][vis ? 'show' : 'hide'](true);
}
});
if (point.legendItem) {
chart.legend.colorizeItem(point, vis);
}
// #4170, hide halo after hiding point
if (!vis && point.state === 'hover') {
point.setState('');
}
// Handle ignore hidden slices
if (ignoreHiddenPoint) {
series.isDirty = true;
}
if (redraw) {
chart.redraw();
}
}
},
/**
* Set or toggle whether the slice is cut out from the pie
* @param {Boolean} sliced When undefined, the slice state is toggled
* @param {Boolean} redraw Whether to redraw the chart. True by default.
*/
slice: function(sliced, redraw, animation) {
var point = this,
series = point.series,
chart = series.chart;
setAnimation(animation, chart);
// redraw is true by default
redraw = pick(redraw, true);
// if called without an argument, toggle
point.sliced = point.options.sliced = sliced = defined(sliced) ? sliced : !point.sliced;
series.options.data[inArray(point, series.data)] = point.options; // update userOptions.data
point.graphic.animate(this.getTranslate());
if (point.shadowGroup) {
point.shadowGroup.animate(this.getTranslate());
}
},
getTranslate: function() {
return this.sliced ? this.slicedTranslation : {
translateX: 0,
translateY: 0
};
},
haloPath: function(size) {
var shapeArgs = this.shapeArgs;
return this.sliced || !this.visible ? [] :
this.series.chart.renderer.symbols.arc(
shapeArgs.x,
shapeArgs.y,
shapeArgs.r + size,
shapeArgs.r + size, {
innerR: this.shapeArgs.r,
start: shapeArgs.start,
end: shapeArgs.end
}
);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
arrayMax = H.arrayMax,
defined = H.defined,
each = H.each,
extend = H.extend,
format = H.format,
map = H.map,
merge = H.merge,
noop = H.noop,
pick = H.pick,
relativeLength = H.relativeLength,
Series = H.Series,
seriesTypes = H.seriesTypes,
stableSort = H.stableSort;
/**
* Generatl distribution algorithm for distributing labels of differing size along a
* confined length in two dimensions. The algorithm takes an array of objects containing
* a size, a target and a rank. It will place the labels as close as possible to their
* targets, skipping the lowest ranked labels if necessary.
*/
H.distribute = function(boxes, len) {
var i,
overlapping = true,
origBoxes = boxes, // Original array will be altered with added .pos
restBoxes = [], // The outranked overshoot
box,
target,
total = 0;
function sortByTarget(a, b) {
return a.target - b.target;
}
// If the total size exceeds the len, remove those boxes with the lowest rank
i = boxes.length;
while (i--) {
total += boxes[i].size;
}
// Sort by rank, then slice away overshoot
if (total > len) {
stableSort(boxes, function(a, b) {
return (b.rank || 0) - (a.rank || 0);
});
i = 0;
total = 0;
while (total <= len) {
total += boxes[i].size;
i++;
}
restBoxes = boxes.splice(i - 1, boxes.length);
}
// Order by target
stableSort(boxes, sortByTarget);
// So far we have been mutating the original array. Now
// create a copy with target arrays
boxes = map(boxes, function(box) {
return {
size: box.size,
targets: [box.target]
};
});
while (overlapping) {
// Initial positions: target centered in box
i = boxes.length;
while (i--) {
box = boxes[i];
// Composite box, average of targets
target = (Math.min.apply(0, box.targets) + Math.max.apply(0, box.targets)) / 2;
box.pos = Math.min(Math.max(0, target - box.size / 2), len - box.size);
}
// Detect overlap and join boxes
i = boxes.length;
overlapping = false;
while (i--) {
if (i > 0 && boxes[i - 1].pos + boxes[i - 1].size > boxes[i].pos) { // Overlap
boxes[i - 1].size += boxes[i].size; // Add this size to the previous box
boxes[i - 1].targets = boxes[i - 1].targets.concat(boxes[i].targets);
// Overlapping right, push left
if (boxes[i - 1].pos + boxes[i - 1].size > len) {
boxes[i - 1].pos = len - boxes[i - 1].size;
}
boxes.splice(i, 1); // Remove this item
overlapping = true;
}
}
}
// Now the composite boxes are placed, we need to put the original boxes within them
i = 0;
each(boxes, function(box) {
var posInCompositeBox = 0;
each(box.targets, function() {
origBoxes[i].pos = box.pos + posInCompositeBox;
posInCompositeBox += origBoxes[i].size;
i++;
});
});
// Add the rest (hidden) boxes and sort by target
origBoxes.push.apply(origBoxes, restBoxes);
stableSort(origBoxes, sortByTarget);
};
/**
* Draw the data labels
*/
Series.prototype.drawDataLabels = function() {
var series = this,
seriesOptions = series.options,
options = seriesOptions.dataLabels,
points = series.points,
pointOptions,
generalOptions,
hasRendered = series.hasRendered || 0,
str,
dataLabelsGroup,
defer = pick(options.defer, true),
renderer = series.chart.renderer;
if (options.enabled || series._hasPointLabels) {
// Process default alignment of data labels for columns
if (series.dlProcessOptions) {
series.dlProcessOptions(options);
}
// Create a separate group for the data labels to avoid rotation
dataLabelsGroup = series.plotGroup(
'dataLabelsGroup',
'data-labels',
defer && !hasRendered ? 'hidden' : 'visible', // #5133
options.zIndex || 6
);
if (defer) {
dataLabelsGroup.attr({
opacity: +hasRendered
}); // #3300
if (!hasRendered) {
addEvent(series, 'afterAnimate', function() {
if (series.visible) { // #2597, #3023, #3024
dataLabelsGroup.show(true);
}
dataLabelsGroup[seriesOptions.animation ? 'animate' : 'attr']({
opacity: 1
}, {
duration: 200
});
});
}
}
// Make the labels for each point
generalOptions = options;
each(points, function(point) {
var enabled,
dataLabel = point.dataLabel,
labelConfig,
attr,
name,
rotation,
connector = point.connector,
isNew = !dataLabel,
style;
// Determine if each data label is enabled
// @note dataLabelAttribs (like pointAttribs) would eradicate
// the need for dlOptions, and simplify the section below.
pointOptions = point.dlOptions || (point.options && point.options.dataLabels); // dlOptions is used in treemaps
enabled = pick(pointOptions && pointOptions.enabled, generalOptions.enabled) && point.y !== null; // #2282, #4641
if (enabled) {
// Create individual options structure that can be extended without
// affecting others
options = merge(generalOptions, pointOptions);
labelConfig = point.getLabelConfig();
str = options.format ?
format(options.format, labelConfig) :
options.formatter.call(labelConfig, options);
style = options.style;
rotation = options.rotation;
// Determine the color
style.color = pick(options.color, style.color, series.color, '#000000');
// Get automated contrast color
if (style.color === 'contrast') {
point.contrastColor = renderer.getContrast(point.color || series.color);
style.color = options.inside || options.distance < 0 || !!seriesOptions.stacking ?
point.contrastColor : '#000000';
}
if (seriesOptions.cursor) {
style.cursor = seriesOptions.cursor;
}
attr = {
//align: align,
fill: options.backgroundColor,
stroke: options.borderColor,
'stroke-width': options.borderWidth,
r: options.borderRadius || 0,
rotation: rotation,
padding: options.padding,
zIndex: 1
};
// Remove unused attributes (#947)
for (name in attr) {
if (attr[name] === undefined) {
delete attr[name];
}
}
}
// If the point is outside the plot area, destroy it. #678, #820
if (dataLabel && (!enabled || !defined(str))) {
point.dataLabel = dataLabel = dataLabel.destroy();
if (connector) {
point.connector = connector.destroy();
}
// Individual labels are disabled if the are explicitly disabled
// in the point options, or if they fall outside the plot area.
} else if (enabled && defined(str)) {
// create new label
if (!dataLabel) {
dataLabel = point.dataLabel = renderer[rotation ? 'text' : 'label']( // labels don't support rotation
str,
0, -9999,
options.shape,
null,
null,
options.useHTML,
null,
'data-label'
);
dataLabel.addClass(
'highcharts-data-label-color-' + point.colorIndex +
' ' + (options.className || '') +
(options.useHTML ? 'highcharts-tracker' : '') // #3398
);
} else {
attr.text = str;
}
dataLabel.attr(attr);
// Styles must be applied before add in order to read text bounding box
dataLabel.css(style).shadow(options.shadow);
if (!dataLabel.added) {
dataLabel.add(dataLabelsGroup);
}
// Now the data label is created and placed at 0,0, so we need to align it
series.alignDataLabel(point, dataLabel, options, null, isNew);
}
});
}
};
/**
* Align each individual data label
*/
Series.prototype.alignDataLabel = function(point, dataLabel, options, alignTo, isNew) {
var chart = this.chart,
inverted = chart.inverted,
plotX = pick(point.plotX, -9999),
plotY = pick(point.plotY, -9999),
bBox = dataLabel.getBBox(),
fontSize,
baseline,
rotation = options.rotation,
normRotation,
negRotation,
align = options.align,
rotCorr, // rotation correction
// Math.round for rounding errors (#2683), alignTo to allow column labels (#2700)
visible =
this.visible &&
(
point.series.forceDL ||
chart.isInsidePlot(plotX, Math.round(plotY), inverted) ||
(
alignTo && chart.isInsidePlot(
plotX,
inverted ? alignTo.x + 1 : alignTo.y + alignTo.height - 1,
inverted
)
)
),
alignAttr, // the final position;
justify = pick(options.overflow, 'justify') === 'justify';
if (visible) {
fontSize = options.style.fontSize;
baseline = chart.renderer.fontMetrics(fontSize, dataLabel).b;
// The alignment box is a singular point
alignTo = extend({
x: inverted ? chart.plotWidth - plotY : plotX,
y: Math.round(inverted ? chart.plotHeight - plotX : plotY),
width: 0,
height: 0
}, alignTo);
// Add the text size for alignment calculation
extend(options, {
width: bBox.width,
height: bBox.height
});
// Allow a hook for changing alignment in the last moment, then do the alignment
if (rotation) {
justify = false; // Not supported for rotated text
rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
alignAttr = {
x: alignTo.x + options.x + alignTo.width / 2 + rotCorr.x,
y: alignTo.y + options.y + {
top: 0,
middle: 0.5,
bottom: 1
}[options.verticalAlign] * alignTo.height
};
dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
.attr({ // #3003
align: align
});
// Compensate for the rotated label sticking out on the sides
normRotation = (rotation + 720) % 360;
negRotation = normRotation > 180 && normRotation < 360;
if (align === 'left') {
alignAttr.y -= negRotation ? bBox.height : 0;
} else if (align === 'center') {
alignAttr.x -= bBox.width / 2;
alignAttr.y -= bBox.height / 2;
} else if (align === 'right') {
alignAttr.x -= bBox.width;
alignAttr.y -= negRotation ? 0 : bBox.height;
}
} else {
dataLabel.align(options, null, alignTo);
alignAttr = dataLabel.alignAttr;
}
// Handle justify or crop
if (justify) {
point.isLabelJustified = this.justifyDataLabel(
dataLabel,
options,
alignAttr,
bBox,
alignTo,
isNew
);
// Now check that the data label is within the plot area
} else if (pick(options.crop, true)) {
visible = chart.isInsidePlot(alignAttr.x, alignAttr.y) && chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height);
}
// When we're using a shape, make it possible with a connector or an arrow pointing to thie point
if (options.shape && !rotation) {
dataLabel.attr({
anchorX: point.plotX,
anchorY: point.plotY
});
}
}
// Show or hide based on the final aligned position
if (!visible) {
dataLabel.attr({
y: -9999
});
dataLabel.placed = false; // don't animate back in
}
};
/**
* If data labels fall partly outside the plot area, align them back in, in a way that
* doesn't hide the point.
*/
Series.prototype.justifyDataLabel = function(dataLabel, options, alignAttr, bBox, alignTo, isNew) {
var chart = this.chart,
align = options.align,
verticalAlign = options.verticalAlign,
off,
justified,
padding = dataLabel.box ? 0 : (dataLabel.padding || 0);
// Off left
off = alignAttr.x + padding;
if (off < 0) {
if (align === 'right') {
options.align = 'left';
} else {
options.x = -off;
}
justified = true;
}
// Off right
off = alignAttr.x + bBox.width - padding;
if (off > chart.plotWidth) {
if (align === 'left') {
options.align = 'right';
} else {
options.x = chart.plotWidth - off;
}
justified = true;
}
// Off top
off = alignAttr.y + padding;
if (off < 0) {
if (verticalAlign === 'bottom') {
options.verticalAlign = 'top';
} else {
options.y = -off;
}
justified = true;
}
// Off bottom
off = alignAttr.y + bBox.height - padding;
if (off > chart.plotHeight) {
if (verticalAlign === 'top') {
options.verticalAlign = 'bottom';
} else {
options.y = chart.plotHeight - off;
}
justified = true;
}
if (justified) {
dataLabel.placed = !isNew;
dataLabel.align(options, null, alignTo);
}
return justified;
};
/**
* Override the base drawDataLabels method by pie specific functionality
*/
if (seriesTypes.pie) {
seriesTypes.pie.prototype.drawDataLabels = function() {
var series = this,
data = series.data,
point,
chart = series.chart,
options = series.options.dataLabels,
connectorPadding = pick(options.connectorPadding, 10),
connectorWidth = pick(options.connectorWidth, 1),
plotWidth = chart.plotWidth,
plotHeight = chart.plotHeight,
connector,
distanceOption = options.distance,
seriesCenter = series.center,
radius = seriesCenter[2] / 2,
centerY = seriesCenter[1],
outside = distanceOption > 0,
dataLabel,
dataLabelWidth,
labelPos,
labelHeight,
halves = [ // divide the points into right and left halves for anti collision
[], // right
[] // left
],
x,
y,
visibility,
j,
overflow = [0, 0, 0, 0]; // top, right, bottom, left
// get out if not enabled
if (!series.visible || (!options.enabled && !series._hasPointLabels)) {
return;
}
// Reset all labels that have been shortened
each(data, function(point) {
if (point.dataLabel && point.visible && point.dataLabel.shortened) {
point.dataLabel
.attr({
width: 'auto'
}).css({
width: 'auto',
textOverflow: 'clip'
});
point.dataLabel.shortened = false;
}
});
// run parent method
Series.prototype.drawDataLabels.apply(series);
each(data, function(point) {
if (point.dataLabel && point.visible) { // #407, #2510
// Arrange points for detection collision
halves[point.half].push(point);
// Reset positions (#4905)
point.dataLabel._pos = null;
}
});
/* Loop over the points in each half, starting from the top and bottom
* of the pie to detect overlapping labels.
*/
each(halves, function(points, i) {
var top,
bottom,
length = points.length,
positions,
naturalY,
sideOverflow,
size;
if (!length) {
return;
}
// Sort by angle
series.sortByAngle(points, i - 0.5);
// Only do anti-collision when we are outside the pie and have connectors (#856)
if (distanceOption > 0) {
top = Math.max(0, centerY - radius - distanceOption);
bottom = Math.min(centerY + radius + distanceOption, chart.plotHeight);
positions = map(points, function(point) {
if (point.dataLabel) {
size = point.dataLabel.getBBox().height || 21;
return {
target: point.labelPos[1] - top + size / 2,
size: size,
rank: point.y
};
}
});
H.distribute(positions, bottom + size - top);
}
// now the used slots are sorted, fill them up sequentially
for (j = 0; j < length; j++) {
point = points[j];
labelPos = point.labelPos;
dataLabel = point.dataLabel;
visibility = point.visible === false ? 'hidden' : 'inherit';
naturalY = labelPos[1];
if (positions) {
if (positions[j].pos === undefined) {
visibility = 'hidden';
} else {
labelHeight = positions[j].size;
y = top + positions[j].pos;
}
} else {
y = naturalY;
}
// get the x - use the natural x position for labels near the top and bottom, to prevent the top
// and botton slice connectors from touching each other on either side
if (options.justify) {
x = seriesCenter[0] + (i ? -1 : 1) * (radius + distanceOption);
} else {
x = series.getX(y < top + 2 || y > bottom - 2 ? naturalY : y, i);
}
// Record the placement and visibility
dataLabel._attr = {
visibility: visibility,
align: labelPos[6]
};
dataLabel._pos = {
x: x + options.x +
({
left: connectorPadding,
right: -connectorPadding
}[labelPos[6]] || 0),
y: y + options.y - 10 // 10 is for the baseline (label vs text)
};
labelPos.x = x;
labelPos.y = y;
// Detect overflowing data labels
if (series.options.size === null) {
dataLabelWidth = dataLabel.getBBox().width;
sideOverflow = null;
// Overflow left
if (x - dataLabelWidth < connectorPadding) {
sideOverflow = Math.round(
dataLabelWidth - x + connectorPadding
);
overflow[3] = Math.max(sideOverflow, overflow[3]);
// Overflow right
} else if (x + dataLabelWidth > plotWidth - connectorPadding) {
sideOverflow = Math.round(
x + dataLabelWidth - plotWidth + connectorPadding
);
overflow[1] = Math.max(sideOverflow, overflow[1]);
}
// Overflow top
if (y - labelHeight / 2 < 0) {
overflow[0] = Math.max(
Math.round(-y + labelHeight / 2),
overflow[0]
);
// Overflow left
} else if (y + labelHeight / 2 > plotHeight) {
overflow[2] = Math.max(
Math.round(y + labelHeight / 2 - plotHeight),
overflow[2]
);
}
dataLabel.sideOverflow = sideOverflow;
}
} // for each point
}); // for each half
// Do not apply the final placement and draw the connectors until we have verified
// that labels are not spilling over.
if (arrayMax(overflow) === 0 || this.verifyDataLabelOverflow(overflow)) {
// Place the labels in the final position
this.placeDataLabels();
// Draw the connectors
if (outside && connectorWidth) {
each(this.points, function(point) {
var isNew;
connector = point.connector;
dataLabel = point.dataLabel;
if (dataLabel && dataLabel._pos && point.visible) {
visibility = dataLabel._attr.visibility;
isNew = !connector;
if (isNew) {
point.connector = connector = chart.renderer.path()
.addClass('highcharts-data-label-connector highcharts-color-' + point.colorIndex)
.add(series.dataLabelsGroup);
connector.attr({
'stroke-width': connectorWidth,
'stroke': options.connectorColor || point.color || '#666666'
});
}
connector[isNew ? 'attr' : 'animate']({
d: series.connectorPath(point.labelPos)
});
connector.attr('visibility', visibility);
} else if (connector) {
point.connector = connector.destroy();
}
});
}
}
};
/**
* Extendable method for getting the path of the connector between the data label
* and the pie slice.
*/
seriesTypes.pie.prototype.connectorPath = function(labelPos) {
var x = labelPos.x,
y = labelPos.y;
return pick(this.options.dataLabels.softConnector, true) ? [
'M',
x + (labelPos[6] === 'left' ? 5 : -5), y, // end of the string at the label
'C',
x, y, // first break, next to the label
2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
labelPos[2], labelPos[3], // second break
'L',
labelPos[4], labelPos[5] // base
] : [
'M',
x + (labelPos[6] === 'left' ? 5 : -5), y, // end of the string at the label
'L',
labelPos[2], labelPos[3], // second break
'L',
labelPos[4], labelPos[5] // base
];
};
/**
* Perform the final placement of the data labels after we have verified that they
* fall within the plot area.
*/
seriesTypes.pie.prototype.placeDataLabels = function() {
each(this.points, function(point) {
var dataLabel = point.dataLabel,
_pos;
if (dataLabel && point.visible) {
_pos = dataLabel._pos;
if (_pos) {
// Shorten data labels with ellipsis if they still overflow
// after the pie has reached minSize (#223).
if (dataLabel.sideOverflow) {
dataLabel._attr.width =
dataLabel.getBBox().width - dataLabel.sideOverflow;
dataLabel.css({
width: dataLabel._attr.width + 'px',
textOverflow: 'ellipsis'
});
dataLabel.shortened = true;
}
dataLabel.attr(dataLabel._attr);
dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
dataLabel.moved = true;
} else if (dataLabel) {
dataLabel.attr({
y: -9999
});
}
}
}, this);
};
seriesTypes.pie.prototype.alignDataLabel = noop;
/**
* Verify whether the data labels are allowed to draw, or we should run more translation and data
* label positioning to keep them inside the plot area. Returns true when data labels are ready
* to draw.
*/
seriesTypes.pie.prototype.verifyDataLabelOverflow = function(overflow) {
var center = this.center,
options = this.options,
centerOption = options.center,
minSize = options.minSize || 80,
newSize = minSize,
ret;
// Handle horizontal size and center
if (centerOption[0] !== null) { // Fixed center
newSize = Math.max(center[2] - Math.max(overflow[1], overflow[3]), minSize);
} else { // Auto center
newSize = Math.max(
center[2] - overflow[1] - overflow[3], // horizontal overflow
minSize
);
center[0] += (overflow[3] - overflow[1]) / 2; // horizontal center
}
// Handle vertical size and center
if (centerOption[1] !== null) { // Fixed center
newSize = Math.max(Math.min(newSize, center[2] - Math.max(overflow[0], overflow[2])), minSize);
} else { // Auto center
newSize = Math.max(
Math.min(
newSize,
center[2] - overflow[0] - overflow[2] // vertical overflow
),
minSize
);
center[1] += (overflow[0] - overflow[2]) / 2; // vertical center
}
// If the size must be decreased, we need to run translate and drawDataLabels again
if (newSize < center[2]) {
center[2] = newSize;
center[3] = Math.min(relativeLength(options.innerSize || 0, newSize), newSize); // #3632
this.translate(center);
if (this.drawDataLabels) {
this.drawDataLabels();
}
// Else, return true to indicate that the pie and its labels is within the plot area
} else {
ret = true;
}
return ret;
};
}
if (seriesTypes.column) {
/**
* Override the basic data label alignment by adjusting for the position of the column
*/
seriesTypes.column.prototype.alignDataLabel = function(point, dataLabel, options, alignTo, isNew) {
var inverted = this.chart.inverted,
series = point.series,
dlBox = point.dlBox || point.shapeArgs, // data label box for alignment
below = pick(point.below, point.plotY > pick(this.translatedThreshold, series.yAxis.len)), // point.below is used in range series
inside = pick(options.inside, !!this.options.stacking), // draw it inside the box?
overshoot;
// Align to the column itself, or the top of it
if (dlBox) { // Area range uses this method but not alignTo
alignTo = merge(dlBox);
if (alignTo.y < 0) {
alignTo.height += alignTo.y;
alignTo.y = 0;
}
overshoot = alignTo.y + alignTo.height - series.yAxis.len;
if (overshoot > 0) {
alignTo.height -= overshoot;
}
if (inverted) {
alignTo = {
x: series.yAxis.len - alignTo.y - alignTo.height,
y: series.xAxis.len - alignTo.x - alignTo.width,
width: alignTo.height,
height: alignTo.width
};
}
// Compute the alignment box
if (!inside) {
if (inverted) {
alignTo.x += below ? 0 : alignTo.width;
alignTo.width = 0;
} else {
alignTo.y += below ? alignTo.height : 0;
alignTo.height = 0;
}
}
}
// When alignment is undefined (typically columns and bars), display the individual
// point below or above the point depending on the threshold
options.align = pick(
options.align, !inverted || inside ? 'center' : below ? 'right' : 'left'
);
options.verticalAlign = pick(
options.verticalAlign,
inverted || inside ? 'middle' : below ? 'top' : 'bottom'
);
// Call the parent method
Series.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
// If label was justified and we have contrast, set it:
if (point.isLabelJustified && point.contrastColor) {
point.dataLabel.css({
color: point.contrastColor
});
}
};
}
}(Highcharts));
(function(H) {
/**
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/**
* Highcharts module to hide overlapping data labels. This module is included in
* Highcharts.
*/
var Chart = H.Chart,
each = H.each,
pick = H.pick,
addEvent = H.addEvent;
// Collect potensial overlapping data labels. Stack labels probably don't need
// to be considered because they are usually accompanied by data labels that lie
// inside the columns.
Chart.prototype.callbacks.push(function(chart) {
function collectAndHide() {
var labels = [];
each(chart.series || [], function(series) {
var dlOptions = series.options.dataLabels,
// Range series have two collections
collections = series.dataLabelCollections || ['dataLabel'];
if (
(dlOptions.enabled || series._hasPointLabels) &&
!dlOptions.allowOverlap &&
series.visible
) { // #3866
each(collections, function(coll) {
each(series.points, function(point) {
if (point[coll]) {
point[coll].labelrank = pick(
point.labelrank,
point.shapeArgs && point.shapeArgs.height
); // #4118
labels.push(point[coll]);
}
});
});
}
});
chart.hideOverlappingLabels(labels);
}
// Do it now ...
collectAndHide();
// ... and after each chart redraw
addEvent(chart, 'redraw', collectAndHide);
});
/**
* Hide overlapping labels. Labels are moved and faded in and out on zoom to
* provide a smooth visual imression.
*/
Chart.prototype.hideOverlappingLabels = function(labels) {
var len = labels.length,
label,
i,
j,
label1,
label2,
isIntersecting,
pos1,
pos2,
parent1,
parent2,
padding,
intersectRect = function(x1, y1, w1, h1, x2, y2, w2, h2) {
return !(
x2 > x1 + w1 ||
x2 + w2 < x1 ||
y2 > y1 + h1 ||
y2 + h2 < y1
);
};
// Mark with initial opacity
for (i = 0; i < len; i++) {
label = labels[i];
if (label) {
label.oldOpacity = label.opacity;
label.newOpacity = 1;
}
}
// Prevent a situation in a gradually rising slope, that each label will
// hide the previous one because the previous one always has lower rank.
labels.sort(function(a, b) {
return (b.labelrank || 0) - (a.labelrank || 0);
});
// Detect overlapping labels
for (i = 0; i < len; i++) {
label1 = labels[i];
for (j = i + 1; j < len; ++j) {
label2 = labels[j];
if (
label1 && label2 &&
label1 !== label2 && // #6465, polar chart with connectEnds
label1.placed && label2.placed &&
label1.newOpacity !== 0 && label2.newOpacity !== 0
) {
pos1 = label1.alignAttr;
pos2 = label2.alignAttr;
// Different panes have different positions
parent1 = label1.parentGroup;
parent2 = label2.parentGroup;
// Substract the padding if no background or border (#4333)
padding = 2 * (label1.box ? 0 : label1.padding);
isIntersecting = intersectRect(
pos1.x + parent1.translateX,
pos1.y + parent1.translateY,
label1.width - padding,
label1.height - padding,
pos2.x + parent2.translateX,
pos2.y + parent2.translateY,
label2.width - padding,
label2.height - padding
);
if (isIntersecting) {
(label1.labelrank < label2.labelrank ? label1 : label2)
.newOpacity = 0;
}
}
}
}
// Hide or show
each(labels, function(label) {
var complete,
newOpacity;
if (label) {
newOpacity = label.newOpacity;
if (label.oldOpacity !== newOpacity && label.placed) {
// Make sure the label is completely hidden to avoid catching
// clicks (#4362)
if (newOpacity) {
label.show(true);
} else {
complete = function() {
label.hide();
};
}
// Animate or set the opacity
label.alignAttr.opacity = newOpacity;
label[label.isOld ? 'animate' : 'attr'](
label.alignAttr,
null,
complete
);
}
label.isOld = true;
}
});
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
Chart = H.Chart,
createElement = H.createElement,
css = H.css,
defaultOptions = H.defaultOptions,
defaultPlotOptions = H.defaultPlotOptions,
each = H.each,
extend = H.extend,
fireEvent = H.fireEvent,
hasTouch = H.hasTouch,
inArray = H.inArray,
isObject = H.isObject,
Legend = H.Legend,
merge = H.merge,
pick = H.pick,
Point = H.Point,
Series = H.Series,
seriesTypes = H.seriesTypes,
svg = H.svg,
TrackerMixin;
/**
* TrackerMixin for points and graphs.
*
* @mixin
*/
TrackerMixin = H.TrackerMixin = {
/**
* Draw the tracker for a point.
*/
drawTrackerPoint: function() {
var series = this,
chart = series.chart,
pointer = chart.pointer,
onMouseOver = function(e) {
var point = pointer.getPointFromEvent(e);
// undefined on graph in scatterchart
if (point !== undefined) {
point.onMouseOver(e);
}
};
// Add reference to the point
each(series.points, function(point) {
if (point.graphic) {
point.graphic.element.point = point;
}
if (point.dataLabel) {
if (point.dataLabel.div) {
point.dataLabel.div.point = point;
} else {
point.dataLabel.element.point = point;
}
}
});
// Add the event listeners, we need to do this only once
if (!series._hasTracking) {
each(series.trackerGroups, function(key) {
if (series[key]) { // we don't always have dataLabelsGroup
series[key]
.addClass('highcharts-tracker')
.on('mouseover', onMouseOver)
.on('mouseout', function(e) {
pointer.onTrackerMouseOut(e);
});
if (hasTouch) {
series[key].on('touchstart', onMouseOver);
}
if (series.options.cursor) {
series[key]
.css(css)
.css({
cursor: series.options.cursor
});
}
}
});
series._hasTracking = true;
}
},
/**
* Draw the tracker object that sits above all data labels and markers to
* track mouse events on the graph or points. For the line type charts
* the tracker uses the same graphPath, but with a greater stroke width
* for better control.
*/
drawTrackerGraph: function() {
var series = this,
options = series.options,
trackByArea = options.trackByArea,
trackerPath = [].concat(trackByArea ? series.areaPath : series.graphPath),
trackerPathLength = trackerPath.length,
chart = series.chart,
pointer = chart.pointer,
renderer = chart.renderer,
snap = chart.options.tooltip.snap,
tracker = series.tracker,
i,
onMouseOver = function() {
if (chart.hoverSeries !== series) {
series.onMouseOver();
}
},
/*
* Empirical lowest possible opacities for TRACKER_FILL for an element to stay invisible but clickable
* IE6: 0.002
* IE7: 0.002
* IE8: 0.002
* IE9: 0.00000000001 (unlimited)
* IE10: 0.0001 (exporting only)
* FF: 0.00000000001 (unlimited)
* Chrome: 0.000001
* Safari: 0.000001
* Opera: 0.00000000001 (unlimited)
*/
TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';
// Extend end points. A better way would be to use round linecaps,
// but those are not clickable in VML.
if (trackerPathLength && !trackByArea) {
i = trackerPathLength + 1;
while (i--) {
if (trackerPath[i] === 'M') { // extend left side
trackerPath.splice(i + 1, 0, trackerPath[i + 1] - snap, trackerPath[i + 2], 'L');
}
if ((i && trackerPath[i] === 'M') || i === trackerPathLength) { // extend right side
trackerPath.splice(i, 0, 'L', trackerPath[i - 2] + snap, trackerPath[i - 1]);
}
}
}
// handle single points
/*for (i = 0; i < singlePoints.length; i++) {
singlePoint = singlePoints[i];
trackerPath.push(M, singlePoint.plotX - snap, singlePoint.plotY,
L, singlePoint.plotX + snap, singlePoint.plotY);
}*/
// draw the tracker
if (tracker) {
tracker.attr({
d: trackerPath
});
} else if (series.graph) { // create
series.tracker = renderer.path(trackerPath)
.attr({
'stroke-linejoin': 'round', // #1225
visibility: series.visible ? 'visible' : 'hidden',
stroke: TRACKER_FILL,
fill: trackByArea ? TRACKER_FILL : 'none',
'stroke-width': series.graph.strokeWidth() + (trackByArea ? 0 : 2 * snap),
zIndex: 2
})
.add(series.group);
// The tracker is added to the series group, which is clipped, but is covered
// by the marker group. So the marker group also needs to capture events.
each([series.tracker, series.markerGroup], function(tracker) {
tracker.addClass('highcharts-tracker')
.on('mouseover', onMouseOver)
.on('mouseout', function(e) {
pointer.onTrackerMouseOut(e);
});
if (options.cursor) {
tracker.css({
cursor: options.cursor
});
}
if (hasTouch) {
tracker.on('touchstart', onMouseOver);
}
});
}
}
};
/* End TrackerMixin */
/**
* Add tracking event listener to the series group, so the point graphics
* themselves act as trackers
*/
if (seriesTypes.column) {
seriesTypes.column.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
}
if (seriesTypes.pie) {
seriesTypes.pie.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
}
if (seriesTypes.scatter) {
seriesTypes.scatter.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
}
/*
* Extend Legend for item events
*/
extend(Legend.prototype, {
setItemEvents: function(item, legendItem, useHTML) {
var legend = this,
boxWrapper = legend.chart.renderer.boxWrapper,
activeClass = 'highcharts-legend-' + (item.series ? 'point' : 'series') + '-active';
// Set the events on the item group, or in case of useHTML, the item itself (#1249)
(useHTML ? legendItem : item.legendGroup).on('mouseover', function() {
item.setState('hover');
// A CSS class to dim or hide other than the hovered series
boxWrapper.addClass(activeClass);
legendItem.css(legend.options.itemHoverStyle);
})
.on('mouseout', function() {
legendItem.css(item.visible ? legend.itemStyle : legend.itemHiddenStyle);
// A CSS class to dim or hide other than the hovered series
boxWrapper.removeClass(activeClass);
item.setState();
})
.on('click', function(event) {
var strLegendItemClick = 'legendItemClick',
fnLegendItemClick = function() {
if (item.setVisible) {
item.setVisible();
}
};
// Pass over the click/touch event. #4.
event = {
browserEvent: event
};
// click the name or symbol
if (item.firePointEvent) { // point
item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
} else {
fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
}
});
},
createCheckboxForItem: function(item) {
var legend = this;
item.checkbox = createElement('input', {
type: 'checkbox',
checked: item.selected,
defaultChecked: item.selected // required by IE7
}, legend.options.itemCheckboxStyle, legend.chart.container);
addEvent(item.checkbox, 'click', function(event) {
var target = event.target;
fireEvent(
item.series || item,
'checkboxClick', { // #3712
checked: target.checked,
item: item
},
function() {
item.select();
}
);
});
}
});
// Add pointer cursor to legend itemstyle in defaultOptions
defaultOptions.legend.itemStyle.cursor = 'pointer';
/*
* Extend the Chart object with interaction
*/
extend(Chart.prototype, /** @lends Chart.prototype */ {
/**
* Display the zoom button
*/
showResetZoom: function() {
var chart = this,
lang = defaultOptions.lang,
btnOptions = chart.options.chart.resetZoomButton,
theme = btnOptions.theme,
states = theme.states,
alignTo = btnOptions.relativeTo === 'chart' ? null : 'plotBox';
function zoomOut() {
chart.zoomOut();
}
this.resetZoomButton = chart.renderer.button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
.attr({
align: btnOptions.position.align,
title: lang.resetZoomTitle
})
.addClass('highcharts-reset-zoom')
.add()
.align(btnOptions.position, false, alignTo);
},
/**
* Zoom out to 1:1
*/
zoomOut: function() {
var chart = this;
fireEvent(chart, 'selection', {
resetSelection: true
}, function() {
chart.zoom();
});
},
/**
* Zoom into a given portion of the chart given by axis coordinates
* @param {Object} event
*/
zoom: function(event) {
var chart = this,
hasZoomed,
pointer = chart.pointer,
displayButton = false,
resetZoomButton;
// If zoom is called with no arguments, reset the axes
if (!event || event.resetSelection) {
each(chart.axes, function(axis) {
hasZoomed = axis.zoom();
});
} else { // else, zoom in on all axes
each(event.xAxis.concat(event.yAxis), function(axisData) {
var axis = axisData.axis,
isXAxis = axis.isXAxis;
// don't zoom more than minRange
if (pointer[isXAxis ? 'zoomX' : 'zoomY']) {
hasZoomed = axis.zoom(axisData.min, axisData.max);
if (axis.displayBtn) {
displayButton = true;
}
}
});
}
// Show or hide the Reset zoom button
resetZoomButton = chart.resetZoomButton;
if (displayButton && !resetZoomButton) {
chart.showResetZoom();
} else if (!displayButton && isObject(resetZoomButton)) {
chart.resetZoomButton = resetZoomButton.destroy();
}
// Redraw
if (hasZoomed) {
chart.redraw(
pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100) // animation
);
}
},
/**
* Pan the chart by dragging the mouse across the pane. This function is called
* on mouse move, and the distance to pan is computed from chartX compared to
* the first chartX position in the dragging operation.
*/
pan: function(e, panning) {
var chart = this,
hoverPoints = chart.hoverPoints,
doRedraw;
// remove active points for shared tooltip
if (hoverPoints) {
each(hoverPoints, function(point) {
point.setState();
});
}
each(panning === 'xy' ? [1, 0] : [1], function(isX) { // xy is used in maps
var axis = chart[isX ? 'xAxis' : 'yAxis'][0],
horiz = axis.horiz,
mousePos = e[horiz ? 'chartX' : 'chartY'],
mouseDown = horiz ? 'mouseDownX' : 'mouseDownY',
startPos = chart[mouseDown],
halfPointRange = (axis.pointRange || 0) / 2,
extremes = axis.getExtremes(),
panMin = axis.toValue(startPos - mousePos, true) +
halfPointRange,
panMax = axis.toValue(startPos + axis.len - mousePos, true) -
halfPointRange,
flipped = panMax < panMin,
newMin = flipped ? panMax : panMin,
newMax = flipped ? panMin : panMax,
paddedMin = axis.toValue(
axis.toPixels(extremes.min) - axis.minPixelPadding
),
paddedMax = axis.toValue(
axis.toPixels(extremes.max) + axis.minPixelPadding
),
distMin = Math.min(extremes.dataMin, paddedMin) - newMin,
distMax = newMax - Math.max(extremes.dataMax, paddedMax);
// Negative distMin and distMax means that we're still inside the
// data range.
if (axis.series.length && distMin < 0 && distMax < 0) {
axis.setExtremes(
newMin,
newMax,
false,
false, {
trigger: 'pan'
}
);
doRedraw = true;
}
chart[mouseDown] = mousePos; // set new reference for next run
});
if (doRedraw) {
chart.redraw(false);
}
css(chart.container, {
cursor: 'move'
});
}
});
/*
* Extend the Point object with interaction
*/
extend(Point.prototype, /** @lends Point.prototype */ {
/**
* Toggle the selection status of a point
* @param {Boolean} selected Whether to select or unselect the point.
* @param {Boolean} accumulate Whether to add to the previous selection. By default,
* this happens if the control key (Cmd on Mac) was pressed during clicking.
*/
select: function(selected, accumulate) {
var point = this,
series = point.series,
chart = series.chart;
selected = pick(selected, !point.selected);
// fire the event with the default handler
point.firePointEvent(selected ? 'select' : 'unselect', {
accumulate: accumulate
}, function() {
point.selected = point.options.selected = selected;
series.options.data[inArray(point, series.data)] = point.options;
point.setState(selected && 'select');
// unselect all other points unless Ctrl or Cmd + click
if (!accumulate) {
each(chart.getSelectedPoints(), function(loopPoint) {
if (loopPoint.selected && loopPoint !== point) {
loopPoint.selected = loopPoint.options.selected = false;
series.options.data[inArray(loopPoint, series.data)] = loopPoint.options;
loopPoint.setState('');
loopPoint.firePointEvent('unselect');
}
});
}
});
},
/**
* Runs on mouse over the point
*
* @param {Object} e The event arguments
*/
onMouseOver: function(e) {
var point = this,
series = point.series,
chart = series.chart,
pointer = chart.pointer;
point.firePointEvent('mouseOver');
pointer.runPointActions(e, point);
},
/**
* Runs on mouse out from the point
*/
onMouseOut: function() {
var point = this,
chart = point.series.chart;
point.firePointEvent('mouseOut');
each(chart.hoverPoints || [], function(p) {
p.setState();
});
chart.hoverPoints = chart.hoverPoint = null;
},
/**
* Import events from the series' and point's options. Only do it on
* demand, to save processing time on hovering.
*/
importEvents: function() {
if (!this.hasImportedEvents) {
var point = this,
options = merge(point.series.options.point, point.options),
events = options.events,
eventType;
point.events = events;
for (eventType in events) {
addEvent(point, eventType, events[eventType]);
}
this.hasImportedEvents = true;
}
},
/**
* Set the point's state
* @param {String} state
*/
setState: function(state, move) {
var point = this,
plotX = Math.floor(point.plotX), // #4586
plotY = point.plotY,
series = point.series,
stateOptions = series.options.states[state] || {},
markerOptions = defaultPlotOptions[series.type].marker &&
series.options.marker,
normalDisabled = markerOptions && markerOptions.enabled === false,
markerStateOptions = (markerOptions && markerOptions.states &&
markerOptions.states[state]) || {},
stateDisabled = markerStateOptions.enabled === false,
stateMarkerGraphic = series.stateMarkerGraphic,
pointMarker = point.marker || {},
chart = series.chart,
halo = series.halo,
haloOptions,
markerAttribs,
hasMarkers = markerOptions && series.markerAttribs,
newSymbol;
state = state || ''; // empty string
if (
// already has this state
(state === point.state && !move) ||
// selected points don't respond to hover
(point.selected && state !== 'select') ||
// series' state options is disabled
(stateOptions.enabled === false) ||
// general point marker's state options is disabled
(state && (stateDisabled || (normalDisabled && markerStateOptions.enabled === false))) ||
// individual point marker's state options is disabled
(state && pointMarker.states && pointMarker.states[state] && pointMarker.states[state].enabled === false) // #1610
) {
return;
}
if (hasMarkers) {
markerAttribs = series.markerAttribs(point, state);
}
// Apply hover styles to the existing point
if (point.graphic) {
if (point.state) {
point.graphic.removeClass('highcharts-point-' + point.state);
}
if (state) {
point.graphic.addClass('highcharts-point-' + state);
}
/*attribs = radius ? { // new symbol attributes (#507, #612)
x: plotX - radius,
y: plotY - radius,
width: 2 * radius,
height: 2 * radius
} : {};*/
//attribs = merge(series.pointAttribs(point, state), attribs);
point.graphic.attr(series.pointAttribs(point, state));
if (markerAttribs) {
point.graphic.animate(
markerAttribs,
pick(
chart.options.chart.animation, // Turn off globally
markerStateOptions.animation,
markerOptions.animation
)
);
}
// Zooming in from a range with no markers to a range with markers
if (stateMarkerGraphic) {
stateMarkerGraphic.hide();
}
} else {
// if a graphic is not applied to each point in the normal state, create a shared
// graphic for the hover state
if (state && markerStateOptions) {
newSymbol = pointMarker.symbol || series.symbol;
// If the point has another symbol than the previous one, throw away the
// state marker graphic and force a new one (#1459)
if (stateMarkerGraphic && stateMarkerGraphic.currentSymbol !== newSymbol) {
stateMarkerGraphic = stateMarkerGraphic.destroy();
}
// Add a new state marker graphic
if (!stateMarkerGraphic) {
if (newSymbol) {
series.stateMarkerGraphic = stateMarkerGraphic = chart.renderer.symbol(
newSymbol,
markerAttribs.x,
markerAttribs.y,
markerAttribs.width,
markerAttribs.height
)
.add(series.markerGroup);
stateMarkerGraphic.currentSymbol = newSymbol;
}
// Move the existing graphic
} else {
stateMarkerGraphic[move ? 'animate' : 'attr']({ // #1054
x: markerAttribs.x,
y: markerAttribs.y
});
}
if (stateMarkerGraphic) {
stateMarkerGraphic.attr(series.pointAttribs(point, state));
}
}
if (stateMarkerGraphic) {
stateMarkerGraphic[state && chart.isInsidePlot(plotX, plotY, chart.inverted) ? 'show' : 'hide'](); // #2450
stateMarkerGraphic.element.point = point; // #4310
}
}
// Show me your halo
haloOptions = stateOptions.halo;
if (haloOptions && haloOptions.size) {
if (!halo) {
series.halo = halo = chart.renderer.path()
// #5818, #5903
.add(hasMarkers ? series.markerGroup : series.group);
}
halo[move ? 'animate' : 'attr']({
d: point.haloPath(haloOptions.size)
});
halo.attr({
'class': 'highcharts-halo highcharts-color-' +
pick(point.colorIndex, series.colorIndex)
});
halo.point = point; // #6055
halo.attr(extend({
'fill': point.color || series.color,
'fill-opacity': haloOptions.opacity,
'zIndex': -1 // #4929, IE8 added halo above everything
}, haloOptions.attributes));
} else if (halo && halo.point && halo.point.haloPath) {
// Animate back to 0 on the current halo point (#6055)
halo.animate({
d: halo.point.haloPath(0)
});
}
point.state = state;
},
/**
* Get the circular path definition for the halo
* @param {Number} size The radius of the circular halo.
* @returns {Array} The path definition
*/
haloPath: function(size) {
var series = this.series,
chart = series.chart;
return chart.renderer.symbols.circle(
Math.floor(this.plotX) - size,
this.plotY - size,
size * 2,
size * 2
);
}
});
/*
* Extend the Series object with interaction
*/
extend(Series.prototype, /** @lends Series.prototype */ {
/**
* Series mouse over handler
*/
onMouseOver: function() {
var series = this,
chart = series.chart,
hoverSeries = chart.hoverSeries;
// set normal state to previous series
if (hoverSeries && hoverSeries !== series) {
hoverSeries.onMouseOut();
}
// trigger the event, but to save processing time,
// only if defined
if (series.options.events.mouseOver) {
fireEvent(series, 'mouseOver');
}
// hover this
series.setState('hover');
chart.hoverSeries = series;
},
/**
* Series mouse out handler
*/
onMouseOut: function() {
// trigger the event only if listeners exist
var series = this,
options = series.options,
chart = series.chart,
tooltip = chart.tooltip,
hoverPoint = chart.hoverPoint;
chart.hoverSeries = null; // #182, set to null before the mouseOut event fires
// trigger mouse out on the point, which must be in this series
if (hoverPoint) {
hoverPoint.onMouseOut();
}
// fire the mouse out event
if (series && options.events.mouseOut) {
fireEvent(series, 'mouseOut');
}
// hide the tooltip
if (tooltip && !series.stickyTracking && (!tooltip.shared || series.noSharedTooltip)) {
tooltip.hide();
}
// set normal state
series.setState();
},
/**
* Set the state of the graph
*/
setState: function(state) {
var series = this,
options = series.options,
graph = series.graph,
stateOptions = options.states,
lineWidth = options.lineWidth,
attribs,
i = 0;
state = state || '';
if (series.state !== state) {
// Toggle class names
each([
series.group,
series.markerGroup,
series.dataLabelsGroup
], function(group) {
if (group) {
// Old state
if (series.state) {
group.removeClass('highcharts-series-' + series.state);
}
// New state
if (state) {
group.addClass('highcharts-series-' + state);
}
}
});
series.state = state;
if (stateOptions[state] && stateOptions[state].enabled === false) {
return;
}
if (state) {
lineWidth = stateOptions[state].lineWidth || lineWidth + (stateOptions[state].lineWidthPlus || 0); // #4035
}
if (graph && !graph.dashstyle) { // hover is turned off for dashed lines in VML
attribs = {
'stroke-width': lineWidth
};
// Animate the graph stroke-width. By default a quick animation
// to hover, slower to un-hover.
graph.animate(
attribs,
pick(
series.chart.options.chart.animation,
stateOptions[state] && stateOptions[state].animation
)
);
while (series['zone-graph-' + i]) {
series['zone-graph-' + i].attr(attribs);
i = i + 1;
}
}
}
},
/**
* Set the visibility of the graph
*
* @param vis {Boolean} True to show the series, false to hide. If undefined,
* the visibility is toggled.
*/
setVisible: function(vis, redraw) {
var series = this,
chart = series.chart,
legendItem = series.legendItem,
showOrHide,
ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
oldVisibility = series.visible;
// if called without an argument, toggle visibility
series.visible = vis = series.options.visible = series.userOptions.visible = vis === undefined ? !oldVisibility : vis; // #5618
showOrHide = vis ? 'show' : 'hide';
// show or hide elements
each(['group', 'dataLabelsGroup', 'markerGroup', 'tracker', 'tt'], function(key) {
if (series[key]) {
series[key][showOrHide]();
}
});
// hide tooltip (#1361)
if (chart.hoverSeries === series || (chart.hoverPoint && chart.hoverPoint.series) === series) {
series.onMouseOut();
}
if (legendItem) {
chart.legend.colorizeItem(series, vis);
}
// rescale or adapt to resized chart
series.isDirty = true;
// in a stack, all other series are affected
if (series.options.stacking) {
each(chart.series, function(otherSeries) {
if (otherSeries.options.stacking && otherSeries.visible) {
otherSeries.isDirty = true;
}
});
}
// show or hide linked series
each(series.linkedSeries, function(otherSeries) {
otherSeries.setVisible(vis, false);
});
if (ignoreHiddenSeries) {
chart.isDirtyBox = true;
}
if (redraw !== false) {
chart.redraw();
}
fireEvent(series, showOrHide);
},
/**
* Show the graph
*/
show: function() {
this.setVisible(true);
},
/**
* Hide the graph
*/
hide: function() {
this.setVisible(false);
},
/**
* Set the selected state of the graph
*
* @param selected {Boolean} True to select the series, false to unselect. If
* undefined, the selection state is toggled.
*/
select: function(selected) {
var series = this;
// if called without an argument, toggle
series.selected = selected = (selected === undefined) ? !series.selected : selected;
if (series.checkbox) {
series.checkbox.checked = selected;
}
fireEvent(series, selected ? 'select' : 'unselect');
},
drawTracker: TrackerMixin.drawTrackerGraph
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Chart = H.Chart,
each = H.each,
inArray = H.inArray,
isArray = H.isArray,
isObject = H.isObject,
pick = H.pick,
splat = H.splat;
/**
* Update the chart based on the current chart/document size and options for
* responsiveness.
*/
Chart.prototype.setResponsive = function(redraw) {
var options = this.options.responsive,
ruleIds = [],
currentResponsive = this.currentResponsive,
currentRuleIds;
if (options && options.rules) {
each(options.rules, function(rule) {
if (rule._id === undefined) {
rule._id = H.uniqueKey();
}
this.matchResponsiveRule(rule, ruleIds, redraw);
}, this);
}
// Merge matching rules
var mergedOptions = H.merge.apply(0, H.map(ruleIds, function(ruleId) {
return H.find(options.rules, function(rule) {
return rule._id === ruleId;
}).chartOptions;
}));
// Stringified key for the rules that currently apply.
ruleIds = ruleIds.toString() || undefined;
currentRuleIds = currentResponsive && currentResponsive.ruleIds;
// Changes in what rules apply
if (ruleIds !== currentRuleIds) {
// Undo previous rules. Before we apply a new set of rules, we need to
// roll back completely to base options (#6291).
if (currentResponsive) {
this.update(currentResponsive.undoOptions, redraw);
}
if (ruleIds) {
// Get undo-options for matching rules
this.currentResponsive = {
ruleIds: ruleIds,
mergedOptions: mergedOptions,
undoOptions: this.currentOptions(mergedOptions)
};
this.update(mergedOptions, redraw);
} else {
this.currentResponsive = undefined;
}
}
};
/**
* Handle a single responsiveness rule
*/
Chart.prototype.matchResponsiveRule = function(rule, matches) {
var condition = rule.condition,
fn = condition.callback || function() {
return this.chartWidth <= pick(condition.maxWidth, Number.MAX_VALUE) &&
this.chartHeight <= pick(condition.maxHeight, Number.MAX_VALUE) &&
this.chartWidth >= pick(condition.minWidth, 0) &&
this.chartHeight >= pick(condition.minHeight, 0);
};
if (fn.call(this)) {
matches.push(rule._id);
}
};
/**
* Get the current values for a given set of options. Used before we update
* the chart with a new responsiveness rule.
* TODO: Restore axis options (by id?)
*/
Chart.prototype.currentOptions = function(options) {
var ret = {};
/**
* Recurse over a set of options and its current values,
* and store the current values in the ret object.
*/
function getCurrent(options, curr, ret, depth) {
var key, i;
for (key in options) {
if (!depth && inArray(key, ['series', 'xAxis', 'yAxis']) > -1) {
options[key] = splat(options[key]);
ret[key] = [];
// Iterate over collections like series, xAxis or yAxis and map
// the items by index.
for (i = 0; i < options[key].length; i++) {
if (curr[key][i]) { // Item exists in current data (#6347)
ret[key][i] = {};
getCurrent(
options[key][i],
curr[key][i],
ret[key][i],
depth + 1
);
}
}
} else if (isObject(options[key])) {
ret[key] = isArray(options[key]) ? [] : {};
getCurrent(
options[key],
curr[key] || {},
ret[key],
depth + 1
);
} else {
ret[key] = curr[key] || null;
}
}
}
getCurrent(options, this.options, ret, 0);
return ret;
};
}(Highcharts));
return Highcharts
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /*
Highmaps JS v5.0.10 (2017-03-31)
(c) 2011-2016 Torstein Honsi
License: www.highcharts.com/license
*/
(function(J,a){"object"===typeof module&&module.exports?module.exports=J.document?a(J):a:J.Highcharts=a(J)})("undefined"!==typeof window?window:this,function(J){J=function(){var a=window,z=a.document,F=a.navigator&&a.navigator.userAgent||"",D=z&&z.createElementNS&&!!z.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,B=/(edge|msie|trident)/i.test(F)&&!window.opera,f=!D,h=/Firefox/.test(F),t=h&&4>parseInt(F.split("Firefox/")[1],10);return a.Highcharts?a.Highcharts.error(16,!0):{product:"Highmaps",
version:"5.0.10",deg2rad:2*Math.PI/360,doc:z,hasBidiBug:t,hasTouch:z&&void 0!==z.documentElement.ontouchstart,isMS:B,isWebKit:/AppleWebKit/.test(F),isFirefox:h,isTouchDevice:/(Mobile|Android|Windows Phone)/.test(F),SVG_NS:"http://www.w3.org/2000/svg",chartCount:0,seriesTypes:{},symbolSizes:{},svg:D,vml:f,win:a,charts:[],marginNames:["plotTop","marginRight","marginBottom","plotLeft"],noop:function(){}}}();(function(a){var z=[],F=a.charts,D=a.doc,B=a.win;a.error=function(f,h){f=a.isNumber(f)?"Highcharts error #"+
f+": www.highcharts.com/errors/"+f:f;if(h)throw Error(f);B.console&&console.log(f)};a.Fx=function(a,h,t){this.options=h;this.elem=a;this.prop=t};a.Fx.prototype={dSetter:function(){var a=this.paths[0],h=this.paths[1],t=[],r=this.now,m=a.length,d;if(1===r)t=this.toD;else if(m===h.length&&1>r)for(;m--;)d=parseFloat(a[m]),t[m]=isNaN(d)?a[m]:r*parseFloat(h[m]-d)+d;else t=h;this.elem.attr("d",t,null,!0)},update:function(){var a=this.elem,h=this.prop,t=this.now,r=this.options.step;if(this[h+"Setter"])this[h+
"Setter"]();else a.attr?a.element&&a.attr(h,t,null,!0):a.style[h]=t+this.unit;r&&r.call(a,t,this)},run:function(a,h,t){var f=this,m=function(a){return m.stopped?!1:f.step(a)},d;this.startTime=+new Date;this.start=a;this.end=h;this.unit=t;this.now=this.start;this.pos=0;m.elem=this.elem;m.prop=this.prop;m()&&1===z.push(m)&&(m.timerId=setInterval(function(){for(d=0;d<z.length;d++)z[d]()||z.splice(d--,1);z.length||clearInterval(m.timerId)},13))},step:function(a){var f=+new Date,t,r=this.options;t=this.elem;
var m=r.complete,d=r.duration,g=r.curAnim,n;if(t.attr&&!t.element)t=!1;else if(a||f>=d+this.startTime){this.now=this.end;this.pos=1;this.update();a=g[this.prop]=!0;for(n in g)!0!==g[n]&&(a=!1);a&&m&&m.call(t);t=!1}else this.pos=r.easing((f-this.startTime)/d),this.now=this.start+(this.end-this.start)*this.pos,this.update(),t=!0;return t},initPath:function(f,h,t){function r(a){var b,e;for(c=a.length;c--;)b="M"===a[c]||"L"===a[c],e=/[a-zA-Z]/.test(a[c+3]),b&&e&&a.splice(c+1,0,a[c+1],a[c+2],a[c+1],a[c+
2])}function m(a,e){for(;a.length<l;){a[0]=e[l-a.length];var q=a.slice(0,b);[].splice.apply(a,[0,0].concat(q));E&&(q=a.slice(a.length-b),[].splice.apply(a,[a.length,0].concat(q)),c--)}a[0]="M"}function d(a,c){for(var q=(l-a.length)/b;0<q&&q--;)e=a.slice().splice(a.length/u-b,b*u),e[0]=c[l-b-q*b],w&&(e[b-6]=e[b-2],e[b-5]=e[b-1]),[].splice.apply(a,[a.length/u,0].concat(e)),E&&q--}h=h||"";var g,n=f.startX,y=f.endX,w=-1<h.indexOf("C"),b=w?7:3,l,e,c;h=h.split(" ");t=t.slice();var E=f.isArea,u=E?2:1,q;
w&&(r(h),r(t));if(n&&y){for(c=0;c<n.length;c++)if(n[c]===y[0]){g=c;break}else if(n[0]===y[y.length-n.length+c]){g=c;q=!0;break}void 0===g&&(h=[])}h.length&&a.isNumber(g)&&(l=t.length+g*u*b,q?(m(h,t),d(t,h)):(m(t,h),d(h,t)));return[h,t]}};a.extend=function(a,h){var f;a||(a={});for(f in h)a[f]=h[f];return a};a.merge=function(){var f,h=arguments,t,r={},m=function(d,g){var n,f;"object"!==typeof d&&(d={});for(f in g)g.hasOwnProperty(f)&&(n=g[f],a.isObject(n,!0)&&"renderTo"!==f&&"number"!==typeof n.nodeType?
d[f]=m(d[f]||{},n):d[f]=g[f]);return d};!0===h[0]&&(r=h[1],h=Array.prototype.slice.call(h,2));t=h.length;for(f=0;f<t;f++)r=m(r,h[f]);return r};a.pInt=function(a,h){return parseInt(a,h||10)};a.isString=function(a){return"string"===typeof a};a.isArray=function(a){a=Object.prototype.toString.call(a);return"[object Array]"===a||"[object Array Iterator]"===a};a.isObject=function(f,h){return f&&"object"===typeof f&&(!h||!a.isArray(f))};a.isNumber=function(a){return"number"===typeof a&&!isNaN(a)};a.erase=
function(a,h){for(var f=a.length;f--;)if(a[f]===h){a.splice(f,1);break}};a.defined=function(a){return void 0!==a&&null!==a};a.attr=function(f,h,t){var r,m;if(a.isString(h))a.defined(t)?f.setAttribute(h,t):f&&f.getAttribute&&(m=f.getAttribute(h));else if(a.defined(h)&&a.isObject(h))for(r in h)f.setAttribute(r,h[r]);return m};a.splat=function(f){return a.isArray(f)?f:[f]};a.syncTimeout=function(a,h,t){if(h)return setTimeout(a,h,t);a.call(0,t)};a.pick=function(){var a=arguments,h,t,r=a.length;for(h=
0;h<r;h++)if(t=a[h],void 0!==t&&null!==t)return t};a.css=function(f,h){a.isMS&&!a.svg&&h&&void 0!==h.opacity&&(h.filter="alpha(opacity\x3d"+100*h.opacity+")");a.extend(f.style,h)};a.createElement=function(f,h,t,r,m){f=D.createElement(f);var d=a.css;h&&a.extend(f,h);m&&d(f,{padding:0,border:"none",margin:0});t&&d(f,t);r&&r.appendChild(f);return f};a.extendClass=function(f,h){var t=function(){};t.prototype=new f;a.extend(t.prototype,h);return t};a.pad=function(a,h,t){return Array((h||2)+1-String(a).length).join(t||
0)+a};a.relativeLength=function(a,h){return/%$/.test(a)?h*parseFloat(a)/100:parseFloat(a)};a.wrap=function(a,h,t){var f=a[h];a[h]=function(){var a=Array.prototype.slice.call(arguments),d=arguments,g=this;g.proceed=function(){f.apply(g,arguments.length?arguments:d)};a.unshift(f);a=t.apply(this,a);g.proceed=null;return a}};a.getTZOffset=function(f){var h=a.Date;return 6E4*(h.hcGetTimezoneOffset&&h.hcGetTimezoneOffset(f)||h.hcTimezoneOffset||0)};a.dateFormat=function(f,h,t){if(!a.defined(h)||isNaN(h))return a.defaultOptions.lang.invalidDate||
"";f=a.pick(f,"%Y-%m-%d %H:%M:%S");var r=a.Date,m=new r(h-a.getTZOffset(h)),d,g=m[r.hcGetHours](),n=m[r.hcGetDay](),y=m[r.hcGetDate](),w=m[r.hcGetMonth](),b=m[r.hcGetFullYear](),l=a.defaultOptions.lang,e=l.weekdays,c=l.shortWeekdays,E=a.pad,r=a.extend({a:c?c[n]:e[n].substr(0,3),A:e[n],d:E(y),e:E(y,2," "),w:n,b:l.shortMonths[w],B:l.months[w],m:E(w+1),y:b.toString().substr(2,2),Y:b,H:E(g),k:g,I:E(g%12||12),l:g%12||12,M:E(m[r.hcGetMinutes]()),p:12>g?"AM":"PM",P:12>g?"am":"pm",S:E(m.getSeconds()),L:E(Math.round(h%
1E3),3)},a.dateFormats);for(d in r)for(;-1!==f.indexOf("%"+d);)f=f.replace("%"+d,"function"===typeof r[d]?r[d](h):r[d]);return t?f.substr(0,1).toUpperCase()+f.substr(1):f};a.formatSingle=function(f,h){var t=/\.([0-9])/,r=a.defaultOptions.lang;/f$/.test(f)?(t=(t=f.match(t))?t[1]:-1,null!==h&&(h=a.numberFormat(h,t,r.decimalPoint,-1<f.indexOf(",")?r.thousandsSep:""))):h=a.dateFormat(f,h);return h};a.format=function(f,h){for(var t="{",r=!1,m,d,g,n,y=[],w;f;){t=f.indexOf(t);if(-1===t)break;m=f.slice(0,
t);if(r){m=m.split(":");d=m.shift().split(".");n=d.length;w=h;for(g=0;g<n;g++)w=w[d[g]];m.length&&(w=a.formatSingle(m.join(":"),w));y.push(w)}else y.push(m);f=f.slice(t+1);t=(r=!r)?"}":"{"}y.push(f);return y.join("")};a.getMagnitude=function(a){return Math.pow(10,Math.floor(Math.log(a)/Math.LN10))};a.normalizeTickInterval=function(f,h,t,r,m){var d,g=f;t=a.pick(t,1);d=f/t;h||(h=m?[1,1.2,1.5,2,2.5,3,4,5,6,8,10]:[1,2,2.5,5,10],!1===r&&(1===t?h=a.grep(h,function(a){return 0===a%1}):.1>=t&&(h=[1/t])));
for(r=0;r<h.length&&!(g=h[r],m&&g*t>=f||!m&&d<=(h[r]+(h[r+1]||h[r]))/2);r++);return g=a.correctFloat(g*t,-Math.round(Math.log(.001)/Math.LN10))};a.stableSort=function(a,h){var f=a.length,r,m;for(m=0;m<f;m++)a[m].safeI=m;a.sort(function(a,g){r=h(a,g);return 0===r?a.safeI-g.safeI:r});for(m=0;m<f;m++)delete a[m].safeI};a.arrayMin=function(a){for(var h=a.length,f=a[0];h--;)a[h]<f&&(f=a[h]);return f};a.arrayMax=function(a){for(var h=a.length,f=a[0];h--;)a[h]>f&&(f=a[h]);return f};a.destroyObjectProperties=
function(a,h){for(var f in a)a[f]&&a[f]!==h&&a[f].destroy&&a[f].destroy(),delete a[f]};a.discardElement=function(f){var h=a.garbageBin;h||(h=a.createElement("div"));f&&h.appendChild(f);h.innerHTML=""};a.correctFloat=function(a,h){return parseFloat(a.toPrecision(h||14))};a.setAnimation=function(f,h){h.renderer.globalAnimation=a.pick(f,h.options.chart.animation,!0)};a.animObject=function(f){return a.isObject(f)?a.merge(f):{duration:f?500:0}};a.timeUnits={millisecond:1,second:1E3,minute:6E4,hour:36E5,
day:864E5,week:6048E5,month:24192E5,year:314496E5};a.numberFormat=function(f,h,t,r){f=+f||0;h=+h;var m=a.defaultOptions.lang,d=(f.toString().split(".")[1]||"").length,g,n;-1===h?h=Math.min(d,20):a.isNumber(h)||(h=2);n=(Math.abs(f)+Math.pow(10,-Math.max(h,d)-1)).toFixed(h);d=String(a.pInt(n));g=3<d.length?d.length%3:0;t=a.pick(t,m.decimalPoint);r=a.pick(r,m.thousandsSep);f=(0>f?"-":"")+(g?d.substr(0,g)+r:"");f+=d.substr(g).replace(/(\d{3})(?=\d)/g,"$1"+r);h&&(f+=t+n.slice(-h));return f};Math.easeInOutSine=
function(a){return-.5*(Math.cos(Math.PI*a)-1)};a.getStyle=function(f,h){return"width"===h?Math.min(f.offsetWidth,f.scrollWidth)-a.getStyle(f,"padding-left")-a.getStyle(f,"padding-right"):"height"===h?Math.min(f.offsetHeight,f.scrollHeight)-a.getStyle(f,"padding-top")-a.getStyle(f,"padding-bottom"):(f=B.getComputedStyle(f,void 0))&&a.pInt(f.getPropertyValue(h))};a.inArray=function(a,h){return h.indexOf?h.indexOf(a):[].indexOf.call(h,a)};a.grep=function(a,h){return[].filter.call(a,h)};a.find=function(a,
h){return[].find.call(a,h)};a.map=function(a,h){for(var f=[],r=0,m=a.length;r<m;r++)f[r]=h.call(a[r],a[r],r,a);return f};a.offset=function(a){var h=D.documentElement;a=a.getBoundingClientRect();return{top:a.top+(B.pageYOffset||h.scrollTop)-(h.clientTop||0),left:a.left+(B.pageXOffset||h.scrollLeft)-(h.clientLeft||0)}};a.stop=function(a,h){for(var f=z.length;f--;)z[f].elem!==a||h&&h!==z[f].prop||(z[f].stopped=!0)};a.each=function(a,h,t){return Array.prototype.forEach.call(a,h,t)};a.addEvent=function(f,
h,t){function r(a){a.target=a.srcElement||B;t.call(f,a)}var m=f.hcEvents=f.hcEvents||{};f.addEventListener?f.addEventListener(h,t,!1):f.attachEvent&&(f.hcEventsIE||(f.hcEventsIE={}),f.hcEventsIE[t.toString()]=r,f.attachEvent("on"+h,r));m[h]||(m[h]=[]);m[h].push(t);return function(){a.removeEvent(f,h,t)}};a.removeEvent=function(f,h,t){function r(a,g){f.removeEventListener?f.removeEventListener(a,g,!1):f.attachEvent&&(g=f.hcEventsIE[g.toString()],f.detachEvent("on"+a,g))}function m(){var a,d;if(f.nodeName)for(d in h?
(a={},a[h]=!0):a=g,a)if(g[d])for(a=g[d].length;a--;)r(d,g[d][a])}var d,g=f.hcEvents,n;g&&(h?(d=g[h]||[],t?(n=a.inArray(t,d),-1<n&&(d.splice(n,1),g[h]=d),r(h,t)):(m(),g[h]=[])):(m(),f.hcEvents={}))};a.fireEvent=function(f,h,t,r){var m;m=f.hcEvents;var d,g;t=t||{};if(D.createEvent&&(f.dispatchEvent||f.fireEvent))m=D.createEvent("Events"),m.initEvent(h,!0,!0),a.extend(m,t),f.dispatchEvent?f.dispatchEvent(m):f.fireEvent(h,m);else if(m)for(m=m[h]||[],d=m.length,t.target||a.extend(t,{preventDefault:function(){t.defaultPrevented=
!0},target:f,type:h}),h=0;h<d;h++)(g=m[h])&&!1===g.call(f,t)&&t.preventDefault();r&&!t.defaultPrevented&&r(t)};a.animate=function(f,h,t){var r,m="",d,g,n;a.isObject(t)||(r=arguments,t={duration:r[2],easing:r[3],complete:r[4]});a.isNumber(t.duration)||(t.duration=400);t.easing="function"===typeof t.easing?t.easing:Math[t.easing]||Math.easeInOutSine;t.curAnim=a.merge(h);for(n in h)a.stop(f,n),g=new a.Fx(f,t,n),d=null,"d"===n?(g.paths=g.initPath(f,f.d,h.d),g.toD=h.d,r=0,d=1):f.attr?r=f.attr(n):(r=parseFloat(a.getStyle(f,
n))||0,"opacity"!==n&&(m="px")),d||(d=h[n]),d&&d.match&&d.match("px")&&(d=d.replace(/px/g,"")),g.run(r,d,m)};a.seriesType=function(f,h,t,r,m){var d=a.getOptions(),g=a.seriesTypes;d.plotOptions[f]=a.merge(d.plotOptions[h],t);g[f]=a.extendClass(g[h]||function(){},r);g[f].prototype.type=f;m&&(g[f].prototype.pointClass=a.extendClass(a.Point,m));return g[f]};a.uniqueKey=function(){var a=Math.random().toString(36).substring(2,9),h=0;return function(){return"highcharts-"+a+"-"+h++}}();B.jQuery&&(B.jQuery.fn.highcharts=
function(){var f=[].slice.call(arguments);if(this[0])return f[0]?(new (a[a.isString(f[0])?f.shift():"Chart"])(this[0],f[0],f[1]),this):F[a.attr(this[0],"data-highcharts-chart")]});D&&!D.defaultView&&(a.getStyle=function(f,h){var t={width:"clientWidth",height:"clientHeight"}[h];if(f.style[h])return a.pInt(f.style[h]);"opacity"===h&&(h="filter");if(t)return f.style.zoom=1,Math.max(f[t]-2*a.getStyle(f,"padding"),0);f=f.currentStyle[h.replace(/\-(\w)/g,function(a,m){return m.toUpperCase()})];"filter"===
h&&(f=f.replace(/alpha\(opacity=([0-9]+)\)/,function(a,m){return m/100}));return""===f?1:a.pInt(f)});Array.prototype.forEach||(a.each=function(a,h,t){for(var f=0,m=a.length;f<m;f++)if(!1===h.call(t,a[f],f,a))return f});Array.prototype.indexOf||(a.inArray=function(a,h){var f,r=0;if(h)for(f=h.length;r<f;r++)if(h[r]===a)return r;return-1});Array.prototype.filter||(a.grep=function(a,h){for(var f=[],r=0,m=a.length;r<m;r++)h(a[r],r)&&f.push(a[r]);return f});Array.prototype.find||(a.find=function(a,h){var f,
r=a.length;for(f=0;f<r;f++)if(h(a[f],f))return a[f]})})(J);(function(a){var z=a.each,F=a.isNumber,D=a.map,B=a.merge,f=a.pInt;a.Color=function(h){if(!(this instanceof a.Color))return new a.Color(h);this.init(h)};a.Color.prototype={parsers:[{regex:/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,parse:function(a){return[f(a[1]),f(a[2]),f(a[3]),parseFloat(a[4],10)]}},{regex:/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,parse:function(a){return[f(a[1]),
f(a[2]),f(a[3]),1]}}],names:{white:"#ffffff",black:"#000000"},init:function(h){var f,r,m,d;if((this.input=h=this.names[h&&h.toLowerCase?h.toLowerCase():""]||h)&&h.stops)this.stops=D(h.stops,function(g){return new a.Color(g[1])});else if(h&&"#"===h[0]&&(f=h.length,h=parseInt(h.substr(1),16),7===f?r=[(h&16711680)>>16,(h&65280)>>8,h&255,1]:4===f&&(r=[(h&3840)>>4|(h&3840)>>8,(h&240)>>4|h&240,(h&15)<<4|h&15,1])),!r)for(m=this.parsers.length;m--&&!r;)d=this.parsers[m],(f=d.regex.exec(h))&&(r=d.parse(f));
this.rgba=r||[]},get:function(a){var h=this.input,f=this.rgba,m;this.stops?(m=B(h),m.stops=[].concat(m.stops),z(this.stops,function(d,g){m.stops[g]=[m.stops[g][0],d.get(a)]})):m=f&&F(f[0])?"rgb"===a||!a&&1===f[3]?"rgb("+f[0]+","+f[1]+","+f[2]+")":"a"===a?f[3]:"rgba("+f.join(",")+")":h;return m},brighten:function(a){var h,r=this.rgba;if(this.stops)z(this.stops,function(m){m.brighten(a)});else if(F(a)&&0!==a)for(h=0;3>h;h++)r[h]+=f(255*a),0>r[h]&&(r[h]=0),255<r[h]&&(r[h]=255);return this},setOpacity:function(a){this.rgba[3]=
a;return this}};a.color=function(f){return new a.Color(f)}})(J);(function(a){function z(){var m=a.defaultOptions.global,d=r.moment;if(m.timezone){if(d)return function(a){return-d.tz(a,m.timezone).utcOffset()};a.error(25)}return m.useUTC&&m.getTimezoneOffset}function F(){var m=a.defaultOptions.global,d,g=m.useUTC,n=g?"getUTC":"get",h=g?"setUTC":"set";a.Date=d=m.Date||r.Date;d.hcTimezoneOffset=g&&m.timezoneOffset;d.hcGetTimezoneOffset=z();d.hcMakeTime=function(a,b,l,e,c,n){var u;g?(u=d.UTC.apply(0,
arguments),u+=f(u)):u=(new d(a,b,t(l,1),t(e,0),t(c,0),t(n,0))).getTime();return u};B("Minutes Hours Day Date Month FullYear".split(" "),function(a){d["hcGet"+a]=n+a});B("Milliseconds Seconds Minutes Hours Date Month FullYear".split(" "),function(a){d["hcSet"+a]=h+a})}var D=a.color,B=a.each,f=a.getTZOffset,h=a.merge,t=a.pick,r=a.win;a.defaultOptions={colors:"#7cb5ec #434348 #90ed7d #f7a35c #8085e9 #f15c80 #e4d354 #2b908f #f45b5b #91e8e1".split(" "),symbols:["circle","diamond","square","triangle","triangle-down"],
lang:{loading:"Loading...",months:"January February March April May June July August September October November December".split(" "),shortMonths:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),weekdays:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),decimalPoint:".",numericSymbols:"kMGTPE".split(""),resetZoom:"Reset zoom",resetZoomTitle:"Reset zoom level 1:1",thousandsSep:" "},global:{useUTC:!0,VMLRadialGradientURL:"http://code.highcharts.com/5.0.10/gfx/vml-radial-gradient.png"},
chart:{borderRadius:0,defaultSeriesType:"line",ignoreHiddenSeries:!0,spacing:[10,10,15,10],resetZoomButton:{theme:{zIndex:20},position:{align:"right",x:-10,y:10}},width:null,height:null,borderColor:"#335cad",backgroundColor:"#ffffff",plotBorderColor:"#cccccc"},title:{text:"Chart title",align:"center",margin:15,widthAdjust:-44},subtitle:{text:"",align:"center",widthAdjust:-44},plotOptions:{},labels:{style:{position:"absolute",color:"#333333"}},legend:{enabled:!0,align:"center",layout:"horizontal",
labelFormatter:function(){return this.name},borderColor:"#999999",borderRadius:0,navigation:{activeColor:"#003399",inactiveColor:"#cccccc"},itemStyle:{color:"#333333",fontSize:"12px",fontWeight:"bold"},itemHoverStyle:{color:"#000000"},itemHiddenStyle:{color:"#cccccc"},shadow:!1,itemCheckboxStyle:{position:"absolute",width:"13px",height:"13px"},squareSymbol:!0,symbolPadding:5,verticalAlign:"bottom",x:0,y:0,title:{style:{fontWeight:"bold"}}},loading:{labelStyle:{fontWeight:"bold",position:"relative",
top:"45%"},style:{position:"absolute",backgroundColor:"#ffffff",opacity:.5,textAlign:"center"}},tooltip:{enabled:!0,animation:a.svg,borderRadius:3,dateTimeLabelFormats:{millisecond:"%A, %b %e, %H:%M:%S.%L",second:"%A, %b %e, %H:%M:%S",minute:"%A, %b %e, %H:%M",hour:"%A, %b %e, %H:%M",day:"%A, %b %e, %Y",week:"Week from %A, %b %e, %Y",month:"%B %Y",year:"%Y"},footerFormat:"",padding:8,snap:a.isTouchDevice?25:10,backgroundColor:D("#f7f7f7").setOpacity(.85).get(),borderWidth:1,headerFormat:'\x3cspan style\x3d"font-size: 10px"\x3e{point.key}\x3c/span\x3e\x3cbr/\x3e',
pointFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e {series.name}: \x3cb\x3e{point.y}\x3c/b\x3e\x3cbr/\x3e',shadow:!0,style:{color:"#333333",cursor:"default",fontSize:"12px",pointerEvents:"none",whiteSpace:"nowrap"}},credits:{enabled:!0,href:"http://www.highcharts.com",position:{align:"right",x:-10,verticalAlign:"bottom",y:-5},style:{cursor:"pointer",color:"#999999",fontSize:"9px"},text:"Highcharts.com"}};a.setOptions=function(m){a.defaultOptions=h(!0,a.defaultOptions,m);F();
return a.defaultOptions};a.getOptions=function(){return a.defaultOptions};a.defaultPlotOptions=a.defaultOptions.plotOptions;F()})(J);(function(a){var z,F,D=a.addEvent,B=a.animate,f=a.attr,h=a.charts,t=a.color,r=a.css,m=a.createElement,d=a.defined,g=a.deg2rad,n=a.destroyObjectProperties,y=a.doc,w=a.each,b=a.extend,l=a.erase,e=a.grep,c=a.hasTouch,E=a.inArray,u=a.isArray,q=a.isFirefox,x=a.isMS,A=a.isObject,H=a.isString,k=a.isWebKit,G=a.merge,I=a.noop,L=a.pick,K=a.pInt,p=a.removeEvent,C=a.stop,M=a.svg,
N=a.SVG_NS,Q=a.symbolSizes,O=a.win;z=a.SVGElement=function(){return this};z.prototype={opacity:1,SVG_NS:N,textProps:"direction fontSize fontWeight fontFamily fontStyle color lineHeight width textAlign textDecoration textOverflow textOutline".split(" "),init:function(a,b){this.element="span"===b?m(b):y.createElementNS(this.SVG_NS,b);this.renderer=a},animate:function(v,b,p){b=a.animObject(L(b,this.renderer.globalAnimation,!0));0!==b.duration?(p&&(b.complete=p),B(this,v,b)):(this.attr(v,null,p),b.step&&
b.step.call(this));return this},colorGradient:function(v,b,p){var e=this.renderer,c,q,k,C,x,l,P,g,A,n,m,f=[],h;v.radialGradient?q="radialGradient":v.linearGradient&&(q="linearGradient");if(q){k=v[q];x=e.gradients;P=v.stops;n=p.radialReference;u(k)&&(v[q]=k={x1:k[0],y1:k[1],x2:k[2],y2:k[3],gradientUnits:"userSpaceOnUse"});"radialGradient"===q&&n&&!d(k.gradientUnits)&&(C=k,k=G(k,e.getRadialAttr(n,C),{gradientUnits:"userSpaceOnUse"}));for(m in k)"id"!==m&&f.push(m,k[m]);for(m in P)f.push(P[m]);f=f.join(",");
x[f]?n=x[f].attr("id"):(k.id=n=a.uniqueKey(),x[f]=l=e.createElement(q).attr(k).add(e.defs),l.radAttr=C,l.stops=[],w(P,function(v){0===v[1].indexOf("rgba")?(c=a.color(v[1]),g=c.get("rgb"),A=c.get("a")):(g=v[1],A=1);v=e.createElement("stop").attr({offset:v[0],"stop-color":g,"stop-opacity":A}).add(l);l.stops.push(v)}));h="url("+e.url+"#"+n+")";p.setAttribute(b,h);p.gradient=f;v.toString=function(){return h}}},applyTextOutline:function(v){var b=this.element,p,e,c,q,k;-1!==v.indexOf("contrast")&&(v=v.replace(/contrast/g,
this.renderer.getContrast(b.style.fill)));v=v.split(" ");e=v[v.length-1];if((c=v[0])&&"none"!==c&&a.svg){this.fakeTS=!0;v=[].slice.call(b.getElementsByTagName("tspan"));this.ySetter=this.xSetter;c=c.replace(/(^[\d\.]+)(.*?)$/g,function(a,v,b){return 2*v+b});for(k=v.length;k--;)p=v[k],"highcharts-text-outline"===p.getAttribute("class")&&l(v,b.removeChild(p));q=b.firstChild;w(v,function(a,v){0===v&&(a.setAttribute("x",b.getAttribute("x")),v=b.getAttribute("y"),a.setAttribute("y",v||0),null===v&&b.setAttribute("y",
0));a=a.cloneNode(1);f(a,{"class":"highcharts-text-outline",fill:e,stroke:e,"stroke-width":c,"stroke-linejoin":"round"});b.insertBefore(a,q)})}},attr:function(a,b,p,e){var v,c=this.element,q,k=this,x;"string"===typeof a&&void 0!==b&&(v=a,a={},a[v]=b);if("string"===typeof a)k=(this[a+"Getter"]||this._defaultGetter).call(this,a,c);else{for(v in a)b=a[v],x=!1,e||C(this,v),this.symbolName&&/^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)$/.test(v)&&(q||(this.symbolAttr(a),q=!0),x=!0),!this.rotation||
"x"!==v&&"y"!==v||(this.doTransform=!0),x||(x=this[v+"Setter"]||this._defaultSetter,x.call(this,b,v,c),this.shadows&&/^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(v)&&this.updateShadows(v,b,x));this.doTransform&&(this.updateTransform(),this.doTransform=!1)}p&&p();return k},updateShadows:function(a,b,p){for(var v=this.shadows,e=v.length;e--;)p.call(v[e],"height"===a?Math.max(b-(v[e].cutHeight||0),0):"d"===a?this.d:b,a,v[e])},addClass:function(a,b){var v=this.attr("class")||"";-1===v.indexOf(a)&&
(b||(a=(v+(v?" ":"")+a).replace(" "," ")),this.attr("class",a));return this},hasClass:function(a){return-1!==f(this.element,"class").indexOf(a)},removeClass:function(a){f(this.element,"class",(f(this.element,"class")||"").replace(a,""));return this},symbolAttr:function(a){var v=this;w("x y r start end width height innerR anchorX anchorY".split(" "),function(b){v[b]=L(a[b],v[b])});v.attr({d:v.renderer.symbols[v.symbolName](v.x,v.y,v.width,v.height,v)})},clip:function(a){return this.attr("clip-path",
a?"url("+this.renderer.url+"#"+a.id+")":"none")},crisp:function(a,b){var v,p={},e;b=b||a.strokeWidth||0;e=Math.round(b)%2/2;a.x=Math.floor(a.x||this.x||0)+e;a.y=Math.floor(a.y||this.y||0)+e;a.width=Math.floor((a.width||this.width||0)-2*e);a.height=Math.floor((a.height||this.height||0)-2*e);d(a.strokeWidth)&&(a.strokeWidth=b);for(v in a)this[v]!==a[v]&&(this[v]=p[v]=a[v]);return p},css:function(a){var v=this.styles,p={},e=this.element,c,q="",k=!v,C=["textOutline","textOverflow","width"];a&&a.color&&
(a.fill=a.color);if(v)for(c in a)a[c]!==v[c]&&(p[c]=a[c],k=!0);if(k){v&&(a=b(v,p));v=this.textWidth=a&&a.width&&"auto"!==a.width&&"text"===e.nodeName.toLowerCase()&&K(a.width);this.styles=a;v&&!M&&this.renderer.forExport&&delete a.width;if(x&&!M)r(this.element,a);else{v=function(a,v){return"-"+v.toLowerCase()};for(c in a)-1===E(c,C)&&(q+=c.replace(/([A-Z])/g,v)+":"+a[c]+";");q&&f(e,"style",q)}this.added&&("text"===this.element.nodeName&&this.renderer.buildText(this),a&&a.textOutline&&this.applyTextOutline(a.textOutline))}return this},
strokeWidth:function(){return this["stroke-width"]||0},on:function(a,b){var v=this,p=v.element;c&&"click"===a?(p.ontouchstart=function(a){v.touchEventFired=Date.now();a.preventDefault();b.call(p,a)},p.onclick=function(a){(-1===O.navigator.userAgent.indexOf("Android")||1100<Date.now()-(v.touchEventFired||0))&&b.call(p,a)}):p["on"+a]=b;return this},setRadialReference:function(a){var v=this.renderer.gradients[this.element.gradient];this.element.radialReference=a;v&&v.radAttr&&v.animate(this.renderer.getRadialAttr(a,
v.radAttr));return this},translate:function(a,b){return this.attr({translateX:a,translateY:b})},invert:function(a){this.inverted=a;this.updateTransform();return this},updateTransform:function(){var a=this.translateX||0,b=this.translateY||0,p=this.scaleX,e=this.scaleY,c=this.inverted,q=this.rotation,k=this.element;c&&(a+=this.width,b+=this.height);a=["translate("+a+","+b+")"];c?a.push("rotate(90) scale(-1,1)"):q&&a.push("rotate("+q+" "+(k.getAttribute("x")||0)+" "+(k.getAttribute("y")||0)+")");(d(p)||
d(e))&&a.push("scale("+L(p,1)+" "+L(e,1)+")");a.length&&k.setAttribute("transform",a.join(" "))},toFront:function(){var a=this.element;a.parentNode.appendChild(a);return this},align:function(a,b,p){var v,e,c,q,k={};e=this.renderer;c=e.alignedObjects;var C,x;if(a){if(this.alignOptions=a,this.alignByTranslate=b,!p||H(p))this.alignTo=v=p||"renderer",l(c,this),c.push(this),p=null}else a=this.alignOptions,b=this.alignByTranslate,v=this.alignTo;p=L(p,e[v],e);v=a.align;e=a.verticalAlign;c=(p.x||0)+(a.x||
0);q=(p.y||0)+(a.y||0);"right"===v?C=1:"center"===v&&(C=2);C&&(c+=(p.width-(a.width||0))/C);k[b?"translateX":"x"]=Math.round(c);"bottom"===e?x=1:"middle"===e&&(x=2);x&&(q+=(p.height-(a.height||0))/x);k[b?"translateY":"y"]=Math.round(q);this[this.placed?"animate":"attr"](k);this.placed=!0;this.alignAttr=k;return this},getBBox:function(a,p){var v,e=this.renderer,c,q=this.element,k=this.styles,C,x=this.textStr,l,G=e.cache,d=e.cacheKeys,A;p=L(p,this.rotation);c=p*g;C=k&&k.fontSize;void 0!==x&&(A=x.toString(),
-1===A.indexOf("\x3c")&&(A=A.replace(/[0-9]/g,"0")),A+=["",p||0,C,k&&k.width,k&&k.textOverflow].join());A&&!a&&(v=G[A]);if(!v){if(q.namespaceURI===this.SVG_NS||e.forExport){try{(l=this.fakeTS&&function(a){w(q.querySelectorAll(".highcharts-text-outline"),function(v){v.style.display=a})})&&l("none"),v=q.getBBox?b({},q.getBBox()):{width:q.offsetWidth,height:q.offsetHeight},l&&l("")}catch(V){}if(!v||0>v.width)v={width:0,height:0}}else v=this.htmlGetBBox();e.isSVG&&(a=v.width,e=v.height,k&&"11px"===k.fontSize&&
17===Math.round(e)&&(v.height=e=14),p&&(v.width=Math.abs(e*Math.sin(c))+Math.abs(a*Math.cos(c)),v.height=Math.abs(e*Math.cos(c))+Math.abs(a*Math.sin(c))));if(A&&0<v.height){for(;250<d.length;)delete G[d.shift()];G[A]||d.push(A);G[A]=v}}return v},show:function(a){return this.attr({visibility:a?"inherit":"visible"})},hide:function(){return this.attr({visibility:"hidden"})},fadeOut:function(a){var v=this;v.animate({opacity:0},{duration:a||150,complete:function(){v.attr({y:-9999})}})},add:function(a){var v=
this.renderer,b=this.element,p;a&&(this.parentGroup=a);this.parentInverted=a&&a.inverted;void 0!==this.textStr&&v.buildText(this);this.added=!0;if(!a||a.handleZ||this.zIndex)p=this.zIndexSetter();p||(a?a.element:v.box).appendChild(b);if(this.onAdd)this.onAdd();return this},safeRemoveChild:function(a){var v=a.parentNode;v&&v.removeChild(a)},destroy:function(){var a=this,b=a.element||{},p=a.renderer.isSVG&&"SPAN"===b.nodeName&&a.parentGroup,e,c;b.onclick=b.onmouseout=b.onmouseover=b.onmousemove=b.point=
null;C(a);a.clipPath&&(w(a.element.ownerSVGElement.querySelectorAll("[clip-path]"),function(v){-1<v.getAttribute("clip-path").indexOf(a.clipPath.element.id)&&v.removeAttribute("clip-path")}),a.clipPath=a.clipPath.destroy());if(a.stops){for(c=0;c<a.stops.length;c++)a.stops[c]=a.stops[c].destroy();a.stops=null}a.safeRemoveChild(b);for(a.destroyShadows();p&&p.div&&0===p.div.childNodes.length;)b=p.parentGroup,a.safeRemoveChild(p.div),delete p.div,p=b;a.alignTo&&l(a.renderer.alignedObjects,a);for(e in a)delete a[e];
return null},shadow:function(a,b,p){var v=[],e,c,q=this.element,k,C,x,l;if(!a)this.destroyShadows();else if(!this.shadows){C=L(a.width,3);x=(a.opacity||.15)/C;l=this.parentInverted?"(-1,-1)":"("+L(a.offsetX,1)+", "+L(a.offsetY,1)+")";for(e=1;e<=C;e++)c=q.cloneNode(0),k=2*C+1-2*e,f(c,{isShadow:"true",stroke:a.color||"#000000","stroke-opacity":x*e,"stroke-width":k,transform:"translate"+l,fill:"none"}),p&&(f(c,"height",Math.max(f(c,"height")-k,0)),c.cutHeight=k),b?b.element.appendChild(c):q.parentNode.insertBefore(c,
q),v.push(c);this.shadows=v}return this},destroyShadows:function(){w(this.shadows||[],function(a){this.safeRemoveChild(a)},this);this.shadows=void 0},xGetter:function(a){"circle"===this.element.nodeName&&("x"===a?a="cx":"y"===a&&(a="cy"));return this._defaultGetter(a)},_defaultGetter:function(a){a=L(this[a],this.element?this.element.getAttribute(a):null,0);/^[\-0-9\.]+$/.test(a)&&(a=parseFloat(a));return a},dSetter:function(a,b,p){a&&a.join&&(a=a.join(" "));/(NaN| {2}|^$)/.test(a)&&(a="M 0 0");p.setAttribute(b,
a);this[b]=a},dashstyleSetter:function(a){var b,v=this["stroke-width"];"inherit"===v&&(v=1);if(a=a&&a.toLowerCase()){a=a.replace("shortdashdotdot","3,1,1,1,1,1,").replace("shortdashdot","3,1,1,1").replace("shortdot","1,1,").replace("shortdash","3,1,").replace("longdash","8,3,").replace(/dot/g,"1,3,").replace("dash","4,3,").replace(/,$/,"").split(",");for(b=a.length;b--;)a[b]=K(a[b])*v;a=a.join(",").replace(/NaN/g,"none");this.element.setAttribute("stroke-dasharray",a)}},alignSetter:function(a){this.element.setAttribute("text-anchor",
{left:"start",center:"middle",right:"end"}[a])},opacitySetter:function(a,b,p){this[b]=a;p.setAttribute(b,a)},titleSetter:function(a){var b=this.element.getElementsByTagName("title")[0];b||(b=y.createElementNS(this.SVG_NS,"title"),this.element.appendChild(b));b.firstChild&&b.removeChild(b.firstChild);b.appendChild(y.createTextNode(String(L(a),"").replace(/<[^>]*>/g,"")))},textSetter:function(a){a!==this.textStr&&(delete this.bBox,this.textStr=a,this.added&&this.renderer.buildText(this))},fillSetter:function(a,
b,p){"string"===typeof a?p.setAttribute(b,a):a&&this.colorGradient(a,b,p)},visibilitySetter:function(a,b,p){"inherit"===a?p.removeAttribute(b):p.setAttribute(b,a)},zIndexSetter:function(a,b){var v=this.renderer,p=this.parentGroup,e=(p||v).element||v.box,c,q=this.element,k;c=this.added;var C;d(a)&&(q.zIndex=a,a=+a,this[b]===a&&(c=!1),this[b]=a);if(c){(a=this.zIndex)&&p&&(p.handleZ=!0);b=e.childNodes;for(C=0;C<b.length&&!k;C++)p=b[C],c=p.zIndex,p!==q&&(K(c)>a||!d(a)&&d(c)||0>a&&!d(c)&&e!==v.box)&&(e.insertBefore(q,
p),k=!0);k||e.appendChild(q)}return k},_defaultSetter:function(a,b,p){p.setAttribute(b,a)}};z.prototype.yGetter=z.prototype.xGetter;z.prototype.translateXSetter=z.prototype.translateYSetter=z.prototype.rotationSetter=z.prototype.verticalAlignSetter=z.prototype.scaleXSetter=z.prototype.scaleYSetter=function(a,b){this[b]=a;this.doTransform=!0};z.prototype["stroke-widthSetter"]=z.prototype.strokeSetter=function(a,b,p){this[b]=a;this.stroke&&this["stroke-width"]?(z.prototype.fillSetter.call(this,this.stroke,
"stroke",p),p.setAttribute("stroke-width",this["stroke-width"]),this.hasStroke=!0):"stroke-width"===b&&0===a&&this.hasStroke&&(p.removeAttribute("stroke"),this.hasStroke=!1)};F=a.SVGRenderer=function(){this.init.apply(this,arguments)};F.prototype={Element:z,SVG_NS:N,init:function(a,b,p,e,c,C){var v;e=this.createElement("svg").attr({version:"1.1","class":"highcharts-root"}).css(this.getStyle(e));v=e.element;a.appendChild(v);-1===a.innerHTML.indexOf("xmlns")&&f(v,"xmlns",this.SVG_NS);this.isSVG=!0;
this.box=v;this.boxWrapper=e;this.alignedObjects=[];this.url=(q||k)&&y.getElementsByTagName("base").length?O.location.href.replace(/#.*?$/,"").replace(/<[^>]*>/g,"").replace(/([\('\)])/g,"\\$1").replace(/ /g,"%20"):"";this.createElement("desc").add().element.appendChild(y.createTextNode("Created with Highmaps 5.0.10"));this.defs=this.createElement("defs").add();this.allowHTML=C;this.forExport=c;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(b,p,!1);var x;q&&a.getBoundingClientRect&&
(b=function(){r(a,{left:0,top:0});x=a.getBoundingClientRect();r(a,{left:Math.ceil(x.left)-x.left+"px",top:Math.ceil(x.top)-x.top+"px"})},b(),this.unSubPixelFix=D(O,"resize",b))},getStyle:function(a){return this.style=b({fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif',fontSize:"12px"},a)},setStyle:function(a){this.boxWrapper.css(this.getStyle(a))},isHidden:function(){return!this.boxWrapper.getBBox().width},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=
this.boxWrapper.destroy();n(this.gradients||{});this.gradients=null;a&&(this.defs=a.destroy());this.unSubPixelFix&&this.unSubPixelFix();return this.alignedObjects=null},createElement:function(a){var b=new this.Element;b.init(this,a);return b},draw:I,getRadialAttr:function(a,b){return{cx:a[0]-a[2]/2+b.cx*a[2],cy:a[1]-a[2]/2+b.cy*a[2],r:b.r*a[2]}},getSpanWidth:function(a,b){var p=a.getBBox(!0).width;!M&&this.forExport&&(p=this.measureSpanWidth(b.firstChild.data,a.styles));return p},applyEllipsis:function(a,
b,p,e){var v=this.getSpanWidth(a,b),c=v>e,v=p,q,k=0,C=p.length,x=function(a){b.removeChild(b.firstChild);a&&b.appendChild(y.createTextNode(a))};if(c){for(;k<=C;)q=Math.ceil((k+C)/2),v=p.substring(0,q)+"\u2026",x(v),v=this.getSpanWidth(a,b),k===C?k=C+1:v>e?C=q-1:k=q;0===C&&x("")}return c},buildText:function(a){var b=a.element,p=this,v=p.forExport,c=L(a.textStr,"").toString(),q=-1!==c.indexOf("\x3c"),k=b.childNodes,C,x,l,G,g=f(b,"x"),d=a.styles,A=a.textWidth,u=d&&d.lineHeight,n=d&&d.textOutline,m=d&&
"ellipsis"===d.textOverflow,h=d&&"nowrap"===d.whiteSpace,E=d&&d.fontSize,H,I,t=k.length,d=A&&!a.added&&this.box,Q=function(a){var v;v=/(px|em)$/.test(a&&a.style.fontSize)?a.style.fontSize:E||p.style.fontSize||12;return u?K(u):p.fontMetrics(v,a.getAttribute("style")?a:b).h};H=[c,m,h,u,n,E,A].join();if(H!==a.textCache){for(a.textCache=H;t--;)b.removeChild(k[t]);q||n||m||A||-1!==c.indexOf(" ")?(C=/<.*class="([^"]+)".*>/,x=/<.*style="([^"]+)".*>/,l=/<.*href="(http[^"]+)".*>/,d&&d.appendChild(b),c=q?c.replace(/<(b|strong)>/g,
'\x3cspan style\x3d"font-weight:bold"\x3e').replace(/<(i|em)>/g,'\x3cspan style\x3d"font-style:italic"\x3e').replace(/<a/g,"\x3cspan").replace(/<\/(b|strong|i|em|a)>/g,"\x3c/span\x3e").split(/<br.*?>/g):[c],c=e(c,function(a){return""!==a}),w(c,function(c,e){var q,k=0;c=c.replace(/^\s+|\s+$/g,"").replace(/<span/g,"|||\x3cspan").replace(/<\/span>/g,"\x3c/span\x3e|||");q=c.split("|||");w(q,function(c){if(""!==c||1===q.length){var d={},n=y.createElementNS(p.SVG_NS,"tspan"),u,w;C.test(c)&&(u=c.match(C)[1],
f(n,"class",u));x.test(c)&&(w=c.match(x)[1].replace(/(;| |^)color([ :])/,"$1fill$2"),f(n,"style",w));l.test(c)&&!v&&(f(n,"onclick",'location.href\x3d"'+c.match(l)[1]+'"'),r(n,{cursor:"pointer"}));c=(c.replace(/<(.|\n)*?>/g,"")||" ").replace(/</g,"\x3c").replace(/>/g,"\x3e");if(" "!==c){n.appendChild(y.createTextNode(c));k?d.dx=0:e&&null!==g&&(d.x=g);f(n,d);b.appendChild(n);!k&&I&&(!M&&v&&r(n,{display:"block"}),f(n,"dy",Q(n)));if(A){d=c.replace(/([^\^])-/g,"$1- ").split(" ");u=1<q.length||e||
1<d.length&&!h;var E=[],H,P=Q(n),L=a.rotation;for(m&&(G=p.applyEllipsis(a,n,c,A));!m&&u&&(d.length||E.length);)a.rotation=0,H=p.getSpanWidth(a,n),c=H>A,void 0===G&&(G=c),c&&1!==d.length?(n.removeChild(n.firstChild),E.unshift(d.pop())):(d=E,E=[],d.length&&!h&&(n=y.createElementNS(N,"tspan"),f(n,{dy:P,x:g}),w&&f(n,"style",w),b.appendChild(n)),H>A&&(A=H)),d.length&&n.appendChild(y.createTextNode(d.join(" ").replace(/- /g,"-")));a.rotation=L}k++}}});I=I||b.childNodes.length}),G&&a.attr("title",a.textStr),
d&&d.removeChild(b),n&&a.applyTextOutline&&a.applyTextOutline(n)):b.appendChild(y.createTextNode(c.replace(/</g,"\x3c").replace(/>/g,"\x3e")))}},getContrast:function(a){a=t(a).rgba;return 510<a[0]+a[1]+a[2]?"#000000":"#FFFFFF"},button:function(a,p,c,e,q,k,C,l,d){var v=this.label(a,p,c,d,null,null,null,null,"button"),g=0;v.attr(G({padding:8,r:2},q));var n,A,u,m;q=G({fill:"#f7f7f7",stroke:"#cccccc","stroke-width":1,style:{color:"#333333",cursor:"pointer",fontWeight:"normal"}},q);n=q.style;delete q.style;
k=G(q,{fill:"#e6e6e6"},k);A=k.style;delete k.style;C=G(q,{fill:"#e6ebf5",style:{color:"#000000",fontWeight:"bold"}},C);u=C.style;delete C.style;l=G(q,{style:{color:"#cccccc"}},l);m=l.style;delete l.style;D(v.element,x?"mouseover":"mouseenter",function(){3!==g&&v.setState(1)});D(v.element,x?"mouseout":"mouseleave",function(){3!==g&&v.setState(g)});v.setState=function(a){1!==a&&(v.state=g=a);v.removeClass(/highcharts-button-(normal|hover|pressed|disabled)/).addClass("highcharts-button-"+["normal","hover",
"pressed","disabled"][a||0]);v.attr([q,k,C,l][a||0]).css([n,A,u,m][a||0])};v.attr(q).css(b({cursor:"default"},n));return v.on("click",function(a){3!==g&&e.call(v,a)})},crispLine:function(a,b){a[1]===a[4]&&(a[1]=a[4]=Math.round(a[1])-b%2/2);a[2]===a[5]&&(a[2]=a[5]=Math.round(a[2])+b%2/2);return a},path:function(a){var p={fill:"none"};u(a)?p.d=a:A(a)&&b(p,a);return this.createElement("path").attr(p)},circle:function(a,b,p){a=A(a)?a:{x:a,y:b,r:p};b=this.createElement("circle");b.xSetter=b.ySetter=function(a,
b,p){p.setAttribute("c"+b,a)};return b.attr(a)},arc:function(a,b,p,c,e,q){A(a)?(c=a,b=c.y,p=c.r,a=c.x):c={innerR:c,start:e,end:q};a=this.symbol("arc",a,b,p,p,c);a.r=p;return a},rect:function(a,b,p,c,e,q){e=A(a)?a.r:e;var v=this.createElement("rect");a=A(a)?a:void 0===a?{}:{x:a,y:b,width:Math.max(p,0),height:Math.max(c,0)};void 0!==q&&(a.strokeWidth=q,a=v.crisp(a));a.fill="none";e&&(a.r=e);v.rSetter=function(a,b,p){f(p,{rx:a,ry:a})};return v.attr(a)},setSize:function(a,b,p){var c=this.alignedObjects,
e=c.length;this.width=a;this.height=b;for(this.boxWrapper.animate({width:a,height:b},{step:function(){this.attr({viewBox:"0 0 "+this.attr("width")+" "+this.attr("height")})},duration:L(p,!0)?void 0:0});e--;)c[e].align()},g:function(a){var b=this.createElement("g");return a?b.attr({"class":"highcharts-"+a}):b},image:function(a,p,c,e,q){var v={preserveAspectRatio:"none"};1<arguments.length&&b(v,{x:p,y:c,width:e,height:q});v=this.createElement("image").attr(v);v.element.setAttributeNS?v.element.setAttributeNS("http://www.w3.org/1999/xlink",
"href",a):v.element.setAttribute("hc-svg-href",a);return v},symbol:function(a,p,c,e,q,k){var v=this,C,x=this.symbols[a],l=d(p)&&x&&this.symbols[a](Math.round(p),Math.round(c),e,q,k),g=/^url\((.*?)\)$/,G,n;x?(C=this.path(l),C.attr("fill","none"),b(C,{symbolName:a,x:p,y:c,width:e,height:q}),k&&b(C,k)):g.test(a)&&(G=a.match(g)[1],C=this.image(G),C.imgwidth=L(Q[G]&&Q[G].width,k&&k.width),C.imgheight=L(Q[G]&&Q[G].height,k&&k.height),n=function(){C.attr({width:C.width,height:C.height})},w(["width","height"],
function(a){C[a+"Setter"]=function(a,b){var p={},c=this["img"+b],e="width"===b?"translateX":"translateY";this[b]=a;d(c)&&(this.element&&this.element.setAttribute(b,c),this.alignByTranslate||(p[e]=((this[b]||0)-c)/2,this.attr(p)))}}),d(p)&&C.attr({x:p,y:c}),C.isImg=!0,d(C.imgwidth)&&d(C.imgheight)?n():(C.attr({width:0,height:0}),m("img",{onload:function(){var a=h[v.chartIndex];0===this.width&&(r(this,{position:"absolute",top:"-999em"}),y.body.appendChild(this));Q[G]={width:this.width,height:this.height};
C.imgwidth=this.width;C.imgheight=this.height;C.element&&n();this.parentNode&&this.parentNode.removeChild(this);v.imgCount--;if(!v.imgCount&&a&&a.onload)a.onload()},src:G}),this.imgCount++));return C},symbols:{circle:function(a,b,p,c){return this.arc(a+p/2,b+c/2,p/2,c/2,{start:0,end:2*Math.PI,open:!1})},square:function(a,b,p,c){return["M",a,b,"L",a+p,b,a+p,b+c,a,b+c,"Z"]},triangle:function(a,b,p,c){return["M",a+p/2,b,"L",a+p,b+c,a,b+c,"Z"]},"triangle-down":function(a,b,p,c){return["M",a,b,"L",a+p,
b,a+p/2,b+c,"Z"]},diamond:function(a,b,p,c){return["M",a+p/2,b,"L",a+p,b+c/2,a+p/2,b+c,a,b+c/2,"Z"]},arc:function(a,b,p,c,e){var q=e.start,k=e.r||p,v=e.r||c||p,C=e.end-.001;p=e.innerR;c=e.open;var x=Math.cos(q),l=Math.sin(q),G=Math.cos(C),C=Math.sin(C);e=e.end-q<Math.PI?0:1;k=["M",a+k*x,b+v*l,"A",k,v,0,e,1,a+k*G,b+v*C];d(p)&&k.push(c?"M":"L",a+p*G,b+p*C,"A",p,p,0,e,0,a+p*x,b+p*l);k.push(c?"":"Z");return k},callout:function(a,b,p,c,e){var q=Math.min(e&&e.r||0,p,c),k=q+6,C=e&&e.anchorX;e=e&&e.anchorY;
var v;v=["M",a+q,b,"L",a+p-q,b,"C",a+p,b,a+p,b,a+p,b+q,"L",a+p,b+c-q,"C",a+p,b+c,a+p,b+c,a+p-q,b+c,"L",a+q,b+c,"C",a,b+c,a,b+c,a,b+c-q,"L",a,b+q,"C",a,b,a,b,a+q,b];C&&C>p?e>b+k&&e<b+c-k?v.splice(13,3,"L",a+p,e-6,a+p+6,e,a+p,e+6,a+p,b+c-q):v.splice(13,3,"L",a+p,c/2,C,e,a+p,c/2,a+p,b+c-q):C&&0>C?e>b+k&&e<b+c-k?v.splice(33,3,"L",a,e+6,a-6,e,a,e-6,a,b+q):v.splice(33,3,"L",a,c/2,C,e,a,c/2,a,b+q):e&&e>c&&C>a+k&&C<a+p-k?v.splice(23,3,"L",C+6,b+c,C,b+c+6,C-6,b+c,a+q,b+c):e&&0>e&&C>a+k&&C<a+p-k&&v.splice(3,
3,"L",C-6,b,C,b-6,C+6,b,p-q,b);return v}},clipRect:function(b,p,c,e){var q=a.uniqueKey(),k=this.createElement("clipPath").attr({id:q}).add(this.defs);b=this.rect(b,p,c,e,0).add(k);b.id=q;b.clipPath=k;b.count=0;return b},text:function(a,b,p,c){var e=!M&&this.forExport,q={};if(c&&(this.allowHTML||!this.forExport))return this.html(a,b,p);q.x=Math.round(b||0);p&&(q.y=Math.round(p));if(a||0===a)q.text=a;a=this.createElement("text").attr(q);e&&a.css({position:"absolute"});c||(a.xSetter=function(a,b,p){var c=
p.getElementsByTagName("tspan"),e,q=p.getAttribute(b),k;for(k=0;k<c.length;k++)e=c[k],e.getAttribute(b)===q&&e.setAttribute(b,a);p.setAttribute(b,a)});return a},fontMetrics:function(a,b){a=a||b&&b.style&&b.style.fontSize||this.style&&this.style.fontSize;a=/px/.test(a)?K(a):/em/.test(a)?parseFloat(a)*(b?this.fontMetrics(null,b.parentNode).f:16):12;b=24>a?a+3:Math.round(1.2*a);return{h:b,b:Math.round(.8*b),f:a}},rotCorr:function(a,b,p){var c=a;b&&p&&(c=Math.max(c*Math.cos(b*g),4));return{x:-a/3*Math.sin(b*
g),y:c}},label:function(c,e,q,k,C,x,l,g,n){var v=this,A=v.g("button"!==n&&"label"),u=A.text=v.text("",0,0,l).attr({zIndex:1}),m,f,h=0,E=3,H=0,y,I,M,N,r,L={},K,t,Q=/^url\((.*?)\)$/.test(k),P=Q,R,S,O,U;n&&A.addClass("highcharts-"+n);P=Q;R=function(){return(K||0)%2/2};S=function(){var a=u.element.style,p={};f=(void 0===y||void 0===I||r)&&d(u.textStr)&&u.getBBox();A.width=(y||f.width||0)+2*E+H;A.height=(I||f.height||0)+2*E;t=E+v.fontMetrics(a&&a.fontSize,u).b;P&&(m||(A.box=m=v.symbols[k]||Q?v.symbol(k):
v.rect(),m.addClass(("button"===n?"":"highcharts-label-box")+(n?" highcharts-"+n+"-box":"")),m.add(A),a=R(),p.x=a,p.y=(g?-t:0)+a),p.width=Math.round(A.width),p.height=Math.round(A.height),m.attr(b(p,L)),L={})};O=function(){var a=H+E,b;b=g?0:t;d(y)&&f&&("center"===r||"right"===r)&&(a+={center:.5,right:1}[r]*(y-f.width));if(a!==u.x||b!==u.y)u.attr("x",a),void 0!==b&&u.attr("y",b);u.x=a;u.y=b};U=function(a,b){m?m.attr(a,b):L[a]=b};A.onAdd=function(){u.add(A);A.attr({text:c||0===c?c:"",x:e,y:q});m&&d(C)&&
A.attr({anchorX:C,anchorY:x})};A.widthSetter=function(b){y=a.isNumber(b)?b:null};A.heightSetter=function(a){I=a};A["text-alignSetter"]=function(a){r=a};A.paddingSetter=function(a){d(a)&&a!==E&&(E=A.padding=a,O())};A.paddingLeftSetter=function(a){d(a)&&a!==H&&(H=a,O())};A.alignSetter=function(a){a={left:0,center:.5,right:1}[a];a!==h&&(h=a,f&&A.attr({x:M}))};A.textSetter=function(a){void 0!==a&&u.textSetter(a);S();O()};A["stroke-widthSetter"]=function(a,b){a&&(P=!0);K=this["stroke-width"]=a;U(b,a)};
A.strokeSetter=A.fillSetter=A.rSetter=function(a,b){"fill"===b&&a&&(P=!0);U(b,a)};A.anchorXSetter=function(a,b){C=a;U(b,Math.round(a)-R()-M)};A.anchorYSetter=function(a,b){x=a;U(b,a-N)};A.xSetter=function(a){A.x=a;h&&(a-=h*((y||f.width)+2*E));M=Math.round(a);A.attr("translateX",M)};A.ySetter=function(a){N=A.y=Math.round(a);A.attr("translateY",N)};var B=A.css;return b(A,{css:function(a){if(a){var b={};a=G(a);w(A.textProps,function(p){void 0!==a[p]&&(b[p]=a[p],delete a[p])});u.css(b)}return B.call(A,
a)},getBBox:function(){return{width:f.width+2*E,height:f.height+2*E,x:f.x-E,y:f.y-E}},shadow:function(a){a&&(S(),m&&m.shadow(a));return A},destroy:function(){p(A.element,"mouseenter");p(A.element,"mouseleave");u&&(u=u.destroy());m&&(m=m.destroy());z.prototype.destroy.call(A);A=v=S=O=U=null}})}};a.Renderer=F})(J);(function(a){var z=a.attr,F=a.createElement,D=a.css,B=a.defined,f=a.each,h=a.extend,t=a.isFirefox,r=a.isMS,m=a.isWebKit,d=a.pInt,g=a.SVGRenderer,n=a.win,y=a.wrap;h(a.SVGElement.prototype,
{htmlCss:function(a){var b=this.element;if(b=a&&"SPAN"===b.tagName&&a.width)delete a.width,this.textWidth=b,this.updateTransform();a&&"ellipsis"===a.textOverflow&&(a.whiteSpace="nowrap",a.overflow="hidden");this.styles=h(this.styles,a);D(this.element,a);return this},htmlGetBBox:function(){var a=this.element;"text"===a.nodeName&&(a.style.position="absolute");return{x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight}},htmlUpdateTransform:function(){if(this.added){var a=this.renderer,
b=this.element,l=this.translateX||0,e=this.translateY||0,c=this.x||0,g=this.y||0,n=this.textAlign||"left",q={left:0,center:.5,right:1}[n],x=this.styles;D(b,{marginLeft:l,marginTop:e});this.shadows&&f(this.shadows,function(a){D(a,{marginLeft:l+1,marginTop:e+1})});this.inverted&&f(b.childNodes,function(c){a.invertChild(c,b)});if("SPAN"===b.tagName){var A=this.rotation,h=d(this.textWidth),k=x&&x.whiteSpace,G=[A,n,b.innerHTML,this.textWidth,this.textAlign].join();G!==this.cTT&&(x=a.fontMetrics(b.style.fontSize).b,
B(A)&&this.setSpanRotation(A,q,x),D(b,{width:"",whiteSpace:k||"nowrap"}),b.offsetWidth>h&&/[ \-]/.test(b.textContent||b.innerText)&&D(b,{width:h+"px",display:"block",whiteSpace:k||"normal"}),this.getSpanCorrection(b.offsetWidth,x,q,A,n));D(b,{left:c+(this.xCorr||0)+"px",top:g+(this.yCorr||0)+"px"});m&&(x=b.offsetHeight);this.cTT=G}}else this.alignOnAdd=!0},setSpanRotation:function(a,b,l){var e={},c=r?"-ms-transform":m?"-webkit-transform":t?"MozTransform":n.opera?"-o-transform":"";e[c]=e.transform=
"rotate("+a+"deg)";e[c+(t?"Origin":"-origin")]=e.transformOrigin=100*b+"% "+l+"px";D(this.element,e)},getSpanCorrection:function(a,b,l){this.xCorr=-a*l;this.yCorr=-b}});h(g.prototype,{html:function(a,b,l){var e=this.createElement("span"),c=e.element,d=e.renderer,g=d.isSVG,q=function(a,b){f(["opacity","visibility"],function(c){y(a,c+"Setter",function(a,c,e,q){a.call(this,c,e,q);b[e]=c})})};e.textSetter=function(a){a!==c.innerHTML&&delete this.bBox;c.innerHTML=this.textStr=a;e.htmlUpdateTransform()};
g&&q(e,e.element.style);e.xSetter=e.ySetter=e.alignSetter=e.rotationSetter=function(a,b){"align"===b&&(b="textAlign");e[b]=a;e.htmlUpdateTransform()};e.attr({text:a,x:Math.round(b),y:Math.round(l)}).css({fontFamily:this.style.fontFamily,fontSize:this.style.fontSize,position:"absolute"});c.style.whiteSpace="nowrap";e.css=e.htmlCss;g&&(e.add=function(a){var b,x=d.box.parentNode,k=[];if(this.parentGroup=a){if(b=a.div,!b){for(;a;)k.push(a),a=a.parentGroup;f(k.reverse(),function(a){var c,l=z(a.element,
"class");l&&(l={className:l});b=a.div=a.div||F("div",l,{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px",display:a.display,opacity:a.opacity,pointerEvents:a.styles&&a.styles.pointerEvents},b||x);c=b.style;h(a,{on:function(){e.on.apply({element:k[0].div},arguments);return a},translateXSetter:function(b,p){c.left=b+"px";a[p]=b;a.doTransform=!0},translateYSetter:function(b,p){c.top=b+"px";a[p]=b;a.doTransform=!0}});q(a,c)})}}else b=x;b.appendChild(c);e.added=!0;e.alignOnAdd&&
e.htmlUpdateTransform();return e});return e}})})(J);(function(a){var z,F,D=a.createElement,B=a.css,f=a.defined,h=a.deg2rad,t=a.discardElement,r=a.doc,m=a.each,d=a.erase,g=a.extend;z=a.extendClass;var n=a.isArray,y=a.isNumber,w=a.isObject,b=a.merge;F=a.noop;var l=a.pick,e=a.pInt,c=a.SVGElement,E=a.SVGRenderer,u=a.win;a.svg||(F={docMode8:r&&8===r.documentMode,init:function(a,b){var c=["\x3c",b,' filled\x3d"f" stroked\x3d"f"'],e=["position: ","absolute",";"],q="div"===b;("shape"===b||q)&&e.push("left:0;top:0;width:1px;height:1px;");
e.push("visibility: ",q?"hidden":"visible");c.push(' style\x3d"',e.join(""),'"/\x3e');b&&(c=q||"span"===b||"img"===b?c.join(""):a.prepVML(c),this.element=D(c));this.renderer=a},add:function(a){var b=this.renderer,c=this.element,e=b.box,q=a&&a.inverted,e=a?a.element||a:e;a&&(this.parentGroup=a);q&&b.invertChild(c,e);e.appendChild(c);this.added=!0;this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform();if(this.onAdd)this.onAdd();this.className&&this.attr("class",this.className);return this},
updateTransform:c.prototype.htmlUpdateTransform,setSpanRotation:function(){var a=this.rotation,b=Math.cos(a*h),c=Math.sin(a*h);B(this.element,{filter:a?["progid:DXImageTransform.Microsoft.Matrix(M11\x3d",b,", M12\x3d",-c,", M21\x3d",c,", M22\x3d",b,", sizingMethod\x3d'auto expand')"].join(""):"none"})},getSpanCorrection:function(a,b,c,e,k){var q=e?Math.cos(e*h):1,x=e?Math.sin(e*h):0,d=l(this.elemHeight,this.element.offsetHeight),g;this.xCorr=0>q&&-a;this.yCorr=0>x&&-d;g=0>q*x;this.xCorr+=x*b*(g?1-
c:c);this.yCorr-=q*b*(e?g?c:1-c:1);k&&"left"!==k&&(this.xCorr-=a*c*(0>q?-1:1),e&&(this.yCorr-=d*c*(0>x?-1:1)),B(this.element,{textAlign:k}))},pathToVML:function(a){for(var b=a.length,c=[];b--;)y(a[b])?c[b]=Math.round(10*a[b])-5:"Z"===a[b]?c[b]="x":(c[b]=a[b],!a.isArc||"wa"!==a[b]&&"at"!==a[b]||(c[b+5]===c[b+7]&&(c[b+7]+=a[b+7]>a[b+5]?1:-1),c[b+6]===c[b+8]&&(c[b+8]+=a[b+8]>a[b+6]?1:-1)));return c.join(" ")||"x"},clip:function(a){var b=this,c;a?(c=a.members,d(c,b),c.push(b),b.destroyClip=function(){d(c,
b)},a=a.getCSS(b)):(b.destroyClip&&b.destroyClip(),a={clip:b.docMode8?"inherit":"rect(auto)"});return b.css(a)},css:c.prototype.htmlCss,safeRemoveChild:function(a){a.parentNode&&t(a)},destroy:function(){this.destroyClip&&this.destroyClip();return c.prototype.destroy.apply(this)},on:function(a,b){this.element["on"+a]=function(){var a=u.event;a.target=a.srcElement;b(a)};return this},cutOffPath:function(a,b){var c;a=a.split(/[ ,]/);c=a.length;if(9===c||11===c)a[c-4]=a[c-2]=e(a[c-2])-10*b;return a.join(" ")},
shadow:function(a,b,c){var q=[],k,d=this.element,g=this.renderer,x,n=d.style,p,C=d.path,u,A,m,f;C&&"string"!==typeof C.value&&(C="x");A=C;if(a){m=l(a.width,3);f=(a.opacity||.15)/m;for(k=1;3>=k;k++)u=2*m+1-2*k,c&&(A=this.cutOffPath(C.value,u+.5)),p=['\x3cshape isShadow\x3d"true" strokeweight\x3d"',u,'" filled\x3d"false" path\x3d"',A,'" coordsize\x3d"10 10" style\x3d"',d.style.cssText,'" /\x3e'],x=D(g.prepVML(p),null,{left:e(n.left)+l(a.offsetX,1),top:e(n.top)+l(a.offsetY,1)}),c&&(x.cutOff=u+1),p=['\x3cstroke color\x3d"',
a.color||"#000000",'" opacity\x3d"',f*k,'"/\x3e'],D(g.prepVML(p),null,null,x),b?b.element.appendChild(x):d.parentNode.insertBefore(x,d),q.push(x);this.shadows=q}return this},updateShadows:F,setAttr:function(a,b){this.docMode8?this.element[a]=b:this.element.setAttribute(a,b)},classSetter:function(a){(this.added?this.element:this).className=a},dashstyleSetter:function(a,b,c){(c.getElementsByTagName("stroke")[0]||D(this.renderer.prepVML(["\x3cstroke/\x3e"]),null,null,c))[b]=a||"solid";this[b]=a},dSetter:function(a,
b,c){var e=this.shadows;a=a||[];this.d=a.join&&a.join(" ");c.path=a=this.pathToVML(a);if(e)for(c=e.length;c--;)e[c].path=e[c].cutOff?this.cutOffPath(a,e[c].cutOff):a;this.setAttr(b,a)},fillSetter:function(a,b,c){var e=c.nodeName;"SPAN"===e?c.style.color=a:"IMG"!==e&&(c.filled="none"!==a,this.setAttr("fillcolor",this.renderer.color(a,c,b,this)))},"fill-opacitySetter":function(a,b,c){D(this.renderer.prepVML(["\x3c",b.split("-")[0],' opacity\x3d"',a,'"/\x3e']),null,null,c)},opacitySetter:F,rotationSetter:function(a,
b,c){c=c.style;this[b]=c[b]=a;c.left=-Math.round(Math.sin(a*h)+1)+"px";c.top=Math.round(Math.cos(a*h))+"px"},strokeSetter:function(a,b,c){this.setAttr("strokecolor",this.renderer.color(a,c,b,this))},"stroke-widthSetter":function(a,b,c){c.stroked=!!a;this[b]=a;y(a)&&(a+="px");this.setAttr("strokeweight",a)},titleSetter:function(a,b){this.setAttr(b,a)},visibilitySetter:function(a,b,c){"inherit"===a&&(a="visible");this.shadows&&m(this.shadows,function(c){c.style[b]=a});"DIV"===c.nodeName&&(a="hidden"===
a?"-999em":0,this.docMode8||(c.style[b]=a?"visible":"hidden"),b="top");c.style[b]=a},xSetter:function(a,b,c){this[b]=a;"x"===b?b="left":"y"===b&&(b="top");this.updateClipping?(this[b]=a,this.updateClipping()):c.style[b]=a},zIndexSetter:function(a,b,c){c.style[b]=a}},F["stroke-opacitySetter"]=F["fill-opacitySetter"],a.VMLElement=F=z(c,F),F.prototype.ySetter=F.prototype.widthSetter=F.prototype.heightSetter=F.prototype.xSetter,F={Element:F,isIE8:-1<u.navigator.userAgent.indexOf("MSIE 8.0"),init:function(a,
b,c){var e,k;this.alignedObjects=[];e=this.createElement("div").css({position:"relative"});k=e.element;a.appendChild(e.element);this.isVML=!0;this.box=k;this.boxWrapper=e;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(b,c,!1);if(!r.namespaces.hcv){r.namespaces.add("hcv","urn:schemas-microsoft-com:vml");try{r.createStyleSheet().cssText="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}catch(G){r.styleSheets[0].cssText+=
"hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}}},isHidden:function(){return!this.box.offsetWidth},clipRect:function(a,b,c,e){var k=this.createElement(),q=w(a);return g(k,{members:[],count:0,left:(q?a.x:a)+1,top:(q?a.y:b)+1,width:(q?a.width:c)-1,height:(q?a.height:e)-1,getCSS:function(a){var b=a.element,c=b.nodeName,p=a.inverted,e=this.top-("shape"===c?b.offsetTop:0),k=this.left,b=k+this.width,q=e+this.height,e={clip:"rect("+Math.round(p?
k:e)+"px,"+Math.round(p?q:b)+"px,"+Math.round(p?b:q)+"px,"+Math.round(p?e:k)+"px)"};!p&&a.docMode8&&"DIV"===c&&g(e,{width:b+"px",height:q+"px"});return e},updateClipping:function(){m(k.members,function(a){a.element&&a.css(k.getCSS(a))})}})},color:function(b,c,e,l){var k=this,q,d=/^rgba/,g,n,p="none";b&&b.linearGradient?n="gradient":b&&b.radialGradient&&(n="pattern");if(n){var C,u,x=b.linearGradient||b.radialGradient,f,h,v,A,E,y="";b=b.stops;var w,H=[],r=function(){g=['\x3cfill colors\x3d"'+H.join(",")+
'" opacity\x3d"',v,'" o:opacity2\x3d"',h,'" type\x3d"',n,'" ',y,'focus\x3d"100%" method\x3d"any" /\x3e'];D(k.prepVML(g),null,null,c)};f=b[0];w=b[b.length-1];0<f[0]&&b.unshift([0,f[1]]);1>w[0]&&b.push([1,w[1]]);m(b,function(b,c){d.test(b[1])?(q=a.color(b[1]),C=q.get("rgb"),u=q.get("a")):(C=b[1],u=1);H.push(100*b[0]+"% "+C);c?(v=u,A=C):(h=u,E=C)});if("fill"===e)if("gradient"===n)e=x.x1||x[0]||0,b=x.y1||x[1]||0,f=x.x2||x[2]||0,x=x.y2||x[3]||0,y='angle\x3d"'+(90-180*Math.atan((x-b)/(f-e))/Math.PI)+'"',
r();else{var p=x.r,t=2*p,B=2*p,z=x.cx,F=x.cy,J=c.radialReference,T,p=function(){J&&(T=l.getBBox(),z+=(J[0]-T.x)/T.width-.5,F+=(J[1]-T.y)/T.height-.5,t*=J[2]/T.width,B*=J[2]/T.height);y='src\x3d"'+a.getOptions().global.VMLRadialGradientURL+'" size\x3d"'+t+","+B+'" origin\x3d"0.5,0.5" position\x3d"'+z+","+F+'" color2\x3d"'+E+'" ';r()};l.added?p():l.onAdd=p;p=A}else p=C}else d.test(b)&&"IMG"!==c.tagName?(q=a.color(b),l[e+"-opacitySetter"](q.get("a"),e,c),p=q.get("rgb")):(p=c.getElementsByTagName(e),
p.length&&(p[0].opacity=1,p[0].type="solid"),p=b);return p},prepVML:function(a){var b=this.isIE8;a=a.join("");b?(a=a.replace("/\x3e",' xmlns\x3d"urn:schemas-microsoft-com:vml" /\x3e'),a=-1===a.indexOf('style\x3d"')?a.replace("/\x3e",' style\x3d"display:inline-block;behavior:url(#default#VML);" /\x3e'):a.replace('style\x3d"','style\x3d"display:inline-block;behavior:url(#default#VML);')):a=a.replace("\x3c","\x3chcv:");return a},text:E.prototype.html,path:function(a){var b={coordsize:"10 10"};n(a)?b.d=
a:w(a)&&g(b,a);return this.createElement("shape").attr(b)},circle:function(a,b,c){var e=this.symbol("circle");w(a)&&(c=a.r,b=a.y,a=a.x);e.isCircle=!0;e.r=c;return e.attr({x:a,y:b})},g:function(a){var b;a&&(b={className:"highcharts-"+a,"class":"highcharts-"+a});return this.createElement("div").attr(b)},image:function(a,b,c,e,k){var l=this.createElement("img").attr({src:a});1<arguments.length&&l.attr({x:b,y:c,width:e,height:k});return l},createElement:function(a){return"rect"===a?this.symbol(a):E.prototype.createElement.call(this,
a)},invertChild:function(a,b){var c=this;b=b.style;var l="IMG"===a.tagName&&a.style;B(a,{flip:"x",left:e(b.width)-(l?e(l.top):1),top:e(b.height)-(l?e(l.left):1),rotation:-90});m(a.childNodes,function(b){c.invertChild(b,a)})},symbols:{arc:function(a,b,c,e,k){var l=k.start,q=k.end,d=k.r||c||e;c=k.innerR;e=Math.cos(l);var g=Math.sin(l),p=Math.cos(q),C=Math.sin(q);if(0===q-l)return["x"];l=["wa",a-d,b-d,a+d,b+d,a+d*e,b+d*g,a+d*p,b+d*C];k.open&&!c&&l.push("e","M",a,b);l.push("at",a-c,b-c,a+c,b+c,a+c*p,
b+c*C,a+c*e,b+c*g,"x","e");l.isArc=!0;return l},circle:function(a,b,c,e,k){k&&f(k.r)&&(c=e=2*k.r);k&&k.isCircle&&(a-=c/2,b-=e/2);return["wa",a,b,a+c,b+e,a+c,b+e/2,a+c,b+e/2,"e"]},rect:function(a,b,c,e,k){return E.prototype.symbols[f(k)&&k.r?"callout":"square"].call(0,a,b,c,e,k)}}},a.VMLRenderer=z=function(){this.init.apply(this,arguments)},z.prototype=b(E.prototype,F),a.Renderer=z);E.prototype.measureSpanWidth=function(a,b){var c=r.createElement("span");a=r.createTextNode(a);c.appendChild(a);B(c,
b);this.box.appendChild(c);b=c.offsetWidth;t(c);return b}})(J);(function(a){var z=a.correctFloat,F=a.defined,D=a.destroyObjectProperties,B=a.isNumber,f=a.merge,h=a.pick,t=a.deg2rad;a.Tick=function(a,m,d,g){this.axis=a;this.pos=m;this.type=d||"";this.isNew=!0;d||g||this.addLabel()};a.Tick.prototype={addLabel:function(){var a=this.axis,m=a.options,d=a.chart,g=a.categories,n=a.names,y=this.pos,w=m.labels,b=a.tickPositions,l=y===b[0],e=y===b[b.length-1],n=g?h(g[y],n[y],y):y,g=this.label,b=b.info,c;a.isDatetimeAxis&&
b&&(c=m.dateTimeLabelFormats[b.higherRanks[y]||b.unitName]);this.isFirst=l;this.isLast=e;m=a.labelFormatter.call({axis:a,chart:d,isFirst:l,isLast:e,dateTimeLabelFormat:c,value:a.isLog?z(a.lin2log(n)):n});F(g)?g&&g.attr({text:m}):(this.labelLength=(this.label=g=F(m)&&w.enabled?d.renderer.text(m,0,0,w.useHTML).css(f(w.style)).add(a.labelGroup):null)&&g.getBBox().width,this.rotation=0)},getLabelSize:function(){return this.label?this.label.getBBox()[this.axis.horiz?"height":"width"]:0},handleOverflow:function(a){var m=
this.axis,d=a.x,g=m.chart.chartWidth,n=m.chart.spacing,f=h(m.labelLeft,Math.min(m.pos,n[3])),n=h(m.labelRight,Math.max(m.pos+m.len,g-n[1])),w=this.label,b=this.rotation,l={left:0,center:.5,right:1}[m.labelAlign],e=w.getBBox().width,c=m.getSlotWidth(),E=c,u=1,q,x={};if(b)0>b&&d-l*e<f?q=Math.round(d/Math.cos(b*t)-f):0<b&&d+l*e>n&&(q=Math.round((g-d)/Math.cos(b*t)));else if(g=d+(1-l)*e,d-l*e<f?E=a.x+E*(1-l)-f:g>n&&(E=n-a.x+E*l,u=-1),E=Math.min(c,E),E<c&&"center"===m.labelAlign&&(a.x+=u*(c-E-l*(c-Math.min(e,
E)))),e>E||m.autoRotation&&(w.styles||{}).width)q=E;q&&(x.width=q,(m.options.labels.style||{}).textOverflow||(x.textOverflow="ellipsis"),w.css(x))},getPosition:function(a,m,d,g){var n=this.axis,f=n.chart,h=g&&f.oldChartHeight||f.chartHeight;return{x:a?n.translate(m+d,null,null,g)+n.transB:n.left+n.offset+(n.opposite?(g&&f.oldChartWidth||f.chartWidth)-n.right-n.left:0),y:a?h-n.bottom+n.offset-(n.opposite?n.height:0):h-n.translate(m+d,null,null,g)-n.transB}},getLabelPosition:function(a,m,d,g,n,f,h,
b){var l=this.axis,e=l.transA,c=l.reversed,E=l.staggerLines,u=l.tickRotCorr||{x:0,y:0},q=n.y;F(q)||(q=0===l.side?d.rotation?-8:-d.getBBox().height:2===l.side?u.y+8:Math.cos(d.rotation*t)*(u.y-d.getBBox(!1,0).height/2));a=a+n.x+u.x-(f&&g?f*e*(c?-1:1):0);m=m+q-(f&&!g?f*e*(c?1:-1):0);E&&(d=h/(b||1)%E,l.opposite&&(d=E-d-1),m+=l.labelOffset/E*d);return{x:a,y:Math.round(m)}},getMarkPath:function(a,m,d,g,n,f){return f.crispLine(["M",a,m,"L",a+(n?0:-d),m+(n?d:0)],g)},renderGridLine:function(a,m,d){var g=
this.axis,n=g.options,f=this.gridLine,h={},b=this.pos,l=this.type,e=g.tickmarkOffset,c=g.chart.renderer,E=l?l+"Grid":"grid",u=n[E+"LineWidth"],q=n[E+"LineColor"],n=n[E+"LineDashStyle"];f||(h.stroke=q,h["stroke-width"]=u,n&&(h.dashstyle=n),l||(h.zIndex=1),a&&(h.opacity=0),this.gridLine=f=c.path().attr(h).addClass("highcharts-"+(l?l+"-":"")+"grid-line").add(g.gridGroup));if(!a&&f&&(a=g.getPlotLinePath(b+e,f.strokeWidth()*d,a,!0)))f[this.isNew?"attr":"animate"]({d:a,opacity:m})},renderMark:function(a,
f,d){var g=this.axis,n=g.options,m=g.chart.renderer,w=this.type,b=w?w+"Tick":"tick",l=g.tickSize(b),e=this.mark,c=!e,E=a.x;a=a.y;var u=h(n[b+"Width"],!w&&g.isXAxis?1:0),n=n[b+"Color"];l&&(g.opposite&&(l[0]=-l[0]),c&&(this.mark=e=m.path().addClass("highcharts-"+(w?w+"-":"")+"tick").add(g.axisGroup),e.attr({stroke:n,"stroke-width":u})),e[c?"attr":"animate"]({d:this.getMarkPath(E,a,l[0],e.strokeWidth()*d,g.horiz,m),opacity:f}))},renderLabel:function(a,f,d,g){var n=this.axis,m=n.horiz,w=n.options,b=this.label,
l=w.labels,e=l.step,c=n.tickmarkOffset,E=!0,u=a.x;a=a.y;b&&B(u)&&(b.xy=a=this.getLabelPosition(u,a,b,m,l,c,g,e),this.isFirst&&!this.isLast&&!h(w.showFirstLabel,1)||this.isLast&&!this.isFirst&&!h(w.showLastLabel,1)?E=!1:!m||n.isRadial||l.step||l.rotation||f||0===d||this.handleOverflow(a),e&&g%e&&(E=!1),E&&B(a.y)?(a.opacity=d,b[this.isNew?"attr":"animate"](a)):b.attr("y",-9999),this.isNew=!1)},render:function(a,f,d){var g=this.axis,n=g.horiz,m=this.getPosition(n,this.pos,g.tickmarkOffset,f),w=m.x,b=
m.y,g=n&&w===g.pos+g.len||!n&&b===g.pos?-1:1;d=h(d,1);this.isActive=!0;this.renderGridLine(f,d,g);this.renderMark(m,d,g);this.renderLabel(m,f,d,a)},destroy:function(){D(this,this.axis)}}})(J);(function(a){var z=a.arrayMax,F=a.arrayMin,D=a.defined,B=a.destroyObjectProperties,f=a.each,h=a.erase,t=a.merge,r=a.pick;a.PlotLineOrBand=function(a,d){this.axis=a;d&&(this.options=d,this.id=d.id)};a.PlotLineOrBand.prototype={render:function(){var a=this,d=a.axis,g=d.horiz,n=a.options,f=n.label,h=a.label,b=n.to,
l=n.from,e=n.value,c=D(l)&&D(b),E=D(e),u=a.svgElem,q=!u,x=[],A,H=n.color,k=r(n.zIndex,0),G=n.events,x={"class":"highcharts-plot-"+(c?"band ":"line ")+(n.className||"")},I={},L=d.chart.renderer,K=c?"bands":"lines",p=d.log2lin;d.isLog&&(l=p(l),b=p(b),e=p(e));E?(x={stroke:H,"stroke-width":n.width},n.dashStyle&&(x.dashstyle=n.dashStyle)):c&&(H&&(x.fill=H),n.borderWidth&&(x.stroke=n.borderColor,x["stroke-width"]=n.borderWidth));I.zIndex=k;K+="-"+k;(H=d.plotLinesAndBandsGroups[K])||(d.plotLinesAndBandsGroups[K]=
H=L.g("plot-"+K).attr(I).add());q&&(a.svgElem=u=L.path().attr(x).add(H));if(E)x=d.getPlotLinePath(e,u.strokeWidth());else if(c)x=d.getPlotBandPath(l,b,n);else return;if(q&&x&&x.length){if(u.attr({d:x}),G)for(A in n=function(b){u.on(b,function(c){G[b].apply(a,[c])})},G)n(A)}else u&&(x?(u.show(),u.animate({d:x})):(u.hide(),h&&(a.label=h=h.destroy())));f&&D(f.text)&&x&&x.length&&0<d.width&&0<d.height&&!x.flat?(f=t({align:g&&c&&"center",x:g?!c&&4:10,verticalAlign:!g&&c&&"middle",y:g?c?16:10:c?6:-4,rotation:g&&
!c&&90},f),this.renderLabel(f,x,c,k)):h&&h.hide();return a},renderLabel:function(a,d,g,n){var f=this.label,h=this.axis.chart.renderer;f||(f={align:a.textAlign||a.align,rotation:a.rotation,"class":"highcharts-plot-"+(g?"band":"line")+"-label "+(a.className||"")},f.zIndex=n,this.label=f=h.text(a.text,0,0,a.useHTML).attr(f).add(),f.css(a.style));n=[d[1],d[4],g?d[6]:d[1]];d=[d[2],d[5],g?d[7]:d[2]];g=F(n);h=F(d);f.align(a,!1,{x:g,y:h,width:z(n)-g,height:z(d)-h});f.show()},destroy:function(){h(this.axis.plotLinesAndBands,
this);delete this.axis;B(this)}};a.AxisPlotLineOrBandExtension={getPlotBandPath:function(a,d){var g=this.getPlotLinePath(d,null,null,!0),n=this.getPlotLinePath(a,null,null,!0),f=this.horiz,h=1;a=a<this.min&&d<this.min||a>this.max&&d>this.max;n&&g?(a&&(n.flat=n.toString()===g.toString(),h=0),n.push(f&&g[4]===n[4]?g[4]+h:g[4],f||g[5]!==n[5]?g[5]:g[5]+h,f&&g[1]===n[1]?g[1]+h:g[1],f||g[2]!==n[2]?g[2]:g[2]+h)):n=null;return n},addPlotBand:function(a){return this.addPlotBandOrLine(a,"plotBands")},addPlotLine:function(a){return this.addPlotBandOrLine(a,
"plotLines")},addPlotBandOrLine:function(f,d){var g=(new a.PlotLineOrBand(this,f)).render(),n=this.userOptions;g&&(d&&(n[d]=n[d]||[],n[d].push(f)),this.plotLinesAndBands.push(g));return g},removePlotBandOrLine:function(a){for(var d=this.plotLinesAndBands,g=this.options,n=this.userOptions,m=d.length;m--;)d[m].id===a&&d[m].destroy();f([g.plotLines||[],n.plotLines||[],g.plotBands||[],n.plotBands||[]],function(d){for(m=d.length;m--;)d[m].id===a&&h(d,d[m])})}}})(J);(function(a){var z=a.addEvent,F=a.animObject,
D=a.arrayMax,B=a.arrayMin,f=a.AxisPlotLineOrBandExtension,h=a.color,t=a.correctFloat,r=a.defaultOptions,m=a.defined,d=a.deg2rad,g=a.destroyObjectProperties,n=a.each,y=a.extend,w=a.fireEvent,b=a.format,l=a.getMagnitude,e=a.grep,c=a.inArray,E=a.isArray,u=a.isNumber,q=a.isString,x=a.merge,A=a.normalizeTickInterval,H=a.pick,k=a.PlotLineOrBand,G=a.removeEvent,I=a.splat,L=a.syncTimeout,K=a.Tick;a.Axis=function(){this.init.apply(this,arguments)};a.Axis.prototype={defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",
second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M",day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,labels:{enabled:!0,style:{color:"#666666",cursor:"default",fontSize:"11px"},x:0},minPadding:.01,maxPadding:.01,minorTickLength:2,minorTickPosition:"outside",startOfWeek:1,startOnTick:!1,tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",title:{align:"middle",style:{color:"#666666"}},type:"linear",minorGridLineColor:"#f2f2f2",minorGridLineWidth:1,minorTickColor:"#999999",
lineColor:"#ccd6eb",lineWidth:1,gridLineColor:"#e6e6e6",tickColor:"#ccd6eb"},defaultYAxisOptions:{endOnTick:!0,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8},maxPadding:.05,minPadding:.05,startOnTick:!0,title:{rotation:270,text:"Values"},stackLabels:{enabled:!1,formatter:function(){return a.numberFormat(this.total,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"#000000",textOutline:"1px contrast"}},gridLineWidth:1,lineWidth:0},defaultLeftAxisOptions:{labels:{x:-15},title:{rotation:270}},
defaultRightAxisOptions:{labels:{x:15},title:{rotation:90}},defaultBottomAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},defaultTopAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},init:function(a,b){var p=b.isX;this.chart=a;this.horiz=a.inverted?!p:p;this.isXAxis=p;this.coll=this.coll||(p?"xAxis":"yAxis");this.opposite=b.opposite;this.side=b.side||(this.horiz?this.opposite?0:2:this.opposite?1:3);this.setOptions(b);var e=this.options,k=e.type;this.labelFormatter=e.labels.formatter||
this.defaultLabelFormatter;this.userOptions=b;this.minPixelPadding=0;this.reversed=e.reversed;this.visible=!1!==e.visible;this.zoomEnabled=!1!==e.zoomEnabled;this.hasNames="category"===k||!0===e.categories;this.categories=e.categories||this.hasNames;this.names=this.names||[];this.plotLinesAndBandsGroups={};this.isLog="logarithmic"===k;this.isDatetimeAxis="datetime"===k;this.positiveValuesOnly=this.isLog&&!this.allowNegativeLog;this.isLinked=m(e.linkedTo);this.ticks={};this.labelEdge=[];this.minorTicks=
{};this.plotLinesAndBands=[];this.alternateBands={};this.len=0;this.minRange=this.userMinRange=e.minRange||e.maxZoom;this.range=e.range;this.offset=e.offset||0;this.stacks={};this.oldStacks={};this.stacksTouched=0;this.min=this.max=null;this.crosshair=H(e.crosshair,I(a.options.tooltip.crosshairs)[p?0:1],!1);var C;b=this.options.events;-1===c(this,a.axes)&&(p?a.axes.splice(a.xAxis.length,0,this):a.axes.push(this),a[this.coll].push(this));this.series=this.series||[];a.inverted&&p&&void 0===this.reversed&&
(this.reversed=!0);this.removePlotLine=this.removePlotBand=this.removePlotBandOrLine;for(C in b)z(this,C,b[C]);this.lin2log=e.linearToLogConverter||this.lin2log;this.isLog&&(this.val2lin=this.log2lin,this.lin2val=this.lin2log)},setOptions:function(a){this.options=x(this.defaultOptions,"yAxis"===this.coll&&this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions,this.defaultLeftAxisOptions][this.side],x(r[this.coll],a))},defaultLabelFormatter:function(){var c=
this.axis,e=this.value,k=c.categories,l=this.dateTimeLabelFormat,d=r.lang,q=d.numericSymbols,d=d.numericSymbolMagnitude||1E3,v=q&&q.length,g,n=c.options.labels.format,c=c.isLog?Math.abs(e):c.tickInterval;if(n)g=b(n,this);else if(k)g=e;else if(l)g=a.dateFormat(l,e);else if(v&&1E3<=c)for(;v--&&void 0===g;)k=Math.pow(d,v+1),c>=k&&0===10*e%k&&null!==q[v]&&0!==e&&(g=a.numberFormat(e/k,-1)+q[v]);void 0===g&&(g=1E4<=Math.abs(e)?a.numberFormat(e,-1):a.numberFormat(e,-1,void 0,""));return g},getSeriesExtremes:function(){var a=
this,b=a.chart;a.hasVisibleSeries=!1;a.dataMin=a.dataMax=a.threshold=null;a.softThreshold=!a.isXAxis;a.buildStacks&&a.buildStacks();n(a.series,function(c){if(c.visible||!b.options.chart.ignoreHiddenSeries){var p=c.options,k=p.threshold,C;a.hasVisibleSeries=!0;a.positiveValuesOnly&&0>=k&&(k=null);if(a.isXAxis)p=c.xData,p.length&&(c=B(p),u(c)||c instanceof Date||(p=e(p,function(a){return u(a)}),c=B(p)),a.dataMin=Math.min(H(a.dataMin,p[0]),c),a.dataMax=Math.max(H(a.dataMax,p[0]),D(p)));else if(c.getExtremes(),
C=c.dataMax,c=c.dataMin,m(c)&&m(C)&&(a.dataMin=Math.min(H(a.dataMin,c),c),a.dataMax=Math.max(H(a.dataMax,C),C)),m(k)&&(a.threshold=k),!p.softThreshold||a.positiveValuesOnly)a.softThreshold=!1}})},translate:function(a,b,c,e,k,l){var p=this.linkedParent||this,C=1,d=0,q=e?p.oldTransA:p.transA;e=e?p.oldMin:p.min;var g=p.minPixelPadding;k=(p.isOrdinal||p.isBroken||p.isLog&&k)&&p.lin2val;q||(q=p.transA);c&&(C*=-1,d=p.len);p.reversed&&(C*=-1,d-=C*(p.sector||p.len));b?(a=(a*C+d-g)/q+e,k&&(a=p.lin2val(a))):
(k&&(a=p.val2lin(a)),a=C*(a-e)*q+d+C*g+(u(l)?q*l:0));return a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a-(b?0:this.pos),!0,!this.horiz,null,!0)},getPlotLinePath:function(a,b,c,e,k){var p=this.chart,C=this.left,l=this.top,d,q,g=c&&p.oldChartHeight||p.chartHeight,n=c&&p.oldChartWidth||p.chartWidth,f;d=this.transB;var h=function(a,b,c){if(a<b||a>c)e?a=Math.min(Math.max(b,a),c):f=!0;return a};k=H(k,this.translate(a,
null,null,c));a=c=Math.round(k+d);d=q=Math.round(g-k-d);u(k)?this.horiz?(d=l,q=g-this.bottom,a=c=h(a,C,C+this.width)):(a=C,c=n-this.right,d=q=h(d,l,l+this.height)):f=!0;return f&&!e?null:p.renderer.crispLine(["M",a,d,"L",c,q],b||1)},getLinearTickPositions:function(a,b,c){var e,p=t(Math.floor(b/a)*a);c=t(Math.ceil(c/a)*a);var k=[];if(this.single)return[b];for(b=p;b<=c;){k.push(b);b=t(b+a);if(b===e)break;e=b}return k},getMinorTickPositions:function(){var a=this,b=a.options,c=a.tickPositions,e=a.minorTickInterval,
k=[],l=a.pointRangePadding||0,d=a.min-l,l=a.max+l,q=l-d;if(q&&q/e<a.len/3)if(a.isLog)n(this.paddedTicks,function(b,c,p){c&&k.push.apply(k,a.getLogTickPositions(e,p[c-1],p[c],!0))});else if(a.isDatetimeAxis&&"auto"===b.minorTickInterval)k=k.concat(a.getTimeTicks(a.normalizeTimeTickInterval(e),d,l,b.startOfWeek));else for(b=d+(c[0]-d)%e;b<=l&&b!==k[0];b+=e)k.push(b);0!==k.length&&a.trimTicks(k);return k},adjustForMinRange:function(){var a=this.options,b=this.min,c=this.max,e,k=this.dataMax-this.dataMin>=
this.minRange,l,d,q,g,f,u;this.isXAxis&&void 0===this.minRange&&!this.isLog&&(m(a.min)||m(a.max)?this.minRange=null:(n(this.series,function(a){g=a.xData;for(d=f=a.xIncrement?1:g.length-1;0<d;d--)if(q=g[d]-g[d-1],void 0===l||q<l)l=q}),this.minRange=Math.min(5*l,this.dataMax-this.dataMin)));c-b<this.minRange&&(u=this.minRange,e=(u-c+b)/2,e=[b-e,H(a.min,b-e)],k&&(e[2]=this.isLog?this.log2lin(this.dataMin):this.dataMin),b=D(e),c=[b+u,H(a.max,b+u)],k&&(c[2]=this.isLog?this.log2lin(this.dataMax):this.dataMax),
c=B(c),c-b<u&&(e[0]=c-u,e[1]=H(a.min,c-u),b=D(e)));this.min=b;this.max=c},getClosest:function(){var a;this.categories?a=1:n(this.series,function(b){var c=b.closestPointRange,e=b.visible||!b.chart.options.chart.ignoreHiddenSeries;!b.noSharedTooltip&&m(c)&&e&&(a=m(a)?Math.min(a,c):c)});return a},nameToX:function(a){var b=E(this.categories),e=b?this.categories:this.names,p=a.options.x,k;a.series.requireSorting=!1;m(p)||(p=!1===this.options.uniqueNames?a.series.autoIncrement():c(a.name,e));-1===p?b||
(k=e.length):k=p;void 0!==k&&(this.names[k]=a.name);return k},updateNames:function(){var a=this;0<this.names.length&&(this.names.length=0,this.minRange=void 0,n(this.series||[],function(b){b.xIncrement=null;if(!b.points||b.isDirtyData)b.processData(),b.generatePoints();n(b.points,function(c,e){var p;c.options&&(p=a.nameToX(c),void 0!==p&&p!==c.x&&(c.x=p,b.xData[e]=p))})}))},setAxisTranslation:function(a){var b=this,c=b.max-b.min,e=b.axisPointRange||0,p,k=0,l=0,d=b.linkedParent,g=!!b.categories,f=
b.transA,u=b.isXAxis;if(u||g||e)p=b.getClosest(),d?(k=d.minPointOffset,l=d.pointRangePadding):n(b.series,function(a){var c=g?1:u?H(a.options.pointRange,p,0):b.axisPointRange||0;a=a.options.pointPlacement;e=Math.max(e,c);b.single||(k=Math.max(k,q(a)?0:c/2),l=Math.max(l,"on"===a?0:c))}),d=b.ordinalSlope&&p?b.ordinalSlope/p:1,b.minPointOffset=k*=d,b.pointRangePadding=l*=d,b.pointRange=Math.min(e,c),u&&(b.closestPointRange=p);a&&(b.oldTransA=f);b.translationSlope=b.transA=f=b.options.staticScale||b.len/
(c+l||1);b.transB=b.horiz?b.left:b.bottom;b.minPixelPadding=f*k},minFromRange:function(){return this.max-this.range},setTickInterval:function(b){var c=this,e=c.chart,p=c.options,k=c.isLog,d=c.log2lin,q=c.isDatetimeAxis,g=c.isXAxis,f=c.isLinked,h=p.maxPadding,G=p.minPadding,x=p.tickInterval,E=p.tickPixelInterval,y=c.categories,I=c.threshold,L=c.softThreshold,K,r,B,z;q||y||f||this.getTickAmount();B=H(c.userMin,p.min);z=H(c.userMax,p.max);f?(c.linkedParent=e[c.coll][p.linkedTo],e=c.linkedParent.getExtremes(),
c.min=H(e.min,e.dataMin),c.max=H(e.max,e.dataMax),p.type!==c.linkedParent.options.type&&a.error(11,1)):(!L&&m(I)&&(c.dataMin>=I?(K=I,G=0):c.dataMax<=I&&(r=I,h=0)),c.min=H(B,K,c.dataMin),c.max=H(z,r,c.dataMax));k&&(c.positiveValuesOnly&&!b&&0>=Math.min(c.min,H(c.dataMin,c.min))&&a.error(10,1),c.min=t(d(c.min),15),c.max=t(d(c.max),15));c.range&&m(c.max)&&(c.userMin=c.min=B=Math.max(c.min,c.minFromRange()),c.userMax=z=c.max,c.range=null);w(c,"foundExtremes");c.beforePadding&&c.beforePadding();c.adjustForMinRange();
!(y||c.axisPointRange||c.usePercentage||f)&&m(c.min)&&m(c.max)&&(d=c.max-c.min)&&(!m(B)&&G&&(c.min-=d*G),!m(z)&&h&&(c.max+=d*h));u(p.softMin)&&(c.min=Math.min(c.min,p.softMin));u(p.softMax)&&(c.max=Math.max(c.max,p.softMax));u(p.floor)&&(c.min=Math.max(c.min,p.floor));u(p.ceiling)&&(c.max=Math.min(c.max,p.ceiling));L&&m(c.dataMin)&&(I=I||0,!m(B)&&c.min<I&&c.dataMin>=I?c.min=I:!m(z)&&c.max>I&&c.dataMax<=I&&(c.max=I));c.tickInterval=c.min===c.max||void 0===c.min||void 0===c.max?1:f&&!x&&E===c.linkedParent.options.tickPixelInterval?
x=c.linkedParent.tickInterval:H(x,this.tickAmount?(c.max-c.min)/Math.max(this.tickAmount-1,1):void 0,y?1:(c.max-c.min)*E/Math.max(c.len,E));g&&!b&&n(c.series,function(a){a.processData(c.min!==c.oldMin||c.max!==c.oldMax)});c.setAxisTranslation(!0);c.beforeSetTickPositions&&c.beforeSetTickPositions();c.postProcessTickInterval&&(c.tickInterval=c.postProcessTickInterval(c.tickInterval));c.pointRange&&!x&&(c.tickInterval=Math.max(c.pointRange,c.tickInterval));b=H(p.minTickInterval,c.isDatetimeAxis&&c.closestPointRange);
!x&&c.tickInterval<b&&(c.tickInterval=b);q||k||x||(c.tickInterval=A(c.tickInterval,null,l(c.tickInterval),H(p.allowDecimals,!(.5<c.tickInterval&&5>c.tickInterval&&1E3<c.max&&9999>c.max)),!!this.tickAmount));this.tickAmount||(c.tickInterval=c.unsquish());this.setTickPositions()},setTickPositions:function(){var a=this.options,b,c=a.tickPositions,e=a.tickPositioner,k=a.startOnTick,l=a.endOnTick;this.tickmarkOffset=this.categories&&"between"===a.tickmarkPlacement&&1===this.tickInterval?.5:0;this.minorTickInterval=
"auto"===a.minorTickInterval&&this.tickInterval?this.tickInterval/5:a.minorTickInterval;this.single=this.min===this.max&&m(this.min)&&!this.tickAmount&&!1!==a.allowDecimals;this.tickPositions=b=c&&c.slice();!b&&(b=this.isDatetimeAxis?this.getTimeTicks(this.normalizeTimeTickInterval(this.tickInterval,a.units),this.min,this.max,a.startOfWeek,this.ordinalPositions,this.closestPointRange,!0):this.isLog?this.getLogTickPositions(this.tickInterval,this.min,this.max):this.getLinearTickPositions(this.tickInterval,
this.min,this.max),b.length>this.len&&(b=[b[0],b.pop()]),this.tickPositions=b,e&&(e=e.apply(this,[this.min,this.max])))&&(this.tickPositions=b=e);this.paddedTicks=b.slice(0);this.trimTicks(b,k,l);this.isLinked||(this.single&&(this.min-=.5,this.max+=.5),c||e||this.adjustTickAmount())},trimTicks:function(a,b,c){var e=a[0],p=a[a.length-1],k=this.minPointOffset||0;if(!this.isLinked){if(b&&-Infinity!==e)this.min=e;else for(;this.min-k>a[0];)a.shift();if(c)this.max=p;else for(;this.max+k<a[a.length-1];)a.pop();
0===a.length&&m(e)&&a.push((p+e)/2)}},alignToOthers:function(){var a={},b,c=this.options;!1===this.chart.options.chart.alignTicks||!1===c.alignTicks||this.isLog||n(this.chart[this.coll],function(c){var e=c.options,e=[c.horiz?e.left:e.top,e.width,e.height,e.pane].join();c.series.length&&(a[e]?b=!0:a[e]=1)});return b},getTickAmount:function(){var a=this.options,b=a.tickAmount,c=a.tickPixelInterval;!m(a.tickInterval)&&this.len<c&&!this.isRadial&&!this.isLog&&a.startOnTick&&a.endOnTick&&(b=2);!b&&this.alignToOthers()&&
(b=Math.ceil(this.len/c)+1);4>b&&(this.finalTickAmt=b,b=5);this.tickAmount=b},adjustTickAmount:function(){var a=this.tickInterval,b=this.tickPositions,c=this.tickAmount,e=this.finalTickAmt,k=b&&b.length;if(k<c){for(;b.length<c;)b.push(t(b[b.length-1]+a));this.transA*=(k-1)/(c-1);this.max=b[b.length-1]}else k>c&&(this.tickInterval*=2,this.setTickPositions());if(m(e)){for(a=c=b.length;a--;)(3===e&&1===a%2||2>=e&&0<a&&a<c-1)&&b.splice(a,1);this.finalTickAmt=void 0}},setScale:function(){var a,b;this.oldMin=
this.min;this.oldMax=this.max;this.oldAxisLength=this.len;this.setAxisSize();b=this.len!==this.oldAxisLength;n(this.series,function(b){if(b.isDirtyData||b.isDirty||b.xAxis.isDirty)a=!0});b||a||this.isLinked||this.forceRedraw||this.userMin!==this.oldUserMin||this.userMax!==this.oldUserMax||this.alignToOthers()?(this.resetStacks&&this.resetStacks(),this.forceRedraw=!1,this.getSeriesExtremes(),this.setTickInterval(),this.oldUserMin=this.userMin,this.oldUserMax=this.userMax,this.isDirty||(this.isDirty=
b||this.min!==this.oldMin||this.max!==this.oldMax)):this.cleanStacks&&this.cleanStacks()},setExtremes:function(a,b,c,e,k){var p=this,l=p.chart;c=H(c,!0);n(p.series,function(a){delete a.kdTree});k=y(k,{min:a,max:b});w(p,"setExtremes",k,function(){p.userMin=a;p.userMax=b;p.eventArgs=k;c&&l.redraw(e)})},zoom:function(a,b){var c=this.dataMin,e=this.dataMax,p=this.options,k=Math.min(c,H(p.min,c)),p=Math.max(e,H(p.max,e));if(a!==this.min||b!==this.max)this.allowZoomOutside||(m(c)&&(a<k&&(a=k),a>p&&(a=p)),
m(e)&&(b<k&&(b=k),b>p&&(b=p))),this.displayBtn=void 0!==a||void 0!==b,this.setExtremes(a,b,!1,void 0,{trigger:"zoom"});return!0},setAxisSize:function(){var a=this.chart,b=this.options,c=b.offsets||[0,0,0,0],e=this.horiz,k=H(b.width,a.plotWidth-c[3]+c[1]),l=H(b.height,a.plotHeight-c[0]+c[2]),d=H(b.top,a.plotTop+c[0]),b=H(b.left,a.plotLeft+c[3]),c=/%$/;c.test(l)&&(l=Math.round(parseFloat(l)/100*a.plotHeight));c.test(d)&&(d=Math.round(parseFloat(d)/100*a.plotHeight+a.plotTop));this.left=b;this.top=d;
this.width=k;this.height=l;this.bottom=a.chartHeight-l-d;this.right=a.chartWidth-k-b;this.len=Math.max(e?k:l,0);this.pos=e?b:d},getExtremes:function(){var a=this.isLog,b=this.lin2log;return{min:a?t(b(this.min)):this.min,max:a?t(b(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}},getThreshold:function(a){var b=this.isLog,c=this.lin2log,e=b?c(this.min):this.min,b=b?c(this.max):this.max;null===a?a=e:e>a?a=e:b<a&&(a=b);return this.translate(a,0,
1,0,1)},autoLabelAlign:function(a){a=(H(a,0)-90*this.side+720)%360;return 15<a&&165>a?"right":195<a&&345>a?"left":"center"},tickSize:function(a){var b=this.options,c=b[a+"Length"],e=H(b[a+"Width"],"tick"===a&&this.isXAxis?1:0);if(e&&c)return"inside"===b[a+"Position"]&&(c=-c),[c,e]},labelMetrics:function(){return this.chart.renderer.fontMetrics(this.options.labels.style&&this.options.labels.style.fontSize,this.ticks[0]&&this.ticks[0].label)},unsquish:function(){var a=this.options.labels,b=this.horiz,
c=this.tickInterval,e=c,k=this.len/(((this.categories?1:0)+this.max-this.min)/c),l,q=a.rotation,g=this.labelMetrics(),f,u=Number.MAX_VALUE,h,G=function(a){a/=k||1;a=1<a?Math.ceil(a):1;return a*c};b?(h=!a.staggerLines&&!a.step&&(m(q)?[q]:k<H(a.autoRotationLimit,80)&&a.autoRotation))&&n(h,function(a){var b;if(a===q||a&&-90<=a&&90>=a)f=G(Math.abs(g.h/Math.sin(d*a))),b=f+Math.abs(a/360),b<u&&(u=b,l=a,e=f)}):a.step||(e=G(g.h));this.autoRotation=h;this.labelRotation=H(l,q);return e},getSlotWidth:function(){var a=
this.chart,b=this.horiz,c=this.options.labels,e=Math.max(this.tickPositions.length-(this.categories?0:1),1),k=a.margin[3];return b&&2>(c.step||0)&&!c.rotation&&(this.staggerLines||1)*this.len/e||!b&&(k&&k-a.spacing[3]||.33*a.chartWidth)},renderUnsquish:function(){var a=this.chart,b=a.renderer,c=this.tickPositions,e=this.ticks,k=this.options.labels,l=this.horiz,d=this.getSlotWidth(),g=Math.max(1,Math.round(d-2*(k.padding||5))),f={},u=this.labelMetrics(),h=k.style&&k.style.textOverflow,G,m=0,E,A;q(k.rotation)||
(f.rotation=k.rotation||0);n(c,function(a){(a=e[a])&&a.labelLength>m&&(m=a.labelLength)});this.maxLabelLength=m;if(this.autoRotation)m>g&&m>u.h?f.rotation=this.labelRotation:this.labelRotation=0;else if(d&&(G={width:g+"px"},!h))for(G.textOverflow="clip",E=c.length;!l&&E--;)if(A=c[E],g=e[A].label)g.styles&&"ellipsis"===g.styles.textOverflow?g.css({textOverflow:"clip"}):e[A].labelLength>d&&g.css({width:d+"px"}),g.getBBox().height>this.len/c.length-(u.h-u.f)&&(g.specCss={textOverflow:"ellipsis"});f.rotation&&
(G={width:(m>.5*a.chartHeight?.33*a.chartHeight:a.chartHeight)+"px"},h||(G.textOverflow="ellipsis"));if(this.labelAlign=k.align||this.autoLabelAlign(this.labelRotation))f.align=this.labelAlign;n(c,function(a){var b=(a=e[a])&&a.label;b&&(b.attr(f),G&&b.css(x(G,b.specCss)),delete b.specCss,a.rotation=f.rotation)});this.tickRotCorr=b.rotCorr(u.b,this.labelRotation||0,0!==this.side)},hasData:function(){return this.hasVisibleSeries||m(this.min)&&m(this.max)&&!!this.tickPositions},addTitle:function(a){var b=
this.chart.renderer,c=this.horiz,e=this.opposite,k=this.options.title,p;this.axisTitle||((p=k.textAlign)||(p=(c?{low:"left",middle:"center",high:"right"}:{low:e?"right":"left",middle:"center",high:e?"left":"right"})[k.align]),this.axisTitle=b.text(k.text,0,0,k.useHTML).attr({zIndex:7,rotation:k.rotation||0,align:p}).addClass("highcharts-axis-title").css(k.style).add(this.axisGroup),this.axisTitle.isNew=!0);this.axisTitle[a?"show":"hide"](!0)},generateTick:function(a){var b=this.ticks;b[a]?b[a].addLabel():
b[a]=new K(this,a)},getOffset:function(){var a=this,b=a.chart,c=b.renderer,e=a.options,k=a.tickPositions,l=a.ticks,d=a.horiz,g=a.side,q=b.inverted?[1,0,3,2][g]:g,f,u,h=0,G,x=0,E=e.title,A=e.labels,w=0,I=b.axisOffset,b=b.clipOffset,y=[-1,1,1,-1][g],L,K=e.className,r=a.axisParent,t=this.tickSize("tick");f=a.hasData();a.showAxis=u=f||H(e.showEmpty,!0);a.staggerLines=a.horiz&&A.staggerLines;a.axisGroup||(a.gridGroup=c.g("grid").attr({zIndex:e.gridZIndex||1}).addClass("highcharts-"+this.coll.toLowerCase()+
"-grid "+(K||"")).add(r),a.axisGroup=c.g("axis").attr({zIndex:e.zIndex||2}).addClass("highcharts-"+this.coll.toLowerCase()+" "+(K||"")).add(r),a.labelGroup=c.g("axis-labels").attr({zIndex:A.zIndex||7}).addClass("highcharts-"+a.coll.toLowerCase()+"-labels "+(K||"")).add(r));if(f||a.isLinked)n(k,function(b,c){a.generateTick(b,c)}),a.renderUnsquish(),!1===A.reserveSpace||0!==g&&2!==g&&{1:"left",3:"right"}[g]!==a.labelAlign&&"center"!==a.labelAlign||n(k,function(a){w=Math.max(l[a].getLabelSize(),w)}),
a.staggerLines&&(w*=a.staggerLines,a.labelOffset=w*(a.opposite?-1:1));else for(L in l)l[L].destroy(),delete l[L];E&&E.text&&!1!==E.enabled&&(a.addTitle(u),u&&(h=a.axisTitle.getBBox()[d?"height":"width"],G=E.offset,x=m(G)?0:H(E.margin,d?5:10)));a.renderLine();a.offset=y*H(e.offset,I[g]);a.tickRotCorr=a.tickRotCorr||{x:0,y:0};c=0===g?-a.labelMetrics().h:2===g?a.tickRotCorr.y:0;x=Math.abs(w)+x;w&&(x=x-c+y*(d?H(A.y,a.tickRotCorr.y+8*y):A.x));a.axisTitleMargin=H(G,x);I[g]=Math.max(I[g],a.axisTitleMargin+
h+y*a.offset,x,f&&k.length&&t?t[0]+y*a.offset:0);e=e.offset?0:2*Math.floor(a.axisLine.strokeWidth()/2);b[q]=Math.max(b[q],e)},getLinePath:function(a){var b=this.chart,c=this.opposite,e=this.offset,k=this.horiz,p=this.left+(c?this.width:0)+e,e=b.chartHeight-this.bottom-(c?this.height:0)+e;c&&(a*=-1);return b.renderer.crispLine(["M",k?this.left:p,k?e:this.top,"L",k?b.chartWidth-this.right:p,k?e:b.chartHeight-this.bottom],a)},renderLine:function(){this.axisLine||(this.axisLine=this.chart.renderer.path().addClass("highcharts-axis-line").add(this.axisGroup),
this.axisLine.attr({stroke:this.options.lineColor,"stroke-width":this.options.lineWidth,zIndex:7}))},getTitlePosition:function(){var a=this.horiz,b=this.left,c=this.top,e=this.len,k=this.options.title,l=a?b:c,d=this.opposite,g=this.offset,q=k.x||0,f=k.y||0,n=this.chart.renderer.fontMetrics(k.style&&k.style.fontSize,this.axisTitle).f,e={low:l+(a?0:e),middle:l+e/2,high:l+(a?e:0)}[k.align],b=(a?c+this.height:b)+(a?1:-1)*(d?-1:1)*this.axisTitleMargin+(2===this.side?n:0);return{x:a?e+q:b+(d?this.width:
0)+g+q,y:a?b+f-(d?this.height:0)+g:e+f}},renderMinorTick:function(a){var b=this.chart.hasRendered&&u(this.oldMin),c=this.minorTicks;c[a]||(c[a]=new K(this,a,"minor"));b&&c[a].isNew&&c[a].render(null,!0);c[a].render(null,!1,1)},renderTick:function(a,b){var c=this.isLinked,e=this.ticks,k=this.chart.hasRendered&&u(this.oldMin);if(!c||a>=this.min&&a<=this.max)e[a]||(e[a]=new K(this,a)),k&&e[a].isNew&&e[a].render(b,!0,.1),e[a].render(b)},render:function(){var a=this,b=a.chart,c=a.options,e=a.isLog,l=a.lin2log,
d=a.isLinked,g=a.tickPositions,q=a.axisTitle,f=a.ticks,u=a.minorTicks,h=a.alternateBands,G=c.stackLabels,x=c.alternateGridColor,m=a.tickmarkOffset,E=a.axisLine,A=a.showAxis,w=F(b.renderer.globalAnimation),I,y;a.labelEdge.length=0;a.overlap=!1;n([f,u,h],function(a){for(var b in a)a[b].isActive=!1});if(a.hasData()||d)a.minorTickInterval&&!a.categories&&n(a.getMinorTickPositions(),function(b){a.renderMinorTick(b)}),g.length&&(n(g,function(b,c){a.renderTick(b,c)}),m&&(0===a.min||a.single)&&(f[-1]||(f[-1]=
new K(a,-1,null,!0)),f[-1].render(-1))),x&&n(g,function(c,p){y=void 0!==g[p+1]?g[p+1]+m:a.max-m;0===p%2&&c<a.max&&y<=a.max+(b.polar?-m:m)&&(h[c]||(h[c]=new k(a)),I=c+m,h[c].options={from:e?l(I):I,to:e?l(y):y,color:x},h[c].render(),h[c].isActive=!0)}),a._addedPlotLB||(n((c.plotLines||[]).concat(c.plotBands||[]),function(b){a.addPlotBandOrLine(b)}),a._addedPlotLB=!0);n([f,u,h],function(a){var c,e,k=[],l=w.duration;for(c in a)a[c].isActive||(a[c].render(c,!1,0),a[c].isActive=!1,k.push(c));L(function(){for(e=
k.length;e--;)a[k[e]]&&!a[k[e]].isActive&&(a[k[e]].destroy(),delete a[k[e]])},a!==h&&b.hasRendered&&l?l:0)});E&&(E[E.isPlaced?"animate":"attr"]({d:this.getLinePath(E.strokeWidth())}),E.isPlaced=!0,E[A?"show":"hide"](!0));q&&A&&(q[q.isNew?"attr":"animate"](a.getTitlePosition()),q.isNew=!1);G&&G.enabled&&a.renderStackTotals();a.isDirty=!1},redraw:function(){this.visible&&(this.render(),n(this.plotLinesAndBands,function(a){a.render()}));n(this.series,function(a){a.isDirty=!0})},keepProps:"extKey hcEvents names series userMax userMin".split(" "),
destroy:function(a){var b=this,e=b.stacks,k,l=b.plotLinesAndBands,p,d;a||G(b);for(k in e)g(e[k]),e[k]=null;n([b.ticks,b.minorTicks,b.alternateBands],function(a){g(a)});if(l)for(a=l.length;a--;)l[a].destroy();n("stackTotalGroup axisLine axisTitle axisGroup gridGroup labelGroup cross".split(" "),function(a){b[a]&&(b[a]=b[a].destroy())});for(p in b.plotLinesAndBandsGroups)b.plotLinesAndBandsGroups[p]=b.plotLinesAndBandsGroups[p].destroy();for(d in b)b.hasOwnProperty(d)&&-1===c(d,b.keepProps)&&delete b[d]},
drawCrosshair:function(a,b){var c,e=this.crosshair,k=H(e.snap,!0),l,d=this.cross;a||(a=this.cross&&this.cross.e);this.crosshair&&!1!==(m(b)||!k)?(k?m(b)&&(l=this.isXAxis?b.plotX:this.len-b.plotY):l=a&&(this.horiz?a.chartX-this.pos:this.len-a.chartY+this.pos),m(l)&&(c=this.getPlotLinePath(b&&(this.isXAxis?b.x:H(b.stackY,b.y)),null,null,null,l)||null),m(c)?(b=this.categories&&!this.isRadial,d||(this.cross=d=this.chart.renderer.path().addClass("highcharts-crosshair highcharts-crosshair-"+(b?"category ":
"thin ")+e.className).attr({zIndex:H(e.zIndex,2)}).add(),d.attr({stroke:e.color||(b?h("#ccd6eb").setOpacity(.25).get():"#cccccc"),"stroke-width":H(e.width,1)}),e.dashStyle&&d.attr({dashstyle:e.dashStyle})),d.show().attr({d:c}),b&&!e.width&&d.attr({"stroke-width":this.transA}),this.cross.e=a):this.hideCrosshair()):this.hideCrosshair()},hideCrosshair:function(){this.cross&&this.cross.hide()}};y(a.Axis.prototype,f)})(J);(function(a){var z=a.Axis,F=a.getMagnitude,D=a.map,B=a.normalizeTickInterval,f=a.pick;
z.prototype.getLogTickPositions=function(a,t,r,m){var d=this.options,g=this.len,n=this.lin2log,h=this.log2lin,w=[];m||(this._minorAutoInterval=null);if(.5<=a)a=Math.round(a),w=this.getLinearTickPositions(a,t,r);else if(.08<=a)for(var g=Math.floor(t),b,l,e,c,E,d=.3<a?[1,2,4]:.15<a?[1,2,4,6,8]:[1,2,3,4,5,6,7,8,9];g<r+1&&!E;g++)for(l=d.length,b=0;b<l&&!E;b++)e=h(n(g)*d[b]),e>t&&(!m||c<=r)&&void 0!==c&&w.push(c),c>r&&(E=!0),c=e;else t=n(t),r=n(r),a=d[m?"minorTickInterval":"tickInterval"],a=f("auto"===
a?null:a,this._minorAutoInterval,d.tickPixelInterval/(m?5:1)*(r-t)/((m?g/this.tickPositions.length:g)||1)),a=B(a,null,F(a)),w=D(this.getLinearTickPositions(a,t,r),h),m||(this._minorAutoInterval=a/5);m||(this.tickInterval=a);return w};z.prototype.log2lin=function(a){return Math.log(a)/Math.LN10};z.prototype.lin2log=function(a){return Math.pow(10,a)}})(J);(function(a){var z=a.dateFormat,F=a.each,D=a.extend,B=a.format,f=a.isNumber,h=a.map,t=a.merge,r=a.pick,m=a.splat,d=a.syncTimeout,g=a.timeUnits;a.Tooltip=
function(){this.init.apply(this,arguments)};a.Tooltip.prototype={init:function(a,d){this.chart=a;this.options=d;this.crosshairs=[];this.now={x:0,y:0};this.isHidden=!0;this.split=d.split&&!a.inverted;this.shared=d.shared||this.split},cleanSplit:function(a){F(this.chart.series,function(d){var g=d&&d.tt;g&&(!g.isActive||a?d.tt=g.destroy():g.isActive=!1)})},getLabel:function(){var a=this.chart.renderer,d=this.options;this.label||(this.split?this.label=a.g("tooltip"):(this.label=a.label("",0,0,d.shape||
"callout",null,null,d.useHTML,null,"tooltip").attr({padding:d.padding,r:d.borderRadius}),this.label.attr({fill:d.backgroundColor,"stroke-width":d.borderWidth}).css(d.style).shadow(d.shadow)),this.label.attr({zIndex:8}).add());return this.label},update:function(a){this.destroy();this.init(this.chart,t(!0,this.options,a))},destroy:function(){this.label&&(this.label=this.label.destroy());this.split&&this.tt&&(this.cleanSplit(this.chart,!0),this.tt=this.tt.destroy());clearTimeout(this.hideTimer);clearTimeout(this.tooltipTimeout)},
move:function(a,d,g,b){var l=this,e=l.now,c=!1!==l.options.animation&&!l.isHidden&&(1<Math.abs(a-e.x)||1<Math.abs(d-e.y)),f=l.followPointer||1<l.len;D(e,{x:c?(2*e.x+a)/3:a,y:c?(e.y+d)/2:d,anchorX:f?void 0:c?(2*e.anchorX+g)/3:g,anchorY:f?void 0:c?(e.anchorY+b)/2:b});l.getLabel().attr(e);c&&(clearTimeout(this.tooltipTimeout),this.tooltipTimeout=setTimeout(function(){l&&l.move(a,d,g,b)},32))},hide:function(a){var g=this;clearTimeout(this.hideTimer);a=r(a,this.options.hideDelay,500);this.isHidden||(this.hideTimer=
d(function(){g.getLabel()[a?"fadeOut":"hide"]();g.isHidden=!0},a))},getAnchor:function(a,d){var g,b=this.chart,l=b.inverted,e=b.plotTop,c=b.plotLeft,f=0,u=0,q,n;a=m(a);g=a[0].tooltipPos;this.followPointer&&d&&(void 0===d.chartX&&(d=b.pointer.normalize(d)),g=[d.chartX-b.plotLeft,d.chartY-e]);g||(F(a,function(a){q=a.series.yAxis;n=a.series.xAxis;f+=a.plotX+(!l&&n?n.left-c:0);u+=(a.plotLow?(a.plotLow+a.plotHigh)/2:a.plotY)+(!l&&q?q.top-e:0)}),f/=a.length,u/=a.length,g=[l?b.plotWidth-u:f,this.shared&&
!l&&1<a.length&&d?d.chartY-e:l?b.plotHeight-f:u]);return h(g,Math.round)},getPosition:function(a,d,g){var b=this.chart,l=this.distance,e={},c=g.h||0,f,u=["y",b.chartHeight,d,g.plotY+b.plotTop,b.plotTop,b.plotTop+b.plotHeight],q=["x",b.chartWidth,a,g.plotX+b.plotLeft,b.plotLeft,b.plotLeft+b.plotWidth],n=!this.followPointer&&r(g.ttBelow,!b.inverted===!!g.negative),h=function(a,b,k,d,g,q){var p=k<d-l,f=d+l+k<b,u=d-l-k;d+=l;if(n&&f)e[a]=d;else if(!n&&p)e[a]=u;else if(p)e[a]=Math.min(q-k,0>u-c?u:u-c);
else if(f)e[a]=Math.max(g,d+c+k>b?d:d+c);else return!1},m=function(a,b,c,k){var d;k<l||k>b-l?d=!1:e[a]=k<c/2?1:k>b-c/2?b-c-2:k-c/2;return d},k=function(a){var b=u;u=q;q=b;f=a},G=function(){!1!==h.apply(0,u)?!1!==m.apply(0,q)||f||(k(!0),G()):f?e.x=e.y=0:(k(!0),G())};(b.inverted||1<this.len)&&k();G();return e},defaultFormatter:function(a){var d=this.points||m(this),g;g=[a.tooltipFooterHeaderFormatter(d[0])];g=g.concat(a.bodyFormatter(d));g.push(a.tooltipFooterHeaderFormatter(d[0],!0));return g},refresh:function(a,
d){var g,b=this.options,l,e=a,c,f={},u=[];g=b.formatter||this.defaultFormatter;var f=this.shared,q;clearTimeout(this.hideTimer);this.followPointer=m(e)[0].series.tooltipOptions.followPointer;c=this.getAnchor(e,d);d=c[0];l=c[1];!f||e.series&&e.series.noSharedTooltip?f=e.getLabelConfig():(F(e,function(a){a.setState("hover");u.push(a.getLabelConfig())}),f={x:e[0].category,y:e[0].y},f.points=u,e=e[0]);this.len=u.length;f=g.call(f,this);q=e.series;this.distance=r(q.tooltipOptions.distance,16);!1===f?this.hide():
(g=this.getLabel(),this.isHidden&&g.attr({opacity:1}).show(),this.split?this.renderSplit(f,a):(g.attr({text:f&&f.join?f.join(""):f}),g.removeClass(/highcharts-color-[\d]+/g).addClass("highcharts-color-"+r(e.colorIndex,q.colorIndex)),g.attr({stroke:b.borderColor||e.color||q.color||"#666666"}),this.updatePosition({plotX:d,plotY:l,negative:e.negative,ttBelow:e.ttBelow,h:c[2]||0})),this.isHidden=!1)},renderSplit:function(d,g){var f=this,b=[],l=this.chart,e=l.renderer,c=!0,n=this.options,u,q=this.getLabel();
F(d.slice(0,g.length+1),function(a,d){d=g[d-1]||{isHeader:!0,plotX:g[0].plotX};var h=d.series||f,k=h.tt,G=d.series||{},m="highcharts-color-"+r(d.colorIndex,G.colorIndex,"none");k||(h.tt=k=e.label(null,null,null,"callout").addClass("highcharts-tooltip-box "+m).attr({padding:n.padding,r:n.borderRadius,fill:n.backgroundColor,stroke:d.color||G.color||"#333333","stroke-width":n.borderWidth}).add(q));k.isActive=!0;k.attr({text:a});k.css(n.style);a=k.getBBox();G=a.width+k.strokeWidth();d.isHeader?(u=a.height,
G=Math.max(0,Math.min(d.plotX+l.plotLeft-G/2,l.chartWidth-G))):G=d.plotX+l.plotLeft-r(n.distance,16)-G;0>G&&(c=!1);a=(d.series&&d.series.yAxis&&d.series.yAxis.pos)+(d.plotY||0);a-=l.plotTop;b.push({target:d.isHeader?l.plotHeight+u:a,rank:d.isHeader?1:0,size:h.tt.getBBox().height+1,point:d,x:G,tt:k})});this.cleanSplit();a.distribute(b,l.plotHeight+u);F(b,function(a){var b=a.point,e=b.series;a.tt.attr({visibility:void 0===a.pos?"hidden":"inherit",x:c||b.isHeader?a.x:b.plotX+l.plotLeft+r(n.distance,
16),y:a.pos+l.plotTop,anchorX:b.isHeader?b.plotX+l.plotLeft:b.plotX+e.xAxis.pos,anchorY:b.isHeader?a.pos+l.plotTop-15:b.plotY+e.yAxis.pos})})},updatePosition:function(a){var d=this.chart,g=this.getLabel(),g=(this.options.positioner||this.getPosition).call(this,g.width,g.height,a);this.move(Math.round(g.x),Math.round(g.y||0),a.plotX+d.plotLeft,a.plotY+d.plotTop)},getDateFormat:function(a,d,f,b){var l=z("%m-%d %H:%M:%S.%L",d),e,c,n={millisecond:15,second:12,minute:9,hour:6,day:3},u="millisecond";for(c in g){if(a===
g.week&&+z("%w",d)===f&&"00:00:00.000"===l.substr(6)){c="week";break}if(g[c]>a){c=u;break}if(n[c]&&l.substr(n[c])!=="01-01 00:00:00.000".substr(n[c]))break;"week"!==c&&(u=c)}c&&(e=b[c]);return e},getXDateFormat:function(a,d,g){d=d.dateTimeLabelFormats;var b=g&&g.closestPointRange;return(b?this.getDateFormat(b,a.x,g.options.startOfWeek,d):d.day)||d.year},tooltipFooterHeaderFormatter:function(a,d){var g=d?"footer":"header";d=a.series;var b=d.tooltipOptions,l=b.xDateFormat,e=d.xAxis,c=e&&"datetime"===
e.options.type&&f(a.key),g=b[g+"Format"];c&&!l&&(l=this.getXDateFormat(a,b,e));c&&l&&(g=g.replace("{point.key}","{point.key:"+l+"}"));return B(g,{point:a,series:d})},bodyFormatter:function(a){return h(a,function(a){var d=a.series.tooltipOptions;return(d.pointFormatter||a.point.tooltipFormatter).call(a.point,d.pointFormat)})}}})(J);(function(a){var z=a.addEvent,F=a.attr,D=a.charts,B=a.color,f=a.css,h=a.defined,t=a.doc,r=a.each,m=a.extend,d=a.fireEvent,g=a.offset,n=a.pick,y=a.removeEvent,w=a.splat,
b=a.Tooltip,l=a.win;a.Pointer=function(a,b){this.init(a,b)};a.Pointer.prototype={init:function(a,c){this.options=c;this.chart=a;this.runChartClick=c.chart.events&&!!c.chart.events.click;this.pinchDown=[];this.lastValidTouch={};b&&c.tooltip.enabled&&(a.tooltip=new b(a,c.tooltip),this.followTouchMove=n(c.tooltip.followTouchMove,!0));this.setDOMEvents()},zoomOption:function(a){var b=this.chart,e=b.options.chart,d=e.zoomType||"",b=b.inverted;/touch/.test(a.type)&&(d=n(e.pinchType,d));this.zoomX=a=/x/.test(d);
this.zoomY=d=/y/.test(d);this.zoomHor=a&&!b||d&&b;this.zoomVert=d&&!b||a&&b;this.hasZoom=a||d},normalize:function(a,b){var c,e;a=a||l.event;a.target||(a.target=a.srcElement);e=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a;b||(this.chartPosition=b=g(this.chart.container));void 0===e.pageX?(c=Math.max(a.x,a.clientX-b.left),b=a.y):(c=e.pageX-b.left,b=e.pageY-b.top);return m(a,{chartX:Math.round(c),chartY:Math.round(b)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};r(this.chart.axes,
function(c){b[c.isXAxis?"xAxis":"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})});return b},getKDPoints:function(a,b,d){var c=[],e,l,g;r(a,function(a){e=a.noSharedTooltip&&b;l=!b&&a.directTouch;a.visible&&!l&&n(a.options.enableMouseTracking,!0)&&(g=a.searchPoint(d,!e&&0>a.options.findNearestPointBy.indexOf("y")))&&g.series&&c.push(g)});c.sort(function(a,c){var e=a.distX-c.distX,k=a.dist-c.dist,d=(c.series.group&&c.series.group.zIndex)-(a.series.group&&a.series.group.zIndex);
return 0!==e&&b?e:0!==k?k:0!==d?d:a.series.index>c.series.index?-1:1});if(b&&c[0]&&!c[0].series.noSharedTooltip)for(a=c.length;a--;)(c[a].x!==c[0].x||c[a].series.noSharedTooltip)&&c.splice(a,1);return c},getPointFromEvent:function(a){a=a.target;for(var b;a&&!b;)b=a.point,a=a.parentNode;return b},getHoverData:function(b,c,d,l,g,f){var e=b,q=c,k;l?g?(k=[],r(d,function(a){var b=a.noSharedTooltip&&g,c=!g&&a.directTouch;a.visible&&!b&&!c&&n(a.options.enableMouseTracking,!0)&&(a=a.searchKDTree({clientX:e.clientX,
plotY:e.plotY},!b&&1===a.kdDimensions))&&a.series&&k.push(a)}),0===k.length&&(k=[e])):k=[e]:q&&!q.stickyTracking?(g||(d=[q]),k=this.getKDPoints(d,g,f),e=a.find(k,function(a){return a.series===q})):(b=a.grep(d,function(a){return a.stickyTracking}),k=this.getKDPoints(b,g,f),q=(e=k[0])&&e.series,g&&(k=this.getKDPoints(d,g,f)));k.sort(function(a,b){return a.series.index-b.series.index});return{hoverPoint:e,hoverSeries:q,hoverPoints:k}},runPointActions:function(b,c){var e=this.chart,d=e.tooltip,l=d?d.shared:
!1,g=c||e.hoverPoint,f=g&&g.series||e.hoverSeries;c=this.getHoverData(g,f,e.series,!!c||!l&&f&&f.directTouch,l,b);var h,k,g=c.hoverPoint;h=(f=c.hoverSeries)&&f.tooltipOptions.followPointer;k=(l=l&&g&&!g.series.noSharedTooltip)?c.hoverPoints:g?[g]:[];if(g&&(g!==e.hoverPoint||d&&d.isHidden)){r(e.hoverPoints||[],function(b){-1===a.inArray(b,k)&&b.setState()});r(k||[],function(a){a.setState("hover")});if(e.hoverSeries!==f)f.onMouseOver();f&&!f.directTouch&&(e.hoverPoint&&e.hoverPoint.firePointEvent("mouseOut"),
g.firePointEvent("mouseOver"));e.hoverPoints=k;e.hoverPoint=g;d&&d.refresh(l?k:g,b)}else h&&d&&!d.isHidden&&(g=d.getAnchor([{}],b),d.updatePosition({plotX:g[0],plotY:g[1]}));this.unDocMouseMove||(this.unDocMouseMove=z(t,"mousemove",function(b){var c=D[a.hoverChartIndex];if(c)c.pointer.onDocumentMouseMove(b)}));r(e.axes,function(a){n(a.crosshair.snap,!0)?r(k,function(c){c.series[a.coll]===a&&a.drawCrosshair(b,c)}):a.drawCrosshair(b)})},reset:function(a,b){var c=this.chart,e=c.hoverSeries,d=c.hoverPoint,
g=c.hoverPoints,l=c.tooltip,f=l&&l.shared?g:d;a&&f&&r(w(f),function(b){b.series.isCartesian&&void 0===b.plotX&&(a=!1)});if(a)l&&f&&(l.refresh(f),d&&(d.setState(d.state,!0),r(c.axes,function(a){a.crosshair&&a.drawCrosshair(null,d)})));else{if(d)d.onMouseOut();g&&r(g,function(a){a.setState()});if(e)e.onMouseOut();l&&l.hide(b);this.unDocMouseMove&&(this.unDocMouseMove=this.unDocMouseMove());r(c.axes,function(a){a.hideCrosshair()});this.hoverX=c.hoverPoints=c.hoverPoint=null}},scaleGroups:function(a,
b){var c=this.chart,e;r(c.series,function(d){e=a||d.getPlotBox();d.xAxis&&d.xAxis.zoomEnabled&&d.group&&(d.group.attr(e),d.markerGroup&&(d.markerGroup.attr(e),d.markerGroup.clip(b?c.clipRect:null)),d.dataLabelsGroup&&d.dataLabelsGroup.attr(e))});c.clipRect.attr(b||c.clipBox)},dragStart:function(a){var b=this.chart;b.mouseIsDown=a.type;b.cancelClick=!1;b.mouseDownX=this.mouseDownX=a.chartX;b.mouseDownY=this.mouseDownY=a.chartY},drag:function(a){var b=this.chart,e=b.options.chart,d=a.chartX,g=a.chartY,
l=this.zoomHor,f=this.zoomVert,n=b.plotLeft,k=b.plotTop,h=b.plotWidth,m=b.plotHeight,w,r=this.selectionMarker,p=this.mouseDownX,t=this.mouseDownY,y=e.panKey&&a[e.panKey+"Key"];r&&r.touch||(d<n?d=n:d>n+h&&(d=n+h),g<k?g=k:g>k+m&&(g=k+m),this.hasDragged=Math.sqrt(Math.pow(p-d,2)+Math.pow(t-g,2)),10<this.hasDragged&&(w=b.isInsidePlot(p-n,t-k),b.hasCartesianSeries&&(this.zoomX||this.zoomY)&&w&&!y&&!r&&(this.selectionMarker=r=b.renderer.rect(n,k,l?1:h,f?1:m,0).attr({fill:e.selectionMarkerFill||B("#335cad").setOpacity(.25).get(),
"class":"highcharts-selection-marker",zIndex:7}).add()),r&&l&&(d-=p,r.attr({width:Math.abs(d),x:(0<d?0:d)+p})),r&&f&&(d=g-t,r.attr({height:Math.abs(d),y:(0<d?0:d)+t})),w&&!r&&e.panning&&b.pan(a,e.panning)))},drop:function(a){var b=this,e=this.chart,g=this.hasPinched;if(this.selectionMarker){var l={originalEvent:a,xAxis:[],yAxis:[]},n=this.selectionMarker,A=n.attr?n.attr("x"):n.x,w=n.attr?n.attr("y"):n.y,k=n.attr?n.attr("width"):n.width,G=n.attr?n.attr("height"):n.height,I;if(this.hasDragged||g)r(e.axes,
function(c){if(c.zoomEnabled&&h(c.min)&&(g||b[{xAxis:"zoomX",yAxis:"zoomY"}[c.coll]])){var e=c.horiz,d="touchend"===a.type?c.minPixelPadding:0,f=c.toValue((e?A:w)+d),e=c.toValue((e?A+k:w+G)-d);l[c.coll].push({axis:c,min:Math.min(f,e),max:Math.max(f,e)});I=!0}}),I&&d(e,"selection",l,function(a){e.zoom(m(a,g?{animation:!1}:null))});this.selectionMarker=this.selectionMarker.destroy();g&&this.scaleGroups()}e&&(f(e.container,{cursor:e._cursor}),e.cancelClick=10<this.hasDragged,e.mouseIsDown=this.hasDragged=
this.hasPinched=!1,this.pinchDown=[])},onContainerMouseDown:function(a){a=this.normalize(a);this.zoomOption(a);a.preventDefault&&a.preventDefault();this.dragStart(a)},onDocumentMouseUp:function(b){D[a.hoverChartIndex]&&D[a.hoverChartIndex].pointer.drop(b)},onDocumentMouseMove:function(a){var b=this.chart,e=this.chartPosition;a=this.normalize(a,e);!e||this.inClass(a.target,"highcharts-tracker")||b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)||this.reset()},onContainerMouseLeave:function(b){var c=
D[a.hoverChartIndex];c&&(b.relatedTarget||b.toElement)&&(c.pointer.reset(),c.pointer.chartPosition=null)},onContainerMouseMove:function(b){var c=this.chart;h(a.hoverChartIndex)&&D[a.hoverChartIndex]&&D[a.hoverChartIndex].mouseIsDown||(a.hoverChartIndex=c.index);b=this.normalize(b);b.returnValue=!1;"mousedown"===c.mouseIsDown&&this.drag(b);!this.inClass(b.target,"highcharts-tracker")&&!c.isInsidePlot(b.chartX-c.plotLeft,b.chartY-c.plotTop)||c.openMenu||this.runPointActions(b)},inClass:function(a,b){for(var c;a;){if(c=
F(a,"class")){if(-1!==c.indexOf(b))return!0;if(-1!==c.indexOf("highcharts-container"))return!1}a=a.parentNode}},onTrackerMouseOut:function(a){var b=this.chart.hoverSeries;a=a.relatedTarget||a.toElement;if(!(!b||!a||b.stickyTracking||this.inClass(a,"highcharts-tooltip")||this.inClass(a,"highcharts-series-"+b.index)&&this.inClass(a,"highcharts-tracker")))b.onMouseOut()},onContainerClick:function(a){var b=this.chart,e=b.hoverPoint,g=b.plotLeft,l=b.plotTop;a=this.normalize(a);b.cancelClick||(e&&this.inClass(a.target,
"highcharts-tracker")?(d(e.series,"click",m(a,{point:e})),b.hoverPoint&&e.firePointEvent("click",a)):(m(a,this.getCoordinates(a)),b.isInsidePlot(a.chartX-g,a.chartY-l)&&d(b,"click",a)))},setDOMEvents:function(){var b=this,c=b.chart.container;c.onmousedown=function(a){b.onContainerMouseDown(a)};c.onmousemove=function(a){b.onContainerMouseMove(a)};c.onclick=function(a){b.onContainerClick(a)};z(c,"mouseleave",b.onContainerMouseLeave);1===a.chartCount&&z(t,"mouseup",b.onDocumentMouseUp);a.hasTouch&&(c.ontouchstart=
function(a){b.onContainerTouchStart(a)},c.ontouchmove=function(a){b.onContainerTouchMove(a)},1===a.chartCount&&z(t,"touchend",b.onDocumentTouchEnd))},destroy:function(){var b;this.unDocMouseMove&&this.unDocMouseMove();y(this.chart.container,"mouseleave",this.onContainerMouseLeave);a.chartCount||(y(t,"mouseup",this.onDocumentMouseUp),y(t,"touchend",this.onDocumentTouchEnd));clearInterval(this.tooltipTimeout);for(b in this)this[b]=null}}})(J);(function(a){var z=a.charts,F=a.each,D=a.extend,B=a.map,
f=a.noop,h=a.pick;D(a.Pointer.prototype,{pinchTranslate:function(a,f,h,d,g,n){this.zoomHor&&this.pinchTranslateDirection(!0,a,f,h,d,g,n);this.zoomVert&&this.pinchTranslateDirection(!1,a,f,h,d,g,n)},pinchTranslateDirection:function(a,f,h,d,g,n,y,w){var b=this.chart,l=a?"x":"y",e=a?"X":"Y",c="chart"+e,m=a?"width":"height",u=b["plot"+(a?"Left":"Top")],q,x,A=w||1,r=b.inverted,k=b.bounds[a?"h":"v"],G=1===f.length,I=f[0][c],t=h[0][c],K=!G&&f[1][c],p=!G&&h[1][c],C;h=function(){!G&&20<Math.abs(I-K)&&(A=w||
Math.abs(t-p)/Math.abs(I-K));x=(u-t)/A+I;q=b["plot"+(a?"Width":"Height")]/A};h();f=x;f<k.min?(f=k.min,C=!0):f+q>k.max&&(f=k.max-q,C=!0);C?(t-=.8*(t-y[l][0]),G||(p-=.8*(p-y[l][1])),h()):y[l]=[t,p];r||(n[l]=x-u,n[m]=q);n=r?1/A:A;g[m]=q;g[l]=f;d[r?a?"scaleY":"scaleX":"scale"+e]=A;d["translate"+e]=n*u+(t-n*I)},pinch:function(a){var r=this,m=r.chart,d=r.pinchDown,g=a.touches,n=g.length,t=r.lastValidTouch,w=r.hasZoom,b=r.selectionMarker,l={},e=1===n&&(r.inClass(a.target,"highcharts-tracker")&&m.runTrackerClick||
r.runChartClick),c={};1<n&&(r.initiated=!0);w&&r.initiated&&!e&&a.preventDefault();B(g,function(a){return r.normalize(a)});"touchstart"===a.type?(F(g,function(a,b){d[b]={chartX:a.chartX,chartY:a.chartY}}),t.x=[d[0].chartX,d[1]&&d[1].chartX],t.y=[d[0].chartY,d[1]&&d[1].chartY],F(m.axes,function(a){if(a.zoomEnabled){var b=m.bounds[a.horiz?"h":"v"],c=a.minPixelPadding,e=a.toPixels(h(a.options.min,a.dataMin)),d=a.toPixels(h(a.options.max,a.dataMax)),g=Math.max(e,d);b.min=Math.min(a.pos,Math.min(e,d)-
c);b.max=Math.max(a.pos+a.len,g+c)}}),r.res=!0):r.followTouchMove&&1===n?this.runPointActions(r.normalize(a)):d.length&&(b||(r.selectionMarker=b=D({destroy:f,touch:!0},m.plotBox)),r.pinchTranslate(d,g,l,b,c,t),r.hasPinched=w,r.scaleGroups(l,c),r.res&&(r.res=!1,this.reset(!1,0)))},touch:function(f,r){var m=this.chart,d,g;if(m.index!==a.hoverChartIndex)this.onContainerMouseLeave({relatedTarget:!0});a.hoverChartIndex=m.index;1===f.touches.length?(f=this.normalize(f),(g=m.isInsidePlot(f.chartX-m.plotLeft,
f.chartY-m.plotTop))&&!m.openMenu?(r&&this.runPointActions(f),"touchmove"===f.type&&(r=this.pinchDown,d=r[0]?4<=Math.sqrt(Math.pow(r[0].chartX-f.chartX,2)+Math.pow(r[0].chartY-f.chartY,2)):!1),h(d,!0)&&this.pinch(f)):r&&this.reset()):2===f.touches.length&&this.pinch(f)},onContainerTouchStart:function(a){this.zoomOption(a);this.touch(a,!0)},onContainerTouchMove:function(a){this.touch(a)},onDocumentTouchEnd:function(f){z[a.hoverChartIndex]&&z[a.hoverChartIndex].pointer.drop(f)}})})(J);(function(a){var z=
a.addEvent,F=a.charts,D=a.css,B=a.doc,f=a.extend,h=a.noop,t=a.Pointer,r=a.removeEvent,m=a.win,d=a.wrap;if(m.PointerEvent||m.MSPointerEvent){var g={},n=!!m.PointerEvent,y=function(){var a,d=[];d.item=function(a){return this[a]};for(a in g)g.hasOwnProperty(a)&&d.push({pageX:g[a].pageX,pageY:g[a].pageY,target:g[a].target});return d},w=function(b,d,e,c){"touch"!==b.pointerType&&b.pointerType!==b.MSPOINTER_TYPE_TOUCH||!F[a.hoverChartIndex]||(c(b),c=F[a.hoverChartIndex].pointer,c[d]({type:e,target:b.currentTarget,
preventDefault:h,touches:y()}))};f(t.prototype,{onContainerPointerDown:function(a){w(a,"onContainerTouchStart","touchstart",function(a){g[a.pointerId]={pageX:a.pageX,pageY:a.pageY,target:a.currentTarget}})},onContainerPointerMove:function(a){w(a,"onContainerTouchMove","touchmove",function(a){g[a.pointerId]={pageX:a.pageX,pageY:a.pageY};g[a.pointerId].target||(g[a.pointerId].target=a.currentTarget)})},onDocumentPointerUp:function(a){w(a,"onDocumentTouchEnd","touchend",function(a){delete g[a.pointerId]})},
batchMSEvents:function(a){a(this.chart.container,n?"pointerdown":"MSPointerDown",this.onContainerPointerDown);a(this.chart.container,n?"pointermove":"MSPointerMove",this.onContainerPointerMove);a(B,n?"pointerup":"MSPointerUp",this.onDocumentPointerUp)}});d(t.prototype,"init",function(a,d,e){a.call(this,d,e);this.hasZoom&&D(d.container,{"-ms-touch-action":"none","touch-action":"none"})});d(t.prototype,"setDOMEvents",function(a){a.apply(this);(this.hasZoom||this.followTouchMove)&&this.batchMSEvents(z)});
d(t.prototype,"destroy",function(a){this.batchMSEvents(r);a.call(this)})}})(J);(function(a){var z,F=a.addEvent,D=a.css,B=a.discardElement,f=a.defined,h=a.each,t=a.isFirefox,r=a.marginNames,m=a.merge,d=a.pick,g=a.setAnimation,n=a.stableSort,y=a.win,w=a.wrap;z=a.Legend=function(a,d){this.init(a,d)};z.prototype={init:function(a,d){this.chart=a;this.setOptions(d);d.enabled&&(this.render(),F(this.chart,"endResize",function(){this.legend.positionCheckboxes()}))},setOptions:function(a){var b=d(a.padding,
8);this.options=a;this.itemStyle=a.itemStyle;this.itemHiddenStyle=m(this.itemStyle,a.itemHiddenStyle);this.itemMarginTop=a.itemMarginTop||0;this.padding=b;this.initialItemY=b-5;this.itemHeight=this.maxItemWidth=0;this.symbolWidth=d(a.symbolWidth,16);this.pages=[]},update:function(a,g){var b=this.chart;this.setOptions(m(!0,this.options,a));this.destroy();b.isDirtyLegend=b.isDirtyBox=!0;d(g,!0)&&b.redraw()},colorizeItem:function(a,d){a.legendGroup[d?"removeClass":"addClass"]("highcharts-legend-item-hidden");
var b=this.options,c=a.legendItem,g=a.legendLine,l=a.legendSymbol,f=this.itemHiddenStyle.color,b=d?b.itemStyle.color:f,n=d?a.color||f:f,h=a.options&&a.options.marker,m={fill:n},k;c&&c.css({fill:b,color:b});g&&g.attr({stroke:n});if(l){if(h&&l.isMarker&&(m=a.pointAttribs(),!d))for(k in m)m[k]=f;l.attr(m)}},positionItem:function(a){var b=this.options,e=b.symbolPadding,b=!b.rtl,c=a._legendItemPos,d=c[0],c=c[1],g=a.checkbox;(a=a.legendGroup)&&a.element&&a.translate(b?d:this.legendWidth-d-2*e-4,c);g&&(g.x=
d,g.y=c)},destroyItem:function(a){var b=a.checkbox;h(["legendItem","legendLine","legendSymbol","legendGroup"],function(b){a[b]&&(a[b]=a[b].destroy())});b&&B(a.checkbox)},destroy:function(){function a(a){this[a]&&(this[a]=this[a].destroy())}h(this.getAllItems(),function(b){h(["legendItem","legendGroup"],a,b)});h("clipRect up down pager nav box title group".split(" "),a,this);this.display=null},positionCheckboxes:function(a){var b=this.group&&this.group.alignAttr,e,c=this.clipHeight||this.legendHeight,
d=this.titleHeight;b&&(e=b.translateY,h(this.allItems,function(g){var f=g.checkbox,l;f&&(l=e+d+f.y+(a||0)+3,D(f,{left:b.translateX+g.checkboxOffset+f.x-20+"px",top:l+"px",display:l>e-6&&l<e+c-6?"":"none"}))}))},renderTitle:function(){var a=this.padding,d=this.options.title,e=0;d.text&&(this.title||(this.title=this.chart.renderer.label(d.text,a-3,a-4,null,null,null,null,null,"legend-title").attr({zIndex:1}).css(d.style).add(this.group)),a=this.title.getBBox(),e=a.height,this.offsetWidth=a.width,this.contentGroup.attr({translateY:e}));
this.titleHeight=e},setText:function(b){var d=this.options;b.legendItem.attr({text:d.labelFormat?a.format(d.labelFormat,b):d.labelFormatter.call(b)})},renderItem:function(a){var b=this.chart,e=b.renderer,c=this.options,g="horizontal"===c.layout,f=this.symbolWidth,q=c.symbolPadding,n=this.itemStyle,h=this.itemHiddenStyle,w=this.padding,k=g?d(c.itemDistance,20):0,G=!c.rtl,I=c.width,r=c.itemMarginBottom||0,K=this.itemMarginTop,p=a.legendItem,y=!a.series,t=!y&&a.series.drawLegendSymbol?a.series:a,B=t.options,
B=this.createCheckboxForItem&&B&&B.showCheckbox,z=c.useHTML,D=a.options.className;p||(a.legendGroup=e.g("legend-item").addClass("highcharts-"+t.type+"-series highcharts-color-"+a.colorIndex+(D?" "+D:"")+(y?" highcharts-series-"+a.index:"")).attr({zIndex:1}).add(this.scrollGroup),a.legendItem=p=e.text("",G?f+q:-q,this.baseline||0,z).css(m(a.visible?n:h)).attr({align:G?"left":"right",zIndex:2}).add(a.legendGroup),this.baseline||(n=n.fontSize,this.fontMetrics=e.fontMetrics(n,p),this.baseline=this.fontMetrics.f+
3+K,p.attr("y",this.baseline)),this.symbolHeight=c.symbolHeight||this.fontMetrics.f,t.drawLegendSymbol(this,a),this.setItemEvents&&this.setItemEvents(a,p,z),B&&this.createCheckboxForItem(a));this.colorizeItem(a,a.visible);this.setText(a);e=p.getBBox();f=a.checkboxOffset=c.itemWidth||a.legendItemWidth||f+q+e.width+k+(B?20:0);this.itemHeight=q=Math.round(a.legendItemHeight||e.height||this.symbolHeight);g&&this.itemX-w+f>(I||b.spacingBox.width-2*w-c.x)&&(this.itemX=w,this.itemY+=K+this.lastLineHeight+
r,this.lastLineHeight=0);this.maxItemWidth=Math.max(this.maxItemWidth,f);this.lastItemY=K+this.itemY+r;this.lastLineHeight=Math.max(q,this.lastLineHeight);a._legendItemPos=[this.itemX,this.itemY];g?this.itemX+=f:(this.itemY+=K+q+r,this.lastLineHeight=q);this.offsetWidth=I||Math.max((g?this.itemX-w-k:f)+w,this.offsetWidth)},getAllItems:function(){var a=[];h(this.chart.series,function(b){var e=b&&b.options;b&&d(e.showInLegend,f(e.linkedTo)?!1:void 0,!0)&&(a=a.concat(b.legendItems||("point"===e.legendType?
b.data:b)))});return a},adjustMargins:function(a,g){var b=this.chart,c=this.options,l=c.align.charAt(0)+c.verticalAlign.charAt(0)+c.layout.charAt(0);c.floating||h([/(lth|ct|rth)/,/(rtv|rm|rbv)/,/(rbh|cb|lbh)/,/(lbv|lm|ltv)/],function(e,q){e.test(l)&&!f(a[q])&&(b[r[q]]=Math.max(b[r[q]],b.legend[(q+1)%2?"legendHeight":"legendWidth"]+[1,-1,-1,1][q]*c[q%2?"x":"y"]+d(c.margin,12)+g[q]))})},render:function(){var a=this,d=a.chart,e=d.renderer,c=a.group,g,f,q,x,w=a.box,r=a.options,k=a.padding;a.itemX=k;a.itemY=
a.initialItemY;a.offsetWidth=0;a.lastItemY=0;c||(a.group=c=e.g("legend").attr({zIndex:7}).add(),a.contentGroup=e.g().attr({zIndex:1}).add(c),a.scrollGroup=e.g().add(a.contentGroup));a.renderTitle();g=a.getAllItems();n(g,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)});r.reversed&&g.reverse();a.allItems=g;a.display=f=!!g.length;a.lastLineHeight=0;h(g,function(b){a.renderItem(b)});q=(r.width||a.offsetWidth)+k;x=a.lastItemY+a.lastLineHeight+a.titleHeight;
x=a.handleOverflow(x);x+=k;w||(a.box=w=e.rect().addClass("highcharts-legend-box").attr({r:r.borderRadius}).add(c),w.isNew=!0);w.attr({stroke:r.borderColor,"stroke-width":r.borderWidth||0,fill:r.backgroundColor||"none"}).shadow(r.shadow);0<q&&0<x&&(w[w.isNew?"attr":"animate"](w.crisp({x:0,y:0,width:q,height:x},w.strokeWidth())),w.isNew=!1);w[f?"show":"hide"]();a.legendWidth=q;a.legendHeight=x;h(g,function(b){a.positionItem(b)});f&&c.align(m(r,{width:q,height:x}),!0,"spacingBox");d.isResizing||this.positionCheckboxes()},
handleOverflow:function(a){var b=this,e=this.chart,c=e.renderer,g=this.options,f=g.y,q=this.padding,e=e.spacingBox.height+("top"===g.verticalAlign?-f:f)-q,f=g.maxHeight,n,m=this.clipRect,w=g.navigation,k=d(w.animation,!0),G=w.arrowSize||12,I=this.nav,r=this.pages,y,p=this.allItems,t=function(a){a?m.attr({height:a}):m&&(b.clipRect=m.destroy(),b.contentGroup.clip());b.contentGroup.div&&(b.contentGroup.div.style.clip=a?"rect("+q+"px,9999px,"+(q+a)+"px,0)":"auto")};"horizontal"!==g.layout||"middle"===
g.verticalAlign||g.floating||(e/=2);f&&(e=Math.min(e,f));r.length=0;a>e&&!1!==w.enabled?(this.clipHeight=n=Math.max(e-20-this.titleHeight-q,0),this.currentPage=d(this.currentPage,1),this.fullHeight=a,h(p,function(a,b){var c=a._legendItemPos[1];a=Math.round(a.legendItem.getBBox().height);var e=r.length;if(!e||c-r[e-1]>n&&(y||c)!==r[e-1])r.push(y||c),e++;b===p.length-1&&c+a-r[e-1]>n&&r.push(c);c!==y&&(y=c)}),m||(m=b.clipRect=c.clipRect(0,q,9999,0),b.contentGroup.clip(m)),t(n),I||(this.nav=I=c.g().attr({zIndex:1}).add(this.group),
this.up=c.symbol("triangle",0,0,G,G).on("click",function(){b.scroll(-1,k)}).add(I),this.pager=c.text("",15,10).addClass("highcharts-legend-navigation").css(w.style).add(I),this.down=c.symbol("triangle-down",0,0,G,G).on("click",function(){b.scroll(1,k)}).add(I)),b.scroll(0),a=e):I&&(t(),this.nav=I.destroy(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0);return a},scroll:function(a,d){var b=this.pages,c=b.length;a=this.currentPage+a;var f=this.clipHeight,l=this.options.navigation,q=this.pager,
n=this.padding;a>c&&(a=c);0<a&&(void 0!==d&&g(d,this.chart),this.nav.attr({translateX:n,translateY:f+this.padding+7+this.titleHeight,visibility:"visible"}),this.up.attr({"class":1===a?"highcharts-legend-nav-inactive":"highcharts-legend-nav-active"}),q.attr({text:a+"/"+c}),this.down.attr({x:18+this.pager.getBBox().width,"class":a===c?"highcharts-legend-nav-inactive":"highcharts-legend-nav-active"}),this.up.attr({fill:1===a?l.inactiveColor:l.activeColor}).css({cursor:1===a?"default":"pointer"}),this.down.attr({fill:a===
c?l.inactiveColor:l.activeColor}).css({cursor:a===c?"default":"pointer"}),d=-b[a-1]+this.initialItemY,this.scrollGroup.animate({translateY:d}),this.currentPage=a,this.positionCheckboxes(d))}};a.LegendSymbolMixin={drawRectangle:function(a,g){var b=a.symbolHeight,c=a.options.squareSymbol;g.legendSymbol=this.chart.renderer.rect(c?(a.symbolWidth-b)/2:0,a.baseline-b+1,c?b:a.symbolWidth,b,d(a.options.symbolRadius,b/2)).addClass("highcharts-point").attr({zIndex:3}).add(g.legendGroup)},drawLineMarker:function(a){var b=
this.options,e=b.marker,c=a.symbolWidth,g=a.symbolHeight,f=g/2,n=this.chart.renderer,h=this.legendGroup;a=a.baseline-Math.round(.3*a.fontMetrics.b);var w;w={"stroke-width":b.lineWidth||0};b.dashStyle&&(w.dashstyle=b.dashStyle);this.legendLine=n.path(["M",0,a,"L",c,a]).addClass("highcharts-graph").attr(w).add(h);e&&!1!==e.enabled&&(b=Math.min(d(e.radius,f),f),0===this.symbol.indexOf("url")&&(e=m(e,{width:g,height:g}),b=0),this.legendSymbol=e=n.symbol(this.symbol,c/2-b,a-b,2*b,2*b,e).addClass("highcharts-point").add(h),
e.isMarker=!0)}};(/Trident\/7\.0/.test(y.navigator.userAgent)||t)&&w(z.prototype,"positionItem",function(a,d){var b=this,c=function(){d._legendItemPos&&a.call(b,d)};c();setTimeout(c)})})(J);(function(a){var z=a.addEvent,F=a.animate,D=a.animObject,B=a.attr,f=a.doc,h=a.Axis,t=a.createElement,r=a.defaultOptions,m=a.discardElement,d=a.charts,g=a.css,n=a.defined,y=a.each,w=a.extend,b=a.find,l=a.fireEvent,e=a.getStyle,c=a.grep,E=a.isNumber,u=a.isObject,q=a.isString,x=a.Legend,A=a.marginNames,H=a.merge,
k=a.Pointer,G=a.pick,I=a.pInt,L=a.removeEvent,K=a.seriesTypes,p=a.splat,C=a.svg,M=a.syncTimeout,N=a.win,Q=a.Renderer,O=a.Chart=function(){this.getArgs.apply(this,arguments)};a.chart=function(a,b,c){return new O(a,b,c)};O.prototype={callbacks:[],getArgs:function(){var a=[].slice.call(arguments);if(q(a[0])||a[0].nodeName)this.renderTo=a.shift();this.init(a[0],a[1])},init:function(b,c){var e,k=b.series;b.series=null;e=H(r,b);e.series=b.series=k;this.userOptions=b;b=e.chart;k=b.events;this.margin=[];
this.spacing=[];this.bounds={h:{},v:{}};this.callback=c;this.isResizing=0;this.options=e;this.axes=[];this.series=[];this.hasCartesianSeries=b.showAxes;var g;this.index=d.length;d.push(this);a.chartCount++;if(k)for(g in k)z(this,g,k[g]);this.xAxis=[];this.yAxis=[];this.pointCount=this.colorCounter=this.symbolCounter=0;this.firstRender()},initSeries:function(b){var c=this.options.chart;(c=K[b.type||c.type||c.defaultSeriesType])||a.error(17,!0);c=new c;c.init(this,b);return c},orderSeries:function(a){var b=
this.series;for(a=a||0;a<b.length;a++)b[a]&&(b[a].index=a,b[a].name=b[a].name||"Series "+(b[a].index+1))},isInsidePlot:function(a,b,c){var e=c?b:a;a=c?a:b;return 0<=e&&e<=this.plotWidth&&0<=a&&a<=this.plotHeight},redraw:function(b){var c=this.axes,e=this.series,d=this.pointer,k=this.legend,g=this.isDirtyLegend,f,p,n=this.hasCartesianSeries,q=this.isDirtyBox,h,m=this.renderer,v=m.isHidden(),G=[];this.setResponsive&&this.setResponsive(!1);a.setAnimation(b,this);v&&this.cloneRenderTo();this.layOutTitles();
for(b=e.length;b--;)if(h=e[b],h.options.stacking&&(f=!0,h.isDirty)){p=!0;break}if(p)for(b=e.length;b--;)h=e[b],h.options.stacking&&(h.isDirty=!0);y(e,function(a){a.isDirty&&"point"===a.options.legendType&&(a.updateTotals&&a.updateTotals(),g=!0);a.isDirtyData&&l(a,"updatedData")});g&&k.options.enabled&&(k.render(),this.isDirtyLegend=!1);f&&this.getStacks();n&&y(c,function(a){a.updateNames();a.setScale()});this.getMargins();n&&(y(c,function(a){a.isDirty&&(q=!0)}),y(c,function(a){var b=a.min+","+a.max;
a.extKey!==b&&(a.extKey=b,G.push(function(){l(a,"afterSetExtremes",w(a.eventArgs,a.getExtremes()));delete a.eventArgs}));(q||f)&&a.redraw()}));q&&this.drawChartBox();l(this,"predraw");y(e,function(a){(q||a.isDirty)&&a.visible&&a.redraw();a.isDirtyData=!1});d&&d.reset(!0);m.draw();l(this,"redraw");l(this,"render");v&&this.cloneRenderTo(!0);y(G,function(a){a.call()})},get:function(a){function c(b){return b.id===a||b.options&&b.options.id===a}var e,d=this.series,k;e=b(this.axes,c)||b(this.series,c);
for(k=0;!e&&k<d.length;k++)e=b(d[k].points||[],c);return e},getAxes:function(){var a=this,b=this.options,c=b.xAxis=p(b.xAxis||{}),b=b.yAxis=p(b.yAxis||{});y(c,function(a,b){a.index=b;a.isX=!0});y(b,function(a,b){a.index=b});c=c.concat(b);y(c,function(b){new h(a,b)})},getSelectedPoints:function(){var a=[];y(this.series,function(b){a=a.concat(c(b.points||[],function(a){return a.selected}))});return a},getSelectedSeries:function(){return c(this.series,function(a){return a.selected})},setTitle:function(a,
b,c){var e=this,d=e.options,k;k=d.title=H({style:{color:"#333333",fontSize:d.isStock?"16px":"18px"}},d.title,a);d=d.subtitle=H({style:{color:"#666666"}},d.subtitle,b);y([["title",a,k],["subtitle",b,d]],function(a,b){var c=a[0],d=e[c],k=a[1];a=a[2];d&&k&&(e[c]=d=d.destroy());a&&a.text&&!d&&(e[c]=e.renderer.text(a.text,0,0,a.useHTML).attr({align:a.align,"class":"highcharts-"+c,zIndex:a.zIndex||4}).add(),e[c].update=function(a){e.setTitle(!b&&a,b&&a)},e[c].css(a.style))});e.layOutTitles(c)},layOutTitles:function(a){var b=
0,c,e=this.renderer,d=this.spacingBox;y(["title","subtitle"],function(a){var c=this[a],k=this.options[a],g;c&&(g=k.style.fontSize,g=e.fontMetrics(g,c).b,c.css({width:(k.width||d.width+k.widthAdjust)+"px"}).align(w({y:b+g+("title"===a?-3:2)},k),!1,"spacingBox"),k.floating||k.verticalAlign||(b=Math.ceil(b+c.getBBox(k.useHTML).height)))},this);c=this.titleOffset!==b;this.titleOffset=b;!this.isDirtyBox&&c&&(this.isDirtyBox=c,this.hasRendered&&G(a,!0)&&this.isDirtyBox&&this.redraw())},getChartSize:function(){var b=
this.options.chart,c=b.width,b=b.height,d=this.renderToClone||this.renderTo;n(c)||(this.containerWidth=e(d,"width"));n(b)||(this.containerHeight=e(d,"height"));this.chartWidth=Math.max(0,c||this.containerWidth||600);this.chartHeight=Math.max(0,a.relativeLength(b,this.chartWidth)||this.containerHeight||400)},cloneRenderTo:function(a){var b=this.renderToClone,c=this.container;if(a){if(b){for(;b.childNodes.length;)this.renderTo.appendChild(b.firstChild);m(b);delete this.renderToClone}}else c&&c.parentNode===
this.renderTo&&this.renderTo.removeChild(c),this.renderToClone=b=this.renderTo.cloneNode(0),g(b,{position:"absolute",top:"-9999px",display:"block"}),b.style.setProperty&&b.style.setProperty("display","block","important"),f.body.appendChild(b),c&&b.appendChild(c)},setClassName:function(a){this.container.className="highcharts-container "+(a||"")},getContainer:function(){var b,c=this.options,e=c.chart,k,g;b=this.renderTo;var p=a.uniqueKey(),l;b||(this.renderTo=b=e.renderTo);q(b)&&(this.renderTo=b=f.getElementById(b));
b||a.error(13,!0);k=I(B(b,"data-highcharts-chart"));E(k)&&d[k]&&d[k].hasRendered&&d[k].destroy();B(b,"data-highcharts-chart",this.index);b.innerHTML="";e.skipClone||b.offsetWidth||this.cloneRenderTo();this.getChartSize();k=this.chartWidth;g=this.chartHeight;l=w({position:"relative",overflow:"hidden",width:k+"px",height:g+"px",textAlign:"left",lineHeight:"normal",zIndex:0,"-webkit-tap-highlight-color":"rgba(0,0,0,0)"},e.style);this.container=b=t("div",{id:p},l,this.renderToClone||b);this._cursor=b.style.cursor;
this.renderer=new (a[e.renderer]||Q)(b,k,g,null,e.forExport,c.exporting&&c.exporting.allowHTML);this.setClassName(e.className);this.renderer.setStyle(e.style);this.renderer.chartIndex=this.index},getMargins:function(a){var b=this.spacing,c=this.margin,e=this.titleOffset;this.resetMargins();e&&!n(c[0])&&(this.plotTop=Math.max(this.plotTop,e+this.options.title.margin+b[0]));this.legend.display&&this.legend.adjustMargins(c,b);this.extraMargin&&(this[this.extraMargin.type]=(this[this.extraMargin.type]||
0)+this.extraMargin.value);this.extraTopMargin&&(this.plotTop+=this.extraTopMargin);a||this.getAxisMargins()},getAxisMargins:function(){var a=this,b=a.axisOffset=[0,0,0,0],c=a.margin;a.hasCartesianSeries&&y(a.axes,function(a){a.visible&&a.getOffset()});y(A,function(e,d){n(c[d])||(a[e]+=b[d])});a.setChartSize()},reflow:function(a){var b=this,c=b.options.chart,d=b.renderTo,k=n(c.width),g=c.width||e(d,"width"),c=c.height||e(d,"height"),d=a?a.target:N;if(!k&&!b.isPrinting&&g&&c&&(d===N||d===f)){if(g!==
b.containerWidth||c!==b.containerHeight)clearTimeout(b.reflowTimeout),b.reflowTimeout=M(function(){b.container&&b.setSize(void 0,void 0,!1)},a?100:0);b.containerWidth=g;b.containerHeight=c}},initReflow:function(){var a=this,b;b=z(N,"resize",function(b){a.reflow(b)});z(a,"destroy",b)},setSize:function(b,c,e){var d=this,k=d.renderer;d.isResizing+=1;a.setAnimation(e,d);d.oldChartHeight=d.chartHeight;d.oldChartWidth=d.chartWidth;void 0!==b&&(d.options.chart.width=b);void 0!==c&&(d.options.chart.height=
c);d.getChartSize();b=k.globalAnimation;(b?F:g)(d.container,{width:d.chartWidth+"px",height:d.chartHeight+"px"},b);d.setChartSize(!0);k.setSize(d.chartWidth,d.chartHeight,e);y(d.axes,function(a){a.isDirty=!0;a.setScale()});d.isDirtyLegend=!0;d.isDirtyBox=!0;d.layOutTitles();d.getMargins();d.redraw(e);d.oldChartHeight=null;l(d,"resize");M(function(){d&&l(d,"endResize",null,function(){--d.isResizing})},D(b).duration)},setChartSize:function(a){var b=this.inverted,c=this.renderer,e=this.chartWidth,d=
this.chartHeight,k=this.options.chart,g=this.spacing,f=this.clipOffset,p,l,n,q;this.plotLeft=p=Math.round(this.plotLeft);this.plotTop=l=Math.round(this.plotTop);this.plotWidth=n=Math.max(0,Math.round(e-p-this.marginRight));this.plotHeight=q=Math.max(0,Math.round(d-l-this.marginBottom));this.plotSizeX=b?q:n;this.plotSizeY=b?n:q;this.plotBorderWidth=k.plotBorderWidth||0;this.spacingBox=c.spacingBox={x:g[3],y:g[0],width:e-g[3]-g[1],height:d-g[0]-g[2]};this.plotBox=c.plotBox={x:p,y:l,width:n,height:q};
e=2*Math.floor(this.plotBorderWidth/2);b=Math.ceil(Math.max(e,f[3])/2);c=Math.ceil(Math.max(e,f[0])/2);this.clipBox={x:b,y:c,width:Math.floor(this.plotSizeX-Math.max(e,f[1])/2-b),height:Math.max(0,Math.floor(this.plotSizeY-Math.max(e,f[2])/2-c))};a||y(this.axes,function(a){a.setAxisSize();a.setAxisTranslation()})},resetMargins:function(){var a=this,b=a.options.chart;y(["margin","spacing"],function(c){var e=b[c],d=u(e)?e:[e,e,e,e];y(["Top","Right","Bottom","Left"],function(e,k){a[c][k]=G(b[c+e],d[k])})});
y(A,function(b,c){a[b]=G(a.margin[c],a.spacing[c])});a.axisOffset=[0,0,0,0];a.clipOffset=[0,0,0,0]},drawChartBox:function(){var a=this.options.chart,b=this.renderer,c=this.chartWidth,e=this.chartHeight,d=this.chartBackground,k=this.plotBackground,g=this.plotBorder,f,p=this.plotBGImage,l=a.backgroundColor,n=a.plotBackgroundColor,q=a.plotBackgroundImage,h,m=this.plotLeft,G=this.plotTop,u=this.plotWidth,x=this.plotHeight,w=this.plotBox,I=this.clipRect,r=this.clipBox,A="animate";d||(this.chartBackground=
d=b.rect().addClass("highcharts-background").add(),A="attr");f=a.borderWidth||0;h=f+(a.shadow?8:0);l={fill:l||"none"};if(f||d["stroke-width"])l.stroke=a.borderColor,l["stroke-width"]=f;d.attr(l).shadow(a.shadow);d[A]({x:h/2,y:h/2,width:c-h-f%2,height:e-h-f%2,r:a.borderRadius});A="animate";k||(A="attr",this.plotBackground=k=b.rect().addClass("highcharts-plot-background").add());k[A](w);k.attr({fill:n||"none"}).shadow(a.plotShadow);q&&(p?p.animate(w):this.plotBGImage=b.image(q,m,G,u,x).add());I?I.animate({width:r.width,
height:r.height}):this.clipRect=b.clipRect(r);A="animate";g||(A="attr",this.plotBorder=g=b.rect().addClass("highcharts-plot-border").attr({zIndex:1}).add());g.attr({stroke:a.plotBorderColor,"stroke-width":a.plotBorderWidth||0,fill:"none"});g[A](g.crisp({x:m,y:G,width:u,height:x},-g.strokeWidth()));this.isDirtyBox=!1},propFromSeries:function(){var a=this,b=a.options.chart,c,e=a.options.series,d,k;y(["inverted","angular","polar"],function(g){c=K[b.type||b.defaultSeriesType];k=b[g]||c&&c.prototype[g];
for(d=e&&e.length;!k&&d--;)(c=K[e[d].type])&&c.prototype[g]&&(k=!0);a[g]=k})},linkSeries:function(){var a=this,b=a.series;y(b,function(a){a.linkedSeries.length=0});y(b,function(b){var c=b.options.linkedTo;q(c)&&(c=":previous"===c?a.series[b.index-1]:a.get(c))&&c.linkedParent!==b&&(c.linkedSeries.push(b),b.linkedParent=c,b.visible=G(b.options.visible,c.options.visible,b.visible))})},renderSeries:function(){y(this.series,function(a){a.translate();a.render()})},renderLabels:function(){var a=this,b=a.options.labels;
b.items&&y(b.items,function(c){var e=w(b.style,c.style),d=I(e.left)+a.plotLeft,k=I(e.top)+a.plotTop+12;delete e.left;delete e.top;a.renderer.text(c.html,d,k).attr({zIndex:2}).css(e).add()})},render:function(){var a=this.axes,b=this.renderer,c=this.options,e,d,k;this.setTitle();this.legend=new x(this,c.legend);this.getStacks&&this.getStacks();this.getMargins(!0);this.setChartSize();c=this.plotWidth;e=this.plotHeight-=21;y(a,function(a){a.setScale()});this.getAxisMargins();d=1.1<c/this.plotWidth;k=
1.05<e/this.plotHeight;if(d||k)y(a,function(a){(a.horiz&&d||!a.horiz&&k)&&a.setTickInterval(!0)}),this.getMargins();this.drawChartBox();this.hasCartesianSeries&&y(a,function(a){a.visible&&a.render()});this.seriesGroup||(this.seriesGroup=b.g("series-group").attr({zIndex:3}).add());this.renderSeries();this.renderLabels();this.addCredits();this.setResponsive&&this.setResponsive();this.hasRendered=!0},addCredits:function(a){var b=this;a=H(!0,this.options.credits,a);a.enabled&&!this.credits&&(this.credits=
this.renderer.text(a.text+(this.mapCredits||""),0,0).addClass("highcharts-credits").on("click",function(){a.href&&(N.location.href=a.href)}).attr({align:a.position.align,zIndex:8}).css(a.style).add().align(a.position),this.credits.update=function(a){b.credits=b.credits.destroy();b.addCredits(a)})},destroy:function(){var b=this,c=b.axes,e=b.series,k=b.container,g,f=k&&k.parentNode;l(b,"destroy");d[b.index]=void 0;a.chartCount--;b.renderTo.removeAttribute("data-highcharts-chart");L(b);for(g=c.length;g--;)c[g]=
c[g].destroy();this.scroller&&this.scroller.destroy&&this.scroller.destroy();for(g=e.length;g--;)e[g]=e[g].destroy();y("title subtitle chartBackground plotBackground plotBGImage plotBorder seriesGroup clipRect credits pointer rangeSelector legend resetZoomButton tooltip renderer".split(" "),function(a){var c=b[a];c&&c.destroy&&(b[a]=c.destroy())});k&&(k.innerHTML="",L(k),f&&m(k));for(g in b)delete b[g]},isReadyToRender:function(){var a=this;return C||N!=N.top||"complete"===f.readyState?!0:(f.attachEvent("onreadystatechange",
function(){f.detachEvent("onreadystatechange",a.firstRender);"complete"===f.readyState&&a.firstRender()}),!1)},firstRender:function(){var a=this,b=a.options;if(a.isReadyToRender()){a.getContainer();l(a,"init");a.resetMargins();a.setChartSize();a.propFromSeries();a.getAxes();y(b.series||[],function(b){a.initSeries(b)});a.linkSeries();l(a,"beforeRender");k&&(a.pointer=new k(a,b));a.render();if(!a.renderer.imgCount&&a.onload)a.onload();a.cloneRenderTo(!0)}},onload:function(){y([this.callback].concat(this.callbacks),
function(a){a&&void 0!==this.index&&a.apply(this,[this])},this);l(this,"load");l(this,"render");n(this.index)&&!1!==this.options.chart.reflow&&this.initReflow();this.onload=null}}})(J);(function(a){var z,F=a.each,D=a.extend,B=a.erase,f=a.fireEvent,h=a.format,t=a.isArray,r=a.isNumber,m=a.pick,d=a.removeEvent;z=a.Point=function(){};z.prototype={init:function(a,d,f){this.series=a;this.color=a.color;this.applyOptions(d,f);a.options.colorByPoint?(d=a.options.colors||a.chart.options.colors,this.color=this.color||
d[a.colorCounter],d=d.length,f=a.colorCounter,a.colorCounter++,a.colorCounter===d&&(a.colorCounter=0)):f=a.colorIndex;this.colorIndex=m(this.colorIndex,f);a.chart.pointCount++;return this},applyOptions:function(a,d){var g=this.series,f=g.options.pointValKey||g.pointValKey;a=z.prototype.optionsToObject.call(this,a);D(this,a);this.options=this.options?D(this.options,a):a;a.group&&delete this.group;f&&(this.y=this[f]);this.isNull=m(this.isValid&&!this.isValid(),null===this.x||!r(this.y,!0));this.selected&&
(this.state="select");"name"in this&&void 0===d&&g.xAxis&&g.xAxis.hasNames&&(this.x=g.xAxis.nameToX(this));void 0===this.x&&g&&(this.x=void 0===d?g.autoIncrement(this):d);return this},optionsToObject:function(a){var d={},g=this.series,f=g.options.keys,b=f||g.pointArrayMap||["y"],l=b.length,e=0,c=0;if(r(a)||null===a)d[b[0]]=a;else if(t(a))for(!f&&a.length>l&&(g=typeof a[0],"string"===g?d.name=a[0]:"number"===g&&(d.x=a[0]),e++);c<l;)f&&void 0===a[e]||(d[b[c]]=a[e]),e++,c++;else"object"===typeof a&&
(d=a,a.dataLabels&&(g._hasPointLabels=!0),a.marker&&(g._hasPointMarkers=!0));return d},getClassName:function(){return"highcharts-point"+(this.selected?" highcharts-point-select":"")+(this.negative?" highcharts-negative":"")+(this.isNull?" highcharts-null-point":"")+(void 0!==this.colorIndex?" highcharts-color-"+this.colorIndex:"")+(this.options.className?" "+this.options.className:"")+(this.zone&&this.zone.className?" "+this.zone.className.replace("highcharts-negative",""):"")},getZone:function(){var a=
this.series,d=a.zones,a=a.zoneAxis||"y",f=0,h;for(h=d[f];this[a]>=h.value;)h=d[++f];h&&h.color&&!this.options.color&&(this.color=h.color);return h},destroy:function(){var a=this.series.chart,f=a.hoverPoints,h;a.pointCount--;f&&(this.setState(),B(f,this),f.length||(a.hoverPoints=null));if(this===a.hoverPoint)this.onMouseOut();if(this.graphic||this.dataLabel)d(this),this.destroyElements();this.legendItem&&a.legend.destroyItem(this);for(h in this)this[h]=null},destroyElements:function(){for(var a=["graphic",
"dataLabel","dataLabelUpper","connector","shadowGroup"],d,f=6;f--;)d=a[f],this[d]&&(this[d]=this[d].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,color:this.color,colorIndex:this.colorIndex,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},tooltipFormatter:function(a){var d=this.series,g=d.tooltipOptions,f=m(g.valueDecimals,""),b=g.valuePrefix||"",l=g.valueSuffix||"";F(d.pointArrayMap||["y"],function(e){e=
"{point."+e;if(b||l)a=a.replace(e+"}",b+e+"}"+l);a=a.replace(e+"}",e+":,."+f+"f}")});return h(a,{point:this,series:this.series})},firePointEvent:function(a,d,h){var g=this,b=this.series.options;(b.point.events[a]||g.options&&g.options.events&&g.options.events[a])&&this.importEvents();"click"===a&&b.allowPointSelect&&(h=function(a){g.select&&g.select(null,a.ctrlKey||a.metaKey||a.shiftKey)});f(this,a,d,h)},visible:!0}})(J);(function(a){var z=a.addEvent,F=a.animObject,D=a.arrayMax,B=a.arrayMin,f=a.correctFloat,
h=a.Date,t=a.defaultOptions,r=a.defaultPlotOptions,m=a.defined,d=a.each,g=a.erase,n=a.extend,y=a.fireEvent,w=a.grep,b=a.isArray,l=a.isNumber,e=a.isString,c=a.merge,E=a.pick,u=a.removeEvent,q=a.splat,x=a.SVGElement,A=a.syncTimeout,H=a.win;a.Series=a.seriesType("line",null,{lineWidth:2,allowPointSelect:!1,showCheckbox:!1,animation:{duration:1E3},events:{},marker:{lineWidth:0,lineColor:"#ffffff",radius:4,states:{hover:{animation:{duration:50},enabled:!0,radiusPlus:2,lineWidthPlus:1},select:{fillColor:"#cccccc",
lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:{align:"center",formatter:function(){return null===this.y?"":a.numberFormat(this.y,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"contrast",textOutline:"1px contrast"},verticalAlign:"bottom",x:0,y:0,padding:5},cropThreshold:300,pointRange:0,softThreshold:!0,states:{hover:{animation:{duration:50},lineWidthPlus:1,marker:{},halo:{size:10,opacity:.25}},select:{marker:{}}},stickyTracking:!0,turboThreshold:1E3,findNearestPointBy:"x"},
{isCartesian:!0,pointClass:a.Point,sorted:!0,requireSorting:!0,directTouch:!1,axisTypes:["xAxis","yAxis"],colorCounter:0,parallelArrays:["x","y"],coll:"series",init:function(a,b){var c=this,e,k,g=a.series,f;c.chart=a;c.options=b=c.setOptions(b);c.linkedSeries=[];c.bindAxes();n(c,{name:b.name,state:"",visible:!1!==b.visible,selected:!0===b.selected});k=b.events;for(e in k)z(c,e,k[e]);if(k&&k.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)a.runTrackerClick=!0;c.getColor();
c.getSymbol();d(c.parallelArrays,function(a){c[a+"Data"]=[]});c.setData(b.data,!1);c.isCartesian&&(a.hasCartesianSeries=!0);g.length&&(f=g[g.length-1]);c._i=E(f&&f._i,-1)+1;a.orderSeries(this.insert(g))},insert:function(a){var b=this.options.index,c;if(l(b)){for(c=a.length;c--;)if(b>=E(a[c].options.index,a[c]._i)){a.splice(c+1,0,this);break}-1===c&&a.unshift(this);c+=1}else a.push(this);return E(c,a.length-1)},bindAxes:function(){var b=this,c=b.options,e=b.chart,g;d(b.axisTypes||[],function(k){d(e[k],
function(a){g=a.options;if(c[k]===g.index||void 0!==c[k]&&c[k]===g.id||void 0===c[k]&&0===g.index)b.insert(a.series),b[k]=a,a.isDirty=!0});b[k]||b.optionalAxis===k||a.error(18,!0)})},updateParallelArrays:function(a,b){var c=a.series,e=arguments,k=l(b)?function(e){var d="y"===e&&c.toYData?c.toYData(a):a[e];c[e+"Data"][b]=d}:function(a){Array.prototype[b].apply(c[a+"Data"],Array.prototype.slice.call(e,2))};d(c.parallelArrays,k)},autoIncrement:function(){var a=this.options,b=this.xIncrement,c,e=a.pointIntervalUnit,
b=E(b,a.pointStart,0);this.pointInterval=c=E(this.pointInterval,a.pointInterval,1);e&&(a=new h(b),"day"===e?a=+a[h.hcSetDate](a[h.hcGetDate]()+c):"month"===e?a=+a[h.hcSetMonth](a[h.hcGetMonth]()+c):"year"===e&&(a=+a[h.hcSetFullYear](a[h.hcGetFullYear]()+c)),c=a-b);this.xIncrement=b+c;return b},setOptions:function(a){var b=this.chart,e=b.options.plotOptions,b=b.userOptions||{},d=b.plotOptions||{},k=e[this.type];this.userOptions=a;e=c(k,e.series,a);this.tooltipOptions=c(t.tooltip,t.plotOptions[this.type].tooltip,
b.tooltip,d.series&&d.series.tooltip,d[this.type]&&d[this.type].tooltip,a.tooltip);this.stickyTracking=E(a.stickyTracking,d[this.type]&&d[this.type].stickyTracking,d.series&&d.series.stickyTracking,this.tooltipOptions.shared&&!this.noSharedTooltip?!0:e.stickyTracking);null===k.marker&&delete e.marker;this.zoneAxis=e.zoneAxis;a=this.zones=(e.zones||[]).slice();!e.negativeColor&&!e.negativeFillColor||e.zones||a.push({value:e[this.zoneAxis+"Threshold"]||e.threshold||0,className:"highcharts-negative",
color:e.negativeColor,fillColor:e.negativeFillColor});a.length&&m(a[a.length-1].value)&&a.push({color:this.color,fillColor:this.fillColor});return e},getCyclic:function(a,b,c){var e,d=this.chart,k=this.userOptions,g=a+"Index",f=a+"Counter",l=c?c.length:E(d.options.chart[a+"Count"],d[a+"Count"]);b||(e=E(k[g],k["_"+g]),m(e)||(d.series.length||(d[f]=0),k["_"+g]=e=d[f]%l,d[f]+=1),c&&(b=c[e]));void 0!==e&&(this[g]=e);this[a]=b},getColor:function(){this.options.colorByPoint?this.options.color=null:this.getCyclic("color",
this.options.color||r[this.type].color,this.chart.options.colors)},getSymbol:function(){this.getCyclic("symbol",this.options.marker.symbol,this.chart.options.symbols)},drawLegendSymbol:a.LegendSymbolMixin.drawLineMarker,setData:function(c,g,f,q){var k=this,p=k.points,h=p&&p.length||0,n,m=k.options,u=k.chart,G=null,x=k.xAxis,r=m.turboThreshold,w=this.xData,A=this.yData,t=(n=k.pointArrayMap)&&n.length;c=c||[];n=c.length;g=E(g,!0);if(!1!==q&&n&&h===n&&!k.cropped&&!k.hasGroupedData&&k.visible)d(c,function(a,
b){p[b].update&&a!==m.data[b]&&p[b].update(a,!1,null,!1)});else{k.xIncrement=null;k.colorCounter=0;d(this.parallelArrays,function(a){k[a+"Data"].length=0});if(r&&n>r){for(f=0;null===G&&f<n;)G=c[f],f++;if(l(G))for(f=0;f<n;f++)w[f]=this.autoIncrement(),A[f]=c[f];else if(b(G))if(t)for(f=0;f<n;f++)G=c[f],w[f]=G[0],A[f]=G.slice(1,t+1);else for(f=0;f<n;f++)G=c[f],w[f]=G[0],A[f]=G[1];else a.error(12)}else for(f=0;f<n;f++)void 0!==c[f]&&(G={series:k},k.pointClass.prototype.applyOptions.apply(G,[c[f]]),k.updateParallelArrays(G,
f));e(A[0])&&a.error(14,!0);k.data=[];k.options.data=k.userOptions.data=c;for(f=h;f--;)p[f]&&p[f].destroy&&p[f].destroy();x&&(x.minRange=x.userMinRange);k.isDirty=u.isDirtyBox=!0;k.isDirtyData=!!p;f=!1}"point"===m.legendType&&(this.processData(),this.generatePoints());g&&u.redraw(f)},processData:function(b){var c=this.xData,e=this.yData,d=c.length,k;k=0;var g,f,l=this.xAxis,q,h=this.options;q=h.cropThreshold;var n=this.getExtremesFromAll||h.getExtremesFromAll,m=this.isCartesian,h=l&&l.val2lin,u=l&&
l.isLog,x,r;if(m&&!this.isDirty&&!l.isDirty&&!this.yAxis.isDirty&&!b)return!1;l&&(b=l.getExtremes(),x=b.min,r=b.max);if(m&&this.sorted&&!n&&(!q||d>q||this.forceCrop))if(c[d-1]<x||c[0]>r)c=[],e=[];else if(c[0]<x||c[d-1]>r)k=this.cropData(this.xData,this.yData,x,r),c=k.xData,e=k.yData,k=k.start,g=!0;for(q=c.length||1;--q;)d=u?h(c[q])-h(c[q-1]):c[q]-c[q-1],0<d&&(void 0===f||d<f)?f=d:0>d&&this.requireSorting&&a.error(15);this.cropped=g;this.cropStart=k;this.processedXData=c;this.processedYData=e;this.closestPointRange=
f},cropData:function(a,b,c,e){var d=a.length,k=0,g=d,f=E(this.cropShoulder,1),l;for(l=0;l<d;l++)if(a[l]>=c){k=Math.max(0,l-f);break}for(c=l;c<d;c++)if(a[c]>e){g=c+f;break}return{xData:a.slice(k,g),yData:b.slice(k,g),start:k,end:g}},generatePoints:function(){var a=this.options.data,b=this.data,c,e=this.processedXData,d=this.processedYData,g=this.pointClass,f=e.length,l=this.cropStart||0,h,n=this.hasGroupedData,m,u=[],x;b||n||(b=[],b.length=a.length,b=this.data=b);for(x=0;x<f;x++)h=l+x,n?(m=(new g).init(this,
[e[x]].concat(q(d[x]))),m.dataGroup=this.groupMap[x]):(m=b[h])||void 0===a[h]||(b[h]=m=(new g).init(this,a[h],e[x])),m&&(m.index=h,u[x]=m);if(b&&(f!==(c=b.length)||n))for(x=0;x<c;x++)x!==l||n||(x+=f),b[x]&&(b[x].destroyElements(),b[x].plotX=void 0);this.data=b;this.points=u},getExtremes:function(a){var c=this.yAxis,e=this.processedXData,d,k=[],g=0;d=this.xAxis.getExtremes();var f=d.min,q=d.max,h,n,m,u;a=a||this.stackedYData||this.processedYData||[];d=a.length;for(u=0;u<d;u++)if(n=e[u],m=a[u],h=(l(m,
!0)||b(m))&&(!c.positiveValuesOnly||m.length||0<m),n=this.getExtremesFromAll||this.options.getExtremesFromAll||this.cropped||(e[u]||n)>=f&&(e[u]||n)<=q,h&&n)if(h=m.length)for(;h--;)null!==m[h]&&(k[g++]=m[h]);else k[g++]=m;this.dataMin=B(k);this.dataMax=D(k)},translate:function(){this.processedXData||this.processData();this.generatePoints();var a=this.options,b=a.stacking,c=this.xAxis,e=c.categories,d=this.yAxis,g=this.points,h=g.length,q=!!this.modifyValue,n=a.pointPlacement,u="between"===n||l(n),
x=a.threshold,r=a.startFromThreshold?x:0,w,A,t,y,H=Number.MAX_VALUE;"between"===n&&(n=.5);l(n)&&(n*=E(a.pointRange||c.pointRange));for(a=0;a<h;a++){var B=g[a],z=B.x,D=B.y;A=B.low;var F=b&&d.stacks[(this.negStacks&&D<(r?0:x)?"-":"")+this.stackKey],J;d.positiveValuesOnly&&null!==D&&0>=D&&(B.isNull=!0);B.plotX=w=f(Math.min(Math.max(-1E5,c.translate(z,0,0,0,1,n,"flags"===this.type)),1E5));b&&this.visible&&!B.isNull&&F&&F[z]&&(y=this.getStackIndicator(y,z,this.index),J=F[z],D=J.points[y.key],A=D[0],D=
D[1],A===r&&y.key===F[z].base&&(A=E(x,d.min)),d.positiveValuesOnly&&0>=A&&(A=null),B.total=B.stackTotal=J.total,B.percentage=J.total&&B.y/J.total*100,B.stackY=D,J.setOffset(this.pointXOffset||0,this.barW||0));B.yBottom=m(A)?d.translate(A,0,1,0,1):null;q&&(D=this.modifyValue(D,B));B.plotY=A="number"===typeof D&&Infinity!==D?Math.min(Math.max(-1E5,d.translate(D,0,1,0,1)),1E5):void 0;B.isInside=void 0!==A&&0<=A&&A<=d.len&&0<=w&&w<=c.len;B.clientX=u?f(c.translate(z,0,0,0,1,n)):w;B.negative=B.y<(x||0);
B.category=e&&void 0!==e[B.x]?e[B.x]:B.x;B.isNull||(void 0!==t&&(H=Math.min(H,Math.abs(w-t))),t=w);B.zone=this.zones.length&&B.getZone()}this.closestPointRangePx=H},getValidPoints:function(a,b){var c=this.chart;return w(a||this.points||[],function(a){return b&&!c.isInsidePlot(a.plotX,a.plotY,c.inverted)?!1:!a.isNull})},setClip:function(a){var b=this.chart,c=this.options,e=b.renderer,d=b.inverted,k=this.clipBox,g=k||b.clipBox,f=this.sharedClipKey||["_sharedClip",a&&a.duration,a&&a.easing,g.height,
c.xAxis,c.yAxis].join(),l=b[f],h=b[f+"m"];l||(a&&(g.width=0,b[f+"m"]=h=e.clipRect(-99,d?-b.plotLeft:-b.plotTop,99,d?b.chartWidth:b.chartHeight)),b[f]=l=e.clipRect(g),l.count={length:0});a&&!l.count[this.index]&&(l.count[this.index]=!0,l.count.length+=1);!1!==c.clip&&(this.group.clip(a||k?l:b.clipRect),this.markerGroup.clip(h),this.sharedClipKey=f);a||(l.count[this.index]&&(delete l.count[this.index],--l.count.length),0===l.count.length&&f&&b[f]&&(k||(b[f]=b[f].destroy()),b[f+"m"]&&(b[f+"m"]=b[f+"m"].destroy())))},
animate:function(a){var b=this.chart,c=F(this.options.animation),e;a?this.setClip(c):(e=this.sharedClipKey,(a=b[e])&&a.animate({width:b.plotSizeX},c),b[e+"m"]&&b[e+"m"].animate({width:b.plotSizeX+99},c),this.animate=null)},afterAnimate:function(){this.setClip();y(this,"afterAnimate")},drawPoints:function(){var a=this.points,b=this.chart,c,e,d,g,f=this.options.marker,h,q,n,m,u=this.markerGroup,x=E(f.enabled,this.xAxis.isRadial?!0:null,this.closestPointRangePx>=2*f.radius);if(!1!==f.enabled||this._hasPointMarkers)for(e=
0;e<a.length;e++)d=a[e],c=d.plotY,g=d.graphic,h=d.marker||{},q=!!d.marker,n=x&&void 0===h.enabled||h.enabled,m=d.isInside,n&&l(c)&&null!==d.y?(c=E(h.symbol,this.symbol),d.hasImage=0===c.indexOf("url"),n=this.markerAttribs(d,d.selected&&"select"),g?g[m?"show":"hide"](!0).animate(n):m&&(0<n.width||d.hasImage)&&(d.graphic=g=b.renderer.symbol(c,n.x,n.y,n.width,n.height,q?h:f).add(u)),g&&g.attr(this.pointAttribs(d,d.selected&&"select")),g&&g.addClass(d.getClassName(),!0)):g&&(d.graphic=g.destroy())},markerAttribs:function(a,
b){var c=this.options.marker,e=a.marker||{},d=E(e.radius,c.radius);b&&(c=c.states[b],b=e.states&&e.states[b],d=E(b&&b.radius,c&&c.radius,d+(c&&c.radiusPlus||0)));a.hasImage&&(d=0);a={x:Math.floor(a.plotX)-d,y:a.plotY-d};d&&(a.width=a.height=2*d);return a},pointAttribs:function(a,b){var c=this.options.marker,e=a&&a.options,d=e&&e.marker||{},g=this.color,k=e&&e.color,f=a&&a.color,e=E(d.lineWidth,c.lineWidth);a=a&&a.zone&&a.zone.color;g=k||a||f||g;a=d.fillColor||c.fillColor||g;g=d.lineColor||c.lineColor||
g;b&&(c=c.states[b],b=d.states&&d.states[b]||{},e=E(b.lineWidth,c.lineWidth,e+E(b.lineWidthPlus,c.lineWidthPlus,0)),a=b.fillColor||c.fillColor||a,g=b.lineColor||c.lineColor||g);return{stroke:g,"stroke-width":e,fill:a}},destroy:function(){var a=this,b=a.chart,c=/AppleWebKit\/533/.test(H.navigator.userAgent),e,f=a.data||[],l,h,q;y(a,"destroy");u(a);d(a.axisTypes||[],function(b){(q=a[b])&&q.series&&(g(q.series,a),q.isDirty=q.forceRedraw=!0)});a.legendItem&&a.chart.legend.destroyItem(a);for(e=f.length;e--;)(l=
f[e])&&l.destroy&&l.destroy();a.points=null;clearTimeout(a.animationTimeout);for(h in a)a[h]instanceof x&&!a[h].survive&&(e=c&&"group"===h?"hide":"destroy",a[h][e]());b.hoverSeries===a&&(b.hoverSeries=null);g(b.series,a);b.orderSeries();for(h in a)delete a[h]},getGraphPath:function(a,b,c){var e=this,g=e.options,f=g.step,k,l=[],h=[],q;a=a||e.points;(k=a.reversed)&&a.reverse();(f={right:1,center:2}[f]||f&&3)&&k&&(f=4-f);!g.connectNulls||b||c||(a=this.getValidPoints(a));d(a,function(d,k){var n=d.plotX,
p=d.plotY,u=a[k-1];(d.leftCliff||u&&u.rightCliff)&&!c&&(q=!0);d.isNull&&!m(b)&&0<k?q=!g.connectNulls:d.isNull&&!b?q=!0:(0===k||q?k=["M",d.plotX,d.plotY]:e.getPointSpline?k=e.getPointSpline(a,d,k):f?(k=1===f?["L",u.plotX,p]:2===f?["L",(u.plotX+n)/2,u.plotY,"L",(u.plotX+n)/2,p]:["L",n,u.plotY],k.push("L",n,p)):k=["L",n,p],h.push(d.x),f&&h.push(d.x),l.push.apply(l,k),q=!1)});l.xMap=h;return e.graphPath=l},drawGraph:function(){var a=this,b=this.options,c=(this.gappedPath||this.getGraphPath).call(this),
e=[["graph","highcharts-graph",b.lineColor||this.color,b.dashStyle]];d(this.zones,function(c,d){e.push(["zone-graph-"+d,"highcharts-graph highcharts-zone-graph-"+d+" "+(c.className||""),c.color||a.color,c.dashStyle||b.dashStyle])});d(e,function(e,d){var g=e[0],f=a[g];f?(f.endX=c.xMap,f.animate({d:c})):c.length&&(a[g]=a.chart.renderer.path(c).addClass(e[1]).attr({zIndex:1}).add(a.group),f={stroke:e[2],"stroke-width":b.lineWidth,fill:a.fillGraph&&a.color||"none"},e[3]?f.dashstyle=e[3]:"square"!==b.linecap&&
(f["stroke-linecap"]=f["stroke-linejoin"]="round"),f=a[g].attr(f).shadow(2>d&&b.shadow));f&&(f.startX=c.xMap,f.isArea=c.isArea)})},applyZones:function(){var a=this,b=this.chart,c=b.renderer,e=this.zones,g,f,l=this.clips||[],h,q=this.graph,n=this.area,m=Math.max(b.chartWidth,b.chartHeight),u=this[(this.zoneAxis||"y")+"Axis"],x,r,w=b.inverted,A,t,y,H,B=!1;e.length&&(q||n)&&u&&void 0!==u.min&&(r=u.reversed,A=u.horiz,q&&q.hide(),n&&n.hide(),x=u.getExtremes(),d(e,function(e,d){g=r?A?b.plotWidth:0:A?0:
u.toPixels(x.min);g=Math.min(Math.max(E(f,g),0),m);f=Math.min(Math.max(Math.round(u.toPixels(E(e.value,x.max),!0)),0),m);B&&(g=f=u.toPixels(x.max));t=Math.abs(g-f);y=Math.min(g,f);H=Math.max(g,f);u.isXAxis?(h={x:w?H:y,y:0,width:t,height:m},A||(h.x=b.plotHeight-h.x)):(h={x:0,y:w?H:y,width:m,height:t},A&&(h.y=b.plotWidth-h.y));w&&c.isVML&&(h=u.isXAxis?{x:0,y:r?y:H,height:h.width,width:b.chartWidth}:{x:h.y-b.plotLeft-b.spacingBox.x,y:0,width:h.height,height:b.chartHeight});l[d]?l[d].animate(h):(l[d]=
c.clipRect(h),q&&a["zone-graph-"+d].clip(l[d]),n&&a["zone-area-"+d].clip(l[d]));B=e.value>x.max}),this.clips=l)},invertGroups:function(a){function b(){d(["group","markerGroup"],function(b){c[b]&&(e.renderer.isVML&&c[b].attr({width:c.yAxis.len,height:c.xAxis.len}),c[b].width=c.yAxis.len,c[b].height=c.xAxis.len,c[b].invert(a))})}var c=this,e=c.chart,g;c.xAxis&&(g=z(e,"resize",b),z(c,"destroy",g),b(a),c.invertGroups=b)},plotGroup:function(a,b,c,e,d){var g=this[a],f=!g;f&&(this[a]=g=this.chart.renderer.g(b).attr({zIndex:e||
.1}).add(d),g.addClass("highcharts-series-"+this.index+" highcharts-"+this.type+"-series highcharts-color-"+this.colorIndex+" "+(this.options.className||"")));g.attr({visibility:c})[f?"attr":"animate"](this.getPlotBox());return g},getPlotBox:function(){var a=this.chart,b=this.xAxis,c=this.yAxis;a.inverted&&(b=c,c=this.xAxis);return{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var a=this,b=a.chart,c,e=a.options,d=!!a.animate&&b.renderer.isSVG&&F(e.animation).duration,
g=a.visible?"inherit":"hidden",f=e.zIndex,l=a.hasRendered,h=b.seriesGroup,q=b.inverted;c=a.plotGroup("group","series",g,f,h);a.markerGroup=a.plotGroup("markerGroup","markers",g,f,h);d&&a.animate(!0);c.inverted=a.isCartesian?q:!1;a.drawGraph&&(a.drawGraph(),a.applyZones());a.drawDataLabels&&a.drawDataLabels();a.visible&&a.drawPoints();a.drawTracker&&!1!==a.options.enableMouseTracking&&a.drawTracker();a.invertGroups(q);!1===e.clip||a.sharedClipKey||l||c.clip(b.clipRect);d&&a.animate();l||(a.animationTimeout=
A(function(){a.afterAnimate()},d));a.isDirty=!1;a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirty||this.isDirtyData,c=this.group,e=this.xAxis,d=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:E(e&&e.left,a.plotLeft),translateY:E(d&&d.top,a.plotTop)}));this.translate();this.render();b&&delete this.kdTree},kdAxisArray:["clientX","plotY"],searchPoint:function(a,b){var c=this.xAxis,e=this.yAxis,d=this.chart.inverted;return this.searchKDTree({clientX:d?
c.len-a.chartY+c.pos:a.chartX-c.pos,plotY:d?e.len-a.chartX+e.pos:a.chartY-e.pos},b)},buildKDTree:function(){function a(c,e,d){var g,f;if(f=c&&c.length)return g=b.kdAxisArray[e%d],c.sort(function(a,b){return a[g]-b[g]}),f=Math.floor(f/2),{point:c[f],left:a(c.slice(0,f),e+1,d),right:a(c.slice(f+1),e+1,d)}}this.buildingKdTree=!0;var b=this,c=-1<b.options.findNearestPointBy.indexOf("y")?2:1;delete b.kdTree;A(function(){b.kdTree=a(b.getValidPoints(null,!b.directTouch),c,c);b.buildingKdTree=!1},b.options.kdNow?
0:1)},searchKDTree:function(a,b){function c(a,b,k,l){var h=b.point,q=e.kdAxisArray[k%l],n,p,u=h;p=m(a[d])&&m(h[d])?Math.pow(a[d]-h[d],2):null;n=m(a[g])&&m(h[g])?Math.pow(a[g]-h[g],2):null;n=(p||0)+(n||0);h.dist=m(n)?Math.sqrt(n):Number.MAX_VALUE;h.distX=m(p)?Math.sqrt(p):Number.MAX_VALUE;q=a[q]-h[q];n=0>q?"left":"right";p=0>q?"right":"left";b[n]&&(n=c(a,b[n],k+1,l),u=n[f]<u[f]?n:h);b[p]&&Math.sqrt(q*q)<u[f]&&(a=c(a,b[p],k+1,l),u=a[f]<u[f]?a:u);return u}var e=this,d=this.kdAxisArray[0],g=this.kdAxisArray[1],
f=b?"distX":"dist";b=-1<e.options.findNearestPointBy.indexOf("y")?2:1;this.kdTree||this.buildingKdTree||this.buildKDTree();if(this.kdTree)return c(a,this.kdTree,b,b)}})})(J);(function(a){var z=a.addEvent,F=a.animate,D=a.Axis,B=a.createElement,f=a.css,h=a.defined,t=a.each,r=a.erase,m=a.extend,d=a.fireEvent,g=a.inArray,n=a.isNumber,y=a.isObject,w=a.merge,b=a.pick,l=a.Point,e=a.Series,c=a.seriesTypes,E=a.setAnimation,u=a.splat;m(a.Chart.prototype,{addSeries:function(a,c,e){var g,f=this;a&&(c=b(c,!0),
d(f,"addSeries",{options:a},function(){g=f.initSeries(a);f.isDirtyLegend=!0;f.linkSeries();c&&f.redraw(e)}));return g},addAxis:function(a,c,e,d){var g=c?"xAxis":"yAxis",f=this.options;a=w(a,{index:this[g].length,isX:c});new D(this,a);f[g]=u(f[g]||{});f[g].push(a);b(e,!0)&&this.redraw(d)},showLoading:function(a){var b=this,c=b.options,e=b.loadingDiv,d=c.loading,g=function(){e&&f(e,{left:b.plotLeft+"px",top:b.plotTop+"px",width:b.plotWidth+"px",height:b.plotHeight+"px"})};e||(b.loadingDiv=e=B("div",
{className:"highcharts-loading highcharts-loading-hidden"},null,b.container),b.loadingSpan=B("span",{className:"highcharts-loading-inner"},null,e),z(b,"redraw",g));e.className="highcharts-loading";b.loadingSpan.innerHTML=a||c.lang.loading;f(e,m(d.style,{zIndex:10}));f(b.loadingSpan,d.labelStyle);b.loadingShown||(f(e,{opacity:0,display:""}),F(e,{opacity:d.style.opacity||.5},{duration:d.showDuration||0}));b.loadingShown=!0;g()},hideLoading:function(){var a=this.options,b=this.loadingDiv;b&&(b.className=
"highcharts-loading highcharts-loading-hidden",F(b,{opacity:0},{duration:a.loading.hideDuration||100,complete:function(){f(b,{display:"none"})}}));this.loadingShown=!1},propsRequireDirtyBox:"backgroundColor borderColor borderWidth margin marginTop marginRight marginBottom marginLeft spacing spacingTop spacingRight spacingBottom spacingLeft borderRadius plotBackgroundColor plotBackgroundImage plotBorderColor plotBorderWidth plotShadow shadow".split(" "),propsRequireUpdateSeries:"chart.inverted chart.polar chart.ignoreHiddenSeries chart.type colors plotOptions".split(" "),
update:function(a,c){var e,d={credits:"addCredits",title:"setTitle",subtitle:"setSubtitle"},f=a.chart,l,q;if(f){w(!0,this.options.chart,f);"className"in f&&this.setClassName(f.className);if("inverted"in f||"polar"in f)this.propFromSeries(),l=!0;"alignTicks"in f&&(l=!0);for(e in f)f.hasOwnProperty(e)&&(-1!==g("chart."+e,this.propsRequireUpdateSeries)&&(q=!0),-1!==g(e,this.propsRequireDirtyBox)&&(this.isDirtyBox=!0));"style"in f&&this.renderer.setStyle(f.style)}for(e in a){if(this[e]&&"function"===
typeof this[e].update)this[e].update(a[e],!1);else if("function"===typeof this[d[e]])this[d[e]](a[e]);"chart"!==e&&-1!==g(e,this.propsRequireUpdateSeries)&&(q=!0)}a.colors&&(this.options.colors=a.colors);a.plotOptions&&w(!0,this.options.plotOptions,a.plotOptions);t(["xAxis","yAxis","series","colorAxis","pane"],function(b){a[b]&&t(u(a[b]),function(a,c){(c=h(a.id)&&this.get(a.id)||this[b][c])&&c.coll===b&&c.update(a,!1)},this)},this);l&&t(this.axes,function(a){a.update({},!1)});q&&t(this.series,function(a){a.update({},
!1)});a.loading&&w(!0,this.options.loading,a.loading);e=f&&f.width;f=f&&f.height;n(e)&&e!==this.chartWidth||n(f)&&f!==this.chartHeight?this.setSize(e,f):b(c,!0)&&this.redraw()},setSubtitle:function(a){this.setTitle(void 0,a)}});m(l.prototype,{update:function(a,c,e,d){function g(){f.applyOptions(a);null===f.y&&h&&(f.graphic=h.destroy());y(a,!0)&&(h&&h.element&&a&&a.marker&&a.marker.symbol&&(f.graphic=h.destroy()),a&&a.dataLabels&&f.dataLabel&&(f.dataLabel=f.dataLabel.destroy()));n=f.index;l.updateParallelArrays(f,
n);m.data[n]=y(m.data[n],!0)||y(a,!0)?f.options:a;l.isDirty=l.isDirtyData=!0;!l.fixedBox&&l.hasCartesianSeries&&(q.isDirtyBox=!0);"point"===m.legendType&&(q.isDirtyLegend=!0);c&&q.redraw(e)}var f=this,l=f.series,h=f.graphic,n,q=l.chart,m=l.options;c=b(c,!0);!1===d?g():f.firePointEvent("update",{options:a},g)},remove:function(a,b){this.series.removePoint(g(this,this.series.data),a,b)}});m(e.prototype,{addPoint:function(a,c,e,d){var f=this.options,g=this.data,l=this.chart,h=this.xAxis,h=h&&h.hasNames&&
h.names,n=f.data,q,m,u=this.xData,x,r;c=b(c,!0);q={series:this};this.pointClass.prototype.applyOptions.apply(q,[a]);r=q.x;x=u.length;if(this.requireSorting&&r<u[x-1])for(m=!0;x&&u[x-1]>r;)x--;this.updateParallelArrays(q,"splice",x,0,0);this.updateParallelArrays(q,x);h&&q.name&&(h[r]=q.name);n.splice(x,0,a);m&&(this.data.splice(x,0,null),this.processData());"point"===f.legendType&&this.generatePoints();e&&(g[0]&&g[0].remove?g[0].remove(!1):(g.shift(),this.updateParallelArrays(q,"shift"),n.shift()));
this.isDirtyData=this.isDirty=!0;c&&l.redraw(d)},removePoint:function(a,c,e){var d=this,f=d.data,g=f[a],l=d.points,h=d.chart,n=function(){l&&l.length===f.length&&l.splice(a,1);f.splice(a,1);d.options.data.splice(a,1);d.updateParallelArrays(g||{series:d},"splice",a,1);g&&g.destroy();d.isDirty=!0;d.isDirtyData=!0;c&&h.redraw()};E(e,h);c=b(c,!0);g?g.firePointEvent("remove",null,n):n()},remove:function(a,c,e){function f(){g.destroy();l.isDirtyLegend=l.isDirtyBox=!0;l.linkSeries();b(a,!0)&&l.redraw(c)}
var g=this,l=g.chart;!1!==e?d(g,"remove",null,f):f()},update:function(a,e){var d=this,f=this.chart,g=this.userOptions,l=this.oldType||this.type,h=a.type||g.type||f.options.chart.type,n=c[l].prototype,q=["group","markerGroup","dataLabelsGroup"],p;if(h&&h!==l||void 0!==a.zIndex)q.length=0;t(q,function(a){q[a]=d[a];delete d[a]});a=w(g,{animation:!1,index:this.index,pointStart:this.xData[0]},{data:this.options.data},a);this.remove(!1,null,!1);for(p in n)this[p]=void 0;m(this,c[h||l].prototype);t(q,function(a){d[a]=
q[a]});this.init(f,a);this.oldType=l;f.linkSeries();b(e,!0)&&f.redraw(!1)}});m(D.prototype,{update:function(a,c){var e=this.chart;a=e.options[this.coll][this.options.index]=w(this.userOptions,a);this.destroy(!0);this.init(e,m(a,{events:void 0}));e.isDirtyBox=!0;b(c,!0)&&e.redraw()},remove:function(a){for(var c=this.chart,e=this.coll,d=this.series,f=d.length;f--;)d[f]&&d[f].remove(!1);r(c.axes,this);r(c[e],this);c.options[e].splice(this.options.index,1);t(c[e],function(a,b){a.options.index=b});this.destroy();
c.isDirtyBox=!0;b(a,!0)&&c.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}})})(J);(function(a){var z=a.animObject,F=a.color,D=a.each,B=a.extend,f=a.isNumber,h=a.merge,t=a.pick,r=a.Series,m=a.seriesType,d=a.svg;m("column","line",{borderRadius:0,crisp:!0,groupPadding:.2,marker:null,pointPadding:.1,minPointLength:0,cropThreshold:50,pointRange:null,states:{hover:{halo:!1,brightness:.1,shadow:!1},select:{color:"#cccccc",borderColor:"#000000",
shadow:!1}},dataLabels:{align:null,verticalAlign:null,y:null},softThreshold:!1,startFromThreshold:!0,stickyTracking:!1,tooltip:{distance:6},threshold:0,borderColor:"#ffffff"},{cropShoulder:0,directTouch:!0,trackerGroups:["group","dataLabelsGroup"],negStacks:!0,init:function(){r.prototype.init.apply(this,arguments);var a=this,d=a.chart;d.hasRendered&&D(d.series,function(d){d.type===a.type&&(d.isDirty=!0)})},getColumnMetrics:function(){var a=this,d=a.options,f=a.xAxis,h=a.yAxis,b=f.reversed,l,e={},
c=0;!1===d.grouping?c=1:D(a.chart.series,function(b){var d=b.options,f=b.yAxis,g;b.type===a.type&&b.visible&&h.len===f.len&&h.pos===f.pos&&(d.stacking?(l=b.stackKey,void 0===e[l]&&(e[l]=c++),g=e[l]):!1!==d.grouping&&(g=c++),b.columnIndex=g)});var m=Math.min(Math.abs(f.transA)*(f.ordinalSlope||d.pointRange||f.closestPointRange||f.tickInterval||1),f.len),u=m*d.groupPadding,q=(m-2*u)/(c||1),d=Math.min(d.maxPointWidth||f.len,t(d.pointWidth,q*(1-2*d.pointPadding)));a.columnMetrics={width:d,offset:(q-d)/
2+(u+((a.columnIndex||0)+(b?1:0))*q-m/2)*(b?-1:1)};return a.columnMetrics},crispCol:function(a,d,f,h){var b=this.chart,g=this.borderWidth,e=-(g%2?.5:0),g=g%2?.5:1;b.inverted&&b.renderer.isVML&&(g+=1);this.options.crisp&&(f=Math.round(a+f)+e,a=Math.round(a)+e,f-=a);h=Math.round(d+h)+g;e=.5>=Math.abs(d)&&.5<h;d=Math.round(d)+g;h-=d;e&&h&&(--d,h+=1);return{x:a,y:d,width:f,height:h}},translate:function(){var a=this,d=a.chart,f=a.options,h=a.dense=2>a.closestPointRange*a.xAxis.transA,h=a.borderWidth=t(f.borderWidth,
h?0:1),b=a.yAxis,l=a.translatedThreshold=b.getThreshold(f.threshold),e=t(f.minPointLength,5),c=a.getColumnMetrics(),m=c.width,u=a.barW=Math.max(m,1+2*h),q=a.pointXOffset=c.offset;d.inverted&&(l-=.5);f.pointPadding&&(u=Math.ceil(u));r.prototype.translate.apply(a);D(a.points,function(c){var f=t(c.yBottom,l),g=999+Math.abs(f),g=Math.min(Math.max(-g,c.plotY),b.len+g),k=c.plotX+q,h=u,n=Math.min(g,f),r,x=Math.max(g,f)-n;Math.abs(x)<e&&e&&(x=e,r=!b.reversed&&!c.negative||b.reversed&&c.negative,n=Math.abs(n-
l)>e?f-e:l-(r?e:0));c.barX=k;c.pointWidth=m;c.tooltipPos=d.inverted?[b.len+b.pos-d.plotLeft-g,a.xAxis.len-k-h/2,x]:[k+h/2,g+b.pos-d.plotTop,x];c.shapeType="rect";c.shapeArgs=a.crispCol.apply(a,c.isNull?[c.plotX,b.len/2,0,0]:[k,n,h,x])})},getSymbol:a.noop,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,drawGraph:function(){this.group[this.dense?"addClass":"removeClass"]("highcharts-dense-data")},pointAttribs:function(a,d){var f=this.options,g,b=this.pointAttrToOptions||{};g=b.stroke||"borderColor";
var l=b["stroke-width"]||"borderWidth",e=a&&a.color||this.color,c=a[g]||f[g]||this.color||e,n=a[l]||f[l]||this[l]||0,b=f.dashStyle;a&&this.zones.length&&(e=(e=a.getZone())&&e.color||a.options.color||this.color);d&&(a=h(f.states[d],a.options.states&&a.options.states[d]||{}),d=a.brightness,e=a.color||void 0!==d&&F(e).brighten(a.brightness).get()||e,c=a[g]||c,n=a[l]||n,b=a.dashStyle||b);g={fill:e,stroke:c,"stroke-width":n};f.borderRadius&&(g.r=f.borderRadius);b&&(g.dashstyle=b);return g},drawPoints:function(){var a=
this,d=this.chart,m=a.options,r=d.renderer,b=m.animationLimit||250,l;D(a.points,function(e){var c=e.graphic;if(f(e.plotY)&&null!==e.y){l=e.shapeArgs;if(c)c[d.pointCount<b?"animate":"attr"](h(l));else e.graphic=c=r[e.shapeType](l).add(e.group||a.group);c.attr(a.pointAttribs(e,e.selected&&"select")).shadow(m.shadow,null,m.stacking&&!m.borderRadius);c.addClass(e.getClassName(),!0)}else c&&(e.graphic=c.destroy())})},animate:function(a){var f=this,g=this.yAxis,h=f.options,b=this.chart.inverted,l={};d&&
(a?(l.scaleY=.001,a=Math.min(g.pos+g.len,Math.max(g.pos,g.toPixels(h.threshold))),b?l.translateX=a-g.len:l.translateY=a,f.group.attr(l)):(l[b?"translateX":"translateY"]=g.pos,f.group.animate(l,B(z(f.options.animation),{step:function(a,b){f.group.attr({scaleY:Math.max(.001,b.pos)})}})),f.animate=null))},remove:function(){var a=this,d=a.chart;d.hasRendered&&D(d.series,function(d){d.type===a.type&&(d.isDirty=!0)});r.prototype.remove.apply(a,arguments)}})})(J);(function(a){var z=a.Series;a=a.seriesType;
a("scatter","line",{lineWidth:0,findNearestPointBy:"xy",marker:{enabled:!0},tooltip:{headerFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e \x3cspan style\x3d"font-size: 0.85em"\x3e {series.name}\x3c/span\x3e\x3cbr/\x3e',pointFormat:"x: \x3cb\x3e{point.x}\x3c/b\x3e\x3cbr/\x3ey: \x3cb\x3e{point.y}\x3c/b\x3e\x3cbr/\x3e"}},{sorted:!1,requireSorting:!1,noSharedTooltip:!0,trackerGroups:["group","markerGroup","dataLabelsGroup"],takeOrdinalPosition:!1,drawGraph:function(){this.options.lineWidth&&
z.prototype.drawGraph.call(this)}})})(J);(function(a){var z=a.addEvent,F=a.arrayMax,D=a.defined,B=a.each,f=a.extend,h=a.format,t=a.map,r=a.merge,m=a.noop,d=a.pick,g=a.relativeLength,n=a.Series,y=a.seriesTypes,w=a.stableSort;a.distribute=function(a,d){function b(a,b){return a.target-b.target}var c,f=!0,g=a,l=[],h;h=0;for(c=a.length;c--;)h+=a[c].size;if(h>d){w(a,function(a,b){return(b.rank||0)-(a.rank||0)});for(h=c=0;h<=d;)h+=a[c].size,c++;l=a.splice(c-1,a.length)}w(a,b);for(a=t(a,function(a){return{size:a.size,
targets:[a.target]}});f;){for(c=a.length;c--;)f=a[c],h=(Math.min.apply(0,f.targets)+Math.max.apply(0,f.targets))/2,f.pos=Math.min(Math.max(0,h-f.size/2),d-f.size);c=a.length;for(f=!1;c--;)0<c&&a[c-1].pos+a[c-1].size>a[c].pos&&(a[c-1].size+=a[c].size,a[c-1].targets=a[c-1].targets.concat(a[c].targets),a[c-1].pos+a[c-1].size>d&&(a[c-1].pos=d-a[c-1].size),a.splice(c,1),f=!0)}c=0;B(a,function(a){var b=0;B(a.targets,function(){g[c].pos=a.pos+b;b+=g[c].size;c++})});g.push.apply(g,l);w(g,b)};n.prototype.drawDataLabels=
function(){var a=this,f=a.options,e=f.dataLabels,c=a.points,g,n,q=a.hasRendered||0,m,w,t=d(e.defer,!0),k=a.chart.renderer;if(e.enabled||a._hasPointLabels)a.dlProcessOptions&&a.dlProcessOptions(e),w=a.plotGroup("dataLabelsGroup","data-labels",t&&!q?"hidden":"visible",e.zIndex||6),t&&(w.attr({opacity:+q}),q||z(a,"afterAnimate",function(){a.visible&&w.show(!0);w[f.animation?"animate":"attr"]({opacity:1},{duration:200})})),n=e,B(c,function(b){var c,l=b.dataLabel,q,p,u,x=b.connector,t=!l,A;g=b.dlOptions||
b.options&&b.options.dataLabels;if(c=d(g&&g.enabled,n.enabled)&&null!==b.y)for(p in e=r(n,g),q=b.getLabelConfig(),m=e.format?h(e.format,q):e.formatter.call(q,e),A=e.style,u=e.rotation,A.color=d(e.color,A.color,a.color,"#000000"),"contrast"===A.color&&(b.contrastColor=k.getContrast(b.color||a.color),A.color=e.inside||0>e.distance||f.stacking?b.contrastColor:"#000000"),f.cursor&&(A.cursor=f.cursor),q={fill:e.backgroundColor,stroke:e.borderColor,"stroke-width":e.borderWidth,r:e.borderRadius||0,rotation:u,
padding:e.padding,zIndex:1},q)void 0===q[p]&&delete q[p];!l||c&&D(m)?c&&D(m)&&(l?q.text=m:(l=b.dataLabel=k[u?"text":"label"](m,0,-9999,e.shape,null,null,e.useHTML,null,"data-label"),l.addClass("highcharts-data-label-color-"+b.colorIndex+" "+(e.className||"")+(e.useHTML?"highcharts-tracker":""))),l.attr(q),l.css(A).shadow(e.shadow),l.added||l.add(w),a.alignDataLabel(b,l,e,null,t)):(b.dataLabel=l.destroy(),x&&(b.connector=x.destroy()))})};n.prototype.alignDataLabel=function(a,g,e,c,h){var b=this.chart,
l=b.inverted,n=d(a.plotX,-9999),m=d(a.plotY,-9999),r=g.getBBox(),k,w=e.rotation,t=e.align,E=this.visible&&(a.series.forceDL||b.isInsidePlot(n,Math.round(m),l)||c&&b.isInsidePlot(n,l?c.x+1:c.y+c.height-1,l)),y="justify"===d(e.overflow,"justify");E&&(k=e.style.fontSize,k=b.renderer.fontMetrics(k,g).b,c=f({x:l?b.plotWidth-m:n,y:Math.round(l?b.plotHeight-n:m),width:0,height:0},c),f(e,{width:r.width,height:r.height}),w?(y=!1,l=b.renderer.rotCorr(k,w),l={x:c.x+e.x+c.width/2+l.x,y:c.y+e.y+{top:0,middle:.5,
bottom:1}[e.verticalAlign]*c.height},g[h?"attr":"animate"](l).attr({align:t}),n=(w+720)%360,n=180<n&&360>n,"left"===t?l.y-=n?r.height:0:"center"===t?(l.x-=r.width/2,l.y-=r.height/2):"right"===t&&(l.x-=r.width,l.y-=n?0:r.height)):(g.align(e,null,c),l=g.alignAttr),y?a.isLabelJustified=this.justifyDataLabel(g,e,l,r,c,h):d(e.crop,!0)&&(E=b.isInsidePlot(l.x,l.y)&&b.isInsidePlot(l.x+r.width,l.y+r.height)),e.shape&&!w&&g.attr({anchorX:a.plotX,anchorY:a.plotY}));E||(g.attr({y:-9999}),g.placed=!1)};n.prototype.justifyDataLabel=
function(a,d,e,c,f,g){var b=this.chart,l=d.align,h=d.verticalAlign,n,k,m=a.box?0:a.padding||0;n=e.x+m;0>n&&("right"===l?d.align="left":d.x=-n,k=!0);n=e.x+c.width-m;n>b.plotWidth&&("left"===l?d.align="right":d.x=b.plotWidth-n,k=!0);n=e.y+m;0>n&&("bottom"===h?d.verticalAlign="top":d.y=-n,k=!0);n=e.y+c.height-m;n>b.plotHeight&&("top"===h?d.verticalAlign="bottom":d.y=b.plotHeight-n,k=!0);k&&(a.placed=!g,a.align(d,null,f));return k};y.pie&&(y.pie.prototype.drawDataLabels=function(){var b=this,f=b.data,
e,c=b.chart,g=b.options.dataLabels,h=d(g.connectorPadding,10),m=d(g.connectorWidth,1),r=c.plotWidth,w=c.plotHeight,y,k=g.distance,G=b.center,z=G[2]/2,D=G[1],K=0<k,p,C,M,N,J=[[],[]],O,v,P,S,R=[0,0,0,0];b.visible&&(g.enabled||b._hasPointLabels)&&(B(f,function(a){a.dataLabel&&a.visible&&a.dataLabel.shortened&&(a.dataLabel.attr({width:"auto"}).css({width:"auto",textOverflow:"clip"}),a.dataLabel.shortened=!1)}),n.prototype.drawDataLabels.apply(b),B(f,function(a){a.dataLabel&&a.visible&&(J[a.half].push(a),
a.dataLabel._pos=null)}),B(J,function(d,f){var l,n,m=d.length,q,u,x;if(m)for(b.sortByAngle(d,f-.5),0<k&&(l=Math.max(0,D-z-k),n=Math.min(D+z+k,c.plotHeight),q=t(d,function(a){if(a.dataLabel)return x=a.dataLabel.getBBox().height||21,{target:a.labelPos[1]-l+x/2,size:x,rank:a.y}}),a.distribute(q,n+x-l)),S=0;S<m;S++)e=d[S],M=e.labelPos,p=e.dataLabel,P=!1===e.visible?"hidden":"inherit",u=M[1],q?void 0===q[S].pos?P="hidden":(N=q[S].size,v=l+q[S].pos):v=u,O=g.justify?G[0]+(f?-1:1)*(z+k):b.getX(v<l+2||v>n-
2?u:v,f),p._attr={visibility:P,align:M[6]},p._pos={x:O+g.x+({left:h,right:-h}[M[6]]||0),y:v+g.y-10},M.x=O,M.y=v,null===b.options.size&&(C=p.getBBox().width,u=null,O-C<h?(u=Math.round(C-O+h),R[3]=Math.max(u,R[3])):O+C>r-h&&(u=Math.round(O+C-r+h),R[1]=Math.max(u,R[1])),0>v-N/2?R[0]=Math.max(Math.round(-v+N/2),R[0]):v+N/2>w&&(R[2]=Math.max(Math.round(v+N/2-w),R[2])),p.sideOverflow=u)}),0===F(R)||this.verifyDataLabelOverflow(R))&&(this.placeDataLabels(),K&&m&&B(this.points,function(a){var e;y=a.connector;
if((p=a.dataLabel)&&p._pos&&a.visible){P=p._attr.visibility;if(e=!y)a.connector=y=c.renderer.path().addClass("highcharts-data-label-connector highcharts-color-"+a.colorIndex).add(b.dataLabelsGroup),y.attr({"stroke-width":m,stroke:g.connectorColor||a.color||"#666666"});y[e?"attr":"animate"]({d:b.connectorPath(a.labelPos)});y.attr("visibility",P)}else y&&(a.connector=y.destroy())}))},y.pie.prototype.connectorPath=function(a){var b=a.x,e=a.y;return d(this.options.dataLabels.softConnector,!0)?["M",b+
("left"===a[6]?5:-5),e,"C",b,e,2*a[2]-a[4],2*a[3]-a[5],a[2],a[3],"L",a[4],a[5]]:["M",b+("left"===a[6]?5:-5),e,"L",a[2],a[3],"L",a[4],a[5]]},y.pie.prototype.placeDataLabels=function(){B(this.points,function(a){var b=a.dataLabel;b&&a.visible&&((a=b._pos)?(b.sideOverflow&&(b._attr.width=b.getBBox().width-b.sideOverflow,b.css({width:b._attr.width+"px",textOverflow:"ellipsis"}),b.shortened=!0),b.attr(b._attr),b[b.moved?"animate":"attr"](a),b.moved=!0):b&&b.attr({y:-9999}))},this)},y.pie.prototype.alignDataLabel=
m,y.pie.prototype.verifyDataLabelOverflow=function(a){var b=this.center,e=this.options,c=e.center,d=e.minSize||80,f,h;null!==c[0]?f=Math.max(b[2]-Math.max(a[1],a[3]),d):(f=Math.max(b[2]-a[1]-a[3],d),b[0]+=(a[3]-a[1])/2);null!==c[1]?f=Math.max(Math.min(f,b[2]-Math.max(a[0],a[2])),d):(f=Math.max(Math.min(f,b[2]-a[0]-a[2]),d),b[1]+=(a[0]-a[2])/2);f<b[2]?(b[2]=f,b[3]=Math.min(g(e.innerSize||0,f),f),this.translate(b),this.drawDataLabels&&this.drawDataLabels()):h=!0;return h});y.column&&(y.column.prototype.alignDataLabel=
function(a,f,e,c,g){var b=this.chart.inverted,h=a.series,l=a.dlBox||a.shapeArgs,m=d(a.below,a.plotY>d(this.translatedThreshold,h.yAxis.len)),w=d(e.inside,!!this.options.stacking);l&&(c=r(l),0>c.y&&(c.height+=c.y,c.y=0),l=c.y+c.height-h.yAxis.len,0<l&&(c.height-=l),b&&(c={x:h.yAxis.len-c.y-c.height,y:h.xAxis.len-c.x-c.width,width:c.height,height:c.width}),w||(b?(c.x+=m?0:c.width,c.width=0):(c.y+=m?c.height:0,c.height=0)));e.align=d(e.align,!b||w?"center":m?"right":"left");e.verticalAlign=d(e.verticalAlign,
b||w?"middle":m?"top":"bottom");n.prototype.alignDataLabel.call(this,a,f,e,c,g);a.isLabelJustified&&a.contrastColor&&a.dataLabel.css({color:a.contrastColor})})})(J);(function(a){var z=a.Chart,F=a.each,D=a.pick,B=a.addEvent;z.prototype.callbacks.push(function(a){function f(){var f=[];F(a.series||[],function(a){var h=a.options.dataLabels,d=a.dataLabelCollections||["dataLabel"];(h.enabled||a._hasPointLabels)&&!h.allowOverlap&&a.visible&&F(d,function(d){F(a.points,function(a){a[d]&&(a[d].labelrank=D(a.labelrank,
a.shapeArgs&&a.shapeArgs.height),f.push(a[d]))})})});a.hideOverlappingLabels(f)}f();B(a,"redraw",f)});z.prototype.hideOverlappingLabels=function(a){var f=a.length,t,r,m,d,g,n,y,w,b,l=function(a,b,d,f,g,h,l,n){return!(g>a+d||g+l<a||h>b+f||h+n<b)};for(r=0;r<f;r++)if(t=a[r])t.oldOpacity=t.opacity,t.newOpacity=1;a.sort(function(a,b){return(b.labelrank||0)-(a.labelrank||0)});for(r=0;r<f;r++)for(m=a[r],t=r+1;t<f;++t)if(d=a[t],m&&d&&m!==d&&m.placed&&d.placed&&0!==m.newOpacity&&0!==d.newOpacity&&(g=m.alignAttr,
n=d.alignAttr,y=m.parentGroup,w=d.parentGroup,b=2*(m.box?0:m.padding),g=l(g.x+y.translateX,g.y+y.translateY,m.width-b,m.height-b,n.x+w.translateX,n.y+w.translateY,d.width-b,d.height-b)))(m.labelrank<d.labelrank?m:d).newOpacity=0;F(a,function(a){var b,d;a&&(d=a.newOpacity,a.oldOpacity!==d&&a.placed&&(d?a.show(!0):b=function(){a.hide()},a.alignAttr.opacity=d,a[a.isOld?"animate":"attr"](a.alignAttr,null,b)),a.isOld=!0)})}})(J);(function(a){var z=a.addEvent,F=a.Chart,D=a.createElement,B=a.css,f=a.defaultOptions,
h=a.defaultPlotOptions,t=a.each,r=a.extend,m=a.fireEvent,d=a.hasTouch,g=a.inArray,n=a.isObject,y=a.Legend,w=a.merge,b=a.pick,l=a.Point,e=a.Series,c=a.seriesTypes,E=a.svg;a=a.TrackerMixin={drawTrackerPoint:function(){var a=this,b=a.chart.pointer,c=function(a){var c=b.getPointFromEvent(a);if(void 0!==c)c.onMouseOver(a)};t(a.points,function(a){a.graphic&&(a.graphic.element.point=a);a.dataLabel&&(a.dataLabel.div?a.dataLabel.div.point=a:a.dataLabel.element.point=a)});a._hasTracking||(t(a.trackerGroups,
function(e){if(a[e]){a[e].addClass("highcharts-tracker").on("mouseover",c).on("mouseout",function(a){b.onTrackerMouseOut(a)});if(d)a[e].on("touchstart",c);a.options.cursor&&a[e].css(B).css({cursor:a.options.cursor})}}),a._hasTracking=!0)},drawTrackerGraph:function(){var a=this,b=a.options,c=b.trackByArea,e=[].concat(c?a.areaPath:a.graphPath),f=e.length,g=a.chart,h=g.pointer,l=g.renderer,n=g.options.tooltip.snap,m=a.tracker,p,r=function(){if(g.hoverSeries!==a)a.onMouseOver()},w="rgba(192,192,192,"+
(E?.0001:.002)+")";if(f&&!c)for(p=f+1;p--;)"M"===e[p]&&e.splice(p+1,0,e[p+1]-n,e[p+2],"L"),(p&&"M"===e[p]||p===f)&&e.splice(p,0,"L",e[p-2]+n,e[p-1]);m?m.attr({d:e}):a.graph&&(a.tracker=l.path(e).attr({"stroke-linejoin":"round",visibility:a.visible?"visible":"hidden",stroke:w,fill:c?w:"none","stroke-width":a.graph.strokeWidth()+(c?0:2*n),zIndex:2}).add(a.group),t([a.tracker,a.markerGroup],function(a){a.addClass("highcharts-tracker").on("mouseover",r).on("mouseout",function(a){h.onTrackerMouseOut(a)});
b.cursor&&a.css({cursor:b.cursor});if(d)a.on("touchstart",r)}))}};c.column&&(c.column.prototype.drawTracker=a.drawTrackerPoint);c.pie&&(c.pie.prototype.drawTracker=a.drawTrackerPoint);c.scatter&&(c.scatter.prototype.drawTracker=a.drawTrackerPoint);r(y.prototype,{setItemEvents:function(a,b,c){var d=this,e=d.chart.renderer.boxWrapper,f="highcharts-legend-"+(a.series?"point":"series")+"-active";(c?b:a.legendGroup).on("mouseover",function(){a.setState("hover");e.addClass(f);b.css(d.options.itemHoverStyle)}).on("mouseout",
function(){b.css(a.visible?d.itemStyle:d.itemHiddenStyle);e.removeClass(f);a.setState()}).on("click",function(b){var c=function(){a.setVisible&&a.setVisible()};b={browserEvent:b};a.firePointEvent?a.firePointEvent("legendItemClick",b,c):m(a,"legendItemClick",b,c)})},createCheckboxForItem:function(a){a.checkbox=D("input",{type:"checkbox",checked:a.selected,defaultChecked:a.selected},this.options.itemCheckboxStyle,this.chart.container);z(a.checkbox,"click",function(b){m(a.series||a,"checkboxClick",{checked:b.target.checked,
item:a},function(){a.select()})})}});f.legend.itemStyle.cursor="pointer";r(F.prototype,{showResetZoom:function(){var a=this,b=f.lang,c=a.options.chart.resetZoomButton,d=c.theme,e=d.states,g="chart"===c.relativeTo?null:"plotBox";this.resetZoomButton=a.renderer.button(b.resetZoom,null,null,function(){a.zoomOut()},d,e&&e.hover).attr({align:c.position.align,title:b.resetZoomTitle}).addClass("highcharts-reset-zoom").add().align(c.position,!1,g)},zoomOut:function(){var a=this;m(a,"selection",{resetSelection:!0},
function(){a.zoom()})},zoom:function(a){var c,d=this.pointer,e=!1,f;!a||a.resetSelection?t(this.axes,function(a){c=a.zoom()}):t(a.xAxis.concat(a.yAxis),function(a){var b=a.axis;d[b.isXAxis?"zoomX":"zoomY"]&&(c=b.zoom(a.min,a.max),b.displayBtn&&(e=!0))});f=this.resetZoomButton;e&&!f?this.showResetZoom():!e&&n(f)&&(this.resetZoomButton=f.destroy());c&&this.redraw(b(this.options.chart.animation,a&&a.animation,100>this.pointCount))},pan:function(a,b){var c=this,d=c.hoverPoints,e;d&&t(d,function(a){a.setState()});
t("xy"===b?[1,0]:[1],function(b){b=c[b?"xAxis":"yAxis"][0];var d=b.horiz,f=a[d?"chartX":"chartY"],d=d?"mouseDownX":"mouseDownY",g=c[d],h=(b.pointRange||0)/2,l=b.getExtremes(),k=b.toValue(g-f,!0)+h,h=b.toValue(g+b.len-f,!0)-h,n=h<k,g=n?h:k,k=n?k:h,n=b.toValue(b.toPixels(l.min)-b.minPixelPadding),h=b.toValue(b.toPixels(l.max)+b.minPixelPadding),n=Math.min(l.dataMin,n)-g,l=k-Math.max(l.dataMax,h);b.series.length&&0>n&&0>l&&(b.setExtremes(g,k,!1,!1,{trigger:"pan"}),e=!0);c[d]=f});e&&c.redraw(!1);B(c.container,
{cursor:"move"})}});r(l.prototype,{select:function(a,c){var d=this,e=d.series,f=e.chart;a=b(a,!d.selected);d.firePointEvent(a?"select":"unselect",{accumulate:c},function(){d.selected=d.options.selected=a;e.options.data[g(d,e.data)]=d.options;d.setState(a&&"select");c||t(f.getSelectedPoints(),function(a){a.selected&&a!==d&&(a.selected=a.options.selected=!1,e.options.data[g(a,e.data)]=a.options,a.setState(""),a.firePointEvent("unselect"))})})},onMouseOver:function(a){var b=this.series.chart.pointer;
this.firePointEvent("mouseOver");b.runPointActions(a,this)},onMouseOut:function(){var a=this.series.chart;this.firePointEvent("mouseOut");t(a.hoverPoints||[],function(a){a.setState()});a.hoverPoints=a.hoverPoint=null},importEvents:function(){if(!this.hasImportedEvents){var a=w(this.series.options.point,this.options).events,b;this.events=a;for(b in a)z(this,b,a[b]);this.hasImportedEvents=!0}},setState:function(a,c){var d=Math.floor(this.plotX),e=this.plotY,f=this.series,g=f.options.states[a]||{},l=
h[f.type].marker&&f.options.marker,n=l&&!1===l.enabled,m=l&&l.states&&l.states[a]||{},q=!1===m.enabled,p=f.stateMarkerGraphic,w=this.marker||{},u=f.chart,t=f.halo,y,E=l&&f.markerAttribs;a=a||"";if(!(a===this.state&&!c||this.selected&&"select"!==a||!1===g.enabled||a&&(q||n&&!1===m.enabled)||a&&w.states&&w.states[a]&&!1===w.states[a].enabled)){E&&(y=f.markerAttribs(this,a));if(this.graphic)this.state&&this.graphic.removeClass("highcharts-point-"+this.state),a&&this.graphic.addClass("highcharts-point-"+
a),this.graphic.attr(f.pointAttribs(this,a)),y&&this.graphic.animate(y,b(u.options.chart.animation,m.animation,l.animation)),p&&p.hide();else{if(a&&m){l=w.symbol||f.symbol;p&&p.currentSymbol!==l&&(p=p.destroy());if(p)p[c?"animate":"attr"]({x:y.x,y:y.y});else l&&(f.stateMarkerGraphic=p=u.renderer.symbol(l,y.x,y.y,y.width,y.height).add(f.markerGroup),p.currentSymbol=l);p&&p.attr(f.pointAttribs(this,a))}p&&(p[a&&u.isInsidePlot(d,e,u.inverted)?"show":"hide"](),p.element.point=this)}(d=g.halo)&&d.size?
(t||(f.halo=t=u.renderer.path().add(E?f.markerGroup:f.group)),t[c?"animate":"attr"]({d:this.haloPath(d.size)}),t.attr({"class":"highcharts-halo highcharts-color-"+b(this.colorIndex,f.colorIndex)}),t.point=this,t.attr(r({fill:this.color||f.color,"fill-opacity":d.opacity,zIndex:-1},d.attributes))):t&&t.point&&t.point.haloPath&&t.animate({d:t.point.haloPath(0)});this.state=a}},haloPath:function(a){return this.series.chart.renderer.symbols.circle(Math.floor(this.plotX)-a,this.plotY-a,2*a,2*a)}});r(e.prototype,
{onMouseOver:function(){var a=this.chart,b=a.hoverSeries;if(b&&b!==this)b.onMouseOut();this.options.events.mouseOver&&m(this,"mouseOver");this.setState("hover");a.hoverSeries=this},onMouseOut:function(){var a=this.options,b=this.chart,c=b.tooltip,d=b.hoverPoint;b.hoverSeries=null;if(d)d.onMouseOut();this&&a.events.mouseOut&&m(this,"mouseOut");!c||this.stickyTracking||c.shared&&!this.noSharedTooltip||c.hide();this.setState()},setState:function(a){var c=this,d=c.options,e=c.graph,f=d.states,g=d.lineWidth,
d=0;a=a||"";if(c.state!==a&&(t([c.group,c.markerGroup,c.dataLabelsGroup],function(b){b&&(c.state&&b.removeClass("highcharts-series-"+c.state),a&&b.addClass("highcharts-series-"+a))}),c.state=a,!f[a]||!1!==f[a].enabled)&&(a&&(g=f[a].lineWidth||g+(f[a].lineWidthPlus||0)),e&&!e.dashstyle))for(g={"stroke-width":g},e.animate(g,b(c.chart.options.chart.animation,f[a]&&f[a].animation));c["zone-graph-"+d];)c["zone-graph-"+d].attr(g),d+=1},setVisible:function(a,b){var c=this,d=c.chart,e=c.legendItem,f,g=d.options.chart.ignoreHiddenSeries,
l=c.visible;f=(c.visible=a=c.options.visible=c.userOptions.visible=void 0===a?!l:a)?"show":"hide";t(["group","dataLabelsGroup","markerGroup","tracker","tt"],function(a){if(c[a])c[a][f]()});if(d.hoverSeries===c||(d.hoverPoint&&d.hoverPoint.series)===c)c.onMouseOut();e&&d.legend.colorizeItem(c,a);c.isDirty=!0;c.options.stacking&&t(d.series,function(a){a.options.stacking&&a.visible&&(a.isDirty=!0)});t(c.linkedSeries,function(b){b.setVisible(a,!1)});g&&(d.isDirtyBox=!0);!1!==b&&d.redraw();m(c,f)},show:function(){this.setVisible(!0)},
hide:function(){this.setVisible(!1)},select:function(a){this.selected=a=void 0===a?!this.selected:a;this.checkbox&&(this.checkbox.checked=a);m(this,a?"select":"unselect")},drawTracker:a.drawTrackerGraph})})(J);(function(a){var z=a.Chart,F=a.each,D=a.inArray,B=a.isArray,f=a.isObject,h=a.pick,t=a.splat;z.prototype.setResponsive=function(f){var h=this.options.responsive,d=[],g=this.currentResponsive;h&&h.rules&&F(h.rules,function(g){void 0===g._id&&(g._id=a.uniqueKey());this.matchResponsiveRule(g,d,
f)},this);var n=a.merge.apply(0,a.map(d,function(d){return a.find(h.rules,function(a){return a._id===d}).chartOptions})),d=d.toString()||void 0;d!==(g&&g.ruleIds)&&(g&&this.update(g.undoOptions,f),d?(this.currentResponsive={ruleIds:d,mergedOptions:n,undoOptions:this.currentOptions(n)},this.update(n,f)):this.currentResponsive=void 0)};z.prototype.matchResponsiveRule=function(a,f){var d=a.condition;(d.callback||function(){return this.chartWidth<=h(d.maxWidth,Number.MAX_VALUE)&&this.chartHeight<=h(d.maxHeight,
Number.MAX_VALUE)&&this.chartWidth>=h(d.minWidth,0)&&this.chartHeight>=h(d.minHeight,0)}).call(this)&&f.push(a._id)};z.prototype.currentOptions=function(a){function h(a,d,m,r){var b,g;for(b in a)if(!r&&-1<D(b,["series","xAxis","yAxis"]))for(a[b]=t(a[b]),m[b]=[],g=0;g<a[b].length;g++)d[b][g]&&(m[b][g]={},h(a[b][g],d[b][g],m[b][g],r+1));else f(a[b])?(m[b]=B(a[b])?[]:{},h(a[b],d[b]||{},m[b],r+1)):m[b]=d[b]||null}var d={};h(a,this.options,d,0);return d}})(J);(function(a){var z=a.Axis,F=a.each,D=a.pick;
a=a.wrap;a(z.prototype,"getSeriesExtremes",function(a){var f=this.isXAxis,h,t,r=[],m;f&&F(this.series,function(a,f){a.useMapGeometry&&(r[f]=a.xData,a.xData=[])});a.call(this);f&&(h=D(this.dataMin,Number.MAX_VALUE),t=D(this.dataMax,-Number.MAX_VALUE),F(this.series,function(a,f){a.useMapGeometry&&(h=Math.min(h,D(a.minX,h)),t=Math.max(t,D(a.maxX,h)),a.xData=r[f],m=!0)}),m&&(this.dataMin=h,this.dataMax=t))});a(z.prototype,"setAxisTranslation",function(a){var f=this.chart,h=f.plotWidth/f.plotHeight,f=
f.xAxis[0],t;a.call(this);"yAxis"===this.coll&&void 0!==f.transA&&F(this.series,function(a){a.preserveAspectRatio&&(t=!0)});if(t&&(this.transA=f.transA=Math.min(this.transA,f.transA),a=h/((f.max-f.min)/(this.max-this.min)),a=1>a?this:f,h=(a.max-a.min)*a.transA,a.pixelPadding=a.len-h,a.minPixelPadding=a.pixelPadding/2,h=a.fixTo)){h=h[1]-a.toValue(h[0],!0);h*=a.transA;if(Math.abs(h)>a.minPixelPadding||a.min===a.dataMin&&a.max===a.dataMax)h=0;a.minPixelPadding-=h}});a(z.prototype,"render",function(a){a.call(this);
this.fixTo=null})})(J);(function(a){var z=a.Axis,F=a.Chart,D=a.color,B,f=a.each,h=a.extend,t=a.isNumber,r=a.Legend,m=a.LegendSymbolMixin,d=a.noop,g=a.merge,n=a.pick,y=a.wrap;B=a.ColorAxis=function(){this.init.apply(this,arguments)};h(B.prototype,z.prototype);h(B.prototype,{defaultColorAxisOptions:{lineWidth:0,minPadding:0,maxPadding:0,gridLineWidth:1,tickPixelInterval:72,startOnTick:!0,endOnTick:!0,offset:0,marker:{animation:{duration:50},width:.01,color:"#999999"},labels:{overflow:"justify",rotation:0},
minColor:"#e6ebf5",maxColor:"#003399",tickLength:5,showInLegend:!0},keepProps:["legendGroup","legendItemHeight","legendItemWidth","legendItem","legendSymbol"].concat(z.prototype.keepProps),init:function(a,b){var d="vertical"!==a.options.legend.layout,e;this.coll="colorAxis";e=g(this.defaultColorAxisOptions,{side:d?2:1,reversed:!d},b,{opposite:!d,showEmpty:!1,title:null});z.prototype.init.call(this,a,e);b.dataClasses&&this.initDataClasses(b);this.initStops(b);this.horiz=d;this.zoomEnabled=!1;this.defaultLegendLength=
200},tweenColors:function(a,b,d){var e;b.rgba.length&&a.rgba.length?(a=a.rgba,b=b.rgba,e=1!==b[3]||1!==a[3],a=(e?"rgba(":"rgb(")+Math.round(b[0]+(a[0]-b[0])*(1-d))+","+Math.round(b[1]+(a[1]-b[1])*(1-d))+","+Math.round(b[2]+(a[2]-b[2])*(1-d))+(e?","+(b[3]+(a[3]-b[3])*(1-d)):"")+")"):a=b.input||"none";return a},initDataClasses:function(a){var b=this,d=this.chart,e,c=0,h=d.options.chart.colorCount,n=this.options,m=a.dataClasses.length;this.dataClasses=e=[];this.legendItems=[];f(a.dataClasses,function(a,
f){a=g(a);e.push(a);a.color||("category"===n.dataClassColor?(f=d.options.colors,h=f.length,a.color=f[c],a.colorIndex=c,c++,c===h&&(c=0)):a.color=b.tweenColors(D(n.minColor),D(n.maxColor),2>m?.5:f/(m-1)))})},initStops:function(a){this.stops=a.stops||[[0,this.options.minColor],[1,this.options.maxColor]];f(this.stops,function(a){a.color=D(a[1])})},setOptions:function(a){z.prototype.setOptions.call(this,a);this.options.crosshair=this.options.marker},setAxisSize:function(){var a=this.legendSymbol,b=this.chart,
d=b.options.legend||{},e,c;a?(this.left=d=a.attr("x"),this.top=e=a.attr("y"),this.width=c=a.attr("width"),this.height=a=a.attr("height"),this.right=b.chartWidth-d-c,this.bottom=b.chartHeight-e-a,this.len=this.horiz?c:a,this.pos=this.horiz?d:e):this.len=(this.horiz?d.symbolWidth:d.symbolHeight)||this.defaultLegendLength},toColor:function(a,b){var d=this.stops,e,c,f=this.dataClasses,g,h;if(f)for(h=f.length;h--;){if(g=f[h],e=g.from,d=g.to,(void 0===e||a>=e)&&(void 0===d||a<=d)){c=g.color;b&&(b.dataClass=
h,b.colorIndex=g.colorIndex);break}}else{this.isLog&&(a=this.val2lin(a));a=1-(this.max-a)/(this.max-this.min||1);for(h=d.length;h--&&!(a>d[h][0]););e=d[h]||d[h+1];d=d[h+1]||e;a=1-(d[0]-a)/(d[0]-e[0]||1);c=this.tweenColors(e.color,d.color,a)}return c},getOffset:function(){var a=this.legendGroup,b=this.chart.axisOffset[this.side];a&&(this.axisParent=a,z.prototype.getOffset.call(this),this.added||(this.added=!0,this.labelLeft=0,this.labelRight=this.width),this.chart.axisOffset[this.side]=b)},setLegendColor:function(){var a,
b=this.options,d=this.reversed;a=d?1:0;d=d?0:1;a=this.horiz?[a,0,d,0]:[0,d,0,a];this.legendColor={linearGradient:{x1:a[0],y1:a[1],x2:a[2],y2:a[3]},stops:b.stops||[[0,b.minColor],[1,b.maxColor]]}},drawLegendSymbol:function(a,b){var d=a.padding,e=a.options,c=this.horiz,f=n(e.symbolWidth,c?this.defaultLegendLength:12),g=n(e.symbolHeight,c?12:this.defaultLegendLength),h=n(e.labelPadding,c?16:30),e=n(e.itemDistance,10);this.setLegendColor();b.legendSymbol=this.chart.renderer.rect(0,a.baseline-11,f,g).attr({zIndex:1}).add(b.legendGroup);
this.legendItemWidth=f+d+(c?e:h);this.legendItemHeight=g+d+(c?h:0)},setState:d,visible:!0,setVisible:d,getSeriesExtremes:function(){var a=this.series,b=a.length;this.dataMin=Infinity;for(this.dataMax=-Infinity;b--;)void 0!==a[b].valueMin&&(this.dataMin=Math.min(this.dataMin,a[b].valueMin),this.dataMax=Math.max(this.dataMax,a[b].valueMax))},drawCrosshair:function(a,b){var d=b&&b.plotX,e=b&&b.plotY,c,f=this.pos,g=this.len;b&&(c=this.toPixels(b[b.series.colorKey]),c<f?c=f-2:c>f+g&&(c=f+g+2),b.plotX=
c,b.plotY=this.len-c,z.prototype.drawCrosshair.call(this,a,b),b.plotX=d,b.plotY=e,this.cross&&(this.cross.addClass("highcharts-coloraxis-marker").add(this.legendGroup),this.cross.attr({fill:this.crosshair.color})))},getPlotLinePath:function(a,b,d,e,c){return t(c)?this.horiz?["M",c-4,this.top-6,"L",c+4,this.top-6,c,this.top,"Z"]:["M",this.left,c,"L",this.left-6,c+6,this.left-6,c-6,"Z"]:z.prototype.getPlotLinePath.call(this,a,b,d,e)},update:function(a,b){var d=this.chart,e=d.legend;f(this.series,function(a){a.isDirtyData=
!0});a.dataClasses&&e.allItems&&(f(e.allItems,function(a){a.isDataClass&&a.legendGroup.destroy()}),d.isDirtyLegend=!0);d.options[this.coll]=g(this.userOptions,a);z.prototype.update.call(this,a,b);this.legendItem&&(this.setLegendColor(),e.colorizeItem(this,!0))},getDataClassLegendSymbols:function(){var g=this,b=this.chart,l=this.legendItems,e=b.options.legend,c=e.valueDecimals,n=e.valueSuffix||"",r;l.length||f(this.dataClasses,function(e,t){var q=!0,u=e.from,k=e.to;r="";void 0===u?r="\x3c ":void 0===
k&&(r="\x3e ");void 0!==u&&(r+=a.numberFormat(u,c)+n);void 0!==u&&void 0!==k&&(r+=" - ");void 0!==k&&(r+=a.numberFormat(k,c)+n);l.push(h({chart:b,name:r,options:{},drawLegendSymbol:m.drawRectangle,visible:!0,setState:d,isDataClass:!0,setVisible:function(){q=this.visible=!q;f(g.series,function(a){f(a.points,function(a){a.dataClass===t&&a.setVisible(q)})});b.legend.colorizeItem(this,q)}},e))});return l},name:""});f(["fill","stroke"],function(d){a.Fx.prototype[d+"Setter"]=function(){this.elem.attr(d,
B.prototype.tweenColors(D(this.start),D(this.end),this.pos),null,!0)}});y(F.prototype,"getAxes",function(a){var b=this.options.colorAxis;a.call(this);this.colorAxis=[];b&&new B(this,b)});y(r.prototype,"getAllItems",function(a){var b=[],d=this.chart.colorAxis[0];d&&d.options&&(d.options.showInLegend&&(d.options.dataClasses?b=b.concat(d.getDataClassLegendSymbols()):b.push(d)),f(d.series,function(a){a.options.showInLegend=!1}));return b.concat(a.call(this))});y(r.prototype,"colorizeItem",function(a,
b,d){a.call(this,b,d);d&&b.legendColor&&b.legendSymbol.attr({fill:b.legendColor})})})(J);(function(a){var z=a.defined,F=a.each,D=a.noop,B=a.seriesTypes;a.colorPointMixin={isValid:function(){return null!==this.value},setVisible:function(a){var f=this,t=a?"show":"hide";F(["graphic","dataLabel"],function(a){if(f[a])f[a][t]()})},setState:function(f){a.Point.prototype.setState.call(this,f);this.graphic&&this.graphic.attr({zIndex:"hover"===f?1:0})}};a.colorSeriesMixin={pointArrayMap:["value"],axisTypes:["xAxis",
"yAxis","colorAxis"],optionalAxis:"colorAxis",trackerGroups:["group","markerGroup","dataLabelsGroup"],getSymbol:D,parallelArrays:["x","y","value"],colorKey:"value",pointAttribs:B.column.prototype.pointAttribs,translateColors:function(){var a=this,h=this.options.nullColor,t=this.colorAxis,r=this.colorKey;F(this.data,function(f){var d=f[r];if(d=f.options.color||(f.isNull?h:t&&void 0!==d?t.toColor(d,f):f.color||a.color))f.color=d})},colorAttribs:function(a){var f={};z(a.color)&&(f[this.colorProp||"fill"]=
a.color);return f}}})(J);(function(a){function z(a){a&&(a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)}function F(a){this.init(a)}var D=a.addEvent,B=a.Chart,f=a.doc,h=a.each,t=a.extend,r=a.merge,m=a.pick;a=a.wrap;F.prototype.init=function(a){this.chart=a;a.mapNavButtons=[]};F.prototype.update=function(a){var d=this.chart,f=d.options.mapNavigation,h,w,b,l,e,c=function(a){this.handler.call(d,a);z(a)},E=d.mapNavButtons;a&&(f=d.options.mapNavigation=r(d.options.mapNavigation,
a));for(;E.length;)E.pop().destroy();if(m(f.enableButtons,f.enabled)&&!d.renderer.forExport)for(h in a=f.buttons,a)a.hasOwnProperty(h)&&(b=r(f.buttonOptions,a[h]),w=b.theme,w.style=r(b.theme.style,b.style),e=(l=w.states)&&l.hover,l=l&&l.select,w=d.renderer.button(b.text,0,0,c,w,e,l,0,"zoomIn"===h?"topbutton":"bottombutton").addClass("highcharts-map-navigation").attr({width:b.width,height:b.height,title:d.options.lang[h],padding:b.padding,zIndex:5}).add(),w.handler=b.onclick,w.align(t(b,{width:w.width,
height:2*w.height}),null,b.alignTo),D(w.element,"dblclick",z),E.push(w));this.updateEvents(f)};F.prototype.updateEvents=function(a){var d=this.chart;m(a.enableDoubleClickZoom,a.enabled)||a.enableDoubleClickZoomTo?this.unbindDblClick=this.unbindDblClick||D(d.container,"dblclick",function(a){d.pointer.onContainerDblClick(a)}):this.unbindDblClick&&(this.unbindDblClick=this.unbindDblClick());m(a.enableMouseWheelZoom,a.enabled)?this.unbindMouseWheel=this.unbindMouseWheel||D(d.container,void 0===f.onmousewheel?
"DOMMouseScroll":"mousewheel",function(a){d.pointer.onContainerMouseWheel(a);z(a);return!1}):this.unbindMouseWheel&&(this.unbindMouseWheel=this.unbindMouseWheel())};t(B.prototype,{fitToBox:function(a,f){h([["x","width"],["y","height"]],function(d){var g=d[0];d=d[1];a[g]+a[d]>f[g]+f[d]&&(a[d]>f[d]?(a[d]=f[d],a[g]=f[g]):a[g]=f[g]+f[d]-a[d]);a[d]>f[d]&&(a[d]=f[d]);a[g]<f[g]&&(a[g]=f[g])});return a},mapZoom:function(a,f,h,r,t){var b=this.xAxis[0],d=b.max-b.min,e=m(f,b.min+d/2),c=d*a,d=this.yAxis[0],g=
d.max-d.min,n=m(h,d.min+g/2),g=g*a,e=this.fitToBox({x:e-c*(r?(r-b.pos)/b.len:.5),y:n-g*(t?(t-d.pos)/d.len:.5),width:c,height:g},{x:b.dataMin,y:d.dataMin,width:b.dataMax-b.dataMin,height:d.dataMax-d.dataMin}),c=e.x<=b.dataMin&&e.width>=b.dataMax-b.dataMin&&e.y<=d.dataMin&&e.height>=d.dataMax-d.dataMin;r&&(b.fixTo=[r-b.pos,f]);t&&(d.fixTo=[t-d.pos,h]);void 0===a||c?(b.setExtremes(void 0,void 0,!1),d.setExtremes(void 0,void 0,!1)):(b.setExtremes(e.x,e.x+e.width,!1),d.setExtremes(e.y,e.y+e.height,!1));
this.redraw()}});a(B.prototype,"render",function(a){this.mapNavigation=new F(this);this.mapNavigation.update();a.call(this)})})(J);(function(a){var z=a.extend,F=a.pick,D=a.Pointer;a=a.wrap;z(D.prototype,{onContainerDblClick:function(a){var f=this.chart;a=this.normalize(a);f.options.mapNavigation.enableDoubleClickZoomTo?f.pointer.inClass(a.target,"highcharts-tracker")&&f.hoverPoint&&f.hoverPoint.zoomTo():f.isInsidePlot(a.chartX-f.plotLeft,a.chartY-f.plotTop)&&f.mapZoom(.5,f.xAxis[0].toValue(a.chartX),
f.yAxis[0].toValue(a.chartY),a.chartX,a.chartY)},onContainerMouseWheel:function(a){var f=this.chart,h;a=this.normalize(a);h=a.detail||-(a.wheelDelta/120);f.isInsidePlot(a.chartX-f.plotLeft,a.chartY-f.plotTop)&&f.mapZoom(Math.pow(f.options.mapNavigation.mouseWheelSensitivity,h),f.xAxis[0].toValue(a.chartX),f.yAxis[0].toValue(a.chartY),a.chartX,a.chartY)}});a(D.prototype,"zoomOption",function(a){var f=this.chart.options.mapNavigation;F(f.enableTouchZoom,f.enabled)&&(this.chart.options.chart.pinchType=
"xy");a.apply(this,[].slice.call(arguments,1))});a(D.prototype,"pinchTranslate",function(a,f,h,t,r,m,d){a.call(this,f,h,t,r,m,d);"map"===this.chart.options.chart.type&&this.hasZoom&&(a=t.scaleX>t.scaleY,this.pinchTranslateDirection(!a,f,h,t,r,m,d,a?t.scaleX:t.scaleY))})})(J);(function(a){var z=a.color,F=a.ColorAxis,D=a.colorPointMixin,B=a.each,f=a.extend,h=a.isNumber,t=a.map,r=a.merge,m=a.noop,d=a.pick,g=a.isArray,n=a.Point,y=a.Series,w=a.seriesType,b=a.seriesTypes,l=a.splat,e=void 0!==a.doc.documentElement.style.vectorEffect;
w("map","scatter",{allAreas:!0,animation:!1,nullColor:"#f7f7f7",borderColor:"#cccccc",borderWidth:1,marker:null,stickyTracking:!1,joinBy:"hc-key",dataLabels:{formatter:function(){return this.point.value},inside:!0,verticalAlign:"middle",crop:!1,overflow:!1,padding:0},turboThreshold:0,tooltip:{followPointer:!0,pointFormat:"{point.name}: {point.value}\x3cbr/\x3e"},states:{normal:{animation:!0},hover:{brightness:.2,halo:null},select:{color:"#cccccc"}}},r(a.colorSeriesMixin,{type:"map",supportsDrilldown:!0,
getExtremesFromAll:!0,useMapGeometry:!0,forceDL:!0,searchPoint:m,directTouch:!0,preserveAspectRatio:!0,pointArrayMap:["value"],getBox:function(b){var c=Number.MAX_VALUE,e=-c,f=c,g=-c,l=c,n=c,k=this.xAxis,m=this.yAxis,r;B(b||[],function(b){if(b.path){"string"===typeof b.path&&(b.path=a.splitPath(b.path));var k=b.path||[],m=k.length,q=!1,t=-c,u=c,w=-c,x=c,v=b.properties;if(!b._foundBox){for(;m--;)h(k[m])&&(q?(t=Math.max(t,k[m]),u=Math.min(u,k[m])):(w=Math.max(w,k[m]),x=Math.min(x,k[m])),q=!q);b._midX=
u+(t-u)*(b.middleX||v&&v["hc-middle-x"]||.5);b._midY=x+(w-x)*(b.middleY||v&&v["hc-middle-y"]||.5);b._maxX=t;b._minX=u;b._maxY=w;b._minY=x;b.labelrank=d(b.labelrank,(t-u)*(w-x));b._foundBox=!0}e=Math.max(e,b._maxX);f=Math.min(f,b._minX);g=Math.max(g,b._maxY);l=Math.min(l,b._minY);n=Math.min(b._maxX-b._minX,b._maxY-b._minY,n);r=!0}});r&&(this.minY=Math.min(l,d(this.minY,c)),this.maxY=Math.max(g,d(this.maxY,-c)),this.minX=Math.min(f,d(this.minX,c)),this.maxX=Math.max(e,d(this.maxX,-c)),k&&void 0===k.options.minRange&&
(k.minRange=Math.min(5*n,(this.maxX-this.minX)/5,k.minRange||c)),m&&void 0===m.options.minRange&&(m.minRange=Math.min(5*n,(this.maxY-this.minY)/5,m.minRange||c)))},getExtremes:function(){y.prototype.getExtremes.call(this,this.valueData);this.chart.hasRendered&&this.isDirtyData&&this.getBox(this.options.data);this.valueMin=this.dataMin;this.valueMax=this.dataMax;this.dataMin=this.minY;this.dataMax=this.maxY},translatePath:function(a){var b=!1,c=this.xAxis,d=this.yAxis,e=c.min,f=c.transA,c=c.minPixelPadding,
g=d.min,k=d.transA,d=d.minPixelPadding,l,m=[];if(a)for(l=a.length;l--;)h(a[l])?(m[l]=b?(a[l]-e)*f+c:(a[l]-g)*k+d,b=!b):m[l]=a[l];return m},setData:function(b,d,e,f){var c=this.options,m=this.chart.options.chart,n=m&&m.map,k=c.mapData,q=c.joinBy,u=null===q,w=c.keys||this.pointArrayMap,E=[],p={},C,z=this.chart.mapTransforms;!k&&n&&(k="string"===typeof n?a.maps[n]:n);u&&(q="_i");q=this.joinBy=l(q);q[1]||(q[1]=q[0]);b&&B(b,function(a,d){var e=0;if(h(a))b[d]={value:a};else if(g(a)){b[d]={};!c.keys&&a.length>
w.length&&"string"===typeof a[0]&&(b[d]["hc-key"]=a[0],++e);for(var f=0;f<w.length;++f,++e)w[f]&&(b[d][w[f]]=a[e])}u&&(b[d]._i=d)});this.getBox(b);if(this.chart.mapTransforms=z=m&&m.mapTransforms||k&&k["hc-transform"]||z)for(C in z)z.hasOwnProperty(C)&&C.rotation&&(C.cosAngle=Math.cos(C.rotation),C.sinAngle=Math.sin(C.rotation));if(k){"FeatureCollection"===k.type&&(this.mapTitle=k.title,k=a.geojson(k,this.type,this));this.mapData=k;this.mapMap={};for(C=0;C<k.length;C++)m=k[C],n=m.properties,m._i=
C,q[0]&&n&&n[q[0]]&&(m[q[0]]=n[q[0]]),p[m[q[0]]]=m;this.mapMap=p;b&&q[1]&&B(b,function(a){p[a[q[1]]]&&E.push(p[a[q[1]]])});c.allAreas?(this.getBox(k),b=b||[],q[1]&&B(b,function(a){E.push(a[q[1]])}),E="|"+t(E,function(a){return a&&a[q[0]]}).join("|")+"|",B(k,function(a){q[0]&&-1!==E.indexOf("|"+a[q[0]]+"|")||(b.push(r(a,{value:null})),f=!1)})):this.getBox(E)}y.prototype.setData.call(this,b,d,e,f)},drawGraph:m,drawDataLabels:m,doFullTranslate:function(){return this.isDirtyData||this.chart.isResizing||
this.chart.renderer.isVML||!this.baseTrans},translate:function(){var a=this,b=a.xAxis,d=a.yAxis,e=a.doFullTranslate();a.generatePoints();B(a.data,function(c){c.plotX=b.toPixels(c._midX,!0);c.plotY=d.toPixels(c._midY,!0);e&&(c.shapeType="path",c.shapeArgs={d:a.translatePath(c.path)})});a.translateColors()},pointAttribs:function(a,d){d=b.column.prototype.pointAttribs.call(this,a,d);a.isFading&&delete d.fill;e?d["vector-effect"]="non-scaling-stroke":d["stroke-width"]="inherit";return d},drawPoints:function(){var a=
this,d=a.xAxis,f=a.yAxis,g=a.group,h=a.chart,l=h.renderer,m,k,n,r,t=this.baseTrans,w,p,y,z,D;a.transformGroup||(a.transformGroup=l.g().attr({scaleX:1,scaleY:1}).add(g),a.transformGroup.survive=!0);a.doFullTranslate()?(h.hasRendered&&B(a.points,function(b){b.shapeArgs&&(b.shapeArgs.fill=a.pointAttribs(b,b.state).fill)}),a.group=a.transformGroup,b.column.prototype.drawPoints.apply(a),a.group=g,B(a.points,function(a){a.graphic&&(a.name&&a.graphic.addClass("highcharts-name-"+a.name.replace(/ /g,"-").toLowerCase()),
a.properties&&a.properties["hc-key"]&&a.graphic.addClass("highcharts-key-"+a.properties["hc-key"].toLowerCase()))}),this.baseTrans={originX:d.min-d.minPixelPadding/d.transA,originY:f.min-f.minPixelPadding/f.transA+(f.reversed?0:f.len/f.transA),transAX:d.transA,transAY:f.transA},this.transformGroup.animate({translateX:0,translateY:0,scaleX:1,scaleY:1})):(m=d.transA/t.transAX,k=f.transA/t.transAY,n=d.toPixels(t.originX,!0),r=f.toPixels(t.originY,!0),.99<m&&1.01>m&&.99<k&&1.01>k&&(k=m=1,n=Math.round(n),
r=Math.round(r)),w=this.transformGroup,h.renderer.globalAnimation?(p=w.attr("translateX"),y=w.attr("translateY"),z=w.attr("scaleX"),D=w.attr("scaleY"),w.attr({animator:0}).animate({animator:1},{step:function(a,b){w.attr({translateX:p+(n-p)*b.pos,translateY:y+(r-y)*b.pos,scaleX:z+(m-z)*b.pos,scaleY:D+(k-D)*b.pos})}})):w.attr({translateX:n,translateY:r,scaleX:m,scaleY:k}));e||a.group.element.setAttribute("stroke-width",a.options[a.pointAttrToOptions&&a.pointAttrToOptions["stroke-width"]||"borderWidth"]/
(m||1));this.drawMapDataLabels()},drawMapDataLabels:function(){y.prototype.drawDataLabels.call(this);this.dataLabelsGroup&&this.dataLabelsGroup.clip(this.chart.clipRect)},render:function(){var a=this,b=y.prototype.render;a.chart.renderer.isVML&&3E3<a.data.length?setTimeout(function(){b.call(a)}):b.call(a)},animate:function(a){var b=this.options.animation,c=this.group,d=this.xAxis,e=this.yAxis,f=d.pos,g=e.pos;this.chart.renderer.isSVG&&(!0===b&&(b={duration:1E3}),a?c.attr({translateX:f+d.len/2,translateY:g+
e.len/2,scaleX:.001,scaleY:.001}):(c.animate({translateX:f,translateY:g,scaleX:1,scaleY:1},b),this.animate=null))},animateDrilldown:function(a){var b=this.chart.plotBox,c=this.chart.drilldownLevels[this.chart.drilldownLevels.length-1],d=c.bBox,e=this.chart.options.drilldown.animation;a||(a=Math.min(d.width/b.width,d.height/b.height),c.shapeArgs={scaleX:a,scaleY:a,translateX:d.x,translateY:d.y},B(this.points,function(a){a.graphic&&a.graphic.attr(c.shapeArgs).animate({scaleX:1,scaleY:1,translateX:0,
translateY:0},e)}),this.animate=null)},drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,animateDrillupFrom:function(a){b.column.prototype.animateDrillupFrom.call(this,a)},animateDrillupTo:function(a){b.column.prototype.animateDrillupTo.call(this,a)}}),f({applyOptions:function(a,b){a=n.prototype.applyOptions.call(this,a,b);b=this.series;var c=b.joinBy;b.mapData&&((c=void 0!==a[c[1]]&&b.mapMap[a[c[1]]])?(b.xyFromShape&&(a.x=c._midX,a.y=c._midY),f(a,c)):a.value=a.value||null);return a},onMouseOver:function(a){clearTimeout(this.colorInterval);
if(null!==this.value)n.prototype.onMouseOver.call(this,a);else this.series.onMouseOut(a)},onMouseOut:function(){var a=this,b=+new Date,d=z(this.series.pointAttribs(a).fill),e=z(this.series.pointAttribs(a,"hover").fill),f=a.series.options.states.normal.animation,g=f&&(f.duration||500);g&&4===d.rgba.length&&4===e.rgba.length&&"select"!==a.state&&(clearTimeout(a.colorInterval),a.colorInterval=setInterval(function(){var c=(new Date-b)/g,f=a.graphic;1<c&&(c=1);f&&f.attr("fill",F.prototype.tweenColors.call(0,
e,d,c));1<=c&&clearTimeout(a.colorInterval)},13),a.isFading=!0);n.prototype.onMouseOut.call(a);a.isFading=null},zoomTo:function(){var a=this.series;a.xAxis.setExtremes(this._minX,this._maxX,!1);a.yAxis.setExtremes(this._minY,this._maxY,!1);a.chart.redraw()}},D))})(J);(function(a){var z=a.seriesType,F=a.seriesTypes;z("mapline","map",{lineWidth:1,fillColor:"none"},{type:"mapline",colorProp:"stroke",pointAttrToOptions:{stroke:"color","stroke-width":"lineWidth"},pointAttribs:function(a,z){a=F.map.prototype.pointAttribs.call(this,
a,z);a.fill=this.options.fillColor;return a},drawLegendSymbol:F.line.prototype.drawLegendSymbol})})(J);(function(a){var z=a.merge,F=a.Point;a=a.seriesType;a("mappoint","scatter",{dataLabels:{enabled:!0,formatter:function(){return this.point.name},crop:!1,defer:!1,overflow:!1,style:{color:"#000000"}}},{type:"mappoint",forceDL:!0},{applyOptions:function(a,B){a=void 0!==a.lat&&void 0!==a.lon?z(a,this.series.chart.fromLatLonToPoint(a)):a;return F.prototype.applyOptions.call(this,a,B)}})})(J);(function(a){var z=
a.arrayMax,F=a.arrayMin,D=a.Axis,B=a.color,f=a.each,h=a.isNumber,t=a.noop,r=a.pick,m=a.pInt,d=a.Point,g=a.Series,n=a.seriesType,y=a.seriesTypes;n("bubble","scatter",{dataLabels:{formatter:function(){return this.point.z},inside:!0,verticalAlign:"middle"},marker:{lineColor:null,lineWidth:1,radius:null,states:{hover:{radiusPlus:0}},symbol:"circle"},minSize:8,maxSize:"20%",softThreshold:!1,states:{hover:{halo:{size:5}}},tooltip:{pointFormat:"({point.x}, {point.y}), Size: {point.z}"},turboThreshold:0,
zThreshold:0,zoneAxis:"z"},{pointArrayMap:["y","z"],parallelArrays:["x","y","z"],trackerGroups:["markerGroup","dataLabelsGroup"],bubblePadding:!0,zoneAxis:"z",directTouch:!0,pointAttribs:function(a,b){var d=r(this.options.marker.fillOpacity,.5);a=g.prototype.pointAttribs.call(this,a,b);1!==d&&(a.fill=B(a.fill).setOpacity(d).get("rgba"));return a},getRadii:function(a,b,d,e){var c,f,g,h=this.zData,l=[],m=this.options,n="width"!==m.sizeBy,k=m.zThreshold,r=b-a;f=0;for(c=h.length;f<c;f++)g=h[f],m.sizeByAbsoluteValue&&
null!==g&&(g=Math.abs(g-k),b=Math.max(b-k,Math.abs(a-k)),a=0),null===g?g=null:g<a?g=d/2-1:(g=0<r?(g-a)/r:.5,n&&0<=g&&(g=Math.sqrt(g)),g=Math.ceil(d+g*(e-d))/2),l.push(g);this.radii=l},animate:function(a){var b=this.options.animation;a||(f(this.points,function(a){var d=a.graphic,c;d&&d.width&&(c={x:d.x,y:d.y,width:d.width,height:d.height},d.attr({x:a.plotX,y:a.plotY,width:1,height:1}),d.animate(c,b))}),this.animate=null)},translate:function(){var d,b=this.data,f,e,c=this.radii;y.scatter.prototype.translate.call(this);
for(d=b.length;d--;)f=b[d],e=c?c[d]:0,h(e)&&e>=this.minPxSize/2?(f.marker=a.extend(f.marker,{radius:e,width:2*e,height:2*e}),f.dlBox={x:f.plotX-e,y:f.plotY-e,width:2*e,height:2*e}):f.shapeArgs=f.plotY=f.dlBox=void 0},alignDataLabel:y.column.prototype.alignDataLabel,buildKDTree:t,applyZones:t},{haloPath:function(a){return d.prototype.haloPath.call(this,0===a?0:(this.marker?this.marker.radius||0:0)+a)},ttBelow:!1});D.prototype.beforePadding=function(){var a=this,b=this.len,d=this.chart,e=0,c=b,g=this.isXAxis,
n=g?"xData":"yData",q=this.min,t={},y=Math.min(d.plotWidth,d.plotHeight),B=Number.MAX_VALUE,k=-Number.MAX_VALUE,D=this.max-q,I=b/D,J=[];f(this.series,function(b){var c=b.options;!b.bubblePadding||!b.visible&&d.options.chart.ignoreHiddenSeries||(a.allowZoomOutside=!0,J.push(b),g&&(f(["minSize","maxSize"],function(a){var b=c[a],d=/%$/.test(b),b=m(b);t[a]=d?y*b/100:b}),b.minPxSize=t.minSize,b.maxPxSize=Math.max(t.maxSize,t.minSize),b=b.zData,b.length&&(B=r(c.zMin,Math.min(B,Math.max(F(b),!1===c.displayNegative?
c.zThreshold:-Number.MAX_VALUE))),k=r(c.zMax,Math.max(k,z(b))))))});f(J,function(b){var d=b[n],f=d.length,m;g&&b.getRadii(B,k,b.minPxSize,b.maxPxSize);if(0<D)for(;f--;)h(d[f])&&a.dataMin<=d[f]&&d[f]<=a.dataMax&&(m=b.radii[f],e=Math.min((d[f]-q)*I-m,e),c=Math.max((d[f]-q)*I+m,c))});J.length&&0<D&&!this.isLog&&(c-=b,I*=(b+e-c)/b,f([["min","userMin",e],["max","userMax",c]],function(b){void 0===r(a.options[b[0]],a[b[1]])&&(a[b[0]]+=b[2]/I)}))}})(J);(function(a){var z=a.merge,F=a.Point,D=a.seriesType,
B=a.seriesTypes;B.bubble&&D("mapbubble","bubble",{animationLimit:500,tooltip:{pointFormat:"{point.name}: {point.z}"}},{xyFromShape:!0,type:"mapbubble",pointArrayMap:["z"],getMapData:B.map.prototype.getMapData,getBox:B.map.prototype.getBox,setData:B.map.prototype.setData},{applyOptions:function(a,h){return a&&void 0!==a.lat&&void 0!==a.lon?F.prototype.applyOptions.call(this,z(a,this.series.chart.fromLatLonToPoint(a)),h):B.map.prototype.pointClass.prototype.applyOptions.call(this,a,h)},ttBelow:!1})})(J);
(function(a){var z=a.colorPointMixin,F=a.each,D=a.merge,B=a.noop,f=a.pick,h=a.Series,t=a.seriesType,r=a.seriesTypes;t("heatmap","scatter",{animation:!1,borderWidth:0,nullColor:"#f7f7f7",dataLabels:{formatter:function(){return this.point.value},inside:!0,verticalAlign:"middle",crop:!1,overflow:!1,padding:0},marker:null,pointRange:null,tooltip:{pointFormat:"{point.x}, {point.y}: {point.value}\x3cbr/\x3e"},states:{normal:{animation:!0},hover:{halo:!1,brightness:.2}}},D(a.colorSeriesMixin,{pointArrayMap:["y",
"value"],hasPointSpecificOptions:!0,supportsDrilldown:!0,getExtremesFromAll:!0,directTouch:!0,init:function(){var a;r.scatter.prototype.init.apply(this,arguments);a=this.options;a.pointRange=f(a.pointRange,a.colsize||1);this.yAxis.axisPointRange=a.rowsize||1},translate:function(){var a=this.options,d=this.xAxis,f=this.yAxis,h=function(a,d,b){return Math.min(Math.max(d,a),b)};this.generatePoints();F(this.points,function(g){var m=(a.colsize||1)/2,b=(a.rowsize||1)/2,l=h(Math.round(d.len-d.translate(g.x-
m,0,1,0,1)),-d.len,2*d.len),m=h(Math.round(d.len-d.translate(g.x+m,0,1,0,1)),-d.len,2*d.len),e=h(Math.round(f.translate(g.y-b,0,1,0,1)),-f.len,2*f.len),b=h(Math.round(f.translate(g.y+b,0,1,0,1)),-f.len,2*f.len);g.plotX=g.clientX=(l+m)/2;g.plotY=(e+b)/2;g.shapeType="rect";g.shapeArgs={x:Math.min(l,m),y:Math.min(e,b),width:Math.abs(m-l),height:Math.abs(b-e)}});this.translateColors()},drawPoints:function(){r.column.prototype.drawPoints.call(this);F(this.points,function(a){a.graphic.attr(this.colorAttribs(a))},
this)},animate:B,getBox:B,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,alignDataLabel:r.column.prototype.alignDataLabel,getExtremes:function(){h.prototype.getExtremes.call(this,this.valueData);this.valueMin=this.dataMin;this.valueMax=this.dataMax;h.prototype.getExtremes.call(this)}}),z)})(J);(function(a){function z(a,d){var f,h,m,r=!1,b=a.x,l=a.y;a=0;for(f=d.length-1;a<d.length;f=a++)h=d[a][1]>l,m=d[f][1]>l,h!==m&&b<(d[f][0]-d[a][0])*(l-d[a][1])/(d[f][1]-d[a][1])+d[a][0]&&(r=!r);return r}var F=
a.Chart,D=a.each,B=a.extend,f=a.format,h=a.merge,t=a.win,r=a.wrap;F.prototype.transformFromLatLon=function(f,d){if(void 0===t.proj4)return a.error(21),{x:0,y:null};f=t.proj4(d.crs,[f.lon,f.lat]);var g=d.cosAngle||d.rotation&&Math.cos(d.rotation),h=d.sinAngle||d.rotation&&Math.sin(d.rotation);f=d.rotation?[f[0]*g+f[1]*h,-f[0]*h+f[1]*g]:f;return{x:((f[0]-(d.xoffset||0))*(d.scale||1)+(d.xpan||0))*(d.jsonres||1)+(d.jsonmarginX||0),y:(((d.yoffset||0)-f[1])*(d.scale||1)+(d.ypan||0))*(d.jsonres||1)-(d.jsonmarginY||
0)}};F.prototype.transformToLatLon=function(f,d){if(void 0===t.proj4)a.error(21);else{f={x:((f.x-(d.jsonmarginX||0))/(d.jsonres||1)-(d.xpan||0))/(d.scale||1)+(d.xoffset||0),y:((-f.y-(d.jsonmarginY||0))/(d.jsonres||1)+(d.ypan||0))/(d.scale||1)+(d.yoffset||0)};var g=d.cosAngle||d.rotation&&Math.cos(d.rotation),h=d.sinAngle||d.rotation&&Math.sin(d.rotation);d=t.proj4(d.crs,"WGS84",d.rotation?{x:f.x*g+f.y*-h,y:f.x*h+f.y*g}:f);return{lat:d.y,lon:d.x}}};F.prototype.fromPointToLatLon=function(f){var d=this.mapTransforms,
g;if(d){for(g in d)if(d.hasOwnProperty(g)&&d[g].hitZone&&z({x:f.x,y:-f.y},d[g].hitZone.coordinates[0]))return this.transformToLatLon(f,d[g]);return this.transformToLatLon(f,d["default"])}a.error(22)};F.prototype.fromLatLonToPoint=function(f){var d=this.mapTransforms,g,h;if(!d)return a.error(22),{x:0,y:null};for(g in d)if(d.hasOwnProperty(g)&&d[g].hitZone&&(h=this.transformFromLatLon(f,d[g]),z({x:h.x,y:-h.y},d[g].hitZone.coordinates[0])))return h;return this.transformFromLatLon(f,d["default"])};a.geojson=
function(a,d,g){var h=[],m=[],r=function(a){var b,d=a.length;m.push("M");for(b=0;b<d;b++)1===b&&m.push("L"),m.push(a[b][0],-a[b][1])};d=d||"map";D(a.features,function(a){var b=a.geometry,e=b.type,b=b.coordinates;a=a.properties;var c;m=[];"map"===d||"mapbubble"===d?("Polygon"===e?(D(b,r),m.push("Z")):"MultiPolygon"===e&&(D(b,function(a){D(a,r)}),m.push("Z")),m.length&&(c={path:m})):"mapline"===d?("LineString"===e?r(b):"MultiLineString"===e&&D(b,r),m.length&&(c={path:m})):"mappoint"===d&&"Point"===
e&&(c={x:b[0],y:-b[1]});c&&h.push(B(c,{name:a.name||a.NAME,properties:a}))});g&&a.copyrightShort&&(g.chart.mapCredits=f(g.chart.options.credits.mapText,{geojson:a}),g.chart.mapCreditsFull=f(g.chart.options.credits.mapTextFull,{geojson:a}));return h};r(F.prototype,"addCredits",function(a,d){d=h(!0,this.options.credits,d);this.mapCredits&&(d.href=null);a.call(this,d);this.credits&&this.mapCreditsFull&&this.credits.attr({title:this.mapCreditsFull})})})(J);(function(a){function z(a,d,f,h,b,l,e,c){return["M",
a+b,d,"L",a+f-l,d,"C",a+f-l/2,d,a+f,d+l/2,a+f,d+l,"L",a+f,d+h-e,"C",a+f,d+h-e/2,a+f-e/2,d+h,a+f-e,d+h,"L",a+c,d+h,"C",a+c/2,d+h,a,d+h-c/2,a,d+h-c,"L",a,d+b,"C",a,d+b/2,a+b/2,d,a+b,d,"Z"]}var F=a.Chart,D=a.defaultOptions,B=a.each,f=a.extend,h=a.merge,t=a.pick,r=a.Renderer,m=a.SVGRenderer,d=a.VMLRenderer;f(D.lang,{zoomIn:"Zoom in",zoomOut:"Zoom out"});D.mapNavigation={buttonOptions:{alignTo:"plotBox",align:"left",verticalAlign:"top",x:0,width:18,height:18,padding:5,style:{fontSize:"15px",fontWeight:"bold"},
theme:{"stroke-width":1,"text-align":"center"}},buttons:{zoomIn:{onclick:function(){this.mapZoom(.5)},text:"+",y:0},zoomOut:{onclick:function(){this.mapZoom(2)},text:"-",y:28}},mouseWheelSensitivity:1.1};a.splitPath=function(a){var d;a=a.replace(/([A-Za-z])/g," $1 ");a=a.replace(/^\s*/,"").replace(/\s*$/,"");a=a.split(/[ ,]+/);for(d=0;d<a.length;d++)/[a-zA-Z]/.test(a[d])||(a[d]=parseFloat(a[d]));return a};a.maps={};m.prototype.symbols.topbutton=function(a,d,f,h,b){return z(a-1,d-1,f,h,b.r,b.r,0,0)};
m.prototype.symbols.bottombutton=function(a,d,f,h,b){return z(a-1,d-1,f,h,0,0,b.r,b.r)};r===d&&B(["topbutton","bottombutton"],function(a){d.prototype.symbols[a]=m.prototype.symbols[a]});a.Map=a.mapChart=function(d,f,m){var g="string"===typeof d||d.nodeName,b=arguments[g?1:0],l={endOnTick:!1,visible:!1,minPadding:0,maxPadding:0,startOnTick:!1},e,c=a.getOptions().credits;e=b.series;b.series=null;b=h({chart:{panning:"xy",type:"map"},credits:{mapText:t(c.mapText,' \u00a9 \x3ca href\x3d"{geojson.copyrightUrl}"\x3e{geojson.copyrightShort}\x3c/a\x3e'),
mapTextFull:t(c.mapTextFull,"{geojson.copyright}")},tooltip:{followTouchMove:!1},xAxis:l,yAxis:h(l,{reversed:!0})},b,{chart:{inverted:!1,alignTicks:!1}});b.series=e;return g?new F(d,b,m):new F(b,f)}})(J);return J});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 17043 17044 17045 17046 17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 17151 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 17353 17354 17355 17356 17357 17358 17359 17360 17361 17362 17363 17364 17365 17366 17367 17368 17369 17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 17507 17508 17509 17510 17511 17512 17513 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 17531 17532 17533 17534 17535 17536 17537 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 17598 17599 17600 17601 17602 17603 17604 17605 17606 17607 17608 17609 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 17639 17640 17641 17642 17643 17644 17645 17646 17647 17648 17649 17650 17651 17652 17653 17654 17655 17656 17657 17658 17659 17660 17661 17662 17663 17664 17665 17666 17667 17668 17669 17670 17671 17672 17673 17674 17675 17676 17677 17678 17679 17680 17681 17682 17683 17684 17685 17686 17687 17688 17689 17690 17691 17692 17693 17694 17695 17696 17697 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 17748 17749 17750 17751 17752 17753 17754 17755 17756 17757 17758 17759 17760 17761 17762 17763 17764 17765 17766 17767 17768 17769 17770 17771 17772 17773 17774 17775 17776 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 17787 17788 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 17799 17800 17801 17802 17803 17804 17805 17806 17807 17808 17809 17810 17811 17812 17813 17814 17815 17816 17817 17818 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 17843 17844 17845 17846 17847 17848 17849 17850 17851 17852 17853 17854 17855 17856 17857 17858 17859 17860 17861 17862 17863 17864 17865 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 17880 17881 17882 17883 17884 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 17931 17932 17933 17934 17935 17936 17937 17938 17939 17940 17941 17942 17943 17944 17945 17946 17947 17948 17949 17950 17951 17952 17953 17954 17955 17956 17957 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 17988 17989 17990 17991 17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 18002 18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 18038 18039 18040 18041 18042 18043 18044 18045 18046 18047 18048 18049 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 18103 18104 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 18167 18168 18169 18170 18171 18172 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 18185 18186 18187 18188 18189 18190 18191 18192 18193 18194 18195 18196 18197 18198 18199 18200 18201 18202 18203 18204 18205 18206 18207 18208 18209 18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 18242 18243 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 18470 18471 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 18559 18560 18561 18562 18563 18564 18565 18566 18567 18568 18569 18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 18793 18794 18795 18796 18797 18798 18799 18800 18801 18802 18803 18804 18805 18806 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 18880 18881 18882 18883 18884 18885 18886 18887 18888 18889 18890 18891 18892 18893 18894 18895 18896 18897 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 19000 19001 19002 19003 19004 19005 19006 19007 19008 19009 19010 19011 19012 19013 19014 19015 19016 19017 19018 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 19038 19039 19040 19041 19042 19043 19044 19045 19046 19047 19048 19049 19050 19051 19052 19053 19054 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 19088 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 19101 19102 19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352 19353 19354 19355 19356 19357 19358 19359 19360 19361 19362 19363 19364 19365 19366 19367 19368 19369 19370 19371 19372 19373 19374 19375 19376 19377 19378 19379 19380 19381 19382 19383 19384 19385 19386 19387 19388 19389 19390 19391 19392 19393 19394 19395 19396 19397 19398 19399 19400 19401 19402 19403 19404 19405 19406 19407 19408 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 19440 19441 19442 19443 19444 19445 19446 19447 19448 19449 19450 19451 19452 19453 19454 19455 19456 19457 19458 19459 19460 19461 19462 19463 19464 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 19483 19484 19485 19486 19487 19488 19489 19490 19491 19492 19493 19494 19495 19496 19497 19498 19499 19500 19501 19502 19503 19504 19505 19506 19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 19545 19546 19547 19548 19549 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 19565 19566 19567 19568 19569 19570 19571 19572 19573 19574 19575 19576 19577 19578 19579 19580 19581 19582 19583 19584 19585 19586 19587 19588 19589 19590 19591 19592 19593 19594 19595 19596 19597 19598 19599 19600 19601 19602 19603 19604 19605 19606 19607 19608 19609 19610 19611 19612 19613 19614 19615 19616 19617 19618 19619 19620 19621 19622 19623 19624 19625 19626 19627 19628 19629 19630 19631 19632 19633 19634 19635 19636 19637 19638 19639 19640 19641 19642 19643 19644 19645 19646 19647 19648 19649 19650 19651 19652 19653 19654 19655 19656 19657 19658 19659 19660 19661 19662 19663 19664 19665 19666 19667 19668 19669 19670 19671 19672 19673 19674 19675 19676 19677 19678 19679 19680 19681 19682 19683 19684 19685 19686 19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 19711 19712 19713 19714 19715 19716 19717 19718 19719 19720 19721 19722 19723 19724 19725 19726 19727 19728 19729 19730 19731 19732 19733 19734 19735 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 19760 19761 19762 19763 19764 19765 19766 19767 19768 19769 19770 19771 19772 19773 19774 19775 19776 19777 19778 19779 19780 19781 19782 19783 19784 19785 19786 19787 19788 19789 19790 19791 19792 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 19865 19866 19867 19868 19869 19870 19871 19872 19873 19874 19875 19876 19877 19878 19879 19880 19881 19882 19883 19884 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 20131 20132 20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 20148 20149 20150 20151 20152 20153 20154 20155 20156 20157 20158 20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 20326 20327 20328 20329 20330 20331 20332 20333 20334 20335 20336 20337 20338 20339 20340 20341 20342 20343 20344 20345 20346 20347 20348 20349 20350 20351 20352 20353 20354 20355 20356 20357 20358 20359 20360 20361 20362 20363 20364 20365 20366 20367 20368 20369 20370 20371 20372 20373 20374 20375 20376 20377 20378 20379 20380 20381 20382 20383 20384 20385 20386 20387 20388 20389 20390 20391 20392 20393 20394 20395 20396 20397 20398 20399 20400 20401 20402 20403 20404 20405 20406 20407 20408 20409 20410 20411 20412 20413 20414 20415 20416 20417 20418 20419 20420 20421 20422 20423 20424 20425 20426 20427 20428 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 20485 20486 20487 20488 20489 20490 20491 20492 20493 20494 20495 20496 20497 20498 20499 20500 20501 20502 20503 20504 20505 20506 20507 20508 20509 20510 20511 20512 20513 20514 20515 20516 20517 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 20530 20531 20532 20533 20534 20535 20536 20537 20538 20539 20540 20541 20542 20543 20544 20545 20546 20547 20548 20549 20550 20551 20552 20553 20554 20555 20556 20557 20558 20559 20560 20561 20562 20563 20564 20565 20566 20567 20568 20569 20570 20571 20572 20573 20574 20575 20576 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 20607 20608 20609 20610 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 20646 20647 20648 20649 20650 20651 20652 20653 20654 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 20672 20673 20674 20675 20676 20677 20678 20679 20680 20681 20682 20683 20684 20685 20686 20687 20688 20689 20690 20691 20692 20693 20694 20695 20696 20697 20698 20699 20700 20701 20702 20703 20704 20705 20706 20707 20708 20709 20710 20711 20712 20713 20714 20715 20716 20717 20718 20719 20720 20721 20722 20723 20724 20725 20726 20727 20728 20729 20730 20731 20732 20733 20734 20735 20736 20737 20738 20739 20740 20741 20742 20743 20744 20745 20746 20747 20748 20749 20750 20751 20752 20753 20754 20755 20756 20757 20758 20759 20760 20761 20762 20763 20764 20765 20766 20767 20768 20769 20770 20771 20772 20773 20774 20775 20776 20777 20778 20779 20780 20781 20782 20783 20784 20785 20786 20787 20788 20789 20790 20791 20792 20793 20794 20795 20796 20797 20798 20799 20800 20801 20802 20803 20804 20805 20806 20807 20808 20809 20810 20811 20812 20813 20814 20815 20816 20817 20818 20819 20820 20821 20822 20823 20824 20825 20826 20827 20828 20829 20830 20831 20832 20833 20834 20835 20836 20837 20838 20839 20840 20841 20842 20843 20844 20845 20846 20847 20848 20849 20850 20851 20852 20853 20854 20855 20856 20857 20858 20859 20860 20861 20862 20863 20864 20865 20866 20867 20868 20869 20870 20871 20872 20873 20874 20875 20876 20877 20878 20879 20880 20881 20882 20883 20884 20885 20886 20887 20888 20889 20890 20891 20892 20893 20894 20895 20896 20897 20898 20899 20900 20901 20902 20903 20904 20905 20906 20907 20908 20909 20910 20911 20912 20913 20914 20915 20916 20917 20918 20919 20920 20921 20922 20923 20924 20925 20926 20927 20928 20929 20930 20931 20932 20933 20934 20935 20936 20937 20938 20939 20940 20941 20942 20943 20944 20945 20946 20947 20948 20949 20950 20951 20952 20953 20954 20955 20956 20957 20958 20959 20960 20961 20962 20963 20964 20965 20966 20967 20968 20969 20970 20971 20972 20973 20974 20975 20976 20977 20978 20979 20980 20981 20982 20983 20984 20985 20986 20987 20988 20989 20990 20991 20992 20993 20994 20995 20996 20997 20998 20999 21000 21001 21002 21003 21004 21005 21006 21007 21008 21009 21010 21011 21012 21013 21014 21015 21016 21017 21018 21019 21020 21021 21022 21023 21024 21025 21026 21027 21028 21029 21030 21031 21032 21033 21034 21035 21036 21037 21038 21039 21040 21041 21042 21043 21044 21045 21046 21047 21048 21049 21050 21051 21052 21053 21054 21055 21056 21057 21058 21059 21060 21061 21062 21063 21064 21065 21066 21067 21068 21069 21070 21071 21072 21073 21074 21075 21076 21077 21078 21079 21080 21081 21082 21083 21084 21085 21086 21087 21088 21089 21090 21091 21092 21093 21094 21095 21096 21097 21098 21099 21100 21101 21102 21103 21104 21105 21106 21107 21108 21109 21110 21111 21112 21113 21114 21115 21116 21117 21118 21119 21120 21121 21122 21123 21124 21125 21126 21127 21128 21129 21130 21131 21132 21133 21134 21135 21136 21137 21138 21139 21140 21141 21142 21143 21144 21145 21146 21147 21148 21149 21150 21151 21152 21153 21154 21155 21156 21157 21158 21159 21160 21161 21162 21163 21164 21165 21166 21167 21168 21169 21170 21171 21172 21173 21174 21175 21176 21177 21178 21179 21180 21181 21182 21183 21184 21185 21186 21187 21188 21189 21190 21191 21192 21193 21194 21195 21196 21197 21198 21199 21200 21201 21202 21203 21204 21205 21206 21207 21208 21209 21210 21211 21212 21213 21214 21215 21216 21217 21218 21219 21220 21221 21222 21223 21224 21225 21226 21227 21228 21229 21230 21231 21232 21233 21234 21235 21236 21237 21238 21239 21240 21241 21242 21243 21244 21245 21246 21247 21248 21249 21250 21251 21252 21253 21254 21255 21256 21257 21258 21259 21260 21261 21262 21263 21264 21265 21266 21267 21268 21269 21270 21271 21272 21273 21274 21275 21276 21277 21278 21279 21280 21281 21282 21283 21284 21285 21286 21287 21288 21289 21290 21291 21292 21293 21294 21295 21296 21297 21298 21299 21300 21301 21302 21303 21304 21305 21306 21307 21308 21309 21310 21311 21312 21313 21314 21315 21316 21317 21318 21319 21320 21321 21322 21323 21324 21325 21326 21327 21328 21329 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 21345 21346 21347 21348 21349 21350 21351 21352 21353 21354 21355 21356 21357 21358 21359 21360 21361 21362 21363 21364 21365 21366 21367 21368 21369 21370 21371 21372 21373 21374 21375 21376 21377 21378 21379 21380 21381 21382 21383 21384 21385 21386 21387 21388 21389 21390 21391 21392 21393 21394 21395 21396 21397 21398 21399 21400 21401 21402 21403 21404 21405 21406 21407 21408 21409 21410 21411 21412 21413 21414 21415 21416 21417 21418 21419 21420 21421 21422 21423 21424 21425 21426 21427 21428 21429 21430 21431 21432 21433 21434 21435 21436 21437 21438 21439 21440 21441 21442 21443 21444 21445 21446 21447 21448 21449 21450 21451 21452 21453 21454 21455 21456 21457 21458 21459 21460 21461 21462 21463 21464 21465 21466 21467 21468 21469 21470 21471 21472 21473 21474 21475 21476 21477 21478 21479 21480 21481 21482 21483 21484 21485 21486 21487 21488 21489 21490 21491 21492 21493 21494 21495 21496 21497 21498 21499 21500 21501 21502 21503 21504 21505 21506 21507 21508 21509 21510 21511 21512 21513 21514 21515 21516 21517 21518 21519 21520 21521 21522 21523 21524 21525 21526 21527 21528 21529 21530 21531 21532 21533 21534 21535 21536 21537 21538 21539 21540 21541 21542 21543 21544 21545 21546 21547 21548 21549 21550 21551 21552 21553 21554 21555 21556 21557 21558 21559 21560 21561 21562 21563 21564 21565 21566 21567 21568 21569 21570 21571 21572 21573 21574 21575 21576 21577 21578 21579 21580 21581 21582 21583 21584 21585 21586 21587 21588 21589 21590 21591 21592 21593 21594 21595 21596 21597 21598 21599 21600 21601 21602 21603 21604 21605 21606 21607 21608 21609 21610 21611 21612 21613 21614 21615 21616 21617 21618 21619 21620 21621 21622 21623 21624 21625 21626 21627 21628 21629 21630 21631 21632 21633 21634 21635 21636 21637 21638 21639 21640 21641 21642 21643 21644 21645 21646 21647 21648 21649 21650 21651 21652 21653 21654 21655 21656 21657 21658 21659 21660 21661 21662 21663 21664 21665 21666 21667 21668 21669 21670 21671 21672 21673 21674 21675 21676 21677 21678 21679 21680 21681 21682 21683 21684 21685 21686 21687 21688 21689 21690 21691 21692 21693 21694 21695 21696 21697 21698 21699 21700 21701 21702 21703 21704 21705 21706 21707 21708 21709 21710 21711 21712 21713 21714 21715 21716 21717 21718 21719 21720 21721 21722 21723 21724 21725 21726 21727 21728 21729 21730 21731 21732 21733 21734 21735 21736 21737 21738 21739 21740 21741 21742 21743 21744 21745 21746 21747 21748 21749 21750 21751 21752 21753 21754 21755 21756 21757 21758 21759 21760 21761 21762 21763 21764 21765 21766 21767 21768 21769 21770 21771 21772 21773 21774 21775 21776 21777 21778 21779 21780 21781 21782 21783 21784 21785 21786 21787 21788 21789 21790 21791 21792 21793 21794 21795 21796 21797 21798 21799 21800 21801 21802 21803 21804 21805 21806 21807 21808 21809 21810 21811 21812 21813 21814 21815 21816 21817 21818 21819 21820 21821 21822 21823 21824 21825 21826 21827 21828 21829 21830 21831 21832 21833 21834 21835 21836 21837 21838 21839 21840 21841 21842 21843 21844 21845 21846 21847 21848 21849 21850 21851 21852 21853 21854 21855 21856 21857 21858 21859 21860 21861 21862 21863 21864 21865 21866 21867 21868 21869 21870 21871 21872 21873 21874 21875 21876 21877 21878 21879 21880 21881 21882 21883 21884 21885 21886 21887 21888 21889 21890 21891 21892 21893 21894 21895 21896 21897 21898 21899 21900 21901 21902 21903 21904 21905 21906 21907 21908 21909 21910 21911 21912 21913 21914 21915 21916 21917 21918 21919 21920 21921 21922 21923 21924 21925 21926 21927 21928 21929 21930 21931 21932 21933 21934 21935 21936 21937 21938 21939 21940 21941 21942 21943 21944 21945 21946 21947 21948 21949 21950 21951 21952 21953 21954 21955 21956 21957 21958 21959 21960 21961 21962 21963 21964 21965 21966 21967 21968 21969 21970 21971 21972 21973 21974 21975 21976 21977 21978 21979 21980 21981 21982 21983 21984 21985 21986 21987 21988 21989 21990 21991 21992 21993 21994 21995 21996 21997 21998 21999 22000 22001 22002 22003 22004 22005 22006 22007 22008 22009 22010 22011 22012 22013 22014 22015 22016 22017 22018 22019 22020 22021 22022 22023 22024 22025 22026 22027 22028 22029 22030 22031 22032 22033 22034 22035 22036 22037 22038 22039 22040 22041 22042 22043 22044 22045 22046 22047 22048 22049 22050 22051 22052 22053 22054 22055 22056 22057 22058 22059 22060 22061 22062 22063 22064 22065 22066 22067 22068 22069 22070 22071 22072 22073 22074 22075 22076 22077 22078 22079 22080 22081 22082 22083 22084 22085 22086 22087 22088 22089 22090 22091 22092 22093 22094 22095 22096 22097 22098 22099 22100 22101 22102 22103 22104 22105 22106 22107 22108 22109 22110 22111 22112 22113 22114 22115 22116 22117 22118 22119 22120 22121 22122 22123 22124 22125 22126 22127 22128 22129 22130 22131 22132 22133 22134 22135 22136 22137 22138 22139 22140 22141 22142 22143 22144 22145 22146 22147 22148 22149 22150 22151 22152 22153 22154 22155 22156 22157 22158 22159 22160 22161 22162 22163 22164 22165 22166 22167 22168 22169 22170 22171 22172 22173 22174 22175 22176 22177 22178 22179 22180 22181 22182 22183 22184 22185 22186 22187 22188 22189 22190 22191 22192 22193 22194 22195 22196 22197 22198 22199 22200 22201 22202 22203 22204 22205 22206 22207 22208 22209 22210 22211 22212 22213 22214 22215 22216 22217 22218 22219 22220 22221 22222 22223 22224 22225 22226 22227 22228 22229 22230 22231 22232 22233 22234 22235 22236 22237 22238 22239 22240 22241 22242 22243 22244 22245 22246 22247 22248 22249 22250 22251 22252 22253 22254 22255 22256 22257 22258 22259 22260 22261 22262 22263 22264 22265 22266 22267 22268 22269 22270 22271 22272 22273 22274 22275 22276 22277 22278 22279 22280 22281 22282 22283 22284 22285 22286 22287 22288 22289 22290 22291 22292 22293 22294 22295 22296 22297 22298 22299 22300 22301 22302 22303 22304 22305 22306 22307 22308 22309 22310 22311 22312 22313 22314 22315 22316 22317 22318 22319 22320 22321 22322 22323 22324 22325 22326 22327 22328 22329 22330 22331 22332 22333 22334 22335 22336 22337 22338 22339 22340 22341 22342 22343 22344 22345 22346 22347 22348 22349 22350 22351 22352 22353 22354 22355 22356 22357 22358 22359 22360 22361 22362 22363 22364 22365 22366 22367 22368 22369 22370 22371 22372 22373 22374 22375 22376 22377 22378 22379 22380 22381 22382 22383 22384 22385 22386 22387 22388 22389 22390 22391 22392 22393 22394 22395 22396 22397 22398 22399 22400 22401 22402 22403 22404 22405 22406 22407 22408 22409 22410 22411 22412 22413 22414 22415 22416 22417 22418 22419 22420 22421 22422 22423 22424 22425 22426 22427 22428 22429 22430 22431 22432 22433 22434 22435 22436 22437 22438 22439 22440 22441 22442 22443 22444 22445 22446 22447 22448 22449 22450 22451 22452 22453 22454 22455 22456 22457 22458 22459 22460 22461 22462 22463 22464 22465 22466 22467 22468 22469 22470 22471 22472 22473 22474 22475 22476 22477 22478 22479 22480 22481 22482 22483 22484 22485 22486 22487 22488 22489 22490 22491 22492 22493 22494 22495 22496 22497 22498 22499 22500 22501 22502 22503 22504 22505 22506 22507 22508 22509 22510 22511 22512 22513 22514 22515 22516 22517 22518 22519 22520 22521 22522 22523 22524 22525 22526 22527 22528 22529 22530 22531 22532 22533 22534 22535 22536 22537 22538 22539 22540 22541 22542 22543 22544 22545 22546 22547 22548 22549 22550 22551 22552 22553 22554 22555 22556 22557 22558 22559 22560 22561 22562 22563 22564 22565 22566 22567 22568 22569 22570 22571 22572 22573 22574 22575 22576 22577 22578 22579 22580 22581 22582 22583 22584 22585 22586 22587 22588 22589 22590 22591 22592 22593 22594 22595 22596 22597 22598 22599 22600 22601 22602 22603 22604 22605 22606 22607 22608 22609 22610 22611 22612 22613 22614 22615 22616 22617 22618 22619 22620 22621 22622 22623 22624 22625 22626 22627 22628 22629 22630 22631 22632 22633 22634 22635 22636 22637 22638 22639 22640 22641 22642 22643 22644 22645 22646 22647 22648 22649 22650 22651 22652 22653 22654 22655 22656 22657 22658 22659 22660 22661 22662 22663 22664 22665 22666 22667 22668 22669 22670 22671 22672 22673 22674 22675 22676 22677 22678 22679 22680 22681 22682 22683 22684 22685 22686 22687 22688 22689 22690 22691 22692 22693 22694 22695 22696 22697 22698 22699 22700 22701 22702 22703 22704 22705 22706 22707 22708 22709 22710 22711 22712 22713 22714 22715 22716 22717 22718 22719 22720 22721 22722 22723 22724 22725 22726 22727 22728 22729 22730 22731 22732 22733 22734 22735 22736 22737 22738 22739 22740 22741 22742 22743 22744 22745 22746 22747 22748 22749 22750 22751 22752 22753 22754 22755 22756 22757 22758 22759 22760 22761 22762 22763 22764 22765 22766 22767 22768 22769 22770 22771 22772 22773 22774 22775 22776 22777 22778 22779 22780 22781 22782 22783 22784 22785 22786 22787 22788 22789 22790 22791 22792 22793 22794 22795 22796 22797 22798 22799 22800 22801 22802 22803 22804 22805 22806 22807 22808 22809 22810 22811 22812 22813 22814 22815 22816 22817 22818 22819 22820 22821 22822 22823 22824 22825 22826 22827 22828 22829 22830 22831 22832 22833 22834 22835 22836 22837 22838 22839 22840 22841 22842 22843 22844 22845 22846 22847 22848 22849 22850 22851 22852 22853 22854 22855 22856 22857 22858 22859 22860 22861 22862 22863 22864 22865 22866 22867 22868 22869 22870 22871 22872 22873 22874 22875 22876 22877 22878 22879 22880 22881 22882 22883 22884 22885 22886 22887 22888 22889 22890 22891 22892 22893 22894 22895 22896 22897 22898 22899 22900 22901 22902 22903 22904 22905 22906 22907 22908 22909 22910 22911 22912 22913 22914 22915 22916 22917 22918 22919 22920 22921 22922 22923 22924 22925 22926 22927 22928 22929 22930 22931 22932 22933 22934 22935 22936 22937 22938 22939 22940 22941 22942 22943 22944 22945 22946 22947 22948 22949 22950 22951 22952 22953 22954 22955 22956 22957 22958 22959 22960 22961 22962 22963 22964 22965 22966 22967 22968 22969 22970 22971 22972 22973 22974 22975 22976 22977 22978 22979 22980 22981 22982 22983 22984 22985 22986 22987 22988 22989 22990 22991 22992 22993 22994 22995 22996 22997 22998 22999 23000 23001 23002 23003 23004 23005 23006 23007 23008 23009 23010 23011 23012 23013 23014 23015 23016 23017 23018 23019 23020 23021 23022 23023 23024 23025 23026 23027 23028 23029 23030 23031 23032 23033 23034 23035 23036 23037 23038 23039 23040 23041 23042 23043 23044 23045 23046 23047 23048 23049 23050 23051 23052 23053 23054 23055 23056 23057 23058 23059 23060 23061 23062 23063 23064 23065 23066 23067 23068 23069 23070 23071 23072 23073 23074 23075 23076 23077 23078 23079 23080 23081 23082 23083 23084 23085 23086 23087 23088 23089 23090 23091 23092 23093 23094 23095 23096 23097 23098 23099 23100 23101 23102 23103 23104 23105 23106 23107 23108 23109 23110 23111 23112 23113 23114 23115 23116 23117 23118 23119 23120 23121 23122 23123 23124 23125 23126 23127 23128 23129 23130 23131 23132 23133 23134 23135 23136 23137 23138 23139 23140 23141 23142 23143 23144 23145 23146 23147 23148 23149 23150 23151 23152 23153 23154 23155 23156 23157 23158 23159 23160 23161 23162 23163 23164 23165 23166 23167 23168 23169 23170 23171 23172 23173 23174 23175 23176 23177 23178 23179 23180 23181 23182 23183 23184 23185 23186 23187 23188 23189 23190 23191 23192 23193 23194 23195 23196 23197 23198 23199 23200 23201 23202 23203 23204 23205 23206 23207 23208 23209 23210 23211 23212 23213 23214 23215 23216 23217 23218 23219 23220 23221 23222 23223 23224 23225 23226 23227 23228 23229 23230 23231 23232 23233 23234 23235 23236 23237 23238 23239 23240 23241 23242 23243 23244 23245 23246 23247 23248 23249 23250 23251 23252 23253 23254 23255 23256 23257 23258 23259 23260 23261 23262 23263 23264 23265 23266 23267 23268 23269 23270 23271 23272 23273 23274 23275 23276 23277 23278 23279 23280 23281 23282 23283 23284 23285 23286 23287 23288 23289 23290 23291 23292 23293 23294 23295 23296 23297 23298 23299 23300 23301 23302 23303 23304 23305 23306 23307 23308 23309 23310 23311 23312 23313 23314 23315 23316 23317 23318 23319 23320 23321 23322 23323 23324 23325 23326 23327 23328 23329 23330 23331 23332 23333 23334 23335 23336 23337 23338 23339 23340 23341 23342 23343 23344 23345 23346 23347 23348 23349 23350 23351 23352 23353 23354 23355 23356 23357 23358 23359 23360 23361 23362 23363 23364 23365 23366 23367 23368 23369 23370 23371 23372 23373 23374 23375 23376 23377 23378 23379 23380 23381 23382 23383 23384 23385 23386 23387 23388 23389 23390 23391 23392 23393 23394 23395 23396 23397 23398 23399 23400 23401 23402 23403 23404 23405 23406 23407 23408 23409 23410 23411 23412 23413 23414 23415 23416 23417 23418 23419 23420 23421 23422 23423 23424 23425 23426 23427 23428 23429 23430 23431 23432 23433 23434 23435 23436 23437 23438 23439 23440 23441 23442 23443 23444 23445 23446 23447 23448 23449 23450 23451 23452 23453 23454 23455 23456 23457 23458 23459 23460 23461 23462 23463 23464 23465 23466 23467 23468 23469 23470 23471 23472 23473 23474 23475 23476 23477 23478 23479 23480 23481 23482 23483 23484 23485 23486 23487 23488 23489 23490 23491 23492 23493 23494 23495 23496 23497 23498 23499 23500 23501 23502 23503 23504 23505 23506 23507 23508 23509 23510 23511 23512 23513 23514 23515 23516 23517 23518 23519 23520 23521 23522 23523 23524 23525 23526 23527 23528 23529 23530 23531 23532 23533 23534 23535 23536 23537 23538 23539 23540 23541 23542 23543 23544 23545 23546 23547 23548 23549 23550 23551 23552 23553 23554 23555 23556 23557 23558 23559 23560 23561 23562 23563 23564 23565 23566 23567 23568 23569 23570 23571 23572 23573 23574 23575 23576 23577 23578 23579 23580 23581 23582 23583 23584 23585 23586 23587 23588 23589 23590 23591 23592 23593 23594 23595 23596 23597 23598 23599 23600 23601 23602 23603 23604 23605 23606 23607 23608 23609 23610 23611 23612 23613 23614 23615 23616 23617 23618 23619 23620 23621 23622 23623 23624 23625 23626 23627 23628 23629 23630 23631 23632 23633 23634 23635 23636 23637 23638 23639 23640 23641 23642 23643 23644 23645 23646 23647 23648 23649 23650 23651 23652 23653 23654 23655 23656 23657 23658 23659 23660 23661 23662 23663 23664 23665 23666 23667 23668 23669 23670 23671 23672 23673 23674 23675 23676 23677 23678 23679 23680 23681 23682 23683 23684 23685 23686 23687 23688 23689 23690 23691 23692 23693 23694 23695 23696 23697 23698 23699 23700 23701 23702 23703 23704 23705 23706 23707 23708 23709 23710 23711 23712 23713 23714 23715 23716 23717 23718 23719 23720 23721 23722 23723 23724 23725 23726 23727 23728 23729 23730 23731 23732 23733 23734 23735 23736 23737 23738 23739 23740 23741 23742 23743 23744 23745 23746 23747 23748 23749 23750 23751 23752 23753 23754 23755 23756 23757 23758 23759 23760 23761 23762 23763 23764 23765 23766 23767 23768 23769 23770 23771 23772 23773 23774 23775 23776 23777 23778 23779 23780 23781 23782 23783 23784 23785 23786 23787 23788 23789 23790 23791 23792 23793 23794 23795 23796 23797 23798 23799 23800 23801 23802 23803 23804 23805 23806 23807 23808 23809 23810 23811 23812 23813 23814 23815 23816 23817 23818 23819 23820 23821 23822 23823 23824 23825 23826 23827 23828 23829 23830 23831 23832 23833 23834 23835 23836 23837 23838 23839 23840 23841 23842 23843 23844 23845 23846 23847 23848 23849 23850 23851 23852 23853 23854 23855 23856 23857 23858 23859 23860 23861 23862 23863 23864 23865 23866 23867 23868 23869 23870 23871 23872 23873 23874 23875 23876 23877 23878 23879 23880 23881 23882 23883 23884 23885 23886 23887 23888 23889 23890 23891 23892 23893 23894 23895 23896 23897 23898 23899 23900 23901 23902 23903 23904 23905 23906 23907 23908 23909 23910 23911 23912 23913 23914 23915 23916 23917 23918 23919 23920 23921 23922 23923 23924 23925 23926 23927 23928 23929 23930 23931 23932 23933 23934 23935 23936 23937 23938 23939 23940 23941 23942 23943 23944 23945 23946 23947 23948 23949 23950 23951 23952 23953 23954 23955 23956 23957 23958 23959 23960 23961 23962 23963 23964 23965 23966 23967 23968 23969 23970 23971 23972 23973 23974 23975 23976 23977 23978 23979 23980 23981 23982 23983 23984 23985 23986 23987 23988 23989 23990 23991 23992 23993 23994 23995 23996 23997 23998 23999 24000 24001 24002 24003 24004 24005 24006 24007 24008 24009 24010 24011 24012 24013 24014 24015 24016 24017 24018 24019 24020 24021 24022 24023 24024 24025 24026 24027 24028 24029 24030 24031 24032 24033 24034 24035 24036 24037 24038 24039 24040 24041 24042 24043 24044 24045 24046 24047 24048 24049 24050 24051 24052 24053 24054 24055 24056 24057 24058 24059 24060 24061 24062 24063 24064 24065 24066 24067 24068 24069 24070 24071 24072 24073 24074 24075 24076 24077 24078 24079 24080 24081 24082 24083 24084 24085 24086 24087 24088 24089 24090 24091 24092 24093 24094 24095 24096 24097 24098 24099 24100 24101 24102 24103 24104 24105 24106 24107 24108 24109 24110 24111 24112 24113 24114 24115 24116 24117 24118 24119 24120 24121 24122 24123 24124 24125 24126 24127 24128 24129 24130 24131 24132 24133 24134 24135 24136 24137 24138 24139 24140 24141 24142 24143 24144 24145 24146 24147 24148 24149 24150 24151 24152 24153 24154 24155 24156 24157 24158 24159 24160 24161 24162 24163 24164 24165 24166 24167 24168 24169 24170 24171 24172 24173 24174 24175 24176 24177 24178 24179 24180 24181 24182 24183 24184 24185 24186 24187 24188 24189 24190 24191 24192 24193 24194 24195 24196 24197 24198 24199 24200 24201 24202 24203 24204 24205 24206 24207 24208 24209 24210 24211 24212 24213 24214 24215 24216 24217 24218 24219 24220 24221 24222 24223 24224 24225 24226 24227 24228 24229 24230 24231 24232 24233 24234 24235 24236 24237 24238 24239 24240 24241 24242 24243 24244 24245 24246 24247 24248 24249 24250 24251 24252 24253 24254 24255 24256 24257 24258 24259 24260 24261 24262 24263 24264 24265 24266 24267 24268 24269 24270 24271 24272 24273 24274 24275 24276 24277 24278 24279 24280 24281 24282 24283 24284 24285 24286 24287 24288 24289 24290 24291 24292 24293 24294 24295 24296 24297 24298 24299 24300 24301 24302 24303 24304 24305 24306 24307 24308 24309 24310 24311 24312 24313 24314 24315 24316 24317 24318 24319 24320 24321 24322 24323 24324 24325 24326 24327 24328 24329 24330 24331 24332 24333 24334 24335 24336 24337 24338 24339 24340 24341 24342 24343 24344 24345 24346 24347 24348 24349 24350 24351 24352 24353 24354 24355 24356 24357 24358 24359 24360 24361 24362 24363 24364 24365 24366 24367 24368 24369 24370 24371 24372 24373 24374 24375 24376 24377 24378 24379 24380 24381 24382 24383 24384 24385 24386 24387 24388 24389 24390 24391 24392 24393 24394 24395 24396 24397 24398 24399 24400 24401 24402 24403 24404 24405 24406 24407 24408 24409 24410 24411 24412 24413 24414 24415 24416 24417 24418 24419 24420 24421 24422 24423 24424 24425 24426 24427 24428 24429 24430 24431 24432 24433 24434 24435 24436 24437 24438 24439 24440 24441 24442 24443 24444 24445 24446 24447 24448 24449 24450 24451 24452 24453 24454 24455 24456 24457 24458 24459 24460 24461 24462 24463 24464 24465 24466 24467 24468 24469 24470 24471 24472 24473 24474 24475 24476 24477 24478 24479 24480 24481 24482 24483 24484 24485 24486 24487 24488 24489 24490 24491 24492 24493 24494 24495 24496 24497 24498 24499 24500 24501 24502 24503 24504 24505 24506 24507 24508 24509 24510 24511 24512 24513 24514 24515 24516 24517 24518 24519 24520 24521 24522 24523 24524 24525 24526 24527 24528 24529 24530 24531 24532 24533 24534 24535 24536 24537 24538 24539 24540 24541 24542 24543 24544 24545 24546 24547 24548 24549 24550 24551 24552 24553 24554 24555 24556 24557 24558 24559 24560 24561 24562 24563 24564 24565 24566 24567 24568 24569 24570 24571 24572 24573 24574 24575 24576 24577 24578 24579 24580 24581 24582 24583 24584 24585 24586 24587 24588 24589 24590 24591 24592 24593 24594 24595 24596 24597 24598 24599 24600 24601 24602 24603 24604 24605 24606 24607 24608 24609 24610 24611 24612 24613 24614 24615 24616 24617 24618 24619 24620 24621 24622 24623 24624 24625 24626 24627 24628 24629 24630 24631 24632 24633 24634 24635 24636 24637 24638 24639 24640 24641 24642 24643 24644 24645 24646 24647 24648 24649 24650 24651 24652 24653 24654 24655 24656 24657 24658 24659 24660 24661 24662 24663 24664 24665 24666 24667 24668 24669 24670 24671 24672 24673 24674 24675 24676 24677 24678 24679 24680 24681 24682 24683 24684 24685 24686 24687 24688 24689 24690 24691 24692 24693 24694 24695 24696 24697 24698 24699 24700 24701 24702 24703 24704 24705 24706 24707 24708 24709 24710 24711 24712 24713 24714 24715 24716 24717 24718 24719 24720 24721 24722 24723 24724 24725 24726 24727 24728 24729 24730 24731 24732 24733 24734 24735 24736 24737 24738 24739 24740 24741 24742 24743 24744 24745 24746 24747 24748 24749 24750 24751 24752 24753 24754 24755 24756 24757 24758 24759 24760 24761 24762 24763 24764 24765 24766 24767 24768 24769 24770 24771 24772 24773 24774 24775 24776 24777 24778 24779 24780 24781 24782 24783 24784 24785 24786 24787 24788 24789 24790 24791 24792 24793 24794 24795 24796 24797 24798 24799 24800 24801 24802 24803 24804 24805 24806 24807 24808 24809 24810 24811 24812 24813 24814 24815 24816 24817 24818 24819 24820 24821 24822 24823 24824 24825 24826 24827 24828 24829 24830 24831 24832 24833 24834 24835 24836 24837 24838 24839 24840 24841 24842 24843 24844 24845 24846 24847 24848 24849 24850 24851 24852 24853 24854 24855 24856 24857 24858 24859 24860 24861 24862 24863 24864 24865 24866 24867 24868 24869 24870 24871 24872 24873 24874 24875 24876 24877 24878 24879 24880 24881 24882 24883 24884 24885 24886 24887 24888 24889 24890 24891 24892 24893 24894 24895 24896 24897 24898 24899 24900 24901 24902 24903 24904 24905 24906 24907 24908 24909 24910 24911 24912 24913 24914 24915 24916 24917 24918 24919 24920 24921 24922 24923 24924 24925 24926 24927 24928 24929 24930 24931 24932 24933 24934 24935 24936 24937 24938 24939 24940 24941 24942 24943 24944 24945 24946 24947 24948 24949 24950 24951 24952 24953 24954 24955 24956 24957 24958 24959 24960 24961 24962 24963 24964 24965 24966 24967 24968 24969 24970 24971 24972 24973 24974 24975 24976 24977 24978 24979 24980 24981 24982 24983 24984 24985 24986 24987 24988 24989 24990 24991 24992 24993 24994 24995 24996 24997 24998 24999 25000 25001 25002 25003 25004 25005 25006 25007 25008 25009 25010 25011 25012 25013 25014 25015 25016 25017 25018 25019 25020 25021 25022 25023 25024 25025 25026 25027 25028 25029 25030 25031 25032 25033 25034 25035 25036 25037 25038 25039 25040 25041 25042 25043 25044 25045 25046 25047 25048 25049 25050 25051 25052 25053 25054 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /**
* @license Highmaps JS v5.0.10 (2017-03-31)
*
* (c) 2011-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(root, factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = root.document ?
factory(root) :
factory;
} else {
root.Highcharts = factory(root);
}
}(typeof window !== 'undefined' ? window : this, function(win) {
var Highcharts = (function() {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/* global window */
var win = window,
doc = win.document;
var SVG_NS = 'http://www.w3.org/2000/svg',
userAgent = (win.navigator && win.navigator.userAgent) || '',
svg = doc && doc.createElementNS && !!doc.createElementNS(SVG_NS, 'svg').createSVGRect,
isMS = /(edge|msie|trident)/i.test(userAgent) && !window.opera,
vml = !svg,
isFirefox = /Firefox/.test(userAgent),
hasBidiBug = isFirefox && parseInt(userAgent.split('Firefox/')[1], 10) < 4; // issue #38
var Highcharts = win.Highcharts ? win.Highcharts.error(16, true) : {
product: 'Highmaps',
version: '5.0.10',
deg2rad: Math.PI * 2 / 360,
doc: doc,
hasBidiBug: hasBidiBug,
hasTouch: doc && doc.documentElement.ontouchstart !== undefined,
isMS: isMS,
isWebKit: /AppleWebKit/.test(userAgent),
isFirefox: isFirefox,
isTouchDevice: /(Mobile|Android|Windows Phone)/.test(userAgent),
SVG_NS: SVG_NS,
chartCount: 0,
seriesTypes: {},
symbolSizes: {},
svg: svg,
vml: vml,
win: win,
charts: [],
marginNames: ['plotTop', 'marginRight', 'marginBottom', 'plotLeft'],
noop: function() {
return undefined;
}
};
return Highcharts;
}());
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/* eslint max-len: ["warn", 80, 4] */
/**
* The Highcharts object is the placeholder for all other members, and various
* utility functions.
* @namespace Highcharts
*/
var timers = [];
var charts = H.charts,
doc = H.doc,
win = H.win;
/**
* Provide error messages for debugging, with links to online explanation. This
* function can be overridden to provide custom error handling.
*
* @function #error
* @memberOf Highcharts
* @param {Number|String} code - The error code. See [errors.xml]{@link
* https://github.com/highcharts/highcharts/blob/master/errors/errors.xml}
* for available codes. If it is a string, the error message is printed
* directly in the console.
* @param {Boolean} [stop=false] - Whether to throw an error or just log a
* warning in the console.
*/
H.error = function(code, stop) {
var msg = H.isNumber(code) ?
'Highcharts error #' + code + ': www.highcharts.com/errors/' + code :
code;
if (stop) {
throw new Error(msg);
}
// else ...
if (win.console) {
console.log(msg); // eslint-disable-line no-console
}
};
/**
* An animator object. One instance applies to one property (attribute or style
* prop) on one element.
*
* @constructor Fx
* @memberOf Highcharts
* @param {HTMLDOMElement|SVGElement} elem - The element to animate.
* @param {AnimationOptions} options - Animation options.
* @param {string} prop - The single attribute or CSS property to animate.
*/
H.Fx = function(elem, options, prop) {
this.options = options;
this.elem = elem;
this.prop = prop;
};
H.Fx.prototype = {
/**
* Set the current step of a path definition on SVGElement.
*
* @function #dSetter
* @memberOf Highcharts.Fx
*/
dSetter: function() {
var start = this.paths[0],
end = this.paths[1],
ret = [],
now = this.now,
i = start.length,
startVal;
// Land on the final path without adjustment points appended in the ends
if (now === 1) {
ret = this.toD;
} else if (i === end.length && now < 1) {
while (i--) {
startVal = parseFloat(start[i]);
ret[i] =
isNaN(startVal) ? // a letter instruction like M or L
start[i] :
now * (parseFloat(end[i] - startVal)) + startVal;
}
// If animation is finished or length not matching, land on right value
} else {
ret = end;
}
this.elem.attr('d', ret, null, true);
},
/**
* Update the element with the current animation step.
*
* @function #update
* @memberOf Highcharts.Fx
*/
update: function() {
var elem = this.elem,
prop = this.prop, // if destroyed, it is null
now = this.now,
step = this.options.step;
// Animation setter defined from outside
if (this[prop + 'Setter']) {
this[prop + 'Setter']();
// Other animations on SVGElement
} else if (elem.attr) {
if (elem.element) {
elem.attr(prop, now, null, true);
}
// HTML styles, raw HTML content like container size
} else {
elem.style[prop] = now + this.unit;
}
if (step) {
step.call(elem, now, this);
}
},
/**
* Run an animation.
*
* @function #run
* @memberOf Highcharts.Fx
* @param {Number} from - The current value, value to start from.
* @param {Number} to - The end value, value to land on.
* @param {String} [unit] - The property unit, for example `px`.
* @returns {void}
*/
run: function(from, to, unit) {
var self = this,
timer = function(gotoEnd) {
return timer.stopped ? false : self.step(gotoEnd);
},
i;
this.startTime = +new Date();
this.start = from;
this.end = to;
this.unit = unit;
this.now = this.start;
this.pos = 0;
timer.elem = this.elem;
timer.prop = this.prop;
if (timer() && timers.push(timer) === 1) {
timer.timerId = setInterval(function() {
for (i = 0; i < timers.length; i++) {
if (!timers[i]()) {
timers.splice(i--, 1);
}
}
if (!timers.length) {
clearInterval(timer.timerId);
}
}, 13);
}
},
/**
* Run a single step in the animation.
*
* @function #step
* @memberOf Highcharts.Fx
* @param {Boolean} [gotoEnd] - Whether to go to the endpoint of the
* animation after abort.
* @returns {Boolean} Returns `true` if animation continues.
*/
step: function(gotoEnd) {
var t = +new Date(),
ret,
done,
options = this.options,
elem = this.elem,
complete = options.complete,
duration = options.duration,
curAnim = options.curAnim,
i;
if (elem.attr && !elem.element) { // #2616, element is destroyed
ret = false;
} else if (gotoEnd || t >= duration + this.startTime) {
this.now = this.end;
this.pos = 1;
this.update();
curAnim[this.prop] = true;
done = true;
for (i in curAnim) {
if (curAnim[i] !== true) {
done = false;
}
}
if (done && complete) {
complete.call(elem);
}
ret = false;
} else {
this.pos = options.easing((t - this.startTime) / duration);
this.now = this.start + ((this.end - this.start) * this.pos);
this.update();
ret = true;
}
return ret;
},
/**
* Prepare start and end values so that the path can be animated one to one.
*
* @function #initPath
* @memberOf Highcharts.Fx
* @param {SVGElement} elem - The SVGElement item.
* @param {String} fromD - Starting path definition.
* @param {Array} toD - Ending path definition.
* @returns {Array} An array containing start and end paths in array form
* so that they can be animated in parallel.
*/
initPath: function(elem, fromD, toD) {
fromD = fromD || '';
var shift,
startX = elem.startX,
endX = elem.endX,
bezier = fromD.indexOf('C') > -1,
numParams = bezier ? 7 : 3,
fullLength,
slice,
i,
start = fromD.split(' '),
end = toD.slice(), // copy
isArea = elem.isArea,
positionFactor = isArea ? 2 : 1,
reverse;
/**
* In splines make moveTo and lineTo points have six parameters like
* bezier curves, to allow animation one-to-one.
*/
function sixify(arr) {
var isOperator,
nextIsOperator;
i = arr.length;
while (i--) {
// Fill in dummy coordinates only if the next operator comes
// three places behind (#5788)
isOperator = arr[i] === 'M' || arr[i] === 'L';
nextIsOperator = /[a-zA-Z]/.test(arr[i + 3]);
if (isOperator && nextIsOperator) {
arr.splice(
i + 1, 0,
arr[i + 1], arr[i + 2],
arr[i + 1], arr[i + 2]
);
}
}
}
/**
* Insert an array at the given position of another array
*/
function insertSlice(arr, subArr, index) {
[].splice.apply(
arr, [index, 0].concat(subArr)
);
}
/**
* If shifting points, prepend a dummy point to the end path.
*/
function prepend(arr, other) {
while (arr.length < fullLength) {
// Move to, line to or curve to?
arr[0] = other[fullLength - arr.length];
// Prepend a copy of the first point
insertSlice(arr, arr.slice(0, numParams), 0);
// For areas, the bottom path goes back again to the left, so we
// need to append a copy of the last point.
if (isArea) {
insertSlice(
arr,
arr.slice(arr.length - numParams), arr.length
);
i--;
}
}
arr[0] = 'M';
}
/**
* Copy and append last point until the length matches the end length
*/
function append(arr, other) {
var i = (fullLength - arr.length) / numParams;
while (i > 0 && i--) {
// Pull out the slice that is going to be appended or inserted.
// In a line graph, the positionFactor is 1, and the last point
// is sliced out. In an area graph, the positionFactor is 2,
// causing the middle two points to be sliced out, since an area
// path starts at left, follows the upper path then turns and
// follows the bottom back.
slice = arr.slice().splice(
(arr.length / positionFactor) - numParams,
numParams * positionFactor
);
// Move to, line to or curve to?
slice[0] = other[fullLength - numParams - (i * numParams)];
// Disable first control point
if (bezier) {
slice[numParams - 6] = slice[numParams - 2];
slice[numParams - 5] = slice[numParams - 1];
}
// Now insert the slice, either in the middle (for areas) or at
// the end (for lines)
insertSlice(arr, slice, arr.length / positionFactor);
if (isArea) {
i--;
}
}
}
if (bezier) {
sixify(start);
sixify(end);
}
// For sideways animation, find out how much we need to shift to get the
// start path Xs to match the end path Xs.
if (startX && endX) {
for (i = 0; i < startX.length; i++) {
// Moving left, new points coming in on right
if (startX[i] === endX[0]) {
shift = i;
break;
// Moving right
} else if (startX[0] ===
endX[endX.length - startX.length + i]) {
shift = i;
reverse = true;
break;
}
}
if (shift === undefined) {
start = [];
}
}
if (start.length && H.isNumber(shift)) {
// The common target length for the start and end array, where both
// arrays are padded in opposite ends
fullLength = end.length + shift * positionFactor * numParams;
if (!reverse) {
prepend(end, start);
append(start, end);
} else {
prepend(start, end);
append(end, start);
}
}
return [start, end];
}
}; // End of Fx prototype
/**
* Utility function to extend an object with the members of another.
*
* @function #extend
* @memberOf Highcharts
* @param {Object} a - The object to be extended.
* @param {Object} b - The object to add to the first one.
* @returns {Object} Object a, the original object.
*/
H.extend = function(a, b) {
var n;
if (!a) {
a = {};
}
for (n in b) {
a[n] = b[n];
}
return a;
};
/**
* Utility function to deep merge two or more objects and return a third object.
* If the first argument is true, the contents of the second object is copied
* into the first object. The merge function can also be used with a single
* object argument to create a deep copy of an object.
*
* @function #merge
* @memberOf Highcharts
* @param {Boolean} [extend] - Whether to extend the left-side object (a) or
return a whole new object.
* @param {Object} a - The first object to extend. When only this is given, the
function returns a deep copy.
* @param {...Object} [n] - An object to merge into the previous one.
* @returns {Object} - The merged object. If the first argument is true, the
* return is the same as the second argument.
*/
H.merge = function() {
var i,
args = arguments,
len,
ret = {},
doCopy = function(copy, original) {
var value, key;
// An object is replacing a primitive
if (typeof copy !== 'object') {
copy = {};
}
for (key in original) {
if (original.hasOwnProperty(key)) {
value = original[key];
// Copy the contents of objects, but not arrays or DOM nodes
if (H.isObject(value, true) &&
key !== 'renderTo' &&
typeof value.nodeType !== 'number') {
copy[key] = doCopy(copy[key] || {}, value);
// Primitives and arrays are copied over directly
} else {
copy[key] = original[key];
}
}
}
return copy;
};
// If first argument is true, copy into the existing object. Used in
// setOptions.
if (args[0] === true) {
ret = args[1];
args = Array.prototype.slice.call(args, 2);
}
// For each argument, extend the return
len = args.length;
for (i = 0; i < len; i++) {
ret = doCopy(ret, args[i]);
}
return ret;
};
/**
* Shortcut for parseInt
* @ignore
* @param {Object} s
* @param {Number} mag Magnitude
*/
H.pInt = function(s, mag) {
return parseInt(s, mag || 10);
};
/**
* Utility function to check for string type.
*
* @function #isString
* @memberOf Highcharts
* @param {Object} s - The item to check.
* @returns {Boolean} - True if the argument is a string.
*/
H.isString = function(s) {
return typeof s === 'string';
};
/**
* Utility function to check if an item is an array.
*
* @function #isArray
* @memberOf Highcharts
* @param {Object} obj - The item to check.
* @returns {Boolean} - True if the argument is an array.
*/
H.isArray = function(obj) {
var str = Object.prototype.toString.call(obj);
return str === '[object Array]' || str === '[object Array Iterator]';
};
/**
* Utility function to check if an item is of type object.
*
* @function #isObject
* @memberOf Highcharts
* @param {Object} obj - The item to check.
* @param {Boolean} [strict=false] - Also checks that the object is not an
* array.
* @returns {Boolean} - True if the argument is an object.
*/
H.isObject = function(obj, strict) {
return obj && typeof obj === 'object' && (!strict || !H.isArray(obj));
};
/**
* Utility function to check if an item is of type number.
*
* @function #isNumber
* @memberOf Highcharts
* @param {Object} n - The item to check.
* @returns {Boolean} - True if the item is a number and is not NaN.
*/
H.isNumber = function(n) {
return typeof n === 'number' && !isNaN(n);
};
/**
* Remove the last occurence of an item from an array.
*
* @function #erase
* @memberOf Highcharts
* @param {Array} arr - The array.
* @param {*} item - The item to remove.
*/
H.erase = function(arr, item) {
var i = arr.length;
while (i--) {
if (arr[i] === item) {
arr.splice(i, 1);
break;
}
}
};
/**
* Check if an object is null or undefined.
*
* @function #defined
* @memberOf Highcharts
* @param {Object} obj - The object to check.
* @returns {Boolean} - False if the object is null or undefined, otherwise
* true.
*/
H.defined = function(obj) {
return obj !== undefined && obj !== null;
};
/**
* Set or get an attribute or an object of attributes. To use as a setter, pass
* a key and a value, or let the second argument be a collection of keys and
* values. To use as a getter, pass only a string as the second argument.
*
* @function #attr
* @memberOf Highcharts
* @param {Object} elem - The DOM element to receive the attribute(s).
* @param {String|Object} [prop] - The property or an object of key-value pairs.
* @param {String} [value] - The value if a single property is set.
* @returns {*} When used as a getter, return the value.
*/
H.attr = function(elem, prop, value) {
var key,
ret;
// if the prop is a string
if (H.isString(prop)) {
// set the value
if (H.defined(value)) {
elem.setAttribute(prop, value);
// get the value
} else if (elem && elem.getAttribute) {
ret = elem.getAttribute(prop);
}
// else if prop is defined, it is a hash of key/value pairs
} else if (H.defined(prop) && H.isObject(prop)) {
for (key in prop) {
elem.setAttribute(key, prop[key]);
}
}
return ret;
};
/**
* Check if an element is an array, and if not, make it into an array.
*
* @function #splat
* @memberOf Highcharts
* @param obj {*} - The object to splat.
* @returns {Array} The produced or original array.
*/
H.splat = function(obj) {
return H.isArray(obj) ? obj : [obj];
};
/**
* Set a timeout if the delay is given, otherwise perform the function
* synchronously.
*
* @function #syncTimeout
* @memberOf Highcharts
* @param {Function} fn - The function callback.
* @param {Number} delay - Delay in milliseconds.
* @param {Object} [context] - The context.
* @returns {Number} An identifier for the timeout that can later be cleared
* with clearTimeout.
*/
H.syncTimeout = function(fn, delay, context) {
if (delay) {
return setTimeout(fn, delay, context);
}
fn.call(0, context);
};
/**
* Return the first value that is not null or undefined.
*
* @function #pick
* @memberOf Highcharts
* @param {...*} items - Variable number of arguments to inspect.
* @returns {*} The value of the first argument that is not null or undefined.
*/
H.pick = function() {
var args = arguments,
i,
arg,
length = args.length;
for (i = 0; i < length; i++) {
arg = args[i];
if (arg !== undefined && arg !== null) {
return arg;
}
}
};
/**
* @typedef {Object} CSSObject - A style object with camel case property names.
* The properties can be whatever styles are supported on the given SVG or HTML
* element.
* @example
* {
* fontFamily: 'monospace',
* fontSize: '1.2em'
* }
*/
/**
* Set CSS on a given element.
*
* @function #css
* @memberOf Highcharts
* @param {HTMLDOMElement} el - A HTML DOM element.
* @param {CSSObject} styles - Style object with camel case property names.
* @returns {void}
*/
H.css = function(el, styles) {
if (H.isMS && !H.svg) { // #2686
if (styles && styles.opacity !== undefined) {
styles.filter = 'alpha(opacity=' + (styles.opacity * 100) + ')';
}
}
H.extend(el.style, styles);
};
/**
* A HTML DOM element.
* @typedef {Object} HTMLDOMElement
*/
/**
* Utility function to create an HTML element with attributes and styles.
*
* @function #createElement
* @memberOf Highcharts
* @param {String} tag - The HTML tag.
* @param {Object} [attribs] - Attributes as an object of key-value pairs.
* @param {CSSObject} [styles] - Styles as an object of key-value pairs.
* @param {Object} [parent] - The parent HTML object.
* @param {Boolean} [nopad=false] - If true, remove all padding, border and
* margin.
* @returns {HTMLDOMElement} The created DOM element.
*/
H.createElement = function(tag, attribs, styles, parent, nopad) {
var el = doc.createElement(tag),
css = H.css;
if (attribs) {
H.extend(el, attribs);
}
if (nopad) {
css(el, {
padding: 0,
border: 'none',
margin: 0
});
}
if (styles) {
css(el, styles);
}
if (parent) {
parent.appendChild(el);
}
return el;
};
/**
* Extend a prototyped class by new members.
*
* @function #extendClass
* @memberOf Highcharts
* @param {Object} parent - The parent prototype to inherit.
* @param {Object} members - A collection of prototype members to add or
* override compared to the parent prototype.
* @returns {Object} A new prototype.
*/
H.extendClass = function(parent, members) {
var object = function() {};
object.prototype = new parent(); // eslint-disable-line new-cap
H.extend(object.prototype, members);
return object;
};
/**
* Left-pad a string to a given length by adding a character repetetively.
*
* @function #pad
* @memberOf Highcharts
* @param {Number} number - The input string or number.
* @param {Number} length - The desired string length.
* @param {String} [padder=0] - The character to pad with.
* @returns {String} The padded string.
*/
H.pad = function(number, length, padder) {
return new Array((length || 2) + 1 -
String(number).length).join(padder || 0) + number;
};
/**
* @typedef {Number|String} RelativeSize - If a number is given, it defines the
* pixel length. If a percentage string is given, like for example `'50%'`,
* the setting defines a length relative to a base size, for example the size
* of a container.
*/
/**
* Return a length based on either the integer value, or a percentage of a base.
*
* @function #relativeLength
* @memberOf Highcharts
* @param {RelativeSize} value - A percentage string or a number.
* @param {Number} base - The full length that represents 100%.
* @returns {Number} The computed length.
*/
H.relativeLength = function(value, base) {
return (/%$/).test(value) ?
base * parseFloat(value) / 100 :
parseFloat(value);
};
/**
* Wrap a method with extended functionality, preserving the original function.
*
* @function #wrap
* @memberOf Highcharts
* @param {Object} obj - The context object that the method belongs to. In real
* cases, this is often a prototype.
* @param {String} method - The name of the method to extend.
* @param {Function} func - A wrapper function callback. This function is called
* with the same arguments as the original function, except that the
* original function is unshifted and passed as the first argument.
* @returns {void}
*/
H.wrap = function(obj, method, func) {
var proceed = obj[method];
obj[method] = function() {
var args = Array.prototype.slice.call(arguments),
outerArgs = arguments,
ctx = this,
ret;
ctx.proceed = function() {
proceed.apply(ctx, arguments.length ? arguments : outerArgs);
};
args.unshift(proceed);
ret = func.apply(this, args);
ctx.proceed = null;
return ret;
};
};
/**
* Get the time zone offset based on the current timezone information as set in
* the global options.
*
* @function #getTZOffset
* @memberOf Highcharts
* @param {Number} timestamp - The JavaScript timestamp to inspect.
* @return {Number} - The timezone offset in minutes compared to UTC.
*/
H.getTZOffset = function(timestamp) {
var d = H.Date;
return ((d.hcGetTimezoneOffset && d.hcGetTimezoneOffset(timestamp)) ||
d.hcTimezoneOffset || 0) * 60000;
};
/**
* Format a date, based on the syntax for PHP's [strftime]{@link
* http://www.php.net/manual/en/function.strftime.php} function.
*
* @function #dateFormat
* @memberOf Highcharts
* @param {String} format - The desired format where various time
* representations are prefixed with %.
* @param {Number} timestamp - The JavaScript timestamp.
* @param {Boolean} [capitalize=false] - Upper case first letter in the return.
* @returns {String} The formatted date.
*/
H.dateFormat = function(format, timestamp, capitalize) {
if (!H.defined(timestamp) || isNaN(timestamp)) {
return H.defaultOptions.lang.invalidDate || '';
}
format = H.pick(format, '%Y-%m-%d %H:%M:%S');
var D = H.Date,
date = new D(timestamp - H.getTZOffset(timestamp)),
key, // used in for constuct below
// get the basic time values
hours = date[D.hcGetHours](),
day = date[D.hcGetDay](),
dayOfMonth = date[D.hcGetDate](),
month = date[D.hcGetMonth](),
fullYear = date[D.hcGetFullYear](),
lang = H.defaultOptions.lang,
langWeekdays = lang.weekdays,
shortWeekdays = lang.shortWeekdays,
pad = H.pad,
// List all format keys. Custom formats can be added from the outside.
replacements = H.extend({
//-- Day
// Short weekday, like 'Mon'
'a': shortWeekdays ?
shortWeekdays[day] : langWeekdays[day].substr(0, 3),
// Long weekday, like 'Monday'
'A': langWeekdays[day],
// Two digit day of the month, 01 to 31
'd': pad(dayOfMonth),
// Day of the month, 1 through 31
'e': pad(dayOfMonth, 2, ' '),
'w': day,
// Week (none implemented)
//'W': weekNumber(),
//-- Month
// Short month, like 'Jan'
'b': lang.shortMonths[month],
// Long month, like 'January'
'B': lang.months[month],
// Two digit month number, 01 through 12
'm': pad(month + 1),
//-- Year
// Two digits year, like 09 for 2009
'y': fullYear.toString().substr(2, 2),
// Four digits year, like 2009
'Y': fullYear,
//-- Time
// Two digits hours in 24h format, 00 through 23
'H': pad(hours),
// Hours in 24h format, 0 through 23
'k': hours,
// Two digits hours in 12h format, 00 through 11
'I': pad((hours % 12) || 12),
// Hours in 12h format, 1 through 12
'l': (hours % 12) || 12,
// Two digits minutes, 00 through 59
'M': pad(date[D.hcGetMinutes]()),
// Upper case AM or PM
'p': hours < 12 ? 'AM' : 'PM',
// Lower case AM or PM
'P': hours < 12 ? 'am' : 'pm',
// Two digits seconds, 00 through 59
'S': pad(date.getSeconds()),
// Milliseconds (naming from Ruby)
'L': pad(Math.round(timestamp % 1000), 3)
}, H.dateFormats);
// Do the replaces
for (key in replacements) {
// Regex would do it in one line, but this is faster
while (format.indexOf('%' + key) !== -1) {
format = format.replace(
'%' + key,
typeof replacements[key] === 'function' ?
replacements[key](timestamp) :
replacements[key]
);
}
}
// Optionally capitalize the string and return
return capitalize ?
format.substr(0, 1).toUpperCase() + format.substr(1) :
format;
};
/**
* Format a single variable. Similar to sprintf, without the % prefix.
*
* @example
* formatSingle('.2f', 5); // => '5.00'.
*
* @function #formatSingle
* @memberOf Highcharts
* @param {String} format The format string.
* @param {*} val The value.
* @returns {String} The formatted representation of the value.
*/
H.formatSingle = function(format, val) {
var floatRegex = /f$/,
decRegex = /\.([0-9])/,
lang = H.defaultOptions.lang,
decimals;
if (floatRegex.test(format)) { // float
decimals = format.match(decRegex);
decimals = decimals ? decimals[1] : -1;
if (val !== null) {
val = H.numberFormat(
val,
decimals,
lang.decimalPoint,
format.indexOf(',') > -1 ? lang.thousandsSep : ''
);
}
} else {
val = H.dateFormat(format, val);
}
return val;
};
/**
* Format a string according to a subset of the rules of Python's String.format
* method.
*
* @function #format
* @memberOf Highcharts
* @param {String} str The string to format.
* @param {Object} ctx The context, a collection of key-value pairs where each
* key is replaced by its value.
* @returns {String} The formatted string.
*
* @example
* var s = Highcharts.format(
* 'The {color} fox was {len:.2f} feet long',
* { color: 'red', len: Math.PI }
* );
* // => The red fox was 3.14 feet long
*/
H.format = function(str, ctx) {
var splitter = '{',
isInside = false,
segment,
valueAndFormat,
path,
i,
len,
ret = [],
val,
index;
while (str) {
index = str.indexOf(splitter);
if (index === -1) {
break;
}
segment = str.slice(0, index);
if (isInside) { // we're on the closing bracket looking back
valueAndFormat = segment.split(':');
path = valueAndFormat.shift().split('.'); // get first and leave
len = path.length;
val = ctx;
// Assign deeper paths
for (i = 0; i < len; i++) {
val = val[path[i]];
}
// Format the replacement
if (valueAndFormat.length) {
val = H.formatSingle(valueAndFormat.join(':'), val);
}
// Push the result and advance the cursor
ret.push(val);
} else {
ret.push(segment);
}
str = str.slice(index + 1); // the rest
isInside = !isInside; // toggle
splitter = isInside ? '}' : '{'; // now look for next matching bracket
}
ret.push(str);
return ret.join('');
};
/**
* Get the magnitude of a number.
*
* @function #getMagnitude
* @memberOf Highcharts
* @param {Number} number The number.
* @returns {Number} The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2
* etc.
*/
H.getMagnitude = function(num) {
return Math.pow(10, Math.floor(Math.log(num) / Math.LN10));
};
/**
* Take an interval and normalize it to multiples of round numbers.
*
* @todo Move this function to the Axis prototype. It is here only for
* historical reasons.
* @function #normalizeTickInterval
* @memberOf Highcharts
* @param {Number} interval - The raw, un-rounded interval.
* @param {Array} [multiples] - Allowed multiples.
* @param {Number} [magnitude] - The magnitude of the number.
* @param {Boolean} [allowDecimals] - Whether to allow decimals.
* @param {Boolean} [hasTickAmount] - If it has tickAmount, avoid landing
* on tick intervals lower than original.
* @returns {Number} The normalized interval.
*/
H.normalizeTickInterval = function(interval, multiples, magnitude,
allowDecimals, hasTickAmount) {
var normalized,
i,
retInterval = interval;
// round to a tenfold of 1, 2, 2.5 or 5
magnitude = H.pick(magnitude, 1);
normalized = interval / magnitude;
// multiples for a linear scale
if (!multiples) {
multiples = hasTickAmount ?
// Finer grained ticks when the tick amount is hard set, including
// when alignTicks is true on multiple axes (#4580).
[1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :
// Else, let ticks fall on rounder numbers
[1, 2, 2.5, 5, 10];
// the allowDecimals option
if (allowDecimals === false) {
if (magnitude === 1) {
multiples = H.grep(multiples, function(num) {
return num % 1 === 0;
});
} else if (magnitude <= 0.1) {
multiples = [1 / magnitude];
}
}
}
// normalize the interval to the nearest multiple
for (i = 0; i < multiples.length; i++) {
retInterval = multiples[i];
// only allow tick amounts smaller than natural
if ((hasTickAmount && retInterval * magnitude >= interval) ||
(!hasTickAmount && (normalized <= (multiples[i] +
(multiples[i + 1] || multiples[i])) / 2))) {
break;
}
}
// Multiply back to the correct magnitude. Correct floats to appropriate
// precision (#6085).
retInterval = H.correctFloat(
retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10)
);
return retInterval;
};
/**
* Sort an object array and keep the order of equal items. The ECMAScript
* standard does not specify the behaviour when items are equal.
*
* @function #stableSort
* @memberOf Highcharts
* @param {Array} arr - The array to sort.
* @param {Function} sortFunction - The function to sort it with, like with
* regular Array.prototype.sort.
* @returns {void}
*/
H.stableSort = function(arr, sortFunction) {
var length = arr.length,
sortValue,
i;
// Add index to each item
for (i = 0; i < length; i++) {
arr[i].safeI = i; // stable sort index
}
arr.sort(function(a, b) {
sortValue = sortFunction(a, b);
return sortValue === 0 ? a.safeI - b.safeI : sortValue;
});
// Remove index from items
for (i = 0; i < length; i++) {
delete arr[i].safeI; // stable sort index
}
};
/**
* Non-recursive method to find the lowest member of an array. `Math.min` raises
* a maximum call stack size exceeded error in Chrome when trying to apply more
* than 150.000 points. This method is slightly slower, but safe.
*
* @function #arrayMin
* @memberOf Highcharts
* @param {Array} data An array of numbers.
* @returns {Number} The lowest number.
*/
H.arrayMin = function(data) {
var i = data.length,
min = data[0];
while (i--) {
if (data[i] < min) {
min = data[i];
}
}
return min;
};
/**
* Non-recursive method to find the lowest member of an array. `Math.max` raises
* a maximum call stack size exceeded error in Chrome when trying to apply more
* than 150.000 points. This method is slightly slower, but safe.
*
* @function #arrayMax
* @memberOf Highcharts
* @param {Array} data - An array of numbers.
* @returns {Number} The highest number.
*/
H.arrayMax = function(data) {
var i = data.length,
max = data[0];
while (i--) {
if (data[i] > max) {
max = data[i];
}
}
return max;
};
/**
* Utility method that destroys any SVGElement instances that are properties on
* the given object. It loops all properties and invokes destroy if there is a
* destroy method. The property is then delete.
*
* @function #destroyObjectProperties
* @memberOf Highcharts
* @param {Object} obj - The object to destroy properties on.
* @param {Object} [except] - Exception, do not destroy this property, only
* delete it.
* @returns {void}
*/
H.destroyObjectProperties = function(obj, except) {
var n;
for (n in obj) {
// If the object is non-null and destroy is defined
if (obj[n] && obj[n] !== except && obj[n].destroy) {
// Invoke the destroy
obj[n].destroy();
}
// Delete the property from the object.
delete obj[n];
}
};
/**
* Discard a HTML element by moving it to the bin and delete.
*
* @function #discardElement
* @memberOf Highcharts
* @param {HTMLDOMElement} element - The HTML node to discard.
* @returns {void}
*/
H.discardElement = function(element) {
var garbageBin = H.garbageBin;
// create a garbage bin element, not part of the DOM
if (!garbageBin) {
garbageBin = H.createElement('div');
}
// move the node and empty bin
if (element) {
garbageBin.appendChild(element);
}
garbageBin.innerHTML = '';
};
/**
* Fix JS round off float errors.
*
* @function #correctFloat
* @memberOf Highcharts
* @param {Number} num - A float number to fix.
* @param {Number} [prec=14] - The precision.
* @returns {Number} The corrected float number.
*/
H.correctFloat = function(num, prec) {
return parseFloat(
num.toPrecision(prec || 14)
);
};
/**
* Set the global animation to either a given value, or fall back to the given
* chart's animation option.
*
* @function #setAnimation
* @memberOf Highcharts
* @param {Boolean|Animation} animation - The animation object.
* @param {Object} chart - The chart instance.
* @returns {void}
* @todo This function always relates to a chart, and sets a property on the
* renderer, so it should be moved to the SVGRenderer.
*/
H.setAnimation = function(animation, chart) {
chart.renderer.globalAnimation = H.pick(
animation,
chart.options.chart.animation,
true
);
};
/**
* Get the animation in object form, where a disabled animation is always
* returned as `{ duration: 0 }`.
*
* @function #animObject
* @memberOf Highcharts
* @param {Boolean|AnimationOptions} animation - An animation setting. Can be an
* object with duration, complete and easing properties, or a boolean to
* enable or disable.
* @returns {AnimationOptions} An object with at least a duration property.
*/
H.animObject = function(animation) {
return H.isObject(animation) ?
H.merge(animation) : {
duration: animation ? 500 : 0
};
};
/**
* The time unit lookup
*/
H.timeUnits = {
millisecond: 1,
second: 1000,
minute: 60000,
hour: 3600000,
day: 24 * 3600000,
week: 7 * 24 * 3600000,
month: 28 * 24 * 3600000,
year: 364 * 24 * 3600000
};
/**
* Format a number and return a string based on input settings.
*
* @function #numberFormat
* @memberOf Highcharts
* @param {Number} number - The input number to format.
* @param {Number} decimals - The amount of decimals. A value of -1 preserves
* the amount in the input number.
* @param {String} [decimalPoint] - The decimal point, defaults to the one given
* in the lang options.
* @param {String} [thousandsSep] - The thousands separator, defaults to the one
* given in the lang options.
* @returns {String} The formatted number.
*/
H.numberFormat = function(number, decimals, decimalPoint, thousandsSep) {
number = +number || 0;
decimals = +decimals;
var lang = H.defaultOptions.lang,
origDec = (number.toString().split('.')[1] || '').length,
strinteger,
thousands,
ret,
roundedNumber;
if (decimals === -1) {
// Preserve decimals. Not huge numbers (#3793).
decimals = Math.min(origDec, 20);
} else if (!H.isNumber(decimals)) {
decimals = 2;
}
// Add another decimal to avoid rounding errors of float numbers. (#4573)
// Then use toFixed to handle rounding.
roundedNumber = (
Math.abs(number) + Math.pow(10, -Math.max(decimals, origDec) - 1)
).toFixed(decimals);
// A string containing the positive integer component of the number
strinteger = String(H.pInt(roundedNumber));
// Leftover after grouping into thousands. Can be 0, 1 or 3.
thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;
// Language
decimalPoint = H.pick(decimalPoint, lang.decimalPoint);
thousandsSep = H.pick(thousandsSep, lang.thousandsSep);
// Start building the return
ret = number < 0 ? '-' : '';
// Add the leftover after grouping into thousands. For example, in the
// number 42 000 000, this line adds 42.
ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';
// Add the remaining thousands groups, joined by the thousands separator
ret += strinteger
.substr(thousands)
.replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);
// Add the decimal point and the decimal component
if (decimals) {
// Get the decimal component
ret += decimalPoint + roundedNumber.slice(-decimals);
}
return ret;
};
/**
* Easing definition
* @ignore
* @param {Number} pos Current position, ranging from 0 to 1.
*/
Math.easeInOutSine = function(pos) {
return -0.5 * (Math.cos(Math.PI * pos) - 1);
};
/**
* Get the computed CSS value for given element and property, only for numerical
* properties. For width and height, the dimension of the inner box (excluding
* padding) is returned. Used for fitting the chart within the container.
*
* @function #getStyle
* @memberOf Highcharts
* @param {HTMLDOMElement} el - A HTML element.
* @param {String} prop - The property name.
* @returns {Number} - The numeric value.
*/
H.getStyle = function(el, prop) {
var style;
// For width and height, return the actual inner pixel size (#4913)
if (prop === 'width') {
return Math.min(el.offsetWidth, el.scrollWidth) -
H.getStyle(el, 'padding-left') -
H.getStyle(el, 'padding-right');
} else if (prop === 'height') {
return Math.min(el.offsetHeight, el.scrollHeight) -
H.getStyle(el, 'padding-top') -
H.getStyle(el, 'padding-bottom');
}
// Otherwise, get the computed style
style = win.getComputedStyle(el, undefined);
return style && H.pInt(style.getPropertyValue(prop));
};
/**
* Search for an item in an array.
*
* @function #inArray
* @memberOf Highcharts
* @param {*} item - The item to search for.
* @param {arr} arr - The array or node collection to search in.
* @returns {Number} - The index within the array, or -1 if not found.
*/
H.inArray = function(item, arr) {
return arr.indexOf ? arr.indexOf(item) : [].indexOf.call(arr, item);
};
/**
* Filter an array by a callback.
*
* @function #grep
* @memberOf Highcharts
* @param {Array} arr - The array to filter.
* @param {Function} callback - The callback function. The function receives the
* item as the first argument. Return `true` if the item is to be
* preserved.
* @returns {Array} - A new, filtered array.
*/
H.grep = function(arr, callback) {
return [].filter.call(arr, callback);
};
/**
* Return the value of the first element in the array that satisfies the
* provided testing function.
*
* @function #find
* @memberOf Highcharts
* @param {Array} arr - The array to test.
* @param {Function} callback - The callback function. The function receives the
* item as the first argument. Return `true` if this item satisfies the
* condition.
* @returns {Mixed} - The value of the element.
*/
H.find = function(arr, callback) {
return [].find.call(arr, callback);
};
/**
* Map an array by a callback.
*
* @function #map
* @memberOf Highcharts
* @param {Array} arr - The array to map.
* @param {Function} fn - The callback function. Return the new value for the
* new array.
* @returns {Array} - A new array item with modified items.
*/
H.map = function(arr, fn) {
var results = [],
i = 0,
len = arr.length;
for (; i < len; i++) {
results[i] = fn.call(arr[i], arr[i], i, arr);
}
return results;
};
/**
* Get the element's offset position, corrected for `overflow: auto`.
*
* @function #offset
* @memberOf Highcharts
* @param {HTMLDOMElement} el - The HTML element.
* @returns {Object} An object containing `left` and `top` properties for the
* position in the page.
*/
H.offset = function(el) {
var docElem = doc.documentElement,
box = el.getBoundingClientRect();
return {
top: box.top + (win.pageYOffset || docElem.scrollTop) -
(docElem.clientTop || 0),
left: box.left + (win.pageXOffset || docElem.scrollLeft) -
(docElem.clientLeft || 0)
};
};
/**
* Stop running animation.
*
* @todo A possible extension to this would be to stop a single property, when
* we want to continue animating others. Then assign the prop to the timer
* in the Fx.run method, and check for the prop here. This would be an
* improvement in all cases where we stop the animation from .attr. Instead of
* stopping everything, we can just stop the actual attributes we're setting.
*
* @function #stop
* @memberOf Highcharts
* @param {SVGElement} el - The SVGElement to stop animation on.
* @param {string} [prop] - The property to stop animating. If given, the stop
* method will stop a single property from animating, while others continue.
* @returns {void}
*/
H.stop = function(el, prop) {
var i = timers.length;
// Remove timers related to this element (#4519)
while (i--) {
if (timers[i].elem === el && (!prop || prop === timers[i].prop)) {
timers[i].stopped = true; // #4667
}
}
};
/**
* Iterate over an array.
*
* @function #each
* @memberOf Highcharts
* @param {Array} arr - The array to iterate over.
* @param {Function} fn - The iterator callback. It passes three arguments:
* * item - The array item.
* * index - The item's index in the array.
* * arr - The array that each is being applied to.
* @param {Object} [ctx] The context.
*/
H.each = function(arr, fn, ctx) { // modern browsers
return Array.prototype.forEach.call(arr, fn, ctx);
};
/**
* Add an event listener.
*
* @function #addEvent
* @memberOf Highcharts
* @param {Object} el - The element or object to add a listener to. It can be a
* {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
* @param {String} type - The event type.
* @param {Function} fn - The function callback to execute when the event is
* fired.
* @returns {Function} A callback function to remove the added event.
*/
H.addEvent = function(el, type, fn) {
var events = el.hcEvents = el.hcEvents || {};
function wrappedFn(e) {
e.target = e.srcElement || win; // #2820
fn.call(el, e);
}
// Handle DOM events in modern browsers
if (el.addEventListener) {
el.addEventListener(type, fn, false);
// Handle old IE implementation
} else if (el.attachEvent) {
if (!el.hcEventsIE) {
el.hcEventsIE = {};
}
// Link wrapped fn with original fn, so we can get this in removeEvent
el.hcEventsIE[fn.toString()] = wrappedFn;
el.attachEvent('on' + type, wrappedFn);
}
if (!events[type]) {
events[type] = [];
}
events[type].push(fn);
// Return a function that can be called to remove this event.
return function() {
H.removeEvent(el, type, fn);
};
};
/**
* Remove an event that was added with {@link Highcharts#addEvent}.
*
* @function #removeEvent
* @memberOf Highcharts
* @param {Object} el - The element to remove events on.
* @param {String} [type] - The type of events to remove. If undefined, all
* events are removed from the element.
* @param {Function} [fn] - The specific callback to remove. If undefined, all
* events that match the element and optionally the type are removed.
* @returns {void}
*/
H.removeEvent = function(el, type, fn) {
var events,
hcEvents = el.hcEvents,
index;
function removeOneEvent(type, fn) {
if (el.removeEventListener) {
el.removeEventListener(type, fn, false);
} else if (el.attachEvent) {
fn = el.hcEventsIE[fn.toString()];
el.detachEvent('on' + type, fn);
}
}
function removeAllEvents() {
var types,
len,
n;
if (!el.nodeName) {
return; // break on non-DOM events
}
if (type) {
types = {};
types[type] = true;
} else {
types = hcEvents;
}
for (n in types) {
if (hcEvents[n]) {
len = hcEvents[n].length;
while (len--) {
removeOneEvent(n, hcEvents[n][len]);
}
}
}
}
if (hcEvents) {
if (type) {
events = hcEvents[type] || [];
if (fn) {
index = H.inArray(fn, events);
if (index > -1) {
events.splice(index, 1);
hcEvents[type] = events;
}
removeOneEvent(type, fn);
} else {
removeAllEvents();
hcEvents[type] = [];
}
} else {
removeAllEvents();
el.hcEvents = {};
}
}
};
/**
* Fire an event that was registered with {@link Highcharts#addEvent}.
*
* @function #fireEvent
* @memberOf Highcharts
* @param {Object} el - The object to fire the event on. It can be a
* {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
* @param {String} type - The type of event.
* @param {Object} [eventArguments] - Custom event arguments that are passed on
* as an argument to the event handler.
* @param {Function} [defaultFunction] - The default function to execute if the
* other listeners haven't returned false.
* @returns {void}
*/
H.fireEvent = function(el, type, eventArguments, defaultFunction) {
var e,
hcEvents = el.hcEvents,
events,
len,
i,
fn;
eventArguments = eventArguments || {};
if (doc.createEvent && (el.dispatchEvent || el.fireEvent)) {
e = doc.createEvent('Events');
e.initEvent(type, true, true);
//e.target = el;
H.extend(e, eventArguments);
if (el.dispatchEvent) {
el.dispatchEvent(e);
} else {
el.fireEvent(type, e);
}
} else if (hcEvents) {
events = hcEvents[type] || [];
len = events.length;
if (!eventArguments.target) { // We're running a custom event
H.extend(eventArguments, {
// Attach a simple preventDefault function to skip default
// handler if called. The built-in defaultPrevented property is
// not overwritable (#5112)
preventDefault: function() {
eventArguments.defaultPrevented = true;
},
// Setting target to native events fails with clicking the
// zoom-out button in Chrome.
target: el,
// If the type is not set, we're running a custom event (#2297).
// If it is set, we're running a browser event, and setting it
// will cause en error in IE8 (#2465).
type: type
});
}
for (i = 0; i < len; i++) {
fn = events[i];
// If the event handler return false, prevent the default handler
// from executing
if (fn && fn.call(el, eventArguments) === false) {
eventArguments.preventDefault();
}
}
}
// Run the default if not prevented
if (defaultFunction && !eventArguments.defaultPrevented) {
defaultFunction(eventArguments);
}
};
/**
* An animation configuration. Animation configurations can also be defined as
* booleans, where `false` turns off animation and `true` defaults to a duration
* of 500ms.
* @typedef {Object} AnimationOptions
* @property {Number} duration - The animation duration in milliseconds.
* @property {String} [easing] - The name of an easing function as defined on
* the `Math` object.
* @property {Function} [complete] - A callback function to exectute when the
* animation finishes.
* @property {Function} [step] - A callback function to execute on each step of
* each attribute or CSS property that's being animated. The first argument
* contains information about the animation and progress.
*/
/**
* The global animate method, which uses Fx to create individual animators.
*
* @function #animate
* @memberOf Highcharts
* @param {HTMLDOMElement|SVGElement} el - The element to animate.
* @param {Object} params - An object containing key-value pairs of the
* properties to animate. Supports numeric as pixel-based CSS properties
* for HTML objects and attributes for SVGElements.
* @param {AnimationOptions} [opt] - Animation options.
*/
H.animate = function(el, params, opt) {
var start,
unit = '',
end,
fx,
args,
prop;
if (!H.isObject(opt)) { // Number or undefined/null
args = arguments;
opt = {
duration: args[2],
easing: args[3],
complete: args[4]
};
}
if (!H.isNumber(opt.duration)) {
opt.duration = 400;
}
opt.easing = typeof opt.easing === 'function' ?
opt.easing :
(Math[opt.easing] || Math.easeInOutSine);
opt.curAnim = H.merge(params);
for (prop in params) {
// Stop current running animation of this property
H.stop(el, prop);
fx = new H.Fx(el, opt, prop);
end = null;
if (prop === 'd') {
fx.paths = fx.initPath(
el,
el.d,
params.d
);
fx.toD = params.d;
start = 0;
end = 1;
} else if (el.attr) {
start = el.attr(prop);
} else {
start = parseFloat(H.getStyle(el, prop)) || 0;
if (prop !== 'opacity') {
unit = 'px';
}
}
if (!end) {
end = params[prop];
}
if (end && end.match && end.match('px')) {
end = end.replace(/px/g, ''); // #4351
}
fx.run(start, end, unit);
}
};
/**
* Factory to create new series prototypes.
*
* @function #seriesType
* @memberOf Highcharts
*
* @param {String} type - The series type name.
* @param {String} parent - The parent series type name. Use `line` to inherit
* from the basic {@link Series} object.
* @param {Object} options - The additional default options that is merged with
* the parent's options.
* @param {Object} props - The properties (functions and primitives) to set on
* the new prototype.
* @param {Object} [pointProps] - Members for a series-specific extension of the
* {@link Point} prototype if needed.
* @returns {*} - The newly created prototype as extended from {@link Series}
* or its derivatives.
*/
// docs: add to API + extending Highcharts
H.seriesType = function(type, parent, options, props, pointProps) {
var defaultOptions = H.getOptions(),
seriesTypes = H.seriesTypes;
// Merge the options
defaultOptions.plotOptions[type] = H.merge(
defaultOptions.plotOptions[parent],
options
);
// Create the class
seriesTypes[type] = H.extendClass(seriesTypes[parent] ||
function() {}, props);
seriesTypes[type].prototype.type = type;
// Create the point class if needed
if (pointProps) {
seriesTypes[type].prototype.pointClass =
H.extendClass(H.Point, pointProps);
}
return seriesTypes[type];
};
/**
* Get a unique key for using in internal element id's and pointers. The key
* is composed of a random hash specific to this Highcharts instance, and a
* counter.
* @function #uniqueKey
* @memberOf Highcharts
* @return {string} The key.
* @example
* var id = H.uniqueKey(); // => 'highcharts-x45f6hp-0'
*/
H.uniqueKey = (function() {
var uniqueKeyHash = Math.random().toString(36).substring(2, 9),
idCounter = 0;
return function() {
return 'highcharts-' + uniqueKeyHash + '-' + idCounter++;
};
}());
/**
* Register Highcharts as a plugin in jQuery
*/
if (win.jQuery) {
win.jQuery.fn.highcharts = function() {
var args = [].slice.call(arguments);
if (this[0]) { // this[0] is the renderTo div
// Create the chart
if (args[0]) {
new H[ // eslint-disable-line no-new
// Constructor defaults to Chart
H.isString(args[0]) ? args.shift() : 'Chart'
](this[0], args[0], args[1]);
return this;
}
// When called without parameters or with the return argument,
// return an existing chart
return charts[H.attr(this[0], 'data-highcharts-chart')];
}
};
}
/**
* Compatibility section to add support for legacy IE. This can be removed if
* old IE support is not needed.
*/
if (doc && !doc.defaultView) {
H.getStyle = function(el, prop) {
var val,
alias = {
width: 'clientWidth',
height: 'clientHeight'
}[prop];
if (el.style[prop]) {
return H.pInt(el.style[prop]);
}
if (prop === 'opacity') {
prop = 'filter';
}
// Getting the rendered width and height
if (alias) {
el.style.zoom = 1;
return Math.max(el[alias] - 2 * H.getStyle(el, 'padding'), 0);
}
val = el.currentStyle[prop.replace(/\-(\w)/g, function(a, b) {
return b.toUpperCase();
})];
if (prop === 'filter') {
val = val.replace(
/alpha\(opacity=([0-9]+)\)/,
function(a, b) {
return b / 100;
}
);
}
return val === '' ? 1 : H.pInt(val);
};
}
if (!Array.prototype.forEach) {
H.each = function(arr, fn, ctx) { // legacy
var i = 0,
len = arr.length;
for (; i < len; i++) {
if (fn.call(ctx, arr[i], i, arr) === false) {
return i;
}
}
};
}
if (!Array.prototype.indexOf) {
H.inArray = function(item, arr) {
var len,
i = 0;
if (arr) {
len = arr.length;
for (; i < len; i++) {
if (arr[i] === item) {
return i;
}
}
}
return -1;
};
}
if (!Array.prototype.filter) {
H.grep = function(elements, fn) {
var ret = [],
i = 0,
length = elements.length;
for (; i < length; i++) {
if (fn(elements[i], i)) {
ret.push(elements[i]);
}
}
return ret;
};
}
if (!Array.prototype.find) {
H.find = function(arr, fn) {
var i,
length = arr.length;
for (i = 0; i < length; i++) {
if (fn(arr[i], i)) {
return arr[i];
}
}
};
}
//--- End compatibility section ---
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var each = H.each,
isNumber = H.isNumber,
map = H.map,
merge = H.merge,
pInt = H.pInt;
/**
* @typedef {string} ColorString
* A valid color to be parsed and handled by Highcharts. Highcharts internally
* supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
* rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
* browsers and displayed correctly, but Highcharts is not able to process them
* and apply concepts like opacity and brightening.
*/
/**
* Handle color operations. The object methods are chainable.
* @param {String} input The input color in either rbga or hex format
*/
H.Color = function(input) {
// Backwards compatibility, allow instanciation without new
if (!(this instanceof H.Color)) {
return new H.Color(input);
}
// Initialize
this.init(input);
};
H.Color.prototype = {
// Collection of parsers. This can be extended from the outside by pushing parsers
// to Highcharts.Color.prototype.parsers.
parsers: [{
// RGBA color
regex: /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,
parse: function(result) {
return [pInt(result[1]), pInt(result[2]), pInt(result[3]), parseFloat(result[4], 10)];
}
}, {
// RGB color
regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
parse: function(result) {
return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
}
}],
// Collection of named colors. Can be extended from the outside by adding
// colors to Highcharts.Color.prototype.names.
names: {
white: '#ffffff',
black: '#000000'
},
/**
* Parse the input color to rgba array
* @param {String} input
*/
init: function(input) {
var result,
rgba,
i,
parser,
len;
this.input = input = this.names[
input && input.toLowerCase ?
input.toLowerCase() :
''
] || input;
// Gradients
if (input && input.stops) {
this.stops = map(input.stops, function(stop) {
return new H.Color(stop[1]);
});
// Solid colors
} else {
// Check if it's possible to do bitmasking instead of regex
if (input && input[0] === '#') {
len = input.length;
input = parseInt(input.substr(1), 16);
// Handle long-form, e.g. #AABBCC
if (len === 7) {
rgba = [
(input & 0xFF0000) >> 16,
(input & 0xFF00) >> 8,
(input & 0xFF),
1
];
// Handle short-form, e.g. #ABC
// In short form, the value is assumed to be the same
// for both nibbles for each component. e.g. #ABC = #AABBCC
} else if (len === 4) {
rgba = [
((input & 0xF00) >> 4) | (input & 0xF00) >> 8,
((input & 0xF0) >> 4) | (input & 0xF0),
((input & 0xF) << 4) | (input & 0xF),
1
];
}
}
// Otherwise, check regex parsers
if (!rgba) {
i = this.parsers.length;
while (i-- && !rgba) {
parser = this.parsers[i];
result = parser.regex.exec(input);
if (result) {
rgba = parser.parse(result);
}
}
}
}
this.rgba = rgba || [];
},
/**
* Return the color a specified format
* @param {String} format
*/
get: function(format) {
var input = this.input,
rgba = this.rgba,
ret;
if (this.stops) {
ret = merge(input);
ret.stops = [].concat(ret.stops);
each(this.stops, function(stop, i) {
ret.stops[i] = [ret.stops[i][0], stop.get(format)];
});
// it's NaN if gradient colors on a column chart
} else if (rgba && isNumber(rgba[0])) {
if (format === 'rgb' || (!format && rgba[3] === 1)) {
ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
} else if (format === 'a') {
ret = rgba[3];
} else {
ret = 'rgba(' + rgba.join(',') + ')';
}
} else {
ret = input;
}
return ret;
},
/**
* Brighten the color
* @param {Number} alpha
*/
brighten: function(alpha) {
var i,
rgba = this.rgba;
if (this.stops) {
each(this.stops, function(stop) {
stop.brighten(alpha);
});
} else if (isNumber(alpha) && alpha !== 0) {
for (i = 0; i < 3; i++) {
rgba[i] += pInt(alpha * 255);
if (rgba[i] < 0) {
rgba[i] = 0;
}
if (rgba[i] > 255) {
rgba[i] = 255;
}
}
}
return this;
},
/**
* Set the color's opacity to a given alpha value
* @param {Number} alpha
*/
setOpacity: function(alpha) {
this.rgba[3] = alpha;
return this;
}
};
H.color = function(input) {
return new H.Color(input);
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var color = H.color,
each = H.each,
getTZOffset = H.getTZOffset,
isTouchDevice = H.isTouchDevice,
merge = H.merge,
pick = H.pick,
svg = H.svg,
win = H.win;
/* ****************************************************************************
* Handle the options *
*****************************************************************************/
H.defaultOptions = {
colors: '#7cb5ec #434348 #90ed7d #f7a35c #8085e9 #f15c80 #e4d354 #2b908f #f45b5b #91e8e1'.split(' '),
symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
lang: {
loading: 'Loading...',
months: [
'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'
],
shortMonths: [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
],
weekdays: [
'Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday'
],
// invalidDate: '',
decimalPoint: '.',
numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'], // SI prefixes used in axis labels
resetZoom: 'Reset zoom',
resetZoomTitle: 'Reset zoom level 1:1',
thousandsSep: ' '
},
global: {
useUTC: true,
//timezoneOffset: 0,
VMLRadialGradientURL: 'http://code.highcharts.com/5.0.10/gfx/vml-radial-gradient.png'
},
chart: {
//animation: true,
//alignTicks: false,
//reflow: true,
//className: null,
//events: { load, selection },
//margin: [null],
//marginTop: null,
//marginRight: null,
//marginBottom: null,
//marginLeft: null,
borderRadius: 0,
defaultSeriesType: 'line',
ignoreHiddenSeries: true,
//inverted: false,
spacing: [10, 10, 15, 10],
//spacingTop: 10,
//spacingRight: 10,
//spacingBottom: 15,
//spacingLeft: 10,
//zoomType: ''
resetZoomButton: {
theme: {
zIndex: 20
},
position: {
align: 'right',
x: -10,
//verticalAlign: 'top',
y: 10
}
// relativeTo: 'plot'
},
width: null,
height: null,
borderColor: '#335cad',
//borderWidth: 0,
//style: {
// fontFamily: '"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif', // default font
// fontSize: '12px'
//},
backgroundColor: '#ffffff',
//plotBackgroundColor: null,
plotBorderColor: '#cccccc'
//plotBorderWidth: 0,
//plotShadow: false
},
title: {
text: 'Chart title',
align: 'center',
// floating: false,
margin: 15,
// x: 0,
// verticalAlign: 'top',
// y: null,
// style: {}, // defined inline
widthAdjust: -44
},
subtitle: {
text: '',
align: 'center',
// floating: false
// x: 0,
// verticalAlign: 'top',
// y: null,
// style: {}, // defined inline
widthAdjust: -44
},
plotOptions: {},
labels: {
//items: [],
style: {
//font: defaultFont,
position: 'absolute',
color: '#333333'
}
},
legend: {
enabled: true,
align: 'center',
//floating: false,
layout: 'horizontal',
labelFormatter: function() {
return this.name;
},
//borderWidth: 0,
borderColor: '#999999',
borderRadius: 0,
navigation: {
activeColor: '#003399',
inactiveColor: '#cccccc'
// animation: true,
// arrowSize: 12
// style: {} // text styles
},
// margin: 20,
// reversed: false,
// backgroundColor: null,
/*style: {
padding: '5px'
},*/
itemStyle: {
color: '#333333',
fontSize: '12px',
fontWeight: 'bold'
},
itemHoverStyle: {
//cursor: 'pointer', removed as of #601
color: '#000000'
},
itemHiddenStyle: {
color: '#cccccc'
},
shadow: false,
itemCheckboxStyle: {
position: 'absolute',
width: '13px', // for IE precision
height: '13px'
},
// itemWidth: undefined,
squareSymbol: true,
// symbolRadius: 0,
// symbolWidth: 16,
symbolPadding: 5,
verticalAlign: 'bottom',
// width: undefined,
x: 0,
y: 0,
title: {
//text: null,
style: {
fontWeight: 'bold'
}
}
},
loading: {
// hideDuration: 100,
// showDuration: 0,
labelStyle: {
fontWeight: 'bold',
position: 'relative',
top: '45%'
},
style: {
position: 'absolute',
backgroundColor: '#ffffff',
opacity: 0.5,
textAlign: 'center'
}
},
tooltip: {
enabled: true,
animation: svg,
//crosshairs: null,
borderRadius: 3,
dateTimeLabelFormats: {
millisecond: '%A, %b %e, %H:%M:%S.%L',
second: '%A, %b %e, %H:%M:%S',
minute: '%A, %b %e, %H:%M',
hour: '%A, %b %e, %H:%M',
day: '%A, %b %e, %Y',
week: 'Week from %A, %b %e, %Y',
month: '%B %Y',
year: '%Y'
},
footerFormat: '',
//formatter: defaultFormatter,
/* todo: em font-size when finished comparing against HC4
headerFormat: '<span style="font-size: 0.85em">{point.key}</span><br/>',
*/
padding: 8,
//shape: 'callout',
//shared: false,
snap: isTouchDevice ? 25 : 10,
backgroundColor: color('#f7f7f7').setOpacity(0.85).get(),
borderWidth: 1,
headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',
shadow: true,
style: {
color: '#333333',
cursor: 'default',
fontSize: '12px',
pointerEvents: 'none', // #1686 http://caniuse.com/#feat=pointer-events
whiteSpace: 'nowrap'
}
//xDateFormat: '%A, %b %e, %Y',
//valueDecimals: null,
//valuePrefix: '',
//valueSuffix: ''
},
credits: {
enabled: true,
href: 'http://www.highcharts.com',
position: {
align: 'right',
x: -10,
verticalAlign: 'bottom',
y: -5
},
style: {
cursor: 'pointer',
color: '#999999',
fontSize: '9px'
},
text: 'Highcharts.com'
}
};
/**
* Sets the getTimezoneOffset function. If the timezone option is set, a default
* getTimezoneOffset function with that timezone is returned. If not, the
* specified getTimezoneOffset function is returned. If neither are specified,
* undefined is returned.
* @return {function} a getTimezoneOffset function or undefined
*/
function getTimezoneOffsetOption() {
var globalOptions = H.defaultOptions.global,
moment = win.moment;
if (globalOptions.timezone) {
if (!moment) {
// getTimezoneOffset-function stays undefined because it depends on
// Moment.js
H.error(25);
} else {
return function(timestamp) {
return -moment.tz(
timestamp,
globalOptions.timezone
).utcOffset();
};
}
}
// If not timezone is set, look for the getTimezoneOffset callback
return globalOptions.useUTC && globalOptions.getTimezoneOffset;
}
/**
* Set the time methods globally based on the useUTC option. Time method can be
* either local time or UTC (default). It is called internally on initiating
* Highcharts and after running `Highcharts.setOptions`.
*
* @private
*/
function setTimeMethods() {
var globalOptions = H.defaultOptions.global,
Date,
useUTC = globalOptions.useUTC,
GET = useUTC ? 'getUTC' : 'get',
SET = useUTC ? 'setUTC' : 'set';
H.Date = Date = globalOptions.Date || win.Date; // Allow using a different Date class
Date.hcTimezoneOffset = useUTC && globalOptions.timezoneOffset;
Date.hcGetTimezoneOffset = getTimezoneOffsetOption();
Date.hcMakeTime = function(year, month, date, hours, minutes, seconds) {
var d;
if (useUTC) {
d = Date.UTC.apply(0, arguments);
d += getTZOffset(d);
} else {
d = new Date(
year,
month,
pick(date, 1),
pick(hours, 0),
pick(minutes, 0),
pick(seconds, 0)
).getTime();
}
return d;
};
each(['Minutes', 'Hours', 'Day', 'Date', 'Month', 'FullYear'], function(s) {
Date['hcGet' + s] = GET + s;
});
each(['Milliseconds', 'Seconds', 'Minutes', 'Hours', 'Date', 'Month', 'FullYear'], function(s) {
Date['hcSet' + s] = SET + s;
});
}
/**
* Merge the default options with custom options and return the new options structure
* @param {Object} options The new custom options
*/
H.setOptions = function(options) {
// Copy in the default options
H.defaultOptions = merge(true, H.defaultOptions, options);
// Apply UTC
setTimeMethods();
return H.defaultOptions;
};
/**
* Get the updated default options. Until 3.0.7, merely exposing defaultOptions for outside modules
* wasn't enough because the setOptions method created a new object.
*/
H.getOptions = function() {
return H.defaultOptions;
};
// Series defaults
H.defaultPlotOptions = H.defaultOptions.plotOptions;
// set the default time methods
setTimeMethods();
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var SVGElement,
SVGRenderer,
addEvent = H.addEvent,
animate = H.animate,
attr = H.attr,
charts = H.charts,
color = H.color,
css = H.css,
createElement = H.createElement,
defined = H.defined,
deg2rad = H.deg2rad,
destroyObjectProperties = H.destroyObjectProperties,
doc = H.doc,
each = H.each,
extend = H.extend,
erase = H.erase,
grep = H.grep,
hasTouch = H.hasTouch,
inArray = H.inArray,
isArray = H.isArray,
isFirefox = H.isFirefox,
isMS = H.isMS,
isObject = H.isObject,
isString = H.isString,
isWebKit = H.isWebKit,
merge = H.merge,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
removeEvent = H.removeEvent,
splat = H.splat,
stop = H.stop,
svg = H.svg,
SVG_NS = H.SVG_NS,
symbolSizes = H.symbolSizes,
win = H.win;
/**
* @typedef {Object} SVGDOMElement - An SVG DOM element.
*/
/**
* The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
* rendering layer of Highcharts. Combined with the {@link SVGRenderer} object,
* these prototypes allow freeform annotation in the charts or even in HTML
* pages without instanciating a chart. The SVGElement can also wrap HTML
* labels, when `text` or `label` elements are created with the `useHTML`
* parameter.
*
* The SVGElement instances are created through factory functions on the
* {@link SVGRenderer} object, like [rect]{@link SVGRenderer#rect},
* [path]{@link SVGRenderer#path}, [text]{@link SVGRenderer#text}, [label]{@link
* SVGRenderer#label}, [g]{@link SVGRenderer#g} and more.
*
* @class
*/
SVGElement = H.SVGElement = function() {
return this;
};
SVGElement.prototype = {
// Default base for animation
opacity: 1,
SVG_NS: SVG_NS,
/**
* For labels, these CSS properties are applied to the `text` node directly.
* @type {Array.<string>}
*/
textProps: ['direction', 'fontSize', 'fontWeight', 'fontFamily',
'fontStyle', 'color', 'lineHeight', 'width', 'textAlign',
'textDecoration', 'textOverflow', 'textOutline'
],
/**
* Initialize the SVG renderer. This function only exists to make the
* initiation process overridable. It should not be called directly.
*
* @param {SVGRenderer} renderer The SVGRenderer instance to initialize to.
* @param {String} nodeName The SVG node name.
* @returns {void}
*/
init: function(renderer, nodeName) {
/**
* The DOM node. Each SVGRenderer instance wraps a main DOM node, but
* may also represent more nodes.
* @type {SVGDOMNode|HTMLDOMNode}
*/
this.element = nodeName === 'span' ?
createElement(nodeName) :
doc.createElementNS(this.SVG_NS, nodeName);
/**
* The renderer that the SVGElement belongs to.
* @type {SVGRenderer}
*/
this.renderer = renderer;
},
/**
* Animate to given attributes or CSS properties.
*
* @param {SVGAttributes} params SVG attributes or CSS to animate.
* @param {AnimationOptions} [options] Animation options.
* @param {Function} [complete] Function to perform at the end of animation.
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
animate: function(params, options, complete) {
var animOptions = H.animObject(
pick(options, this.renderer.globalAnimation, true)
);
if (animOptions.duration !== 0) {
if (complete) { // allows using a callback with the global animation without overwriting it
animOptions.complete = complete;
}
animate(this, params, animOptions);
} else {
this.attr(params, null, complete);
if (animOptions.step) {
animOptions.step.call(this);
}
}
return this;
},
/**
* @typedef {Object} GradientOptions
* @property {Object} linearGradient Holds an object that defines the start
* position and the end position relative to the shape.
* @property {Number} linearGradient.x1 Start horizontal position of the
* gradient. Ranges 0-1.
* @property {Number} linearGradient.x2 End horizontal position of the
* gradient. Ranges 0-1.
* @property {Number} linearGradient.y1 Start vertical position of the
* gradient. Ranges 0-1.
* @property {Number} linearGradient.y2 End vertical position of the
* gradient. Ranges 0-1.
* @property {Object} radialGradient Holds an object that defines the center
* position and the radius.
* @property {Number} radialGradient.cx Center horizontal position relative
* to the shape. Ranges 0-1.
* @property {Number} radialGradient.cy Center vertical position relative
* to the shape. Ranges 0-1.
* @property {Number} radialGradient.r Radius relative to the shape. Ranges
* 0-1.
* @property {Array.<Array>} stops The first item in each tuple is the
* position in the gradient, where 0 is the start of the gradient and 1
* is the end of the gradient. Multiple stops can be applied. The second
* item is the color for each stop. This color can also be given in the
* rgba format.
*
* @example
* // Linear gradient used as a color option
* color: {
* linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
* stops: [
* [0, '#003399'], // start
* [0.5, '#ffffff'], // middle
* [1, '#3366AA'] // end
* ]
* }
* }
*/
/**
* Build and apply an SVG gradient out of a common JavaScript configuration
* object. This function is called from the attribute setters.
*
* @private
* @param {GradientOptions} color The gradient options structure.
* @param {string} prop The property to apply, can either be `fill` or
* `stroke`.
* @param {SVGDOMElement} elem SVG DOM element to apply the gradient on.
*/
colorGradient: function(color, prop, elem) {
var renderer = this.renderer,
colorObject,
gradName,
gradAttr,
radAttr,
gradients,
gradientObject,
stops,
stopColor,
stopOpacity,
radialReference,
n,
id,
key = [],
value;
// Apply linear or radial gradients
if (color.radialGradient) {
gradName = 'radialGradient';
} else if (color.linearGradient) {
gradName = 'linearGradient';
}
if (gradName) {
gradAttr = color[gradName];
gradients = renderer.gradients;
stops = color.stops;
radialReference = elem.radialReference;
// Keep < 2.2 kompatibility
if (isArray(gradAttr)) {
color[gradName] = gradAttr = {
x1: gradAttr[0],
y1: gradAttr[1],
x2: gradAttr[2],
y2: gradAttr[3],
gradientUnits: 'userSpaceOnUse'
};
}
// Correct the radial gradient for the radial reference system
if (
gradName === 'radialGradient' &&
radialReference &&
!defined(gradAttr.gradientUnits)
) {
radAttr = gradAttr; // Save the radial attributes for updating
gradAttr = merge(
gradAttr,
renderer.getRadialAttr(radialReference, radAttr), {
gradientUnits: 'userSpaceOnUse'
}
);
}
// Build the unique key to detect whether we need to create a new element (#1282)
for (n in gradAttr) {
if (n !== 'id') {
key.push(n, gradAttr[n]);
}
}
for (n in stops) {
key.push(stops[n]);
}
key = key.join(',');
// Check if a gradient object with the same config object is created within this renderer
if (gradients[key]) {
id = gradients[key].attr('id');
} else {
// Set the id and create the element
gradAttr.id = id = H.uniqueKey();
gradients[key] = gradientObject = renderer.createElement(gradName)
.attr(gradAttr)
.add(renderer.defs);
gradientObject.radAttr = radAttr;
// The gradient needs to keep a list of stops to be able to destroy them
gradientObject.stops = [];
each(stops, function(stop) {
var stopObject;
if (stop[1].indexOf('rgba') === 0) {
colorObject = H.color(stop[1]);
stopColor = colorObject.get('rgb');
stopOpacity = colorObject.get('a');
} else {
stopColor = stop[1];
stopOpacity = 1;
}
stopObject = renderer.createElement('stop').attr({
offset: stop[0],
'stop-color': stopColor,
'stop-opacity': stopOpacity
}).add(gradientObject);
// Add the stop element to the gradient
gradientObject.stops.push(stopObject);
});
}
// Set the reference to the gradient object
value = 'url(' + renderer.url + '#' + id + ')';
elem.setAttribute(prop, value);
elem.gradient = key;
// Allow the color to be concatenated into tooltips formatters etc. (#2995)
color.toString = function() {
return value;
};
}
},
/**
* Apply a text outline through a custom CSS property, by copying the text
* element and apply stroke to the copy. Used internally. Contrast checks
* at http://jsfiddle.net/highcharts/43soe9m1/2/ .
*
* @private
* @param {String} textOutline A custom CSS `text-outline` setting, defined
* by `width color`.
* @example
* // Specific color
* text.css({
* textOutline: '1px black'
* });
* // Automatic contrast
* text.css({
* color: '#000000', // black text
* textOutline: '1px contrast' // => white outline
* });
*/
applyTextOutline: function(textOutline) {
var elem = this.element,
tspans,
tspan,
hasContrast = textOutline.indexOf('contrast') !== -1,
styles = {},
color,
strokeWidth,
firstRealChild,
i;
// When the text shadow is set to contrast, use dark stroke for light
// text and vice versa.
if (hasContrast) {
styles.textOutline = textOutline = textOutline.replace(
/contrast/g,
this.renderer.getContrast(elem.style.fill)
);
}
// Extract the stroke width and color
textOutline = textOutline.split(' ');
color = textOutline[textOutline.length - 1];
strokeWidth = textOutline[0];
if (strokeWidth && strokeWidth !== 'none' && H.svg) {
this.fakeTS = true; // Fake text shadow
tspans = [].slice.call(elem.getElementsByTagName('tspan'));
// In order to get the right y position of the clone,
// copy over the y setter
this.ySetter = this.xSetter;
// Since the stroke is applied on center of the actual outline, we
// need to double it to get the correct stroke-width outside the
// glyphs.
strokeWidth = strokeWidth.replace(
/(^[\d\.]+)(.*?)$/g,
function(match, digit, unit) {
return (2 * digit) + unit;
}
);
// Remove shadows from previous runs. Iterate from the end to
// support removing items inside the cycle (#6472).
i = tspans.length;
while (i--) {
tspan = tspans[i];
if (tspan.getAttribute('class') === 'highcharts-text-outline') {
// Remove then erase
erase(tspans, elem.removeChild(tspan));
}
}
// For each of the tspans, create a stroked copy behind it.
firstRealChild = elem.firstChild;
each(tspans, function(tspan, y) {
var clone;
// Let the first line start at the correct X position
if (y === 0) {
tspan.setAttribute('x', elem.getAttribute('x'));
y = elem.getAttribute('y');
tspan.setAttribute('y', y || 0);
if (y === null) {
elem.setAttribute('y', 0);
}
}
// Create the clone and apply outline properties
clone = tspan.cloneNode(1);
attr(clone, {
'class': 'highcharts-text-outline',
'fill': color,
'stroke': color,
'stroke-width': strokeWidth,
'stroke-linejoin': 'round'
});
elem.insertBefore(clone, firstRealChild);
});
}
},
/**
*
* @typedef {Object} SVGAttributes An object of key-value pairs for SVG
* attributes. Attributes in Highcharts elements for the most parts
* correspond to SVG, but some are specific to Highcharts, like `zIndex`,
* `rotation`, `translateX`, `translateY`, `scaleX` and `scaleY`. SVG
* attributes containing a hyphen are _not_ camel-cased, they should be
* quoted to preserve the hyphen.
* @example
* {
* 'stroke': '#ff0000', // basic
* 'stroke-width': 2, // hyphenated
* 'rotation': 45 // custom
* 'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
* }
*/
/**
* Apply native and custom attributes to the SVG elements.
*
* In order to set the rotation center for rotation, set x and y to 0 and
* use `translateX` and `translateY` attributes to position the element
* instead.
*
* Attributes frequently used in Highcharts are `fill`, `stroke`,
* `stroke-width`.
*
* @param {SVGAttributes|String} hash - The native and custom SVG
* attributes.
* @param {string} [val] - If the type of the first argument is `string`,
* the second can be a value, which will serve as a single attribute
* setter. If the first argument is a string and the second is undefined,
* the function serves as a getter and the current value of the property
* is returned.
* @param {Function} complete - A callback function to execute after setting
* the attributes. This makes the function compliant and interchangeable
* with the {@link SVGElement#animate} function.
* @param {boolean} continueAnimation - Used internally when `.attr` is
* called as part of an animation step. Otherwise, calling `.attr` for an
* attribute will stop animation for that attribute.
*
* @returns {SVGElement|string|number} If used as a setter, it returns the
* current {@link SVGElement} so the calls can be chained. If used as a
* getter, the current value of the attribute is returned.
*
* @example
* // Set multiple attributes
* element.attr({
* stroke: 'red',
* fill: 'blue',
* x: 10,
* y: 10
* });
*
* // Set a single attribute
* element.attr('stroke', 'red');
*
* // Get an attribute
* element.attr('stroke'); // => 'red'
*
*/
attr: function(hash, val, complete, continueAnimation) {
var key,
value,
element = this.element,
hasSetSymbolSize,
ret = this,
skipAttr,
setter;
// single key-value pair
if (typeof hash === 'string' && val !== undefined) {
key = hash;
hash = {};
hash[key] = val;
}
// used as a getter: first argument is a string, second is undefined
if (typeof hash === 'string') {
ret = (this[hash + 'Getter'] || this._defaultGetter).call(this, hash, element);
// setter
} else {
for (key in hash) {
value = hash[key];
skipAttr = false;
// Unless .attr is from the animator update, stop current
// running animation of this property
if (!continueAnimation) {
stop(this, key);
}
// Special handling of symbol attributes
if (
this.symbolName &&
/^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)$/
.test(key)
) {
if (!hasSetSymbolSize) {
this.symbolAttr(hash);
hasSetSymbolSize = true;
}
skipAttr = true;
}
if (this.rotation && (key === 'x' || key === 'y')) {
this.doTransform = true;
}
if (!skipAttr) {
setter = this[key + 'Setter'] || this._defaultSetter;
setter.call(this, value, key, element);
// Let the shadow follow the main element
if (this.shadows && /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) {
this.updateShadows(key, value, setter);
}
}
}
// Update transform. Do this outside the loop to prevent redundant updating for batch setting
// of attributes.
if (this.doTransform) {
this.updateTransform();
this.doTransform = false;
}
}
// In accordance with animate, run a complete callback
if (complete) {
complete();
}
return ret;
},
/**
* Update the shadow elements with new attributes.
*
* @private
* @param {String} key - The attribute name.
* @param {String|Number} value - The value of the attribute.
* @param {Function} setter - The setter function, inherited from the
* parent wrapper
* @returns {void}
*/
updateShadows: function(key, value, setter) {
var shadows = this.shadows,
i = shadows.length;
while (i--) {
setter.call(
shadows[i],
key === 'height' ?
Math.max(value - (shadows[i].cutHeight || 0), 0) :
key === 'd' ? this.d : value,
key,
shadows[i]
);
}
},
/**
* Add a class name to an element.
*
* @param {string} className - The new class name to add.
* @param {boolean} [replace=false] - When true, the existing class name(s)
* will be overwritten with the new one. When false, the new one is
* added.
* @returns {SVGElement} Return the SVG element for chainability.
*/
addClass: function(className, replace) {
var currentClassName = this.attr('class') || '';
if (currentClassName.indexOf(className) === -1) {
if (!replace) {
className =
(currentClassName + (currentClassName ? ' ' : '') +
className).replace(' ', ' ');
}
this.attr('class', className);
}
return this;
},
/**
* Check if an element has the given class name.
* @param {string} className - The class name to check for.
* @return {Boolean}
*/
hasClass: function(className) {
return attr(this.element, 'class').indexOf(className) !== -1;
},
/**
* Remove a class name from the element.
* @param {string} className The class name to remove.
* @return {SVGElement} Returns the SVG element for chainability.
*/
removeClass: function(className) {
attr(this.element, 'class', (attr(this.element, 'class') || '').replace(className, ''));
return this;
},
/**
* If one of the symbol size affecting parameters are changed,
* check all the others only once for each call to an element's
* .attr() method
* @param {Object} hash - The attributes to set.
* @private
*/
symbolAttr: function(hash) {
var wrapper = this;
each(['x', 'y', 'r', 'start', 'end', 'width', 'height', 'innerR', 'anchorX', 'anchorY'], function(key) {
wrapper[key] = pick(hash[key], wrapper[key]);
});
wrapper.attr({
d: wrapper.renderer.symbols[wrapper.symbolName](
wrapper.x,
wrapper.y,
wrapper.width,
wrapper.height,
wrapper
)
});
},
/**
* Apply a clipping rectangle to this element.
*
* @param {ClipRect} [clipRect] - The clipping rectangle. If skipped, the
* current clip is removed.
* @returns {SVGElement} Returns the SVG element to allow chaining.
*/
clip: function(clipRect) {
return this.attr(
'clip-path',
clipRect ?
'url(' + this.renderer.url + '#' + clipRect.id + ')' :
'none'
);
},
/**
* Calculate the coordinates needed for drawing a rectangle crisply and
* return the calculated attributes.
*
* @param {Object} rect - A rectangle.
* @param {number} rect.x - The x position.
* @param {number} rect.y - The y position.
* @param {number} rect.width - The width.
* @param {number} rect.height - The height.
* @param {number} [strokeWidth] - The stroke width to consider when
* computing crisp positioning. It can also be set directly on the rect
* parameter.
*
* @returns {{x: Number, y: Number, width: Number, height: Number}} The
* modified rectangle arguments.
*/
crisp: function(rect, strokeWidth) {
var wrapper = this,
key,
attribs = {},
normalizer;
strokeWidth = strokeWidth || rect.strokeWidth || 0;
normalizer = Math.round(strokeWidth) % 2 / 2; // Math.round because strokeWidth can sometimes have roundoff errors
// normalize for crisp edges
rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
rect.width = Math.floor((rect.width || wrapper.width || 0) - 2 * normalizer);
rect.height = Math.floor((rect.height || wrapper.height || 0) - 2 * normalizer);
if (defined(rect.strokeWidth)) {
rect.strokeWidth = strokeWidth;
}
for (key in rect) {
if (wrapper[key] !== rect[key]) { // only set attribute if changed
wrapper[key] = attribs[key] = rect[key];
}
}
return attribs;
},
/**
* Set styles for the element. In addition to CSS styles supported by
* native SVG and HTML elements, there are also some custom made for
* Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
* elements.
* @param {CSSObject} styles The new CSS styles.
* @returns {SVGElement} Return the SVG element for chaining.
*/
css: function(styles) {
var oldStyles = this.styles,
newStyles = {},
elem = this.element,
textWidth,
n,
serializedCss = '',
hyphenate,
hasNew = !oldStyles,
// These CSS properties are interpreted internally by the SVG
// renderer, but are not supported by SVG and should not be added to
// the DOM. In styled mode, no CSS should find its way to the DOM
// whatsoever (#6173, #6474).
svgPseudoProps = ['textOutline', 'textOverflow', 'width'];
// convert legacy
if (styles && styles.color) {
styles.fill = styles.color;
}
// Filter out existing styles to increase performance (#2640)
if (oldStyles) {
for (n in styles) {
if (styles[n] !== oldStyles[n]) {
newStyles[n] = styles[n];
hasNew = true;
}
}
}
if (hasNew) {
// Merge the new styles with the old ones
if (oldStyles) {
styles = extend(
oldStyles,
newStyles
);
}
// Get the text width from style
textWidth = this.textWidth = (
styles &&
styles.width &&
styles.width !== 'auto' &&
elem.nodeName.toLowerCase() === 'text' &&
pInt(styles.width)
);
// store object
this.styles = styles;
if (textWidth && (!svg && this.renderer.forExport)) {
delete styles.width;
}
// serialize and set style attribute
if (isMS && !svg) {
css(this.element, styles);
} else {
hyphenate = function(a, b) {
return '-' + b.toLowerCase();
};
for (n in styles) {
if (inArray(n, svgPseudoProps) === -1) {
serializedCss +=
n.replace(/([A-Z])/g, hyphenate) + ':' +
styles[n] + ';';
}
}
if (serializedCss) {
attr(elem, 'style', serializedCss); // #1881
}
}
if (this.added) {
// Rebuild text after added. Cache mechanisms in the buildText
// will prevent building if there are no significant changes.
if (this.element.nodeName === 'text') {
this.renderer.buildText(this);
}
// Apply text outline after added
if (styles && styles.textOutline) {
this.applyTextOutline(styles.textOutline);
}
}
}
return this;
},
/**
* Get the current stroke width. In classic mode, the setter registers it
* directly on the element.
* @returns {number} The stroke width in pixels.
* @ignore
*/
strokeWidth: function() {
return this['stroke-width'] || 0;
},
/**
* Add an event listener. This is a simple setter that replaces all other
* events of the same type, opposed to the {@link Highcharts#addEvent}
* function.
* @param {string} eventType - The event type. If the type is `click`,
* Highcharts will internally translate it to a `touchstart` event on
* touch devices, to prevent the browser from waiting for a click event
* from firing.
* @param {Function} handler - The handler callback.
* @returns {SVGElement} The SVGElement for chaining.
*/
on: function(eventType, handler) {
var svgElement = this,
element = svgElement.element;
// touch
if (hasTouch && eventType === 'click') {
element.ontouchstart = function(e) {
svgElement.touchEventFired = Date.now(); // #2269
e.preventDefault();
handler.call(element, e);
};
element.onclick = function(e) {
if (win.navigator.userAgent.indexOf('Android') === -1 ||
Date.now() - (svgElement.touchEventFired || 0) > 1100) {
handler.call(element, e);
}
};
} else {
// simplest possible event model for internal use
element['on' + eventType] = handler;
}
return this;
},
/**
* Set the coordinates needed to draw a consistent radial gradient across
* a shape regardless of positioning inside the chart. Used on pie slices
* to make all the slices have the same radial reference point.
*
* @param {Array} coordinates The center reference. The format is
* `[centerX, centerY, diameter]` in pixels.
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
setRadialReference: function(coordinates) {
var existingGradient = this.renderer.gradients[this.element.gradient];
this.element.radialReference = coordinates;
// On redrawing objects with an existing gradient, the gradient needs
// to be repositioned (#3801)
if (existingGradient && existingGradient.radAttr) {
existingGradient.animate(
this.renderer.getRadialAttr(
coordinates,
existingGradient.radAttr
)
);
}
return this;
},
/**
* Move an object and its children by x and y values.
*
* @param {number} x - The x value.
* @param {number} y - The y value.
*/
translate: function(x, y) {
return this.attr({
translateX: x,
translateY: y
});
},
/**
* Invert a group, rotate and flip. This is used internally on inverted
* charts, where the points and graphs are drawn as if not inverted, then
* the series group elements are inverted.
*
* @param {boolean} inverted - Whether to invert or not. An inverted shape
* can be un-inverted by setting it to false.
* @returns {SVGElement} Return the SVGElement for chaining.
*/
invert: function(inverted) {
var wrapper = this;
wrapper.inverted = inverted;
wrapper.updateTransform();
return wrapper;
},
/**
* Update the transform attribute based on internal properties. Deals with
* the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
* attributes and updates the SVG `transform` attribute.
* @private
* @returns {void}
*/
updateTransform: function() {
var wrapper = this,
translateX = wrapper.translateX || 0,
translateY = wrapper.translateY || 0,
scaleX = wrapper.scaleX,
scaleY = wrapper.scaleY,
inverted = wrapper.inverted,
rotation = wrapper.rotation,
element = wrapper.element,
transform;
// flipping affects translate as adjustment for flipping around the group's axis
if (inverted) {
translateX += wrapper.width;
translateY += wrapper.height;
}
// Apply translate. Nearly all transformed elements have translation, so instead
// of checking for translate = 0, do it always (#1767, #1846).
transform = ['translate(' + translateX + ',' + translateY + ')'];
// apply rotation
if (inverted) {
transform.push('rotate(90) scale(-1,1)');
} else if (rotation) { // text rotation
transform.push('rotate(' + rotation + ' ' + (element.getAttribute('x') || 0) + ' ' + (element.getAttribute('y') || 0) + ')');
// Delete bBox memo when the rotation changes
//delete wrapper.bBox;
}
// apply scale
if (defined(scaleX) || defined(scaleY)) {
transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')');
}
if (transform.length) {
element.setAttribute('transform', transform.join(' '));
}
},
/**
* Bring the element to the front.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
toFront: function() {
var element = this.element;
element.parentNode.appendChild(element);
return this;
},
/**
* Align the element relative to the chart or another box.
* ß
* @param {Object} [alignOptions] The alignment options. The function can be
* called without this parameter in order to re-align an element after the
* box has been updated.
* @param {string} [alignOptions.align=left] Horizontal alignment. Can be
* one of `left`, `center` and `right`.
* @param {string} [alignOptions.verticalAlign=top] Vertical alignment. Can
* be one of `top`, `middle` and `bottom`.
* @param {number} [alignOptions.x=0] Horizontal pixel offset from
* alignment.
* @param {number} [alignOptions.y=0] Vertical pixel offset from alignment.
* @param {Boolean} [alignByTranslate=false] Use the `transform` attribute
* with translateX and translateY custom attributes to align this elements
* rather than `x` and `y` attributes.
* @param {String|Object} box The box to align to, needs a width and height.
* When the box is a string, it refers to an object in the Renderer. For
* example, when box is `spacingBox`, it refers to `Renderer.spacingBox`
* which holds `width`, `height`, `x` and `y` properties.
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
align: function(alignOptions, alignByTranslate, box) {
var align,
vAlign,
x,
y,
attribs = {},
alignTo,
renderer = this.renderer,
alignedObjects = renderer.alignedObjects,
alignFactor,
vAlignFactor;
// First call on instanciate
if (alignOptions) {
this.alignOptions = alignOptions;
this.alignByTranslate = alignByTranslate;
if (!box || isString(box)) { // boxes other than renderer handle this internally
this.alignTo = alignTo = box || 'renderer';
erase(alignedObjects, this); // prevent duplicates, like legendGroup after resize
alignedObjects.push(this);
box = null; // reassign it below
}
// When called on resize, no arguments are supplied
} else {
alignOptions = this.alignOptions;
alignByTranslate = this.alignByTranslate;
alignTo = this.alignTo;
}
box = pick(box, renderer[alignTo], renderer);
// Assign variables
align = alignOptions.align;
vAlign = alignOptions.verticalAlign;
x = (box.x || 0) + (alignOptions.x || 0); // default: left align
y = (box.y || 0) + (alignOptions.y || 0); // default: top align
// Align
if (align === 'right') {
alignFactor = 1;
} else if (align === 'center') {
alignFactor = 2;
}
if (alignFactor) {
x += (box.width - (alignOptions.width || 0)) / alignFactor;
}
attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);
// Vertical align
if (vAlign === 'bottom') {
vAlignFactor = 1;
} else if (vAlign === 'middle') {
vAlignFactor = 2;
}
if (vAlignFactor) {
y += (box.height - (alignOptions.height || 0)) / vAlignFactor;
}
attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);
// Animate only if already placed
this[this.placed ? 'animate' : 'attr'](attribs);
this.placed = true;
this.alignAttr = attribs;
return this;
},
/**
* Get the bounding box (width, height, x and y) for the element. Generally
* used to get rendered text size. Since this is called a lot in charts,
* the results are cached based on text properties, in order to save DOM
* traffic. The returned bounding box includes the rotation, so for example
* a single text line of rotation 90 will report a greater height, and a
* width corresponding to the line-height.
*
* @param {boolean} [reload] Skip the cache and get the updated DOM bouding
* box.
* @param {number} [rot] Override the element's rotation. This is internally
* used on axis labels with a value of 0 to find out what the bounding box
* would be have been if it were not rotated.
* @returns {Object} The bounding box with `x`, `y`, `width` and `height`
* properties.
*/
getBBox: function(reload, rot) {
var wrapper = this,
bBox, // = wrapper.bBox,
renderer = wrapper.renderer,
width,
height,
rotation,
rad,
element = wrapper.element,
styles = wrapper.styles,
fontSize,
textStr = wrapper.textStr,
toggleTextShadowShim,
cache = renderer.cache,
cacheKeys = renderer.cacheKeys,
cacheKey;
rotation = pick(rot, wrapper.rotation);
rad = rotation * deg2rad;
fontSize = styles && styles.fontSize;
if (textStr !== undefined) {
cacheKey = textStr.toString();
// Since numbers are monospaced, and numerical labels appear a lot
// in a chart, we assume that a label of n characters has the same
// bounding box as others of the same length. Unless there is inner
// HTML in the label. In that case, leave the numbers as is (#5899).
if (cacheKey.indexOf('<') === -1) {
cacheKey = cacheKey.replace(/[0-9]/g, '0');
}
// Properties that affect bounding box
cacheKey += [
'',
rotation || 0,
fontSize,
styles && styles.width,
styles && styles.textOverflow // #5968
]
.join(',');
}
if (cacheKey && !reload) {
bBox = cache[cacheKey];
}
// No cache found
if (!bBox) {
// SVG elements
if (element.namespaceURI === wrapper.SVG_NS || renderer.forExport) {
try { // Fails in Firefox if the container has display: none.
// When the text shadow shim is used, we need to hide the fake shadows
// to get the correct bounding box (#3872)
toggleTextShadowShim = this.fakeTS && function(display) {
each(element.querySelectorAll('.highcharts-text-outline'), function(tspan) {
tspan.style.display = display;
});
};
// Workaround for #3842, Firefox reporting wrong bounding box for shadows
if (toggleTextShadowShim) {
toggleTextShadowShim('none');
}
bBox = element.getBBox ?
// SVG: use extend because IE9 is not allowed to change width and height in case
// of rotation (below)
extend({}, element.getBBox()) : {
// Legacy IE in export mode
width: element.offsetWidth,
height: element.offsetHeight
};
// #3842
if (toggleTextShadowShim) {
toggleTextShadowShim('');
}
} catch (e) {}
// If the bBox is not set, the try-catch block above failed. The other condition
// is for Opera that returns a width of -Infinity on hidden elements.
if (!bBox || bBox.width < 0) {
bBox = {
width: 0,
height: 0
};
}
// VML Renderer or useHTML within SVG
} else {
bBox = wrapper.htmlGetBBox();
}
// True SVG elements as well as HTML elements in modern browsers using the .useHTML option
// need to compensated for rotation
if (renderer.isSVG) {
width = bBox.width;
height = bBox.height;
// Workaround for wrong bounding box in IE, Edge and Chrome on
// Windows. With Highcharts' default font, IE and Edge report
// a box height of 16.899 and Chrome rounds it to 17. If this
// stands uncorrected, it results in more padding added below
// the text than above when adding a label border or background.
// Also vertical positioning is affected.
// http://jsfiddle.net/highcharts/em37nvuj/
// (#1101, #1505, #1669, #2568, #6213).
if (
styles &&
styles.fontSize === '11px' &&
Math.round(height) === 17
) {
bBox.height = height = 14;
}
// Adjust for rotated text
if (rotation) {
bBox.width = Math.abs(height * Math.sin(rad)) + Math.abs(width * Math.cos(rad));
bBox.height = Math.abs(height * Math.cos(rad)) + Math.abs(width * Math.sin(rad));
}
}
// Cache it. When loading a chart in a hidden iframe in Firefox and IE/Edge, the
// bounding box height is 0, so don't cache it (#5620).
if (cacheKey && bBox.height > 0) {
// Rotate (#4681)
while (cacheKeys.length > 250) {
delete cache[cacheKeys.shift()];
}
if (!cache[cacheKey]) {
cacheKeys.push(cacheKey);
}
cache[cacheKey] = bBox;
}
}
return bBox;
},
/**
* Show the element after it has been hidden.
*
* @param {boolean} [inherit=false] Set the visibility attribute to
* `inherit` rather than `visible`. The difference is that an element with
* `visibility="visible"` will be visible even if the parent is hidden.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
show: function(inherit) {
return this.attr({
visibility: inherit ? 'inherit' : 'visible'
});
},
/**
* Hide the element, equivalent to setting the `visibility` attribute to
* `hidden`.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
hide: function() {
return this.attr({
visibility: 'hidden'
});
},
/**
* Fade out an element by animating its opacity down to 0, and hide it on
* complete. Used internally for the tooltip.
*
* @param {number} [duration=150] The fade duration in milliseconds.
*/
fadeOut: function(duration) {
var elemWrapper = this;
elemWrapper.animate({
opacity: 0
}, {
duration: duration || 150,
complete: function() {
elemWrapper.attr({
y: -9999
}); // #3088, assuming we're only using this for tooltips
}
});
},
/**
* Add the element to the DOM. All elements must be added this way.
*
* @param {SVGElement|SVGDOMElement} [parent] The parent item to add it to.
* If undefined, the element is added to the {@link SVGRenderer.box}.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*
* @sample highcharts/members/renderer-g - Elements added to a group
*/
add: function(parent) {
var renderer = this.renderer,
element = this.element,
inserted;
if (parent) {
this.parentGroup = parent;
}
// mark as inverted
this.parentInverted = parent && parent.inverted;
// build formatted text
if (this.textStr !== undefined) {
renderer.buildText(this);
}
// Mark as added
this.added = true;
// If we're adding to renderer root, or other elements in the group
// have a z index, we need to handle it
if (!parent || parent.handleZ || this.zIndex) {
inserted = this.zIndexSetter();
}
// If zIndex is not handled, append at the end
if (!inserted) {
(parent ? parent.element : renderer.box).appendChild(element);
}
// fire an event for internal hooks
if (this.onAdd) {
this.onAdd();
}
return this;
},
/**
* Removes an element from the DOM.
*
* @private
* @param {SVGDOMElement|HTMLDOMElement} element The DOM node to remove.
*/
safeRemoveChild: function(element) {
var parentNode = element.parentNode;
if (parentNode) {
parentNode.removeChild(element);
}
},
/**
* Destroy the element and element wrapper and clear up the DOM and event
* hooks.
*
* @returns {void}
*/
destroy: function() {
var wrapper = this,
element = wrapper.element || {},
parentToClean = wrapper.renderer.isSVG && element.nodeName === 'SPAN' && wrapper.parentGroup,
grandParent,
key,
i;
// remove events
element.onclick = element.onmouseout = element.onmouseover = element.onmousemove = element.point = null;
stop(wrapper); // stop running animations
if (wrapper.clipPath) {
// Look for existing references to this clipPath and remove them
// before destroying the element (#6196).
each(
wrapper.element.ownerSVGElement.querySelectorAll('[clip-path]'),
function(el) {
if (el.getAttribute('clip-path')
.indexOf(wrapper.clipPath.element.id) > -1) {
el.removeAttribute('clip-path');
}
}
);
wrapper.clipPath = wrapper.clipPath.destroy();
}
// Destroy stops in case this is a gradient object
if (wrapper.stops) {
for (i = 0; i < wrapper.stops.length; i++) {
wrapper.stops[i] = wrapper.stops[i].destroy();
}
wrapper.stops = null;
}
// remove element
wrapper.safeRemoveChild(element);
wrapper.destroyShadows();
// In case of useHTML, clean up empty containers emulating SVG groups (#1960, #2393, #2697).
while (parentToClean && parentToClean.div && parentToClean.div.childNodes.length === 0) {
grandParent = parentToClean.parentGroup;
wrapper.safeRemoveChild(parentToClean.div);
delete parentToClean.div;
parentToClean = grandParent;
}
// remove from alignObjects
if (wrapper.alignTo) {
erase(wrapper.renderer.alignedObjects, wrapper);
}
for (key in wrapper) {
delete wrapper[key];
}
return null;
},
/**
* @typedef {Object} ShadowOptions
* @property {string} [color=#000000] The shadow color.
* @property {number} [offsetX=1] The horizontal offset from the element.
* @property {number} [offsetY=1] The vertical offset from the element.
* @property {number} [opacity=0.15] The shadow opacity.
* @property {number} [width=3] The shadow width or distance from the
* element.
*/
/**
* Add a shadow to the element. Must be called after the element is added to
* the DOM. In styled mode, this method is not used, instead use `defs` and
* filters.
*
* @param {boolean|ShadowOptions} shadowOptions The shadow options. If
* `true`, the default options are applied. If `false`, the current
* shadow will be removed.
* @param {SVGElement} [group] The SVG group element where the shadows will
* be applied. The default is to add it to the same parent as the current
* element. Internally, this is ised for pie slices, where all the
* shadows are added to an element behind all the slices.
* @param {boolean} [cutOff] Used internally for column shadows.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*
* @example
* renderer.rect(10, 100, 100, 100)
* .attr({ fill: 'red' })
* .shadow(true);
*/
shadow: function(shadowOptions, group, cutOff) {
var shadows = [],
i,
shadow,
element = this.element,
strokeWidth,
shadowWidth,
shadowElementOpacity,
// compensate for inverted plot area
transform;
if (!shadowOptions) {
this.destroyShadows();
} else if (!this.shadows) {
shadowWidth = pick(shadowOptions.width, 3);
shadowElementOpacity = (shadowOptions.opacity || 0.15) / shadowWidth;
transform = this.parentInverted ?
'(-1,-1)' :
'(' + pick(shadowOptions.offsetX, 1) + ', ' + pick(shadowOptions.offsetY, 1) + ')';
for (i = 1; i <= shadowWidth; i++) {
shadow = element.cloneNode(0);
strokeWidth = (shadowWidth * 2) + 1 - (2 * i);
attr(shadow, {
'isShadow': 'true',
'stroke': shadowOptions.color || '#000000',
'stroke-opacity': shadowElementOpacity * i,
'stroke-width': strokeWidth,
'transform': 'translate' + transform,
'fill': 'none'
});
if (cutOff) {
attr(shadow, 'height', Math.max(attr(shadow, 'height') - strokeWidth, 0));
shadow.cutHeight = strokeWidth;
}
if (group) {
group.element.appendChild(shadow);
} else {
element.parentNode.insertBefore(shadow, element);
}
shadows.push(shadow);
}
this.shadows = shadows;
}
return this;
},
/**
* Destroy shadows on the element.
* @private
*/
destroyShadows: function() {
each(this.shadows || [], function(shadow) {
this.safeRemoveChild(shadow);
}, this);
this.shadows = undefined;
},
xGetter: function(key) {
if (this.element.nodeName === 'circle') {
if (key === 'x') {
key = 'cx';
} else if (key === 'y') {
key = 'cy';
}
}
return this._defaultGetter(key);
},
/**
* Get the current value of an attribute or pseudo attribute, used mainly
* for animation. Called internally from the {@link SVGRenderer#attr}
* function.
*
* @private
*/
_defaultGetter: function(key) {
var ret = pick(this[key], this.element ? this.element.getAttribute(key) : null, 0);
if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
ret = parseFloat(ret);
}
return ret;
},
dSetter: function(value, key, element) {
if (value && value.join) { // join path
value = value.join(' ');
}
if (/(NaN| {2}|^$)/.test(value)) {
value = 'M 0 0';
}
element.setAttribute(key, value);
this[key] = value;
},
dashstyleSetter: function(value) {
var i,
strokeWidth = this['stroke-width'];
// If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new strokeWidth
// function, we should be able to use that instead.
if (strokeWidth === 'inherit') {
strokeWidth = 1;
}
value = value && value.toLowerCase();
if (value) {
value = value
.replace('shortdashdotdot', '3,1,1,1,1,1,')
.replace('shortdashdot', '3,1,1,1')
.replace('shortdot', '1,1,')
.replace('shortdash', '3,1,')
.replace('longdash', '8,3,')
.replace(/dot/g, '1,3,')
.replace('dash', '4,3,')
.replace(/,$/, '')
.split(','); // ending comma
i = value.length;
while (i--) {
value[i] = pInt(value[i]) * strokeWidth;
}
value = value.join(',')
.replace(/NaN/g, 'none'); // #3226
this.element.setAttribute('stroke-dasharray', value);
}
},
alignSetter: function(value) {
var convert = {
left: 'start',
center: 'middle',
right: 'end'
};
this.element.setAttribute('text-anchor', convert[value]);
},
opacitySetter: function(value, key, element) {
this[key] = value;
element.setAttribute(key, value);
},
titleSetter: function(value) {
var titleNode = this.element.getElementsByTagName('title')[0];
if (!titleNode) {
titleNode = doc.createElementNS(this.SVG_NS, 'title');
this.element.appendChild(titleNode);
}
// Remove text content if it exists
if (titleNode.firstChild) {
titleNode.removeChild(titleNode.firstChild);
}
titleNode.appendChild(
doc.createTextNode(
(String(pick(value), '')).replace(/<[^>]*>/g, '') // #3276, #3895
)
);
},
textSetter: function(value) {
if (value !== this.textStr) {
// Delete bBox memo when the text changes
delete this.bBox;
this.textStr = value;
if (this.added) {
this.renderer.buildText(this);
}
}
},
fillSetter: function(value, key, element) {
if (typeof value === 'string') {
element.setAttribute(key, value);
} else if (value) {
this.colorGradient(value, key, element);
}
},
visibilitySetter: function(value, key, element) {
// IE9-11 doesn't handle visibilty:inherit well, so we remove the attribute instead (#2881, #3909)
if (value === 'inherit') {
element.removeAttribute(key);
} else {
element.setAttribute(key, value);
}
},
zIndexSetter: function(value, key) {
var renderer = this.renderer,
parentGroup = this.parentGroup,
parentWrapper = parentGroup || renderer,
parentNode = parentWrapper.element || renderer.box,
childNodes,
otherElement,
otherZIndex,
element = this.element,
inserted,
run = this.added,
i;
if (defined(value)) {
element.zIndex = value; // So we can read it for other elements in the group
value = +value;
if (this[key] === value) { // Only update when needed (#3865)
run = false;
}
this[key] = value;
}
// Insert according to this and other elements' zIndex. Before .add() is called,
// nothing is done. Then on add, or by later calls to zIndexSetter, the node
// is placed on the right place in the DOM.
if (run) {
value = this.zIndex;
if (value && parentGroup) {
parentGroup.handleZ = true;
}
childNodes = parentNode.childNodes;
for (i = 0; i < childNodes.length && !inserted; i++) {
otherElement = childNodes[i];
otherZIndex = otherElement.zIndex;
if (otherElement !== element && (
// Insert before the first element with a higher zIndex
pInt(otherZIndex) > value ||
// If no zIndex given, insert before the first element with a zIndex
(!defined(value) && defined(otherZIndex)) ||
// Negative zIndex versus no zIndex:
// On all levels except the highest. If the parent is <svg>,
// then we don't want to put items before <desc> or <defs>
(value < 0 && !defined(otherZIndex) && parentNode !== renderer.box)
)) {
parentNode.insertBefore(element, otherElement);
inserted = true;
}
}
if (!inserted) {
parentNode.appendChild(element);
}
}
return inserted;
},
_defaultSetter: function(value, key, element) {
element.setAttribute(key, value);
}
};
// Some shared setters and getters
SVGElement.prototype.yGetter = SVGElement.prototype.xGetter;
SVGElement.prototype.translateXSetter = SVGElement.prototype.translateYSetter =
SVGElement.prototype.rotationSetter = SVGElement.prototype.verticalAlignSetter =
SVGElement.prototype.scaleXSetter = SVGElement.prototype.scaleYSetter = function(value, key) {
this[key] = value;
this.doTransform = true;
};
// WebKit and Batik have problems with a stroke-width of zero, so in this case we remove the
// stroke attribute altogether. #1270, #1369, #3065, #3072.
SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter = function(value, key, element) {
this[key] = value;
// Only apply the stroke attribute if the stroke width is defined and larger than 0
if (this.stroke && this['stroke-width']) {
SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element); // use prototype as instance may be overridden
element.setAttribute('stroke-width', this['stroke-width']);
this.hasStroke = true;
} else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
element.removeAttribute('stroke');
this.hasStroke = false;
}
};
/**
* Allows direct access to the Highcharts rendering layer in order to draw
* primitive shapes like circles, rectangles, paths or text directly on a chart,
* or independent from any chart. The SVGRenderer represents a wrapper object
* for SVGin modern browsers and through the VMLRenderer, for VML in IE < 8.
*
* An existing chart's renderer can be accessed through {@link Chart#renderer}.
* The renderer can also be used completely decoupled from a chart.
*
* @param {HTMLDOMElement} container - Where to put the SVG in the web page.
* @param {number} width - The width of the SVG.
* @param {number} height - The height of the SVG.
* @param {boolean} [forExport=false] - Whether the rendered content is intended
* for export.
* @param {boolean} [allowHTML=true] - Whether the renderer is allowed to
* include HTML text, which will be projected on top of the SVG.
*
* @example
* // Use directly without a chart object.
* var renderer = new Highcharts.Renderer(parentNode, 600, 400);
*
* @sample highcharts/members/renderer-on-chart - Annotating a chart programmatically.
* @sample highcharts/members/renderer-basic - Independedt SVG drawing.
*
* @class
*/
SVGRenderer = H.SVGRenderer = function() {
this.init.apply(this, arguments);
};
SVGRenderer.prototype = {
/**
* A pointer to the renderer's associated Element class. The VMLRenderer
* will have a pointer to VMLElement here.
* @type {SVGElement}
*/
Element: SVGElement,
SVG_NS: SVG_NS,
/**
* Initialize the SVGRenderer. Overridable initiator function that takes
* the same parameters as the constructor.
*/
init: function(container, width, height, style, forExport, allowHTML) {
var renderer = this,
boxWrapper,
element,
desc;
boxWrapper = renderer.createElement('svg')
.attr({
'version': '1.1',
'class': 'highcharts-root'
})
.css(this.getStyle(style));
element = boxWrapper.element;
container.appendChild(element);
// For browsers other than IE, add the namespace attribute (#1978)
if (container.innerHTML.indexOf('xmlns') === -1) {
attr(element, 'xmlns', this.SVG_NS);
}
// object properties
renderer.isSVG = true;
/**
* The root `svg` node of the renderer.
* @type {SVGDOMElement}
*/
this.box = element;
/**
* The wrapper for the root `svg` node of the renderer.
* @type {SVGElement}
*/
this.boxWrapper = boxWrapper;
renderer.alignedObjects = [];
/**
* Page url used for internal references.
* @type {string}
*/
// #24, #672, #1070
this.url = (isFirefox || isWebKit) && doc.getElementsByTagName('base').length ?
win.location.href
.replace(/#.*?$/, '') // remove the hash
.replace(/<[^>]*>/g, '') // wing cut HTML
.replace(/([\('\)])/g, '\\$1') // escape parantheses and quotes
.replace(/ /g, '%20') : // replace spaces (needed for Safari only)
'';
// Add description
desc = this.createElement('desc').add();
desc.element.appendChild(doc.createTextNode('Created with Highmaps 5.0.10'));
renderer.defs = this.createElement('defs').add();
renderer.allowHTML = allowHTML;
renderer.forExport = forExport;
renderer.gradients = {}; // Object where gradient SvgElements are stored
renderer.cache = {}; // Cache for numerical bounding boxes
renderer.cacheKeys = [];
renderer.imgCount = 0;
renderer.setSize(width, height, false);
// Issue 110 workaround:
// In Firefox, if a div is positioned by percentage, its pixel position may land
// between pixels. The container itself doesn't display this, but an SVG element
// inside this container will be drawn at subpixel precision. In order to draw
// sharp lines, this must be compensated for. This doesn't seem to work inside
// iframes though (like in jsFiddle).
var subPixelFix, rect;
if (isFirefox && container.getBoundingClientRect) {
subPixelFix = function() {
css(container, {
left: 0,
top: 0
});
rect = container.getBoundingClientRect();
css(container, {
left: (Math.ceil(rect.left) - rect.left) + 'px',
top: (Math.ceil(rect.top) - rect.top) + 'px'
});
};
// run the fix now
subPixelFix();
// run it on resize
renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
}
},
/**
* Get the global style setting for the renderer.
* @private
* @param {CSSObject} style - Style settings.
* @return {CSSObject} The style settings mixed with defaults.
*/
getStyle: function(style) {
this.style = extend({
fontFamily: '"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif', // default font
fontSize: '12px'
}, style);
return this.style;
},
/**
* Apply the global style on the renderer, mixed with the default styles.
* @param {CSSObject} style - CSS to apply.
*/
setStyle: function(style) {
this.boxWrapper.css(this.getStyle(style));
},
/**
* Detect whether the renderer is hidden. This happens when one of the
* parent elements has display: none. Used internally to detect when we need
* to render preliminarily in another div to get the text bounding boxes
* right.
*
* @returns {boolean} True if it is hidden.
*/
isHidden: function() { // #608
return !this.boxWrapper.getBBox().width;
},
/**
* Destroys the renderer and its allocated members.
*/
destroy: function() {
var renderer = this,
rendererDefs = renderer.defs;
renderer.box = null;
renderer.boxWrapper = renderer.boxWrapper.destroy();
// Call destroy on all gradient elements
destroyObjectProperties(renderer.gradients || {});
renderer.gradients = null;
// Defs are null in VMLRenderer
// Otherwise, destroy them here.
if (rendererDefs) {
renderer.defs = rendererDefs.destroy();
}
// Remove sub pixel fix handler (#982)
if (renderer.unSubPixelFix) {
renderer.unSubPixelFix();
}
renderer.alignedObjects = null;
return null;
},
/**
* Create a wrapper for an SVG element. Serves as a factory for
* {@link SVGElement}, but this function is itself mostly called from
* primitive factories like {@link SVGRenderer#path}, {@link
* SVGRenderer#rect} or {@link SVGRenderer#text}.
*
* @param {string} nodeName - The node name, for example `rect`, `g` etc.
* @returns {SVGElement} The generated SVGElement.
*/
createElement: function(nodeName) {
var wrapper = new this.Element();
wrapper.init(this, nodeName);
return wrapper;
},
/**
* Dummy function for plugins, called every time the renderer is updated.
* Prior to Highcharts 5, this was used for the canvg renderer.
* @function
*/
draw: noop,
/**
* Get converted radial gradient attributes according to the radial
* reference. Used internally from the {@link SVGElement#colorGradient}
* function.
*
* @private
*/
getRadialAttr: function(radialReference, gradAttr) {
return {
cx: (radialReference[0] - radialReference[2] / 2) + gradAttr.cx * radialReference[2],
cy: (radialReference[1] - radialReference[2] / 2) + gradAttr.cy * radialReference[2],
r: gradAttr.r * radialReference[2]
};
},
getSpanWidth: function(wrapper, tspan) {
var renderer = this,
bBox = wrapper.getBBox(true),
actualWidth = bBox.width;
// Old IE cannot measure the actualWidth for SVG elements (#2314)
if (!svg && renderer.forExport) {
actualWidth = renderer.measureSpanWidth(tspan.firstChild.data, wrapper.styles);
}
return actualWidth;
},
applyEllipsis: function(wrapper, tspan, text, width) {
var renderer = this,
actualWidth = renderer.getSpanWidth(wrapper, tspan),
wasTooLong = actualWidth > width,
str = text,
currentIndex,
minIndex = 0,
maxIndex = text.length,
updateTSpan = function(s) {
tspan.removeChild(tspan.firstChild);
if (s) {
tspan.appendChild(doc.createTextNode(s));
}
};
if (wasTooLong) {
while (minIndex <= maxIndex) {
currentIndex = Math.ceil((minIndex + maxIndex) / 2);
str = text.substring(0, currentIndex) + '\u2026';
updateTSpan(str);
actualWidth = renderer.getSpanWidth(wrapper, tspan);
if (minIndex === maxIndex) {
// Complete
minIndex = maxIndex + 1;
} else if (actualWidth > width) {
// Too large. Set max index to current.
maxIndex = currentIndex - 1;
} else {
// Within width. Set min index to current.
minIndex = currentIndex;
}
}
// If max index was 0 it means just ellipsis was also to large.
if (maxIndex === 0) {
// Remove ellipses.
updateTSpan('');
}
}
return wasTooLong;
},
/**
* Parse a simple HTML string into SVG tspans. Called internally when text
* is set on an SVGElement. The function supports a subset of HTML tags,
* CSS text features like `width`, `text-overflow`, `white-space`, and
* also attributes like `href` and `style`.
* @private
* @param {SVGElement} wrapper The parent SVGElement.
*/
buildText: function(wrapper) {
var textNode = wrapper.element,
renderer = this,
forExport = renderer.forExport,
textStr = pick(wrapper.textStr, '').toString(),
hasMarkup = textStr.indexOf('<') !== -1,
lines,
childNodes = textNode.childNodes,
clsRegex,
styleRegex,
hrefRegex,
wasTooLong,
parentX = attr(textNode, 'x'),
textStyles = wrapper.styles,
width = wrapper.textWidth,
textLineHeight = textStyles && textStyles.lineHeight,
textOutline = textStyles && textStyles.textOutline,
ellipsis = textStyles && textStyles.textOverflow === 'ellipsis',
noWrap = textStyles && textStyles.whiteSpace === 'nowrap',
fontSize = textStyles && textStyles.fontSize,
textCache,
isSubsequentLine,
i = childNodes.length,
tempParent = width && !wrapper.added && this.box,
getLineHeight = function(tspan) {
var fontSizeStyle;
fontSizeStyle = /(px|em)$/.test(tspan && tspan.style.fontSize) ?
tspan.style.fontSize :
(fontSize || renderer.style.fontSize || 12);
return textLineHeight ?
pInt(textLineHeight) :
renderer.fontMetrics(
fontSizeStyle,
// Get the computed size from parent if not explicit
tspan.getAttribute('style') ? tspan : textNode
).h;
},
unescapeAngleBrackets = function(inputStr) {
return inputStr.replace(/</g, '<').replace(/>/g, '>');
};
// The buildText code is quite heavy, so if we're not changing something
// that affects the text, skip it (#6113).
textCache = [
textStr,
ellipsis,
noWrap,
textLineHeight,
textOutline,
fontSize,
width
].join(',');
if (textCache === wrapper.textCache) {
return;
}
wrapper.textCache = textCache;
/// remove old text
while (i--) {
textNode.removeChild(childNodes[i]);
}
// Skip tspans, add text directly to text node. The forceTSpan is a hook
// used in text outline hack.
if (!hasMarkup && !textOutline && !ellipsis && !width && textStr.indexOf(' ') === -1) {
textNode.appendChild(doc.createTextNode(unescapeAngleBrackets(textStr)));
// Complex strings, add more logic
} else {
clsRegex = /<.*class="([^"]+)".*>/;
styleRegex = /<.*style="([^"]+)".*>/;
hrefRegex = /<.*href="(http[^"]+)".*>/;
if (tempParent) {
tempParent.appendChild(textNode); // attach it to the DOM to read offset width
}
if (hasMarkup) {
lines = textStr
.replace(/<(b|strong)>/g, '<span style="font-weight:bold">')
.replace(/<(i|em)>/g, '<span style="font-style:italic">')
.replace(/<a/g, '<span')
.replace(/<\/(b|strong|i|em|a)>/g, '</span>')
.split(/<br.*?>/g);
} else {
lines = [textStr];
}
// Trim empty lines (#5261)
lines = grep(lines, function(line) {
return line !== '';
});
// build the lines
each(lines, function buildTextLines(line, lineNo) {
var spans,
spanNo = 0;
line = line
.replace(/^\s+|\s+$/g, '') // Trim to prevent useless/costly process on the spaces (#5258)
.replace(/<span/g, '|||<span')
.replace(/<\/span>/g, '</span>|||');
spans = line.split('|||');
each(spans, function buildTextSpans(span) {
if (span !== '' || spans.length === 1) {
var attributes = {},
tspan = doc.createElementNS(renderer.SVG_NS, 'tspan'),
spanCls,
spanStyle; // #390
if (clsRegex.test(span)) {
spanCls = span.match(clsRegex)[1];
attr(tspan, 'class', spanCls);
}
if (styleRegex.test(span)) {
spanStyle = span.match(styleRegex)[1].replace(/(;| |^)color([ :])/, '$1fill$2');
attr(tspan, 'style', spanStyle);
}
if (hrefRegex.test(span) && !forExport) { // Not for export - #1529
attr(tspan, 'onclick', 'location.href=\"' + span.match(hrefRegex)[1] + '\"');
css(tspan, {
cursor: 'pointer'
});
}
span = unescapeAngleBrackets(span.replace(/<(.|\n)*?>/g, '') || ' ');
// Nested tags aren't supported, and cause crash in Safari (#1596)
if (span !== ' ') {
// add the text node
tspan.appendChild(doc.createTextNode(span));
if (!spanNo) { // first span in a line, align it to the left
if (lineNo && parentX !== null) {
attributes.x = parentX;
}
} else {
attributes.dx = 0; // #16
}
// add attributes
attr(tspan, attributes);
// Append it
textNode.appendChild(tspan);
// first span on subsequent line, add the line height
if (!spanNo && isSubsequentLine) {
// allow getting the right offset height in exporting in IE
if (!svg && forExport) {
css(tspan, {
display: 'block'
});
}
// Set the line height based on the font size of either
// the text element or the tspan element
attr(
tspan,
'dy',
getLineHeight(tspan)
);
}
/*if (width) {
renderer.breakText(wrapper, width);
}*/
// Check width and apply soft breaks or ellipsis
if (width) {
var words = span.replace(/([^\^])-/g, '$1- ').split(' '), // #1273
hasWhiteSpace = spans.length > 1 || lineNo || (words.length > 1 && !noWrap),
tooLong,
rest = [],
actualWidth,
dy = getLineHeight(tspan),
rotation = wrapper.rotation;
if (ellipsis) {
wasTooLong = renderer.applyEllipsis(wrapper, tspan, span, width);
}
while (!ellipsis && hasWhiteSpace && (words.length || rest.length)) {
wrapper.rotation = 0; // discard rotation when computing box
actualWidth = renderer.getSpanWidth(wrapper, tspan);
tooLong = actualWidth > width;
// For ellipsis, do a binary search for the correct string length
if (wasTooLong === undefined) {
wasTooLong = tooLong; // First time
}
// Looping down, this is the first word sequence that is not too long,
// so we can move on to build the next line.
if (!tooLong || words.length === 1) {
words = rest;
rest = [];
if (words.length && !noWrap) {
tspan = doc.createElementNS(SVG_NS, 'tspan');
attr(tspan, {
dy: dy,
x: parentX
});
if (spanStyle) { // #390
attr(tspan, 'style', spanStyle);
}
textNode.appendChild(tspan);
}
if (actualWidth > width) { // a single word is pressing it out
width = actualWidth;
}
} else { // append to existing line tspan
tspan.removeChild(tspan.firstChild);
rest.unshift(words.pop());
}
if (words.length) {
tspan.appendChild(doc.createTextNode(words.join(' ').replace(/- /g, '-')));
}
}
wrapper.rotation = rotation;
}
spanNo++;
}
}
});
// To avoid beginning lines that doesn't add to the textNode (#6144)
isSubsequentLine = isSubsequentLine || textNode.childNodes.length;
});
if (wasTooLong) {
wrapper.attr('title', wrapper.textStr);
}
if (tempParent) {
tempParent.removeChild(textNode); // attach it to the DOM to read offset width
}
// Apply the text outline
if (textOutline && wrapper.applyTextOutline) {
wrapper.applyTextOutline(textOutline);
}
}
},
/*
breakText: function (wrapper, width) {
var bBox = wrapper.getBBox(),
node = wrapper.element,
textLength = node.textContent.length,
pos = Math.round(width * textLength / bBox.width), // try this position first, based on average character width
increment = 0,
finalPos;
if (bBox.width > width) {
while (finalPos === undefined) {
textLength = node.getSubStringLength(0, pos);
if (textLength <= width) {
if (increment === -1) {
finalPos = pos;
} else {
increment = 1;
}
} else {
if (increment === 1) {
finalPos = pos - 1;
} else {
increment = -1;
}
}
pos += increment;
}
}
console.log('width', width, 'stringWidth', node.getSubStringLength(0, finalPos))
},
*/
/**
* Returns white for dark colors and black for bright colors.
*
* @param {ColorString} rgba - The color to get the contrast for.
* @returns {string} The contrast color, either `#000000` or `#FFFFFF`.
*/
getContrast: function(rgba) {
rgba = color(rgba).rgba;
// The threshold may be discussed. Here's a proposal for adding
// different weight to the color channels (#6216)
/*
rgba[0] *= 1; // red
rgba[1] *= 1.2; // green
rgba[2] *= 0.7; // blue
*/
return rgba[0] + rgba[1] + rgba[2] > 2 * 255 ? '#000000' : '#FFFFFF';
},
/**
* Create a button with preset states.
* @param {string} text - The text or HTML to draw.
* @param {number} x - The x position of the button's left side.
* @param {number} y - The y position of the button's top side.
* @param {Function} callback - The function to execute on button click or
* touch.
* @param {SVGAttributes} [normalState] - SVG attributes for the normal
* state.
* @param {SVGAttributes} [hoverState] - SVG attributes for the hover state.
* @param {SVGAttributes} [pressedState] - SVG attributes for the pressed
* state.
* @param {SVGAttributes} [disabledState] - SVG attributes for the disabled
* state.
* @param {Symbol} [shape=rect] - The shape type.
* @returns {SVGRenderer} The button element.
*/
button: function(text, x, y, callback, normalState, hoverState, pressedState, disabledState, shape) {
var label = this.label(text, x, y, shape, null, null, null, null, 'button'),
curState = 0;
// Default, non-stylable attributes
label.attr(merge({
'padding': 8,
'r': 2
}, normalState));
// Presentational
var normalStyle,
hoverStyle,
pressedStyle,
disabledStyle;
// Normal state - prepare the attributes
normalState = merge({
fill: '#f7f7f7',
stroke: '#cccccc',
'stroke-width': 1,
style: {
color: '#333333',
cursor: 'pointer',
fontWeight: 'normal'
}
}, normalState);
normalStyle = normalState.style;
delete normalState.style;
// Hover state
hoverState = merge(normalState, {
fill: '#e6e6e6'
}, hoverState);
hoverStyle = hoverState.style;
delete hoverState.style;
// Pressed state
pressedState = merge(normalState, {
fill: '#e6ebf5',
style: {
color: '#000000',
fontWeight: 'bold'
}
}, pressedState);
pressedStyle = pressedState.style;
delete pressedState.style;
// Disabled state
disabledState = merge(normalState, {
style: {
color: '#cccccc'
}
}, disabledState);
disabledStyle = disabledState.style;
delete disabledState.style;
// Add the events. IE9 and IE10 need mouseover and mouseout to funciton (#667).
addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function() {
if (curState !== 3) {
label.setState(1);
}
});
addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function() {
if (curState !== 3) {
label.setState(curState);
}
});
label.setState = function(state) {
// Hover state is temporary, don't record it
if (state !== 1) {
label.state = curState = state;
}
// Update visuals
label.removeClass(/highcharts-button-(normal|hover|pressed|disabled)/)
.addClass('highcharts-button-' + ['normal', 'hover', 'pressed', 'disabled'][state || 0]);
label.attr([normalState, hoverState, pressedState, disabledState][state || 0])
.css([normalStyle, hoverStyle, pressedStyle, disabledStyle][state || 0]);
};
// Presentational attributes
label
.attr(normalState)
.css(extend({
cursor: 'default'
}, normalStyle));
return label
.on('click', function(e) {
if (curState !== 3) {
callback.call(label, e);
}
});
},
/**
* Make a straight line crisper by not spilling out to neighbour pixels.
*
* @param {Array} points - The original points on the format `['M', 0, 0,
* 'L', 100, 0]`.
* @param {number} width - The width of the line.
* @returns {Array} The original points array, but modified to render
* crisply.
*/
crispLine: function(points, width) {
// normalize to a crisp line
if (points[1] === points[4]) {
// Substract due to #1129. Now bottom and left axis gridlines behave the same.
points[1] = points[4] = Math.round(points[1]) - (width % 2 / 2);
}
if (points[2] === points[5]) {
points[2] = points[5] = Math.round(points[2]) + (width % 2 / 2);
}
return points;
},
/**
* Draw a path, wraps the SVG `path` element.
*
* @param {Array} [path] An SVG path definition in array form.
*
* @example
* var path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
* .attr({ stroke: '#ff00ff' })
* .add();
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw a path, wraps the SVG `path` element.
*
* @param {SVGAttributes} [attribs] The initial attributes.
* @returns {SVGElement} The generated wrapper element.
*/
path: function(path) {
var attribs = {
fill: 'none'
};
if (isArray(path)) {
attribs.d = path;
} else if (isObject(path)) { // attributes
extend(attribs, path);
}
return this.createElement('path').attr(attribs);
},
/**
* Draw a circle, wraps the SVG `circle` element.
*
* @param {number} [x] The center x position.
* @param {number} [y] The center y position.
* @param {number} [r] The radius.
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw a circle, wraps the SVG `circle` element.
*
* @param {SVGAttributes} [attribs] The initial attributes.
* @returns {SVGElement} The generated wrapper element.
*/
circle: function(x, y, r) {
var attribs = isObject(x) ? x : {
x: x,
y: y,
r: r
},
wrapper = this.createElement('circle');
// Setting x or y translates to cx and cy
wrapper.xSetter = wrapper.ySetter = function(value, key, element) {
element.setAttribute('c' + key, value);
};
return wrapper.attr(attribs);
},
/**
* Draw and return an arc.
* @param {number} [x=0] Center X position.
* @param {number} [y=0] Center Y position.
* @param {number} [r=0] The outer radius of the arc.
* @param {number} [innerR=0] Inner radius like used in donut charts.
* @param {number} [start=0] The starting angle of the arc in radians, where
* 0 is to the right and `-Math.PI/2` is up.
* @param {number} [end=0] The ending angle of the arc in radians, where 0
* is to the right and `-Math.PI/2` is up.
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw and return an arc. Overloaded function that takes arguments object.
* @param {SVGAttributes} attribs Initial SVG attributes.
* @returns {SVGElement} The generated wrapper element.
*/
arc: function(x, y, r, innerR, start, end) {
var arc,
options;
if (isObject(x)) {
options = x;
y = options.y;
r = options.r;
innerR = options.innerR;
start = options.start;
end = options.end;
x = options.x;
} else {
options = {
innerR: innerR,
start: start,
end: end
};
}
// Arcs are defined as symbols for the ability to set
// attributes in attr and animate
arc = this.symbol('arc', x, y, r, r, options);
arc.r = r; // #959
return arc;
},
/**
* Draw and return a rectangle.
* @param {number} [x] Left position.
* @param {number} [y] Top position.
* @param {number} [width] Width of the rectangle.
* @param {number} [height] Height of the rectangle.
* @param {number} [r] Border corner radius.
* @param {number} [strokeWidth] A stroke width can be supplied to allow
* crisp drawing.
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw and return a rectangle.
* @param {SVGAttributes} [attributes] General SVG attributes for the
* rectangle.
* @returns {SVGElement} The generated wrapper element.
*/
rect: function(x, y, width, height, r, strokeWidth) {
r = isObject(x) ? x.r : r;
var wrapper = this.createElement('rect'),
attribs = isObject(x) ? x : x === undefined ? {} : {
x: x,
y: y,
width: Math.max(width, 0),
height: Math.max(height, 0)
};
if (strokeWidth !== undefined) {
attribs.strokeWidth = strokeWidth;
attribs = wrapper.crisp(attribs);
}
attribs.fill = 'none';
if (r) {
attribs.r = r;
}
wrapper.rSetter = function(value, key, element) {
attr(element, {
rx: value,
ry: value
});
};
return wrapper.attr(attribs);
},
/**
* Resize the {@link SVGRenderer#box} and re-align all aligned child
* elements.
* @param {number} width The new pixel width.
* @param {number} height The new pixel height.
* @param {boolean} animate Whether to animate.
*/
setSize: function(width, height, animate) {
var renderer = this,
alignedObjects = renderer.alignedObjects,
i = alignedObjects.length;
renderer.width = width;
renderer.height = height;
renderer.boxWrapper.animate({
width: width,
height: height
}, {
step: function() {
this.attr({
viewBox: '0 0 ' + this.attr('width') + ' ' + this.attr('height')
});
},
duration: pick(animate, true) ? undefined : 0
});
while (i--) {
alignedObjects[i].align();
}
},
/**
* Create and return an svg group element.
*
* @param {string} [name] The group will be given a class name of
* `highcharts-{name}`. This can be used for styling and scripting.
* @returns {SVGElement} The generated wrapper element.
*/
g: function(name) {
var elem = this.createElement('g');
return name ? elem.attr({
'class': 'highcharts-' + name
}) : elem;
},
/**
* Display an image.
* @param {string} src The image source.
* @param {number} [x] The X position.
* @param {number} [y] The Y position.
* @param {number} [width] The image width. If omitted, it defaults to the
* image file width.
* @param {number} [height] The image height. If omitted it defaults to the
* image file height.
* @returns {SVGElement} The generated wrapper element.
*/
image: function(src, x, y, width, height) {
var attribs = {
preserveAspectRatio: 'none'
},
elemWrapper;
// optional properties
if (arguments.length > 1) {
extend(attribs, {
x: x,
y: y,
width: width,
height: height
});
}
elemWrapper = this.createElement('image').attr(attribs);
// set the href in the xlink namespace
if (elemWrapper.element.setAttributeNS) {
elemWrapper.element.setAttributeNS('http://www.w3.org/1999/xlink',
'href', src);
} else {
// could be exporting in IE
// using href throws "not supported" in ie7 and under, requries regex shim to fix later
elemWrapper.element.setAttribute('hc-svg-href', src);
}
return elemWrapper;
},
/**
* Draw a symbol out of pre-defined shape paths from {@SVGRenderer#symbols}.
* It is used in Highcharts for point makers, which cake a `symbol` option,
* and label and button backgrounds like in the tooltip and stock flags.
*
* @param {Symbol} symbol - The symbol name.
* @param {number} x - The X coordinate for the top left position.
* @param {number} y - The Y coordinate for the top left position.
* @param {number} width - The pixel width.
* @param {number} height - The pixel height.
* @param {Object} [options] - Additional options, depending on the actual
* symbol drawn.
* @param {number} [options.anchorX] - The anchor X position for the
* `callout` symbol. This is where the chevron points to.
* @param {number} [options.anchorY] - The anchor Y position for the
* `callout` symbol. This is where the chevron points to.
* @param {number} [options.end] - The end angle of an `arc` symbol.
* @param {boolean} [options.open] - Whether to draw `arc` symbol open or
* closed.
* @param {number} [options.r] - The radius of an `arc` symbol, or the
* border radius for the `callout` symbol.
* @param {number} [options.start] - The start angle of an `arc` symbol.
*/
symbol: function(symbol, x, y, width, height, options) {
var ren = this,
obj,
// get the symbol definition function
symbolFn = this.symbols[symbol],
// check if there's a path defined for this symbol
path = defined(x) && symbolFn && this.symbols[symbol](
Math.round(x),
Math.round(y),
width,
height,
options
),
imageRegex = /^url\((.*?)\)$/,
imageSrc,
centerImage;
if (symbolFn) {
obj = this.path(path);
obj.attr('fill', 'none');
// expando properties for use in animate and attr
extend(obj, {
symbolName: symbol,
x: x,
y: y,
width: width,
height: height
});
if (options) {
extend(obj, options);
}
// image symbols
} else if (imageRegex.test(symbol)) {
imageSrc = symbol.match(imageRegex)[1];
// Create the image synchronously, add attribs async
obj = this.image(imageSrc);
// The image width is not always the same as the symbol width. The
// image may be centered within the symbol, as is the case when
// image shapes are used as label backgrounds, for example in flags.
obj.imgwidth = pick(
symbolSizes[imageSrc] && symbolSizes[imageSrc].width,
options && options.width
);
obj.imgheight = pick(
symbolSizes[imageSrc] && symbolSizes[imageSrc].height,
options && options.height
);
/**
* Set the size and position
*/
centerImage = function() {
obj.attr({
width: obj.width,
height: obj.height
});
};
/**
* Width and height setters that take both the image's physical size
* and the label size into consideration, and translates the image
* to center within the label.
*/
each(['width', 'height'], function(key) {
obj[key + 'Setter'] = function(value, key) {
var attribs = {},
imgSize = this['img' + key],
trans = key === 'width' ? 'translateX' : 'translateY';
this[key] = value;
if (defined(imgSize)) {
if (this.element) {
this.element.setAttribute(key, imgSize);
}
if (!this.alignByTranslate) {
attribs[trans] = ((this[key] || 0) - imgSize) / 2;
this.attr(attribs);
}
}
};
});
if (defined(x)) {
obj.attr({
x: x,
y: y
});
}
obj.isImg = true;
if (defined(obj.imgwidth) && defined(obj.imgheight)) {
centerImage();
} else {
// Initialize image to be 0 size so export will still function if there's no cached sizes.
obj.attr({
width: 0,
height: 0
});
// Create a dummy JavaScript image to get the width and height. Due to a bug in IE < 8,
// the created element must be assigned to a variable in order to load (#292).
createElement('img', {
onload: function() {
var chart = charts[ren.chartIndex];
// Special case for SVGs on IE11, the width is not accessible until the image is
// part of the DOM (#2854).
if (this.width === 0) {
css(this, {
position: 'absolute',
top: '-999em'
});
doc.body.appendChild(this);
}
// Center the image
symbolSizes[imageSrc] = { // Cache for next
width: this.width,
height: this.height
};
obj.imgwidth = this.width;
obj.imgheight = this.height;
if (obj.element) {
centerImage();
}
// Clean up after #2854 workaround.
if (this.parentNode) {
this.parentNode.removeChild(this);
}
// Fire the load event when all external images are loaded
ren.imgCount--;
if (!ren.imgCount && chart && chart.onload) {
chart.onload();
}
},
src: imageSrc
});
this.imgCount++;
}
}
return obj;
},
/**
* @typedef {string} Symbol
*
* Can be one of `arc`, `callout`, `circle`, `diamond`, `square`,
* `triangle`, `triangle-down`. Symbols are used internally for point
* markers, button and label borders and backgrounds, or custom shapes.
* Extendable by adding to {@link SVGRenderer#symbols}.
*/
/**
* An extendable collection of functions for defining symbol paths.
*/
symbols: {
'circle': function(x, y, w, h) {
// Return a full arc
return this.arc(x + w / 2, y + h / 2, w / 2, h / 2, {
start: 0,
end: Math.PI * 2,
open: false
});
},
'square': function(x, y, w, h) {
return [
'M', x, y,
'L', x + w, y,
x + w, y + h,
x, y + h,
'Z'
];
},
'triangle': function(x, y, w, h) {
return [
'M', x + w / 2, y,
'L', x + w, y + h,
x, y + h,
'Z'
];
},
'triangle-down': function(x, y, w, h) {
return [
'M', x, y,
'L', x + w, y,
x + w / 2, y + h,
'Z'
];
},
'diamond': function(x, y, w, h) {
return [
'M', x + w / 2, y,
'L', x + w, y + h / 2,
x + w / 2, y + h,
x, y + h / 2,
'Z'
];
},
'arc': function(x, y, w, h, options) {
var start = options.start,
rx = options.r || w,
ry = options.r || h || w,
end = options.end - 0.001, // to prevent cos and sin of start and end from becoming equal on 360 arcs (related: #1561)
innerRadius = options.innerR,
open = options.open,
cosStart = Math.cos(start),
sinStart = Math.sin(start),
cosEnd = Math.cos(end),
sinEnd = Math.sin(end),
longArc = options.end - start < Math.PI ? 0 : 1,
arc;
arc = [
'M',
x + rx * cosStart,
y + ry * sinStart,
'A', // arcTo
rx, // x radius
ry, // y radius
0, // slanting
longArc, // long or short arc
1, // clockwise
x + rx * cosEnd,
y + ry * sinEnd
];
if (defined(innerRadius)) {
arc.push(
open ? 'M' : 'L',
x + innerRadius * cosEnd,
y + innerRadius * sinEnd,
'A', // arcTo
innerRadius, // x radius
innerRadius, // y radius
0, // slanting
longArc, // long or short arc
0, // clockwise
x + innerRadius * cosStart,
y + innerRadius * sinStart
);
}
arc.push(open ? '' : 'Z'); // close
return arc;
},
/**
* Callout shape used for default tooltips, also used for rounded rectangles in VML
*/
callout: function(x, y, w, h, options) {
var arrowLength = 6,
halfDistance = 6,
r = Math.min((options && options.r) || 0, w, h),
safeDistance = r + halfDistance,
anchorX = options && options.anchorX,
anchorY = options && options.anchorY,
path;
path = [
'M', x + r, y,
'L', x + w - r, y, // top side
'C', x + w, y, x + w, y, x + w, y + r, // top-right corner
'L', x + w, y + h - r, // right side
'C', x + w, y + h, x + w, y + h, x + w - r, y + h, // bottom-right corner
'L', x + r, y + h, // bottom side
'C', x, y + h, x, y + h, x, y + h - r, // bottom-left corner
'L', x, y + r, // left side
'C', x, y, x, y, x + r, y // top-left corner
];
// Anchor on right side
if (anchorX && anchorX > w) {
// Chevron
if (anchorY > y + safeDistance && anchorY < y + h - safeDistance) {
path.splice(13, 3,
'L', x + w, anchorY - halfDistance,
x + w + arrowLength, anchorY,
x + w, anchorY + halfDistance,
x + w, y + h - r
);
// Simple connector
} else {
path.splice(13, 3,
'L', x + w, h / 2,
anchorX, anchorY,
x + w, h / 2,
x + w, y + h - r
);
}
// Anchor on left side
} else if (anchorX && anchorX < 0) {
// Chevron
if (anchorY > y + safeDistance && anchorY < y + h - safeDistance) {
path.splice(33, 3,
'L', x, anchorY + halfDistance,
x - arrowLength, anchorY,
x, anchorY - halfDistance,
x, y + r
);
// Simple connector
} else {
path.splice(33, 3,
'L', x, h / 2,
anchorX, anchorY,
x, h / 2,
x, y + r
);
}
} else if (anchorY && anchorY > h && anchorX > x + safeDistance && anchorX < x + w - safeDistance) { // replace bottom
path.splice(23, 3,
'L', anchorX + halfDistance, y + h,
anchorX, y + h + arrowLength,
anchorX - halfDistance, y + h,
x + r, y + h
);
} else if (anchorY && anchorY < 0 && anchorX > x + safeDistance && anchorX < x + w - safeDistance) { // replace top
path.splice(3, 3,
'L', anchorX - halfDistance, y,
anchorX, y - arrowLength,
anchorX + halfDistance, y,
w - r, y
);
}
return path;
}
},
/**
* @typedef {SVGElement} ClipRect - A clipping rectangle that can be applied
* to one or more {@link SVGElement} instances. It is instanciated with the
* {@link SVGRenderer#clipRect} function and applied with the {@link
* SVGElement#clip} function.
*
* @example
* var circle = renderer.circle(100, 100, 100)
* .attr({ fill: 'red' })
* .add();
* var clipRect = renderer.clipRect(100, 100, 100, 100);
*
* // Leave only the lower right quarter visible
* circle.clip(clipRect);
*/
/**
* Define a clipping rectangle
* @param {String} id
* @param {number} x
* @param {number} y
* @param {number} width
* @param {number} height
* @returns {ClipRect} A clipping rectangle.
*/
clipRect: function(x, y, width, height) {
var wrapper,
id = H.uniqueKey(),
clipPath = this.createElement('clipPath').attr({
id: id
}).add(this.defs);
wrapper = this.rect(x, y, width, height, 0).add(clipPath);
wrapper.id = id;
wrapper.clipPath = clipPath;
wrapper.count = 0;
return wrapper;
},
/**
* Add text to the SVG object
* @param {String} str
* @param {number} x Left position
* @param {number} y Top position
* @param {Boolean} useHTML Use HTML to render the text
*/
text: function(str, x, y, useHTML) {
// declare variables
var renderer = this,
fakeSVG = !svg && renderer.forExport,
wrapper,
attribs = {};
if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
return renderer.html(str, x, y);
}
attribs.x = Math.round(x || 0); // X is always needed for line-wrap logic
if (y) {
attribs.y = Math.round(y);
}
if (str || str === 0) {
attribs.text = str;
}
wrapper = renderer.createElement('text')
.attr(attribs);
// Prevent wrapping from creating false offsetWidths in export in legacy IE (#1079, #1063)
if (fakeSVG) {
wrapper.css({
position: 'absolute'
});
}
if (!useHTML) {
wrapper.xSetter = function(value, key, element) {
var tspans = element.getElementsByTagName('tspan'),
tspan,
parentVal = element.getAttribute(key),
i;
for (i = 0; i < tspans.length; i++) {
tspan = tspans[i];
// If the x values are equal, the tspan represents a linebreak
if (tspan.getAttribute(key) === parentVal) {
tspan.setAttribute(key, value);
}
}
element.setAttribute(key, value);
};
}
return wrapper;
},
/**
* Utility to return the baseline offset and total line height from the font
* size.
*
* @param {?string} fontSize The current font size to inspect. If not given,
* the font size will be found from the DOM element.
* @param {SVGElement|SVGDOMElement} [elem] The element to inspect for a
* current font size.
* @returns {Object} An object containing `h`: the line height, `b`: the
* baseline relative to the top of the box, and `f`: the font size.
*/
fontMetrics: function(fontSize, elem) {
var lineHeight,
baseline;
fontSize = fontSize ||
// When the elem is a DOM element (#5932)
(elem && elem.style && elem.style.fontSize) ||
// Fall back on the renderer style default
(this.style && this.style.fontSize);
// Handle different units
if (/px/.test(fontSize)) {
fontSize = pInt(fontSize);
} else if (/em/.test(fontSize)) {
// The em unit depends on parent items
fontSize = parseFloat(fontSize) *
(elem ? this.fontMetrics(null, elem.parentNode).f : 16);
} else {
fontSize = 12;
}
// Empirical values found by comparing font size and bounding box
// height. Applies to the default font family.
// http://jsfiddle.net/highcharts/7xvn7/
lineHeight = fontSize < 24 ? fontSize + 3 : Math.round(fontSize * 1.2);
baseline = Math.round(lineHeight * 0.8);
return {
h: lineHeight,
b: baseline,
f: fontSize
};
},
/**
* Correct X and Y positioning of a label for rotation (#1764)
*/
rotCorr: function(baseline, rotation, alterY) {
var y = baseline;
if (rotation && alterY) {
y = Math.max(y * Math.cos(rotation * deg2rad), 4);
}
return {
x: (-baseline / 3) * Math.sin(rotation * deg2rad),
y: y
};
},
/**
* Add a label, a text item that can hold a colored or gradient background
* as well as a border and shadow. Supported custom attributes include
* `padding`.
*
* @param {string} str
* @param {number} x
* @param {number} y
* @param {String} shape
* @param {number} anchorX In case the shape has a pointer, like a flag, this is the
* coordinates it should be pinned to
* @param {number} anchorY
* @param {Boolean} baseline Whether to position the label relative to the text baseline,
* like renderer.text, or to the upper border of the rectangle.
* @param {String} className Class name for the group
*/
label: function(str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
var renderer = this,
wrapper = renderer.g(className !== 'button' && 'label'),
text = wrapper.text = renderer.text('', 0, 0, useHTML)
.attr({
zIndex: 1
}),
box,
bBox,
alignFactor = 0,
padding = 3,
paddingLeft = 0,
width,
height,
wrapperX,
wrapperY,
textAlign,
deferredAttr = {},
strokeWidth,
baselineOffset,
hasBGImage = /^url\((.*?)\)$/.test(shape),
needsBox = hasBGImage,
getCrispAdjust,
updateBoxSize,
updateTextPadding,
boxAttr;
if (className) {
wrapper.addClass('highcharts-' + className);
}
needsBox = hasBGImage;
getCrispAdjust = function() {
return (strokeWidth || 0) % 2 / 2;
};
/**
* This function runs after the label is added to the DOM (when the bounding box is
* available), and after the text of the label is updated to detect the new bounding
* box and reflect it in the border box.
*/
updateBoxSize = function() {
var style = text.element.style,
crispAdjust,
attribs = {};
bBox = (width === undefined || height === undefined || textAlign) && defined(text.textStr) &&
text.getBBox(); //#3295 && 3514 box failure when string equals 0
wrapper.width = (width || bBox.width || 0) + 2 * padding + paddingLeft;
wrapper.height = (height || bBox.height || 0) + 2 * padding;
// Update the label-scoped y offset
baselineOffset = padding + renderer.fontMetrics(style && style.fontSize, text).b;
if (needsBox) {
// Create the border box if it is not already present
if (!box) {
wrapper.box = box = renderer.symbols[shape] || hasBGImage ? // Symbol definition exists (#5324)
renderer.symbol(shape) :
renderer.rect();
box.addClass(
(className === 'button' ? '' : 'highcharts-label-box') + // Don't use label className for buttons
(className ? ' highcharts-' + className + '-box' : '')
);
box.add(wrapper);
crispAdjust = getCrispAdjust();
attribs.x = crispAdjust;
attribs.y = (baseline ? -baselineOffset : 0) + crispAdjust;
}
// Apply the box attributes
attribs.width = Math.round(wrapper.width);
attribs.height = Math.round(wrapper.height);
box.attr(extend(attribs, deferredAttr));
deferredAttr = {};
}
};
/**
* This function runs after setting text or padding, but only if padding is changed
*/
updateTextPadding = function() {
var textX = paddingLeft + padding,
textY;
// determin y based on the baseline
textY = baseline ? 0 : baselineOffset;
// compensate for alignment
if (defined(width) && bBox && (textAlign === 'center' || textAlign === 'right')) {
textX += {
center: 0.5,
right: 1
}[textAlign] * (width - bBox.width);
}
// update if anything changed
if (textX !== text.x || textY !== text.y) {
text.attr('x', textX);
if (textY !== undefined) {
text.attr('y', textY);
}
}
// record current values
text.x = textX;
text.y = textY;
};
/**
* Set a box attribute, or defer it if the box is not yet created
* @param {Object} key
* @param {Object} value
*/
boxAttr = function(key, value) {
if (box) {
box.attr(key, value);
} else {
deferredAttr[key] = value;
}
};
/**
* After the text element is added, get the desired size of the border box
* and add it before the text in the DOM.
*/
wrapper.onAdd = function() {
text.add(wrapper);
wrapper.attr({
text: (str || str === 0) ? str : '', // alignment is available now // #3295: 0 not rendered if given as a value
x: x,
y: y
});
if (box && defined(anchorX)) {
wrapper.attr({
anchorX: anchorX,
anchorY: anchorY
});
}
};
/*
* Add specific attribute setters.
*/
// only change local variables
wrapper.widthSetter = function(value) {
width = H.isNumber(value) ? value : null; // width:auto => null
};
wrapper.heightSetter = function(value) {
height = value;
};
wrapper['text-alignSetter'] = function(value) {
textAlign = value;
};
wrapper.paddingSetter = function(value) {
if (defined(value) && value !== padding) {
padding = wrapper.padding = value;
updateTextPadding();
}
};
wrapper.paddingLeftSetter = function(value) {
if (defined(value) && value !== paddingLeft) {
paddingLeft = value;
updateTextPadding();
}
};
// change local variable and prevent setting attribute on the group
wrapper.alignSetter = function(value) {
value = {
left: 0,
center: 0.5,
right: 1
}[value];
if (value !== alignFactor) {
alignFactor = value;
if (bBox) { // Bounding box exists, means we're dynamically changing
wrapper.attr({
x: wrapperX
}); // #5134
}
}
};
// apply these to the box and the text alike
wrapper.textSetter = function(value) {
if (value !== undefined) {
text.textSetter(value);
}
updateBoxSize();
updateTextPadding();
};
// apply these to the box but not to the text
wrapper['stroke-widthSetter'] = function(value, key) {
if (value) {
needsBox = true;
}
strokeWidth = this['stroke-width'] = value;
boxAttr(key, value);
};
wrapper.strokeSetter = wrapper.fillSetter = wrapper.rSetter = function(value, key) {
if (key === 'fill' && value) {
needsBox = true;
}
boxAttr(key, value);
};
wrapper.anchorXSetter = function(value, key) {
anchorX = value;
boxAttr(key, Math.round(value) - getCrispAdjust() - wrapperX);
};
wrapper.anchorYSetter = function(value, key) {
anchorY = value;
boxAttr(key, value - wrapperY);
};
// rename attributes
wrapper.xSetter = function(value) {
wrapper.x = value; // for animation getter
if (alignFactor) {
value -= alignFactor * ((width || bBox.width) + 2 * padding);
}
wrapperX = Math.round(value);
wrapper.attr('translateX', wrapperX);
};
wrapper.ySetter = function(value) {
wrapperY = wrapper.y = Math.round(value);
wrapper.attr('translateY', wrapperY);
};
// Redirect certain methods to either the box or the text
var baseCss = wrapper.css;
return extend(wrapper, {
/**
* Pick up some properties and apply them to the text instead of the
* wrapper.
* @ignore
*/
css: function(styles) {
if (styles) {
var textStyles = {};
styles = merge(styles); // create a copy to avoid altering the original object (#537)
each(wrapper.textProps, function(prop) {
if (styles[prop] !== undefined) {
textStyles[prop] = styles[prop];
delete styles[prop];
}
});
text.css(textStyles);
}
return baseCss.call(wrapper, styles);
},
/**
* Return the bounding box of the box, not the group.
* @ignore
*/
getBBox: function() {
return {
width: bBox.width + 2 * padding,
height: bBox.height + 2 * padding,
x: bBox.x - padding,
y: bBox.y - padding
};
},
/**
* Apply the shadow to the box.
* @ignore
*/
shadow: function(b) {
if (b) {
updateBoxSize();
if (box) {
box.shadow(b);
}
}
return wrapper;
},
/**
* Destroy and release memory.
* @ignore
*/
destroy: function() {
// Added by button implementation
removeEvent(wrapper.element, 'mouseenter');
removeEvent(wrapper.element, 'mouseleave');
if (text) {
text = text.destroy();
}
if (box) {
box = box.destroy();
}
// Call base implementation to destroy the rest
SVGElement.prototype.destroy.call(wrapper);
// Release local pointers (#1298)
wrapper = renderer = updateBoxSize = updateTextPadding = boxAttr = null;
}
});
}
}; // end SVGRenderer
// general renderer
H.Renderer = SVGRenderer;
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var attr = H.attr,
createElement = H.createElement,
css = H.css,
defined = H.defined,
each = H.each,
extend = H.extend,
isFirefox = H.isFirefox,
isMS = H.isMS,
isWebKit = H.isWebKit,
pInt = H.pInt,
SVGElement = H.SVGElement,
SVGRenderer = H.SVGRenderer,
win = H.win,
wrap = H.wrap;
// Extend SvgElement for useHTML option
extend(SVGElement.prototype, /** @lends SVGElement.prototype */ {
/**
* Apply CSS to HTML elements. This is used in text within SVG rendering and
* by the VML renderer
*/
htmlCss: function(styles) {
var wrapper = this,
element = wrapper.element,
textWidth = styles && element.tagName === 'SPAN' && styles.width;
if (textWidth) {
delete styles.width;
wrapper.textWidth = textWidth;
wrapper.updateTransform();
}
if (styles && styles.textOverflow === 'ellipsis') {
styles.whiteSpace = 'nowrap';
styles.overflow = 'hidden';
}
wrapper.styles = extend(wrapper.styles, styles);
css(wrapper.element, styles);
return wrapper;
},
/**
* VML and useHTML method for calculating the bounding box based on offsets
* @param {Boolean} refresh Whether to force a fresh value from the DOM or to
* use the cached value
*
* @return {Object} A hash containing values for x, y, width and height
*/
htmlGetBBox: function() {
var wrapper = this,
element = wrapper.element;
// faking getBBox in exported SVG in legacy IE
// faking getBBox in exported SVG in legacy IE (is this a duplicate of the fix for #1079?)
if (element.nodeName === 'text') {
element.style.position = 'absolute';
}
return {
x: element.offsetLeft,
y: element.offsetTop,
width: element.offsetWidth,
height: element.offsetHeight
};
},
/**
* VML override private method to update elements based on internal
* properties based on SVG transform
*/
htmlUpdateTransform: function() {
// aligning non added elements is expensive
if (!this.added) {
this.alignOnAdd = true;
return;
}
var wrapper = this,
renderer = wrapper.renderer,
elem = wrapper.element,
translateX = wrapper.translateX || 0,
translateY = wrapper.translateY || 0,
x = wrapper.x || 0,
y = wrapper.y || 0,
align = wrapper.textAlign || 'left',
alignCorrection = {
left: 0,
center: 0.5,
right: 1
}[align],
styles = wrapper.styles;
// apply translate
css(elem, {
marginLeft: translateX,
marginTop: translateY
});
if (wrapper.shadows) { // used in labels/tooltip
each(wrapper.shadows, function(shadow) {
css(shadow, {
marginLeft: translateX + 1,
marginTop: translateY + 1
});
});
}
// apply inversion
if (wrapper.inverted) { // wrapper is a group
each(elem.childNodes, function(child) {
renderer.invertChild(child, elem);
});
}
if (elem.tagName === 'SPAN') {
var rotation = wrapper.rotation,
baseline,
textWidth = pInt(wrapper.textWidth),
whiteSpace = styles && styles.whiteSpace,
currentTextTransform = [rotation, align, elem.innerHTML, wrapper.textWidth, wrapper.textAlign].join(',');
if (currentTextTransform !== wrapper.cTT) { // do the calculations and DOM access only if properties changed
baseline = renderer.fontMetrics(elem.style.fontSize).b;
// Renderer specific handling of span rotation
if (defined(rotation)) {
wrapper.setSpanRotation(rotation, alignCorrection, baseline);
}
// Reset multiline/ellipsis in order to read width (#4928, #5417)
css(elem, {
width: '',
whiteSpace: whiteSpace || 'nowrap'
});
// Update textWidth
if (elem.offsetWidth > textWidth && /[ \-]/.test(elem.textContent || elem.innerText)) { // #983, #1254
css(elem, {
width: textWidth + 'px',
display: 'block',
whiteSpace: whiteSpace || 'normal' // #3331
});
}
wrapper.getSpanCorrection(elem.offsetWidth, baseline, alignCorrection, rotation, align);
}
// apply position with correction
css(elem, {
left: (x + (wrapper.xCorr || 0)) + 'px',
top: (y + (wrapper.yCorr || 0)) + 'px'
});
// force reflow in webkit to apply the left and top on useHTML element (#1249)
if (isWebKit) {
baseline = elem.offsetHeight; // assigned to baseline for lint purpose
}
// record current text transform
wrapper.cTT = currentTextTransform;
}
},
/**
* Set the rotation of an individual HTML span
*/
setSpanRotation: function(rotation, alignCorrection, baseline) {
var rotationStyle = {},
cssTransformKey = isMS ? '-ms-transform' : isWebKit ? '-webkit-transform' : isFirefox ? 'MozTransform' : win.opera ? '-o-transform' : '';
rotationStyle[cssTransformKey] = rotationStyle.transform = 'rotate(' + rotation + 'deg)';
rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] = rotationStyle.transformOrigin = (alignCorrection * 100) + '% ' + baseline + 'px';
css(this.element, rotationStyle);
},
/**
* Get the correction in X and Y positioning as the element is rotated.
*/
getSpanCorrection: function(width, baseline, alignCorrection) {
this.xCorr = -width * alignCorrection;
this.yCorr = -baseline;
}
});
// Extend SvgRenderer for useHTML option.
extend(SVGRenderer.prototype, /** @lends SVGRenderer.prototype */ {
/**
* Create HTML text node. This is used by the VML renderer as well as the SVG
* renderer through the useHTML option.
*
* @param {String} str
* @param {Number} x
* @param {Number} y
*/
html: function(str, x, y) {
var wrapper = this.createElement('span'),
element = wrapper.element,
renderer = wrapper.renderer,
isSVG = renderer.isSVG,
addSetters = function(element, style) {
// These properties are set as attributes on the SVG group, and as
// identical CSS properties on the div. (#3542)
each(['opacity', 'visibility'], function(prop) {
wrap(element, prop + 'Setter', function(proceed, value, key, elem) {
proceed.call(this, value, key, elem);
style[key] = value;
});
});
};
// Text setter
wrapper.textSetter = function(value) {
if (value !== element.innerHTML) {
delete this.bBox;
}
element.innerHTML = this.textStr = value;
wrapper.htmlUpdateTransform();
};
// Add setters for the element itself (#4938)
if (isSVG) { // #4938, only for HTML within SVG
addSetters(wrapper, wrapper.element.style);
}
// Various setters which rely on update transform
wrapper.xSetter = wrapper.ySetter = wrapper.alignSetter = wrapper.rotationSetter = function(value, key) {
if (key === 'align') {
key = 'textAlign'; // Do not overwrite the SVGElement.align method. Same as VML.
}
wrapper[key] = value;
wrapper.htmlUpdateTransform();
};
// Set the default attributes
wrapper
.attr({
text: str,
x: Math.round(x),
y: Math.round(y)
})
.css({
fontFamily: this.style.fontFamily,
fontSize: this.style.fontSize,
position: 'absolute'
});
// Keep the whiteSpace style outside the wrapper.styles collection
element.style.whiteSpace = 'nowrap';
// Use the HTML specific .css method
wrapper.css = wrapper.htmlCss;
// This is specific for HTML within SVG
if (isSVG) {
wrapper.add = function(svgGroupWrapper) {
var htmlGroup,
container = renderer.box.parentNode,
parentGroup,
parents = [];
this.parentGroup = svgGroupWrapper;
// Create a mock group to hold the HTML elements
if (svgGroupWrapper) {
htmlGroup = svgGroupWrapper.div;
if (!htmlGroup) {
// Read the parent chain into an array and read from top down
parentGroup = svgGroupWrapper;
while (parentGroup) {
parents.push(parentGroup);
// Move up to the next parent group
parentGroup = parentGroup.parentGroup;
}
// Ensure dynamically updating position when any parent is translated
each(parents.reverse(), function(parentGroup) {
var htmlGroupStyle,
cls = attr(parentGroup.element, 'class');
if (cls) {
cls = {
className: cls
};
} // else null
// Create a HTML div and append it to the parent div to emulate
// the SVG group structure
htmlGroup = parentGroup.div = parentGroup.div || createElement('div', cls, {
position: 'absolute',
left: (parentGroup.translateX || 0) + 'px',
top: (parentGroup.translateY || 0) + 'px',
display: parentGroup.display,
opacity: parentGroup.opacity, // #5075
pointerEvents: parentGroup.styles && parentGroup.styles.pointerEvents // #5595
}, htmlGroup || container); // the top group is appended to container
// Shortcut
htmlGroupStyle = htmlGroup.style;
// Set listeners to update the HTML div's position whenever the SVG group
// position is changed
extend(parentGroup, {
on: function() {
wrapper.on.apply({
element: parents[0].div
}, arguments);
return parentGroup;
},
translateXSetter: function(value, key) {
htmlGroupStyle.left = value + 'px';
parentGroup[key] = value;
parentGroup.doTransform = true;
},
translateYSetter: function(value, key) {
htmlGroupStyle.top = value + 'px';
parentGroup[key] = value;
parentGroup.doTransform = true;
}
});
addSetters(parentGroup, htmlGroupStyle);
});
}
} else {
htmlGroup = container;
}
htmlGroup.appendChild(element);
// Shared with VML:
wrapper.added = true;
if (wrapper.alignOnAdd) {
wrapper.htmlUpdateTransform();
}
return wrapper;
};
}
return wrapper;
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var VMLRenderer,
VMLRendererExtension,
VMLElement,
createElement = H.createElement,
css = H.css,
defined = H.defined,
deg2rad = H.deg2rad,
discardElement = H.discardElement,
doc = H.doc,
each = H.each,
erase = H.erase,
extend = H.extend,
extendClass = H.extendClass,
isArray = H.isArray,
isNumber = H.isNumber,
isObject = H.isObject,
merge = H.merge,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
svg = H.svg,
SVGElement = H.SVGElement,
SVGRenderer = H.SVGRenderer,
win = H.win;
/* ****************************************************************************
* *
* START OF INTERNET EXPLORER <= 8 SPECIFIC CODE *
* *
* For applications and websites that don't need IE support, like platform *
* targeted mobile apps and web apps, this code can be removed. *
* *
*****************************************************************************/
/**
* @constructor
*/
if (!svg) {
/**
* The VML element wrapper.
*/
VMLElement = {
docMode8: doc && doc.documentMode === 8,
/**
* Initialize a new VML element wrapper. It builds the markup as a string
* to minimize DOM traffic.
* @param {Object} renderer
* @param {Object} nodeName
*/
init: function(renderer, nodeName) {
var wrapper = this,
markup = ['<', nodeName, ' filled="f" stroked="f"'],
style = ['position: ', 'absolute', ';'],
isDiv = nodeName === 'div';
// divs and shapes need size
if (nodeName === 'shape' || isDiv) {
style.push('left:0;top:0;width:1px;height:1px;');
}
style.push('visibility: ', isDiv ? 'hidden' : 'visible');
markup.push(' style="', style.join(''), '"/>');
// create element with default attributes and style
if (nodeName) {
markup = isDiv || nodeName === 'span' || nodeName === 'img' ?
markup.join('') :
renderer.prepVML(markup);
wrapper.element = createElement(markup);
}
wrapper.renderer = renderer;
},
/**
* Add the node to the given parent
* @param {Object} parent
*/
add: function(parent) {
var wrapper = this,
renderer = wrapper.renderer,
element = wrapper.element,
box = renderer.box,
inverted = parent && parent.inverted,
// get the parent node
parentNode = parent ?
parent.element || parent :
box;
if (parent) {
this.parentGroup = parent;
}
// if the parent group is inverted, apply inversion on all children
if (inverted) { // only on groups
renderer.invertChild(element, parentNode);
}
// append it
parentNode.appendChild(element);
// align text after adding to be able to read offset
wrapper.added = true;
if (wrapper.alignOnAdd && !wrapper.deferUpdateTransform) {
wrapper.updateTransform();
}
// fire an event for internal hooks
if (wrapper.onAdd) {
wrapper.onAdd();
}
// IE8 Standards can't set the class name before the element is appended
if (this.className) {
this.attr('class', this.className);
}
return wrapper;
},
/**
* VML always uses htmlUpdateTransform
*/
updateTransform: SVGElement.prototype.htmlUpdateTransform,
/**
* Set the rotation of a span with oldIE's filter
*/
setSpanRotation: function() {
// Adjust for alignment and rotation. Rotation of useHTML content is not yet implemented
// but it can probably be implemented for Firefox 3.5+ on user request. FF3.5+
// has support for CSS3 transform. The getBBox method also needs to be updated
// to compensate for the rotation, like it currently does for SVG.
// Test case: http://jsfiddle.net/highcharts/Ybt44/
var rotation = this.rotation,
costheta = Math.cos(rotation * deg2rad),
sintheta = Math.sin(rotation * deg2rad);
css(this.element, {
filter: rotation ? ['progid:DXImageTransform.Microsoft.Matrix(M11=', costheta,
', M12=', -sintheta, ', M21=', sintheta, ', M22=', costheta,
', sizingMethod=\'auto expand\')'
].join('') : 'none'
});
},
/**
* Get the positioning correction for the span after rotating.
*/
getSpanCorrection: function(width, baseline, alignCorrection, rotation, align) {
var costheta = rotation ? Math.cos(rotation * deg2rad) : 1,
sintheta = rotation ? Math.sin(rotation * deg2rad) : 0,
height = pick(this.elemHeight, this.element.offsetHeight),
quad,
nonLeft = align && align !== 'left';
// correct x and y
this.xCorr = costheta < 0 && -width;
this.yCorr = sintheta < 0 && -height;
// correct for baseline and corners spilling out after rotation
quad = costheta * sintheta < 0;
this.xCorr += sintheta * baseline * (quad ? 1 - alignCorrection : alignCorrection);
this.yCorr -= costheta * baseline * (rotation ? (quad ? alignCorrection : 1 - alignCorrection) : 1);
// correct for the length/height of the text
if (nonLeft) {
this.xCorr -= width * alignCorrection * (costheta < 0 ? -1 : 1);
if (rotation) {
this.yCorr -= height * alignCorrection * (sintheta < 0 ? -1 : 1);
}
css(this.element, {
textAlign: align
});
}
},
/**
* Converts a subset of an SVG path definition to its VML counterpart. Takes an array
* as the parameter and returns a string.
*/
pathToVML: function(value) {
// convert paths
var i = value.length,
path = [];
while (i--) {
// Multiply by 10 to allow subpixel precision.
// Substracting half a pixel seems to make the coordinates
// align with SVG, but this hasn't been tested thoroughly
if (isNumber(value[i])) {
path[i] = Math.round(value[i] * 10) - 5;
} else if (value[i] === 'Z') { // close the path
path[i] = 'x';
} else {
path[i] = value[i];
// When the start X and end X coordinates of an arc are too close,
// they are rounded to the same value above. In this case, substract or
// add 1 from the end X and Y positions. #186, #760, #1371, #1410.
if (value.isArc && (value[i] === 'wa' || value[i] === 'at')) {
// Start and end X
if (path[i + 5] === path[i + 7]) {
path[i + 7] += value[i + 7] > value[i + 5] ? 1 : -1;
}
// Start and end Y
if (path[i + 6] === path[i + 8]) {
path[i + 8] += value[i + 8] > value[i + 6] ? 1 : -1;
}
}
}
}
// Loop up again to handle path shortcuts (#2132)
/*while (i++ < path.length) {
if (path[i] === 'H') { // horizontal line to
path[i] = 'L';
path.splice(i + 2, 0, path[i - 1]);
} else if (path[i] === 'V') { // vertical line to
path[i] = 'L';
path.splice(i + 1, 0, path[i - 2]);
}
}*/
return path.join(' ') || 'x';
},
/**
* Set the element's clipping to a predefined rectangle
*
* @param {String} id The id of the clip rectangle
*/
clip: function(clipRect) {
var wrapper = this,
clipMembers,
cssRet;
if (clipRect) {
clipMembers = clipRect.members;
erase(clipMembers, wrapper); // Ensure unique list of elements (#1258)
clipMembers.push(wrapper);
wrapper.destroyClip = function() {
erase(clipMembers, wrapper);
};
cssRet = clipRect.getCSS(wrapper);
} else {
if (wrapper.destroyClip) {
wrapper.destroyClip();
}
cssRet = {
clip: wrapper.docMode8 ? 'inherit' : 'rect(auto)'
}; // #1214
}
return wrapper.css(cssRet);
},
/**
* Set styles for the element
* @param {Object} styles
*/
css: SVGElement.prototype.htmlCss,
/**
* Removes a child either by removeChild or move to garbageBin.
* Issue 490; in VML removeChild results in Orphaned nodes according to sIEve, discardElement does not.
*/
safeRemoveChild: function(element) {
// discardElement will detach the node from its parent before attaching it
// to the garbage bin. Therefore it is important that the node is attached and have parent.
if (element.parentNode) {
discardElement(element);
}
},
/**
* Extend element.destroy by removing it from the clip members array
*/
destroy: function() {
if (this.destroyClip) {
this.destroyClip();
}
return SVGElement.prototype.destroy.apply(this);
},
/**
* Add an event listener. VML override for normalizing event parameters.
* @param {String} eventType
* @param {Function} handler
*/
on: function(eventType, handler) {
// simplest possible event model for internal use
this.element['on' + eventType] = function() {
var evt = win.event;
evt.target = evt.srcElement;
handler(evt);
};
return this;
},
/**
* In stacked columns, cut off the shadows so that they don't overlap
*/
cutOffPath: function(path, length) {
var len;
path = path.split(/[ ,]/); // The extra comma tricks the trailing comma remover in "gulp scripts" task
len = path.length;
if (len === 9 || len === 11) {
path[len - 4] = path[len - 2] = pInt(path[len - 2]) - 10 * length;
}
return path.join(' ');
},
/**
* Apply a drop shadow by copying elements and giving them different strokes
* @param {Boolean|Object} shadowOptions
*/
shadow: function(shadowOptions, group, cutOff) {
var shadows = [],
i,
element = this.element,
renderer = this.renderer,
shadow,
elemStyle = element.style,
markup,
path = element.path,
strokeWidth,
modifiedPath,
shadowWidth,
shadowElementOpacity;
// some times empty paths are not strings
if (path && typeof path.value !== 'string') {
path = 'x';
}
modifiedPath = path;
if (shadowOptions) {
shadowWidth = pick(shadowOptions.width, 3);
shadowElementOpacity = (shadowOptions.opacity || 0.15) / shadowWidth;
for (i = 1; i <= 3; i++) {
strokeWidth = (shadowWidth * 2) + 1 - (2 * i);
// Cut off shadows for stacked column items
if (cutOff) {
modifiedPath = this.cutOffPath(path.value, strokeWidth + 0.5);
}
markup = ['<shape isShadow="true" strokeweight="', strokeWidth,
'" filled="false" path="', modifiedPath,
'" coordsize="10 10" style="', element.style.cssText, '" />'
];
shadow = createElement(renderer.prepVML(markup),
null, {
left: pInt(elemStyle.left) + pick(shadowOptions.offsetX, 1),
top: pInt(elemStyle.top) + pick(shadowOptions.offsetY, 1)
}
);
if (cutOff) {
shadow.cutOff = strokeWidth + 1;
}
// apply the opacity
markup = [
'<stroke color="',
shadowOptions.color || '#000000',
'" opacity="', shadowElementOpacity * i, '"/>'
];
createElement(renderer.prepVML(markup), null, null, shadow);
// insert it
if (group) {
group.element.appendChild(shadow);
} else {
element.parentNode.insertBefore(shadow, element);
}
// record it
shadows.push(shadow);
}
this.shadows = shadows;
}
return this;
},
updateShadows: noop, // Used in SVG only
setAttr: function(key, value) {
if (this.docMode8) { // IE8 setAttribute bug
this.element[key] = value;
} else {
this.element.setAttribute(key, value);
}
},
classSetter: function(value) {
// IE8 Standards mode has problems retrieving the className unless set like this.
// IE8 Standards can't set the class name before the element is appended.
(this.added ? this.element : this).className = value;
},
dashstyleSetter: function(value, key, element) {
var strokeElem = element.getElementsByTagName('stroke')[0] ||
createElement(this.renderer.prepVML(['<stroke/>']), null, null, element);
strokeElem[key] = value || 'solid';
this[key] = value;
/* because changing stroke-width will change the dash length
and cause an epileptic effect */
},
dSetter: function(value, key, element) {
var i,
shadows = this.shadows;
value = value || [];
this.d = value.join && value.join(' '); // used in getter for animation
element.path = value = this.pathToVML(value);
// update shadows
if (shadows) {
i = shadows.length;
while (i--) {
shadows[i].path = shadows[i].cutOff ? this.cutOffPath(value, shadows[i].cutOff) : value;
}
}
this.setAttr(key, value);
},
fillSetter: function(value, key, element) {
var nodeName = element.nodeName;
if (nodeName === 'SPAN') { // text color
element.style.color = value;
} else if (nodeName !== 'IMG') { // #1336
element.filled = value !== 'none';
this.setAttr('fillcolor', this.renderer.color(value, element, key, this));
}
},
'fill-opacitySetter': function(value, key, element) {
createElement(
this.renderer.prepVML(['<', key.split('-')[0], ' opacity="', value, '"/>']),
null,
null,
element
);
},
opacitySetter: noop, // Don't bother - animation is too slow and filters introduce artifacts
rotationSetter: function(value, key, element) {
var style = element.style;
this[key] = style[key] = value; // style is for #1873
// Correction for the 1x1 size of the shape container. Used in gauge needles.
style.left = -Math.round(Math.sin(value * deg2rad) + 1) + 'px';
style.top = Math.round(Math.cos(value * deg2rad)) + 'px';
},
strokeSetter: function(value, key, element) {
this.setAttr('strokecolor', this.renderer.color(value, element, key, this));
},
'stroke-widthSetter': function(value, key, element) {
element.stroked = !!value; // VML "stroked" attribute
this[key] = value; // used in getter, issue #113
if (isNumber(value)) {
value += 'px';
}
this.setAttr('strokeweight', value);
},
titleSetter: function(value, key) {
this.setAttr(key, value);
},
visibilitySetter: function(value, key, element) {
// Handle inherited visibility
if (value === 'inherit') {
value = 'visible';
}
// Let the shadow follow the main element
if (this.shadows) {
each(this.shadows, function(shadow) {
shadow.style[key] = value;
});
}
// Instead of toggling the visibility CSS property, move the div out of the viewport.
// This works around #61 and #586
if (element.nodeName === 'DIV') {
value = value === 'hidden' ? '-999em' : 0;
// In order to redraw, IE7 needs the div to be visible when tucked away
// outside the viewport. So the visibility is actually opposite of
// the expected value. This applies to the tooltip only.
if (!this.docMode8) {
element.style[key] = value ? 'visible' : 'hidden';
}
key = 'top';
}
element.style[key] = value;
},
xSetter: function(value, key, element) {
this[key] = value; // used in getter
if (key === 'x') {
key = 'left';
} else if (key === 'y') {
key = 'top';
}
/* else {
value = Math.max(0, value); // don't set width or height below zero (#311)
}*/
// clipping rectangle special
if (this.updateClipping) {
this[key] = value; // the key is now 'left' or 'top' for 'x' and 'y'
this.updateClipping();
} else {
// normal
element.style[key] = value;
}
},
zIndexSetter: function(value, key, element) {
element.style[key] = value;
}
};
VMLElement['stroke-opacitySetter'] = VMLElement['fill-opacitySetter'];
H.VMLElement = VMLElement = extendClass(SVGElement, VMLElement);
// Some shared setters
VMLElement.prototype.ySetter =
VMLElement.prototype.widthSetter =
VMLElement.prototype.heightSetter =
VMLElement.prototype.xSetter;
/**
* The VML renderer
*/
VMLRendererExtension = { // inherit SVGRenderer
Element: VMLElement,
isIE8: win.navigator.userAgent.indexOf('MSIE 8.0') > -1,
/**
* Initialize the VMLRenderer
* @param {Object} container
* @param {Number} width
* @param {Number} height
*/
init: function(container, width, height) {
var renderer = this,
boxWrapper,
box,
css;
renderer.alignedObjects = [];
boxWrapper = renderer.createElement('div')
.css({
position: 'relative'
});
box = boxWrapper.element;
container.appendChild(boxWrapper.element);
// generate the containing box
renderer.isVML = true;
renderer.box = box;
renderer.boxWrapper = boxWrapper;
renderer.gradients = {};
renderer.cache = {}; // Cache for numerical bounding boxes
renderer.cacheKeys = [];
renderer.imgCount = 0;
renderer.setSize(width, height, false);
// The only way to make IE6 and IE7 print is to use a global namespace. However,
// with IE8 the only way to make the dynamic shapes visible in screen and print mode
// seems to be to add the xmlns attribute and the behaviour style inline.
if (!doc.namespaces.hcv) {
doc.namespaces.add('hcv', 'urn:schemas-microsoft-com:vml');
// Setup default CSS (#2153, #2368, #2384)
css = 'hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke' +
'{ behavior:url(#default#VML); display: inline-block; } ';
try {
doc.createStyleSheet().cssText = css;
} catch (e) {
doc.styleSheets[0].cssText += css;
}
}
},
/**
* Detect whether the renderer is hidden. This happens when one of the parent elements
* has display: none
*/
isHidden: function() {
return !this.box.offsetWidth;
},
/**
* Define a clipping rectangle. In VML it is accomplished by storing the values
* for setting the CSS style to all associated members.
*
* @param {Number} x
* @param {Number} y
* @param {Number} width
* @param {Number} height
*/
clipRect: function(x, y, width, height) {
// create a dummy element
var clipRect = this.createElement(),
isObj = isObject(x);
// mimic a rectangle with its style object for automatic updating in attr
return extend(clipRect, {
members: [],
count: 0,
left: (isObj ? x.x : x) + 1,
top: (isObj ? x.y : y) + 1,
width: (isObj ? x.width : width) - 1,
height: (isObj ? x.height : height) - 1,
getCSS: function(wrapper) {
var element = wrapper.element,
nodeName = element.nodeName,
isShape = nodeName === 'shape',
inverted = wrapper.inverted,
rect = this,
top = rect.top - (isShape ? element.offsetTop : 0),
left = rect.left,
right = left + rect.width,
bottom = top + rect.height,
ret = {
clip: 'rect(' +
Math.round(inverted ? left : top) + 'px,' +
Math.round(inverted ? bottom : right) + 'px,' +
Math.round(inverted ? right : bottom) + 'px,' +
Math.round(inverted ? top : left) + 'px)'
};
// issue 74 workaround
if (!inverted && wrapper.docMode8 && nodeName === 'DIV') {
extend(ret, {
width: right + 'px',
height: bottom + 'px'
});
}
return ret;
},
// used in attr and animation to update the clipping of all members
updateClipping: function() {
each(clipRect.members, function(member) {
// Member.element is falsy on deleted series, like in
// stock/members/series-remove demo. Should be removed
// from members, but this will do.
if (member.element) {
member.css(clipRect.getCSS(member));
}
});
}
});
},
/**
* Take a color and return it if it's a string, make it a gradient if it's a
* gradient configuration object, and apply opacity.
*
* @param {Object} color The color or config object
*/
color: function(color, elem, prop, wrapper) {
var renderer = this,
colorObject,
regexRgba = /^rgba/,
markup,
fillType,
ret = 'none';
// Check for linear or radial gradient
if (color && color.linearGradient) {
fillType = 'gradient';
} else if (color && color.radialGradient) {
fillType = 'pattern';
}
if (fillType) {
var stopColor,
stopOpacity,
gradient = color.linearGradient || color.radialGradient,
x1,
y1,
x2,
y2,
opacity1,
opacity2,
color1,
color2,
fillAttr = '',
stops = color.stops,
firstStop,
lastStop,
colors = [],
addFillNode = function() {
// Add the fill subnode. When colors attribute is used, the meanings of opacity and o:opacity2
// are reversed.
markup = ['<fill colors="' + colors.join(',') +
'" opacity="', opacity2, '" o:opacity2="',
opacity1, '" type="', fillType, '" ', fillAttr,
'focus="100%" method="any" />'
];
createElement(renderer.prepVML(markup), null, null, elem);
};
// Extend from 0 to 1
firstStop = stops[0];
lastStop = stops[stops.length - 1];
if (firstStop[0] > 0) {
stops.unshift([
0,
firstStop[1]
]);
}
if (lastStop[0] < 1) {
stops.push([
1,
lastStop[1]
]);
}
// Compute the stops
each(stops, function(stop, i) {
if (regexRgba.test(stop[1])) {
colorObject = H.color(stop[1]);
stopColor = colorObject.get('rgb');
stopOpacity = colorObject.get('a');
} else {
stopColor = stop[1];
stopOpacity = 1;
}
// Build the color attribute
colors.push((stop[0] * 100) + '% ' + stopColor);
// Only start and end opacities are allowed, so we use the first and the last
if (!i) {
opacity1 = stopOpacity;
color2 = stopColor;
} else {
opacity2 = stopOpacity;
color1 = stopColor;
}
});
// Apply the gradient to fills only.
if (prop === 'fill') {
// Handle linear gradient angle
if (fillType === 'gradient') {
x1 = gradient.x1 || gradient[0] || 0;
y1 = gradient.y1 || gradient[1] || 0;
x2 = gradient.x2 || gradient[2] || 0;
y2 = gradient.y2 || gradient[3] || 0;
fillAttr = 'angle="' + (90 - Math.atan(
(y2 - y1) / // y vector
(x2 - x1) // x vector
) * 180 / Math.PI) + '"';
addFillNode();
// Radial (circular) gradient
} else {
var r = gradient.r,
sizex = r * 2,
sizey = r * 2,
cx = gradient.cx,
cy = gradient.cy,
radialReference = elem.radialReference,
bBox,
applyRadialGradient = function() {
if (radialReference) {
bBox = wrapper.getBBox();
cx += (radialReference[0] - bBox.x) / bBox.width - 0.5;
cy += (radialReference[1] - bBox.y) / bBox.height - 0.5;
sizex *= radialReference[2] / bBox.width;
sizey *= radialReference[2] / bBox.height;
}
fillAttr = 'src="' + H.getOptions().global.VMLRadialGradientURL + '" ' +
'size="' + sizex + ',' + sizey + '" ' +
'origin="0.5,0.5" ' +
'position="' + cx + ',' + cy + '" ' +
'color2="' + color2 + '" ';
addFillNode();
};
// Apply radial gradient
if (wrapper.added) {
applyRadialGradient();
} else {
// We need to know the bounding box to get the size and position right
wrapper.onAdd = applyRadialGradient;
}
// The fill element's color attribute is broken in IE8 standards mode, so we
// need to set the parent shape's fillcolor attribute instead.
ret = color1;
}
// Gradients are not supported for VML stroke, return the first color. #722.
} else {
ret = stopColor;
}
// If the color is an rgba color, split it and add a fill node
// to hold the opacity component
} else if (regexRgba.test(color) && elem.tagName !== 'IMG') {
colorObject = H.color(color);
wrapper[prop + '-opacitySetter'](colorObject.get('a'), prop, elem);
ret = colorObject.get('rgb');
} else {
var propNodes = elem.getElementsByTagName(prop); // 'stroke' or 'fill' node
if (propNodes.length) {
propNodes[0].opacity = 1;
propNodes[0].type = 'solid';
}
ret = color;
}
return ret;
},
/**
* Take a VML string and prepare it for either IE8 or IE6/IE7.
* @param {Array} markup A string array of the VML markup to prepare
*/
prepVML: function(markup) {
var vmlStyle = 'display:inline-block;behavior:url(#default#VML);',
isIE8 = this.isIE8;
markup = markup.join('');
if (isIE8) { // add xmlns and style inline
markup = markup.replace('/>', ' xmlns="urn:schemas-microsoft-com:vml" />');
if (markup.indexOf('style="') === -1) {
markup = markup.replace('/>', ' style="' + vmlStyle + '" />');
} else {
markup = markup.replace('style="', 'style="' + vmlStyle);
}
} else { // add namespace
markup = markup.replace('<', '<hcv:');
}
return markup;
},
/**
* Create rotated and aligned text
* @param {String} str
* @param {Number} x
* @param {Number} y
*/
text: SVGRenderer.prototype.html,
/**
* Create and return a path element
* @param {Array} path
*/
path: function(path) {
var attr = {
// subpixel precision down to 0.1 (width and height = 1px)
coordsize: '10 10'
};
if (isArray(path)) {
attr.d = path;
} else if (isObject(path)) { // attributes
extend(attr, path);
}
// create the shape
return this.createElement('shape').attr(attr);
},
/**
* Create and return a circle element. In VML circles are implemented as
* shapes, which is faster than v:oval
* @param {Number} x
* @param {Number} y
* @param {Number} r
*/
circle: function(x, y, r) {
var circle = this.symbol('circle');
if (isObject(x)) {
r = x.r;
y = x.y;
x = x.x;
}
circle.isCircle = true; // Causes x and y to mean center (#1682)
circle.r = r;
return circle.attr({
x: x,
y: y
});
},
/**
* Create a group using an outer div and an inner v:group to allow rotating
* and flipping. A simple v:group would have problems with positioning
* child HTML elements and CSS clip.
*
* @param {String} name The name of the group
*/
g: function(name) {
var wrapper,
attribs;
// set the class name
if (name) {
attribs = {
'className': 'highcharts-' + name,
'class': 'highcharts-' + name
};
}
// the div to hold HTML and clipping
wrapper = this.createElement('div').attr(attribs);
return wrapper;
},
/**
* VML override to create a regular HTML image
* @param {String} src
* @param {Number} x
* @param {Number} y
* @param {Number} width
* @param {Number} height
*/
image: function(src, x, y, width, height) {
var obj = this.createElement('img')
.attr({
src: src
});
if (arguments.length > 1) {
obj.attr({
x: x,
y: y,
width: width,
height: height
});
}
return obj;
},
/**
* For rectangles, VML uses a shape for rect to overcome bugs and rotation problems
*/
createElement: function(nodeName) {
return nodeName === 'rect' ?
this.symbol(nodeName) :
SVGRenderer.prototype.createElement.call(this, nodeName);
},
/**
* In the VML renderer, each child of an inverted div (group) is inverted
* @param {Object} element
* @param {Object} parentNode
*/
invertChild: function(element, parentNode) {
var ren = this,
parentStyle = parentNode.style,
imgStyle = element.tagName === 'IMG' && element.style; // #1111
css(element, {
flip: 'x',
left: pInt(parentStyle.width) - (imgStyle ? pInt(imgStyle.top) : 1),
top: pInt(parentStyle.height) - (imgStyle ? pInt(imgStyle.left) : 1),
rotation: -90
});
// Recursively invert child elements, needed for nested composite
// shapes like box plots and error bars. #1680, #1806.
each(element.childNodes, function(child) {
ren.invertChild(child, element);
});
},
/**
* Symbol definitions that override the parent SVG renderer's symbols
*
*/
symbols: {
// VML specific arc function
arc: function(x, y, w, h, options) {
var start = options.start,
end = options.end,
radius = options.r || w || h,
innerRadius = options.innerR,
cosStart = Math.cos(start),
sinStart = Math.sin(start),
cosEnd = Math.cos(end),
sinEnd = Math.sin(end),
ret;
if (end - start === 0) { // no angle, don't show it.
return ['x'];
}
ret = [
'wa', // clockwise arc to
x - radius, // left
y - radius, // top
x + radius, // right
y + radius, // bottom
x + radius * cosStart, // start x
y + radius * sinStart, // start y
x + radius * cosEnd, // end x
y + radius * sinEnd // end y
];
if (options.open && !innerRadius) {
ret.push(
'e',
'M',
x, // - innerRadius,
y // - innerRadius
);
}
ret.push(
'at', // anti clockwise arc to
x - innerRadius, // left
y - innerRadius, // top
x + innerRadius, // right
y + innerRadius, // bottom
x + innerRadius * cosEnd, // start x
y + innerRadius * sinEnd, // start y
x + innerRadius * cosStart, // end x
y + innerRadius * sinStart, // end y
'x', // finish path
'e' // close
);
ret.isArc = true;
return ret;
},
// Add circle symbol path. This performs significantly faster than v:oval.
circle: function(x, y, w, h, wrapper) {
if (wrapper && defined(wrapper.r)) {
w = h = 2 * wrapper.r;
}
// Center correction, #1682
if (wrapper && wrapper.isCircle) {
x -= w / 2;
y -= h / 2;
}
// Return the path
return [
'wa', // clockwisearcto
x, // left
y, // top
x + w, // right
y + h, // bottom
x + w, // start x
y + h / 2, // start y
x + w, // end x
y + h / 2, // end y
//'x', // finish path
'e' // close
];
},
/**
* Add rectangle symbol path which eases rotation and omits arcsize problems
* compared to the built-in VML roundrect shape. When borders are not rounded,
* use the simpler square path, else use the callout path without the arrow.
*/
rect: function(x, y, w, h, options) {
return SVGRenderer.prototype.symbols[!defined(options) || !options.r ? 'square' : 'callout'].call(0, x, y, w, h, options);
}
}
};
H.VMLRenderer = VMLRenderer = function() {
this.init.apply(this, arguments);
};
VMLRenderer.prototype = merge(SVGRenderer.prototype, VMLRendererExtension);
// general renderer
H.Renderer = VMLRenderer;
}
// This method is used with exporting in old IE, when emulating SVG (see #2314)
SVGRenderer.prototype.measureSpanWidth = function(text, styles) {
var measuringSpan = doc.createElement('span'),
offsetWidth,
textNode = doc.createTextNode(text);
measuringSpan.appendChild(textNode);
css(measuringSpan, styles);
this.box.appendChild(measuringSpan);
offsetWidth = measuringSpan.offsetWidth;
discardElement(measuringSpan); // #2463
return offsetWidth;
};
/* ****************************************************************************
* *
* END OF INTERNET EXPLORER <= 8 SPECIFIC CODE *
* *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var correctFloat = H.correctFloat,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
isNumber = H.isNumber,
merge = H.merge,
pick = H.pick,
deg2rad = H.deg2rad;
/**
* The Tick class
*/
H.Tick = function(axis, pos, type, noLabel) {
this.axis = axis;
this.pos = pos;
this.type = type || '';
this.isNew = true;
if (!type && !noLabel) {
this.addLabel();
}
};
H.Tick.prototype = {
/**
* Write the tick label
*/
addLabel: function() {
var tick = this,
axis = tick.axis,
options = axis.options,
chart = axis.chart,
categories = axis.categories,
names = axis.names,
pos = tick.pos,
labelOptions = options.labels,
str,
tickPositions = axis.tickPositions,
isFirst = pos === tickPositions[0],
isLast = pos === tickPositions[tickPositions.length - 1],
value = categories ?
pick(categories[pos], names[pos], pos) :
pos,
label = tick.label,
tickPositionInfo = tickPositions.info,
dateTimeLabelFormat;
// Set the datetime label format. If a higher rank is set for this position, use that. If not,
// use the general format.
if (axis.isDatetimeAxis && tickPositionInfo) {
dateTimeLabelFormat =
options.dateTimeLabelFormats[
tickPositionInfo.higherRanks[pos] || tickPositionInfo.unitName
];
}
// set properties for access in render method
tick.isFirst = isFirst;
tick.isLast = isLast;
// get the string
str = axis.labelFormatter.call({
axis: axis,
chart: chart,
isFirst: isFirst,
isLast: isLast,
dateTimeLabelFormat: dateTimeLabelFormat,
value: axis.isLog ? correctFloat(axis.lin2log(value)) : value
});
// prepare CSS
//css = width && { width: Math.max(1, Math.round(width - 2 * (labelOptions.padding || 10))) + 'px' };
// first call
if (!defined(label)) {
tick.label = label =
defined(str) && labelOptions.enabled ?
chart.renderer.text(
str,
0,
0,
labelOptions.useHTML
)
// without position absolute, IE export sometimes is wrong
.css(merge(labelOptions.style))
.add(axis.labelGroup) :
null;
tick.labelLength = label && label.getBBox().width; // Un-rotated length
tick.rotation = 0; // Base value to detect change for new calls to getBBox
// update
} else if (label) {
label.attr({
text: str
});
}
},
/**
* Get the offset height or width of the label
*/
getLabelSize: function() {
return this.label ?
this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
0;
},
/**
* Handle the label overflow by adjusting the labels to the left and right edge, or
* hide them if they collide into the neighbour label.
*/
handleOverflow: function(xy) {
var axis = this.axis,
pxPos = xy.x,
chartWidth = axis.chart.chartWidth,
spacing = axis.chart.spacing,
leftBound = pick(axis.labelLeft, Math.min(axis.pos, spacing[3])),
rightBound = pick(axis.labelRight, Math.max(axis.pos + axis.len, chartWidth - spacing[1])),
label = this.label,
rotation = this.rotation,
factor = {
left: 0,
center: 0.5,
right: 1
}[axis.labelAlign],
labelWidth = label.getBBox().width,
slotWidth = axis.getSlotWidth(),
modifiedSlotWidth = slotWidth,
xCorrection = factor,
goRight = 1,
leftPos,
rightPos,
textWidth,
css = {};
// Check if the label overshoots the chart spacing box. If it does, move it.
// If it now overshoots the slotWidth, add ellipsis.
if (!rotation) {
leftPos = pxPos - factor * labelWidth;
rightPos = pxPos + (1 - factor) * labelWidth;
if (leftPos < leftBound) {
modifiedSlotWidth = xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
} else if (rightPos > rightBound) {
modifiedSlotWidth = rightBound - xy.x + modifiedSlotWidth * factor;
goRight = -1;
}
modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
xy.x += goRight * (slotWidth - modifiedSlotWidth - xCorrection *
(slotWidth - Math.min(labelWidth, modifiedSlotWidth)));
}
// If the label width exceeds the available space, set a text width to be
// picked up below. Also, if a width has been set before, we need to set a new
// one because the reported labelWidth will be limited by the box (#3938).
if (labelWidth > modifiedSlotWidth || (axis.autoRotation && (label.styles || {}).width)) {
textWidth = modifiedSlotWidth;
}
// Add ellipsis to prevent rotated labels to be clipped against the edge of the chart
} else if (rotation < 0 && pxPos - factor * labelWidth < leftBound) {
textWidth = Math.round(pxPos / Math.cos(rotation * deg2rad) - leftBound);
} else if (rotation > 0 && pxPos + factor * labelWidth > rightBound) {
textWidth = Math.round((chartWidth - pxPos) / Math.cos(rotation * deg2rad));
}
if (textWidth) {
css.width = textWidth;
if (!(axis.options.labels.style || {}).textOverflow) {
css.textOverflow = 'ellipsis';
}
label.css(css);
}
},
/**
* Get the x and y position for ticks and labels
*/
getPosition: function(horiz, pos, tickmarkOffset, old) {
var axis = this.axis,
chart = axis.chart,
cHeight = (old && chart.oldChartHeight) || chart.chartHeight;
return {
x: horiz ?
axis.translate(pos + tickmarkOffset, null, null, old) + axis.transB : axis.left + axis.offset +
(axis.opposite ?
((old && chart.oldChartWidth) || chart.chartWidth) - axis.right - axis.left :
0
),
y: horiz ?
cHeight - axis.bottom + axis.offset - (axis.opposite ? axis.height : 0) : cHeight - axis.translate(pos + tickmarkOffset, null, null, old) - axis.transB
};
},
/**
* Get the x, y position of the tick label
*/
getLabelPosition: function(x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
var axis = this.axis,
transA = axis.transA,
reversed = axis.reversed,
staggerLines = axis.staggerLines,
rotCorr = axis.tickRotCorr || {
x: 0,
y: 0
},
yOffset = labelOptions.y,
line;
if (!defined(yOffset)) {
if (axis.side === 0) {
yOffset = label.rotation ? -8 : -label.getBBox().height;
} else if (axis.side === 2) {
yOffset = rotCorr.y + 8;
} else {
// #3140, #3140
yOffset = Math.cos(label.rotation * deg2rad) * (rotCorr.y - label.getBBox(false, 0).height / 2);
}
}
x = x + labelOptions.x + rotCorr.x - (tickmarkOffset && horiz ?
tickmarkOffset * transA * (reversed ? -1 : 1) : 0);
y = y + yOffset - (tickmarkOffset && !horiz ?
tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
// Correct for staggered labels
if (staggerLines) {
line = (index / (step || 1) % staggerLines);
if (axis.opposite) {
line = staggerLines - line - 1;
}
y += line * (axis.labelOffset / staggerLines);
}
return {
x: x,
y: Math.round(y)
};
},
/**
* Extendible method to return the path of the marker
*/
getMarkPath: function(x, y, tickLength, tickWidth, horiz, renderer) {
return renderer.crispLine([
'M',
x,
y,
'L',
x + (horiz ? 0 : -tickLength),
y + (horiz ? tickLength : 0)
], tickWidth);
},
/**
* Renders the gridLine.
* @param {Boolean} old Whether or not the tick is old
* @param {number} opacity The opacity of the grid line
* @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
* @return {undefined}
*/
renderGridLine: function(old, opacity, reverseCrisp) {
var tick = this,
axis = tick.axis,
options = axis.options,
gridLine = tick.gridLine,
gridLinePath,
attribs = {},
pos = tick.pos,
type = tick.type,
tickmarkOffset = axis.tickmarkOffset,
renderer = axis.chart.renderer;
var gridPrefix = type ? type + 'Grid' : 'grid',
gridLineWidth = options[gridPrefix + 'LineWidth'],
gridLineColor = options[gridPrefix + 'LineColor'],
dashStyle = options[gridPrefix + 'LineDashStyle'];
if (!gridLine) {
attribs.stroke = gridLineColor;
attribs['stroke-width'] = gridLineWidth;
if (dashStyle) {
attribs.dashstyle = dashStyle;
}
if (!type) {
attribs.zIndex = 1;
}
if (old) {
attribs.opacity = 0;
}
tick.gridLine = gridLine = renderer.path()
.attr(attribs)
.addClass(
'highcharts-' + (type ? type + '-' : '') + 'grid-line'
)
.add(axis.gridGroup);
}
// If the parameter 'old' is set, the current call will be followed
// by another call, therefore do not do any animations this time
if (!old && gridLine) {
gridLinePath = axis.getPlotLinePath(
pos + tickmarkOffset,
gridLine.strokeWidth() * reverseCrisp,
old, true
);
if (gridLinePath) {
gridLine[tick.isNew ? 'attr' : 'animate']({
d: gridLinePath,
opacity: opacity
});
}
}
},
/**
* Renders the tick mark.
* @param {Object} xy The position vector of the mark
* @param {number} xy.x The x position of the mark
* @param {number} xy.y The y position of the mark
* @param {number} opacity The opacity of the mark
* @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
* @return {undefined}
*/
renderMark: function(xy, opacity, reverseCrisp) {
var tick = this,
axis = tick.axis,
options = axis.options,
renderer = axis.chart.renderer,
type = tick.type,
tickPrefix = type ? type + 'Tick' : 'tick',
tickSize = axis.tickSize(tickPrefix),
mark = tick.mark,
isNewMark = !mark,
x = xy.x,
y = xy.y;
var tickWidth = pick(
options[tickPrefix + 'Width'], !type && axis.isXAxis ? 1 : 0
), // X axis defaults to 1
tickColor = options[tickPrefix + 'Color'];
if (tickSize) {
// negate the length
if (axis.opposite) {
tickSize[0] = -tickSize[0];
}
// First time, create it
if (isNewMark) {
tick.mark = mark = renderer.path()
.addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
.add(axis.axisGroup);
mark.attr({
stroke: tickColor,
'stroke-width': tickWidth
});
}
mark[isNewMark ? 'attr' : 'animate']({
d: tick.getMarkPath(
x,
y,
tickSize[0],
mark.strokeWidth() * reverseCrisp,
axis.horiz,
renderer),
opacity: opacity
});
}
},
/**
* Renders the tick label.
* Note: The label should already be created in init(), so it should only
* have to be moved into place.
* @param {Object} xy The position vector of the label
* @param {number} xy.x The x position of the label
* @param {number} xy.y The y position of the label
* @param {Boolean} old Whether or not the tick is old
* @param {number} opacity The opacity of the label
* @param {number} index The index of the tick
* @return {undefined}
*/
renderLabel: function(xy, old, opacity, index) {
var tick = this,
axis = tick.axis,
horiz = axis.horiz,
options = axis.options,
label = tick.label,
labelOptions = options.labels,
step = labelOptions.step,
tickmarkOffset = axis.tickmarkOffset,
show = true,
x = xy.x,
y = xy.y;
if (label && isNumber(x)) {
label.xy = xy = tick.getLabelPosition(
x,
y,
label,
horiz,
labelOptions,
tickmarkOffset,
index,
step
);
// Apply show first and show last. If the tick is both first and
// last, it is a single centered tick, in which case we show the
// label anyway (#2100).
if (
(
tick.isFirst &&
!tick.isLast &&
!pick(options.showFirstLabel, 1)
) ||
(
tick.isLast &&
!tick.isFirst &&
!pick(options.showLastLabel, 1)
)
) {
show = false;
// Handle label overflow and show or hide accordingly
} else if (horiz && !axis.isRadial && !labelOptions.step &&
!labelOptions.rotation && !old && opacity !== 0) {
tick.handleOverflow(xy);
}
// apply step
if (step && index % step) {
// show those indices dividable by step
show = false;
}
// Set the new position, and show or hide
if (show && isNumber(xy.y)) {
xy.opacity = opacity;
label[tick.isNew ? 'attr' : 'animate'](xy);
} else {
label.attr('y', -9999); // #1338
}
tick.isNew = false;
}
},
/**
* Put everything in place
*
* @param index {Number}
* @param old {Boolean} Use old coordinates to prepare an animation into new
* position
*/
render: function(index, old, opacity) {
var tick = this,
axis = tick.axis,
horiz = axis.horiz,
pos = tick.pos,
tickmarkOffset = axis.tickmarkOffset,
xy = tick.getPosition(horiz, pos, tickmarkOffset, old),
x = xy.x,
y = xy.y,
reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
(!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687
opacity = pick(opacity, 1);
this.isActive = true;
// Create the grid line
this.renderGridLine(old, opacity, reverseCrisp);
// create the tick mark
this.renderMark(xy, opacity, reverseCrisp);
// the label is created on init - now move it into place
this.renderLabel(xy, old, opacity, index);
},
/**
* Destructor for the tick prototype
*/
destroy: function() {
destroyObjectProperties(this, this.axis);
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
each = H.each,
erase = H.erase,
merge = H.merge,
pick = H.pick;
/*
* The object wrapper for plot lines and plot bands
* @param {Object} options
*/
H.PlotLineOrBand = function(axis, options) {
this.axis = axis;
if (options) {
this.options = options;
this.id = options.id;
}
};
H.PlotLineOrBand.prototype = {
/**
* Render the plot line or plot band. If it is already existing,
* move it.
*/
render: function() {
var plotLine = this,
axis = plotLine.axis,
horiz = axis.horiz,
options = plotLine.options,
optionsLabel = options.label,
label = plotLine.label,
to = options.to,
from = options.from,
value = options.value,
isBand = defined(from) && defined(to),
isLine = defined(value),
svgElem = plotLine.svgElem,
isNew = !svgElem,
path = [],
addEvent,
eventType,
color = options.color,
zIndex = pick(options.zIndex, 0),
events = options.events,
attribs = {
'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') + (options.className || '')
},
groupAttribs = {},
renderer = axis.chart.renderer,
groupName = isBand ? 'bands' : 'lines',
group,
log2lin = axis.log2lin;
// logarithmic conversion
if (axis.isLog) {
from = log2lin(from);
to = log2lin(to);
value = log2lin(value);
}
// Set the presentational attributes
if (isLine) {
attribs = {
stroke: color,
'stroke-width': options.width
};
if (options.dashStyle) {
attribs.dashstyle = options.dashStyle;
}
} else if (isBand) { // plot band
if (color) {
attribs.fill = color;
}
if (options.borderWidth) {
attribs.stroke = options.borderColor;
attribs['stroke-width'] = options.borderWidth;
}
}
// Grouping and zIndex
groupAttribs.zIndex = zIndex;
groupName += '-' + zIndex;
group = axis.plotLinesAndBandsGroups[groupName];
if (!group) {
axis.plotLinesAndBandsGroups[groupName] = group = renderer.g('plot-' + groupName)
.attr(groupAttribs).add();
}
// Create the path
if (isNew) {
plotLine.svgElem = svgElem =
renderer
.path()
.attr(attribs).add(group);
}
// Set the path or return
if (isLine) {
path = axis.getPlotLinePath(value, svgElem.strokeWidth());
} else if (isBand) { // plot band
path = axis.getPlotBandPath(from, to, options);
} else {
return;
}
// common for lines and bands
if (isNew && path && path.length) {
svgElem.attr({
d: path
});
// events
if (events) {
addEvent = function(eventType) {
svgElem.on(eventType, function(e) {
events[eventType].apply(plotLine, [e]);
});
};
for (eventType in events) {
addEvent(eventType);
}
}
} else if (svgElem) {
if (path) {
svgElem.show();
svgElem.animate({
d: path
});
} else {
svgElem.hide();
if (label) {
plotLine.label = label = label.destroy();
}
}
}
// the plot band/line label
if (optionsLabel && defined(optionsLabel.text) && path && path.length &&
axis.width > 0 && axis.height > 0 && !path.flat) {
// apply defaults
optionsLabel = merge({
align: horiz && isBand && 'center',
x: horiz ? !isBand && 4 : 10,
verticalAlign: !horiz && isBand && 'middle',
y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
rotation: horiz && !isBand && 90
}, optionsLabel);
this.renderLabel(optionsLabel, path, isBand, zIndex);
} else if (label) { // move out of sight
label.hide();
}
// chainable
return plotLine;
},
/**
* Render and align label for plot line or band.
*/
renderLabel: function(optionsLabel, path, isBand, zIndex) {
var plotLine = this,
label = plotLine.label,
renderer = plotLine.axis.chart.renderer,
attribs,
xs,
ys,
x,
y;
// add the SVG element
if (!label) {
attribs = {
align: optionsLabel.textAlign || optionsLabel.align,
rotation: optionsLabel.rotation,
'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') + '-label ' + (optionsLabel.className || '')
};
attribs.zIndex = zIndex;
plotLine.label = label = renderer.text(
optionsLabel.text,
0,
0,
optionsLabel.useHTML
)
.attr(attribs)
.add();
label.css(optionsLabel.style);
}
// get the bounding box and align the label
// #3000 changed to better handle choice between plotband or plotline
xs = [path[1], path[4], (isBand ? path[6] : path[1])];
ys = [path[2], path[5], (isBand ? path[7] : path[2])];
x = arrayMin(xs);
y = arrayMin(ys);
label.align(optionsLabel, false, {
x: x,
y: y,
width: arrayMax(xs) - x,
height: arrayMax(ys) - y
});
label.show();
},
/**
* Remove the plot line or band
*/
destroy: function() {
// remove it from the lookup
erase(this.axis.plotLinesAndBands, this);
delete this.axis;
destroyObjectProperties(this);
}
};
/**
* Object with members for extending the Axis prototype
* @todo Extend directly instead of adding object to Highcharts first
*/
H.AxisPlotLineOrBandExtension = {
/**
* Create the path for a plot band
*/
getPlotBandPath: function(from, to) {
var toPath = this.getPlotLinePath(to, null, null, true),
path = this.getPlotLinePath(from, null, null, true),
// #4964 check if chart is inverted or plotband is on yAxis
horiz = this.horiz,
plus = 1,
outside =
(from < this.min && to < this.min) ||
(from > this.max && to > this.max);
if (path && toPath) {
// Flat paths don't need labels (#3836)
if (outside) {
path.flat = path.toString() === toPath.toString();
plus = 0;
}
// Add 1 pixel, when coordinates are the same
path.push(
horiz && toPath[4] === path[4] ? toPath[4] + plus : toPath[4], !horiz && toPath[5] === path[5] ? toPath[5] + plus : toPath[5],
horiz && toPath[1] === path[1] ? toPath[1] + plus : toPath[1], !horiz && toPath[2] === path[2] ? toPath[2] + plus : toPath[2]
);
} else { // outside the axis area
path = null;
}
return path;
},
addPlotBand: function(options) {
return this.addPlotBandOrLine(options, 'plotBands');
},
addPlotLine: function(options) {
return this.addPlotBandOrLine(options, 'plotLines');
},
/**
* Add a plot band or plot line after render time
*
* @param options {Object} The plotBand or plotLine configuration object
*/
addPlotBandOrLine: function(options, coll) {
var obj = new H.PlotLineOrBand(this, options).render(),
userOptions = this.userOptions;
if (obj) { // #2189
// Add it to the user options for exporting and Axis.update
if (coll) {
userOptions[coll] = userOptions[coll] || [];
userOptions[coll].push(options);
}
this.plotLinesAndBands.push(obj);
}
return obj;
},
/**
* Remove a plot band or plot line from the chart by id
* @param {Object} id
*/
removePlotBandOrLine: function(id) {
var plotLinesAndBands = this.plotLinesAndBands,
options = this.options,
userOptions = this.userOptions,
i = plotLinesAndBands.length;
while (i--) {
if (plotLinesAndBands[i].id === id) {
plotLinesAndBands[i].destroy();
}
}
each([options.plotLines || [], userOptions.plotLines || [], options.plotBands || [], userOptions.plotBands || []], function(arr) {
i = arr.length;
while (i--) {
if (arr[i].id === id) {
erase(arr, arr[i]);
}
}
});
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animObject = H.animObject,
arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
AxisPlotLineOrBandExtension = H.AxisPlotLineOrBandExtension,
color = H.color,
correctFloat = H.correctFloat,
defaultOptions = H.defaultOptions,
defined = H.defined,
deg2rad = H.deg2rad,
destroyObjectProperties = H.destroyObjectProperties,
each = H.each,
extend = H.extend,
fireEvent = H.fireEvent,
format = H.format,
getMagnitude = H.getMagnitude,
grep = H.grep,
inArray = H.inArray,
isArray = H.isArray,
isNumber = H.isNumber,
isString = H.isString,
merge = H.merge,
normalizeTickInterval = H.normalizeTickInterval,
pick = H.pick,
PlotLineOrBand = H.PlotLineOrBand,
removeEvent = H.removeEvent,
splat = H.splat,
syncTimeout = H.syncTimeout,
Tick = H.Tick;
/**
* Create a new axis object.
* @constructor Axis
* @param {Object} chart
* @param {Object} options
*/
H.Axis = function() {
this.init.apply(this, arguments);
};
H.Axis.prototype = {
/**
* Default options for the X axis - the Y axis has extended defaults
*/
defaultOptions: {
// allowDecimals: null,
// alternateGridColor: null,
// categories: [],
dateTimeLabelFormats: {
millisecond: '%H:%M:%S.%L',
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%e. %b',
week: '%e. %b',
month: '%b \'%y',
year: '%Y'
},
endOnTick: false,
// reversed: false,
labels: {
enabled: true,
// rotation: 0,
// align: 'center',
// step: null,
style: {
color: '#666666',
cursor: 'default',
fontSize: '11px'
},
x: 0
//y: undefined
/*formatter: function () {
return this.value;
},*/
},
//linkedTo: null,
//max: undefined,
//min: undefined,
minPadding: 0.01,
maxPadding: 0.01,
//minRange: null,
//minorTickInterval: null,
minorTickLength: 2,
minorTickPosition: 'outside', // inside or outside
//opposite: false,
//offset: 0,
//plotBands: [{
// events: {},
// zIndex: 1,
// labels: { align, x, verticalAlign, y, style, rotation, textAlign }
//}],
//plotLines: [{
// events: {}
// dashStyle: {}
// zIndex:
// labels: { align, x, verticalAlign, y, style, rotation, textAlign }
//}],
//reversed: false,
// showFirstLabel: true,
// showLastLabel: true,
startOfWeek: 1,
startOnTick: false,
//tickInterval: null,
tickLength: 10,
tickmarkPlacement: 'between', // on or between
tickPixelInterval: 100,
tickPosition: 'outside',
title: {
//text: null,
align: 'middle', // low, middle or high
//margin: 0 for horizontal, 10 for vertical axes,
//rotation: 0,
//side: 'outside',
style: {
color: '#666666'
}
//x: 0,
//y: 0
},
type: 'linear', // linear, logarithmic or datetime
//visible: true
minorGridLineColor: '#f2f2f2',
// minorGridLineDashStyle: null,
minorGridLineWidth: 1,
minorTickColor: '#999999',
//minorTickWidth: 0,
lineColor: '#ccd6eb',
lineWidth: 1,
gridLineColor: '#e6e6e6',
// gridLineDashStyle: 'solid',
// gridLineWidth: 0,
tickColor: '#ccd6eb'
// tickWidth: 1
},
/**
* This options set extends the defaultOptions for Y axes
*/
defaultYAxisOptions: {
endOnTick: true,
tickPixelInterval: 72,
showLastLabel: true,
labels: {
x: -8
},
maxPadding: 0.05,
minPadding: 0.05,
startOnTick: true,
title: {
rotation: 270,
text: 'Values'
},
stackLabels: {
enabled: false,
//align: dynamic,
//y: dynamic,
//x: dynamic,
//verticalAlign: dynamic,
//textAlign: dynamic,
//rotation: 0,
formatter: function() {
return H.numberFormat(this.total, -1);
},
style: {
fontSize: '11px',
fontWeight: 'bold',
color: '#000000',
textOutline: '1px contrast'
}
},
gridLineWidth: 1,
lineWidth: 0
// tickWidth: 0
},
/**
* These options extend the defaultOptions for left axes
*/
defaultLeftAxisOptions: {
labels: {
x: -15
},
title: {
rotation: 270
}
},
/**
* These options extend the defaultOptions for right axes
*/
defaultRightAxisOptions: {
labels: {
x: 15
},
title: {
rotation: 90
}
},
/**
* These options extend the defaultOptions for bottom axes
*/
defaultBottomAxisOptions: {
labels: {
autoRotation: [-45],
x: 0
// overflow: undefined,
// staggerLines: null
},
title: {
rotation: 0
}
},
/**
* These options extend the defaultOptions for top axes
*/
defaultTopAxisOptions: {
labels: {
autoRotation: [-45],
x: 0
// overflow: undefined
// staggerLines: null
},
title: {
rotation: 0
}
},
/**
* Initialize the axis
*/
init: function(chart, userOptions) {
var isXAxis = userOptions.isX,
axis = this;
axis.chart = chart;
// Flag, is the axis horizontal
axis.horiz = chart.inverted ? !isXAxis : isXAxis;
// Flag, isXAxis
axis.isXAxis = isXAxis;
axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
axis.opposite = userOptions.opposite; // needed in setOptions
axis.side = userOptions.side || (axis.horiz ?
(axis.opposite ? 0 : 2) : // top : bottom
(axis.opposite ? 1 : 3)); // right : left
axis.setOptions(userOptions);
var options = this.options,
type = options.type,
isDatetimeAxis = type === 'datetime';
axis.labelFormatter = options.labels.formatter || axis.defaultLabelFormatter; // can be overwritten by dynamic format
// Flag, stagger lines or not
axis.userOptions = userOptions;
//axis.axisTitleMargin = undefined,// = options.title.margin,
axis.minPixelPadding = 0;
axis.reversed = options.reversed;
axis.visible = options.visible !== false;
axis.zoomEnabled = options.zoomEnabled !== false;
// Initial categories
axis.hasNames = type === 'category' || options.categories === true;
axis.categories = options.categories || axis.hasNames;
axis.names = axis.names || []; // Preserve on update (#3830)
// Elements
//axis.axisGroup = undefined;
//axis.gridGroup = undefined;
//axis.axisTitle = undefined;
//axis.axisLine = undefined;
// Placeholder for plotlines and plotbands groups
axis.plotLinesAndBandsGroups = {};
// Shorthand types
axis.isLog = type === 'logarithmic';
axis.isDatetimeAxis = isDatetimeAxis;
axis.positiveValuesOnly = axis.isLog && !axis.allowNegativeLog;
// Flag, if axis is linked to another axis
axis.isLinked = defined(options.linkedTo);
// Linked axis.
//axis.linkedParent = undefined;
// Tick positions
//axis.tickPositions = undefined; // array containing predefined positions
// Tick intervals
//axis.tickInterval = undefined;
//axis.minorTickInterval = undefined;
// Major ticks
axis.ticks = {};
axis.labelEdge = [];
// Minor ticks
axis.minorTicks = {};
// List of plotLines/Bands
axis.plotLinesAndBands = [];
// Alternate bands
axis.alternateBands = {};
// Axis metrics
//axis.left = undefined;
//axis.top = undefined;
//axis.width = undefined;
//axis.height = undefined;
//axis.bottom = undefined;
//axis.right = undefined;
//axis.transA = undefined;
//axis.transB = undefined;
//axis.oldTransA = undefined;
axis.len = 0;
//axis.oldMin = undefined;
//axis.oldMax = undefined;
//axis.oldUserMin = undefined;
//axis.oldUserMax = undefined;
//axis.oldAxisLength = undefined;
axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
axis.range = options.range;
axis.offset = options.offset || 0;
// Dictionary for stacks
axis.stacks = {};
axis.oldStacks = {};
axis.stacksTouched = 0;
// Min and max in the data
//axis.dataMin = undefined,
//axis.dataMax = undefined,
// The axis range
axis.max = null;
axis.min = null;
// User set min and max
//axis.userMin = undefined,
//axis.userMax = undefined,
// Crosshair options
axis.crosshair = pick(options.crosshair, splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1], false);
// Run Axis
var eventType,
events = axis.options.events;
// Register
if (inArray(axis, chart.axes) === -1) { // don't add it again on Axis.update()
if (isXAxis) { // #2713
chart.axes.splice(chart.xAxis.length, 0, axis);
} else {
chart.axes.push(axis);
}
chart[axis.coll].push(axis);
}
axis.series = axis.series || []; // populated by Series
// inverted charts have reversed xAxes as default
if (chart.inverted && isXAxis && axis.reversed === undefined) {
axis.reversed = true;
}
axis.removePlotBand = axis.removePlotBandOrLine;
axis.removePlotLine = axis.removePlotBandOrLine;
// register event listeners
for (eventType in events) {
addEvent(axis, eventType, events[eventType]);
}
// extend logarithmic axis
axis.lin2log = options.linearToLogConverter || axis.lin2log;
if (axis.isLog) {
axis.val2lin = axis.log2lin;
axis.lin2val = axis.lin2log;
}
},
/**
* Merge and set options
*/
setOptions: function(userOptions) {
this.options = merge(
this.defaultOptions,
this.coll === 'yAxis' && this.defaultYAxisOptions, [this.defaultTopAxisOptions, this.defaultRightAxisOptions,
this.defaultBottomAxisOptions, this.defaultLeftAxisOptions
][this.side],
merge(
defaultOptions[this.coll], // if set in setOptions (#1053)
userOptions
)
);
},
/**
* The default label formatter. The context is a special config object for the label.
*/
defaultLabelFormatter: function() {
var axis = this.axis,
value = this.value,
categories = axis.categories,
dateTimeLabelFormat = this.dateTimeLabelFormat,
lang = defaultOptions.lang,
numericSymbols = lang.numericSymbols,
numSymMagnitude = lang.numericSymbolMagnitude || 1000,
i = numericSymbols && numericSymbols.length,
multi,
ret,
formatOption = axis.options.labels.format,
// make sure the same symbol is added for all labels on a linear axis
numericSymbolDetector = axis.isLog ? Math.abs(value) : axis.tickInterval;
if (formatOption) {
ret = format(formatOption, this);
} else if (categories) {
ret = value;
} else if (dateTimeLabelFormat) { // datetime axis
ret = H.dateFormat(dateTimeLabelFormat, value);
} else if (i && numericSymbolDetector >= 1000) {
// Decide whether we should add a numeric symbol like k (thousands) or M (millions).
// If we are to enable this in tooltip or other places as well, we can move this
// logic to the numberFormatter and enable it by a parameter.
while (i-- && ret === undefined) {
multi = Math.pow(numSymMagnitude, i + 1);
if (numericSymbolDetector >= multi && (value * 10) % multi === 0 && numericSymbols[i] !== null && value !== 0) { // #5480
ret = H.numberFormat(value / multi, -1) + numericSymbols[i];
}
}
}
if (ret === undefined) {
if (Math.abs(value) >= 10000) { // add thousands separators
ret = H.numberFormat(value, -1);
} else { // small numbers
ret = H.numberFormat(value, -1, undefined, ''); // #2466
}
}
return ret;
},
/**
* Get the minimum and maximum for the series of each axis
*/
getSeriesExtremes: function() {
var axis = this,
chart = axis.chart;
axis.hasVisibleSeries = false;
// Reset properties in case we're redrawing (#3353)
axis.dataMin = axis.dataMax = axis.threshold = null;
axis.softThreshold = !axis.isXAxis;
if (axis.buildStacks) {
axis.buildStacks();
}
// loop through this axis' series
each(axis.series, function(series) {
if (series.visible || !chart.options.chart.ignoreHiddenSeries) {
var seriesOptions = series.options,
xData,
threshold = seriesOptions.threshold,
seriesDataMin,
seriesDataMax;
axis.hasVisibleSeries = true;
// Validate threshold in logarithmic axes
if (axis.positiveValuesOnly && threshold <= 0) {
threshold = null;
}
// Get dataMin and dataMax for X axes
if (axis.isXAxis) {
xData = series.xData;
if (xData.length) {
// If xData contains values which is not numbers, then filter them out.
// To prevent performance hit, we only do this after we have already
// found seriesDataMin because in most cases all data is valid. #5234.
seriesDataMin = arrayMin(xData);
if (!isNumber(seriesDataMin) && !(seriesDataMin instanceof Date)) { // Date for #5010
xData = grep(xData, function(x) {
return isNumber(x);
});
seriesDataMin = arrayMin(xData); // Do it again with valid data
}
axis.dataMin = Math.min(pick(axis.dataMin, xData[0]), seriesDataMin);
axis.dataMax = Math.max(pick(axis.dataMax, xData[0]), arrayMax(xData));
}
// Get dataMin and dataMax for Y axes, as well as handle stacking and processed data
} else {
// Get this particular series extremes
series.getExtremes();
seriesDataMax = series.dataMax;
seriesDataMin = series.dataMin;
// Get the dataMin and dataMax so far. If percentage is used, the min and max are
// always 0 and 100. If seriesDataMin and seriesDataMax is null, then series
// doesn't have active y data, we continue with nulls
if (defined(seriesDataMin) && defined(seriesDataMax)) {
axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
}
// Adjust to threshold
if (defined(threshold)) {
axis.threshold = threshold;
}
// If any series has a hard threshold, it takes precedence
if (!seriesOptions.softThreshold || axis.positiveValuesOnly) {
axis.softThreshold = false;
}
}
}
});
},
/**
* Translate from axis value to pixel position on the chart, or back
*
*/
translate: function(val, backwards, cvsCoord, old, handleLog, pointPlacement) {
var axis = this.linkedParent || this, // #1417
sign = 1,
cvsOffset = 0,
localA = old ? axis.oldTransA : axis.transA,
localMin = old ? axis.oldMin : axis.min,
returnValue,
minPixelPadding = axis.minPixelPadding,
doPostTranslate = (axis.isOrdinal || axis.isBroken || (axis.isLog && handleLog)) && axis.lin2val;
if (!localA) {
localA = axis.transA;
}
// In vertical axes, the canvas coordinates start from 0 at the top like in
// SVG.
if (cvsCoord) {
sign *= -1; // canvas coordinates inverts the value
cvsOffset = axis.len;
}
// Handle reversed axis
if (axis.reversed) {
sign *= -1;
cvsOffset -= sign * (axis.sector || axis.len);
}
// From pixels to value
if (backwards) { // reverse translation
val = val * sign + cvsOffset;
val -= minPixelPadding;
returnValue = val / localA + localMin; // from chart pixel to value
if (doPostTranslate) { // log and ordinal axes
returnValue = axis.lin2val(returnValue);
}
// From value to pixels
} else {
if (doPostTranslate) { // log and ordinal axes
val = axis.val2lin(val);
}
returnValue = sign * (val - localMin) * localA + cvsOffset +
(sign * minPixelPadding) +
(isNumber(pointPlacement) ? localA * pointPlacement : 0);
}
return returnValue;
},
/**
* Utility method to translate an axis value to pixel position.
* @param {Number} value A value in terms of axis units
* @param {Boolean} paneCoordinates Whether to return the pixel coordinate relative to the chart
* or just the axis/pane itself.
*/
toPixels: function(value, paneCoordinates) {
return this.translate(value, false, !this.horiz, null, true) + (paneCoordinates ? 0 : this.pos);
},
/**
* Utility method to translate a pixel position in to an axis value.
* @param {Number} pixel The pixel value coordinate
* @param {Boolean} paneCoordiantes Whether the input pixel is relative to the chart or just the
* axis/pane itself.
*/
toValue: function(pixel, paneCoordinates) {
return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
},
/**
* Create the path for a plot line that goes from the given value on
* this axis, across the plot to the opposite side
* @param {Number} value
* @param {Number} lineWidth Used for calculation crisp line
* @param {Number] old Use old coordinates (for resizing and rescaling)
*/
getPlotLinePath: function(value, lineWidth, old, force, translatedValue) {
var axis = this,
chart = axis.chart,
axisLeft = axis.left,
axisTop = axis.top,
x1,
y1,
x2,
y2,
cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
cWidth = (old && chart.oldChartWidth) || chart.chartWidth,
skip,
transB = axis.transB,
/**
* Check if x is between a and b. If not, either move to a/b or skip,
* depending on the force parameter.
*/
between = function(x, a, b) {
if (x < a || x > b) {
if (force) {
x = Math.min(Math.max(a, x), b);
} else {
skip = true;
}
}
return x;
};
translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
x1 = x2 = Math.round(translatedValue + transB);
y1 = y2 = Math.round(cHeight - translatedValue - transB);
if (!isNumber(translatedValue)) { // no min or max
skip = true;
} else if (axis.horiz) {
y1 = axisTop;
y2 = cHeight - axis.bottom;
x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
} else {
x1 = axisLeft;
x2 = cWidth - axis.right;
y1 = y2 = between(y1, axisTop, axisTop + axis.height);
}
return skip && !force ?
null :
chart.renderer.crispLine(['M', x1, y1, 'L', x2, y2], lineWidth || 1);
},
/**
* Set the tick positions of a linear axis to round values like whole tens or every five.
*/
getLinearTickPositions: function(tickInterval, min, max) {
var pos,
lastPos,
roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval),
roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval),
tickPositions = [];
// For single points, add a tick regardless of the relative position
// (#2662, #6274)
if (this.single) {
return [min];
}
// Populate the intermediate values
pos = roundedMin;
while (pos <= roundedMax) {
// Place the tick on the rounded value
tickPositions.push(pos);
// Always add the raw tickInterval, not the corrected one.
pos = correctFloat(pos + tickInterval);
// If the interval is not big enough in the current min - max range to actually increase
// the loop variable, we need to break out to prevent endless loop. Issue #619
if (pos === lastPos) {
break;
}
// Record the last value
lastPos = pos;
}
return tickPositions;
},
/**
* Return the minor tick positions. For logarithmic axes, reuse the same logic
* as for major ticks.
*/
getMinorTickPositions: function() {
var axis = this,
options = axis.options,
tickPositions = axis.tickPositions,
minorTickInterval = axis.minorTickInterval,
minorTickPositions = [],
pos,
pointRangePadding = axis.pointRangePadding || 0,
min = axis.min - pointRangePadding, // #1498
max = axis.max + pointRangePadding, // #1498
range = max - min;
// If minor ticks get too dense, they are hard to read, and may cause long running script. So we don't draw them.
if (range && range / minorTickInterval < axis.len / 3) { // #3875
if (axis.isLog) {
// For each interval in the major ticks, compute the minor ticks
// separately.
each(this.paddedTicks, function(pos, i, paddedTicks) {
if (i) {
minorTickPositions.push.apply(
minorTickPositions,
axis.getLogTickPositions(
minorTickInterval,
paddedTicks[i - 1],
paddedTicks[i],
true
)
);
}
});
} else if (axis.isDatetimeAxis && options.minorTickInterval === 'auto') { // #1314
minorTickPositions = minorTickPositions.concat(
axis.getTimeTicks(
axis.normalizeTimeTickInterval(minorTickInterval),
min,
max,
options.startOfWeek
)
);
} else {
for (
pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval
) {
// Very, very, tight grid lines (#5771)
if (pos === minorTickPositions[0]) {
break;
}
minorTickPositions.push(pos);
}
}
}
if (minorTickPositions.length !== 0) {
axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
}
return minorTickPositions;
},
/**
* Adjust the min and max for the minimum range. Keep in mind that the series data is
* not yet processed, so we don't have information on data cropping and grouping, or
* updated axis.pointRange or series.pointRange. The data can't be processed until
* we have finally established min and max.
*/
adjustForMinRange: function() {
var axis = this,
options = axis.options,
min = axis.min,
max = axis.max,
zoomOffset,
spaceAvailable = axis.dataMax - axis.dataMin >= axis.minRange,
closestDataRange,
i,
distance,
xData,
loopLength,
minArgs,
maxArgs,
minRange;
// Set the automatic minimum range based on the closest point distance
if (axis.isXAxis && axis.minRange === undefined && !axis.isLog) {
if (defined(options.min) || defined(options.max)) {
axis.minRange = null; // don't do this again
} else {
// Find the closest distance between raw data points, as opposed to
// closestPointRange that applies to processed points (cropped and grouped)
each(axis.series, function(series) {
xData = series.xData;
loopLength = series.xIncrement ? 1 : xData.length - 1;
for (i = loopLength; i > 0; i--) {
distance = xData[i] - xData[i - 1];
if (closestDataRange === undefined || distance < closestDataRange) {
closestDataRange = distance;
}
}
});
axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
}
}
// if minRange is exceeded, adjust
if (max - min < axis.minRange) {
minRange = axis.minRange;
zoomOffset = (minRange - max + min) / 2;
// if min and max options have been set, don't go beyond it
minArgs = [min - zoomOffset, pick(options.min, min - zoomOffset)];
if (spaceAvailable) { // if space is available, stay within the data range
minArgs[2] = axis.isLog ? axis.log2lin(axis.dataMin) : axis.dataMin;
}
min = arrayMax(minArgs);
maxArgs = [min + minRange, pick(options.max, min + minRange)];
if (spaceAvailable) { // if space is availabe, stay within the data range
maxArgs[2] = axis.isLog ? axis.log2lin(axis.dataMax) : axis.dataMax;
}
max = arrayMin(maxArgs);
// now if the max is adjusted, adjust the min back
if (max - min < minRange) {
minArgs[0] = max - minRange;
minArgs[1] = pick(options.min, max - minRange);
min = arrayMax(minArgs);
}
}
// Record modified extremes
axis.min = min;
axis.max = max;
},
/**
* Find the closestPointRange across all series
*/
getClosest: function() {
var ret;
if (this.categories) {
ret = 1;
} else {
each(this.series, function(series) {
var seriesClosest = series.closestPointRange,
visible = series.visible ||
!series.chart.options.chart.ignoreHiddenSeries;
if (!series.noSharedTooltip &&
defined(seriesClosest) &&
visible
) {
ret = defined(ret) ?
Math.min(ret, seriesClosest) :
seriesClosest;
}
});
}
return ret;
},
/**
* When a point name is given and no x, search for the name in the existing categories,
* or if categories aren't provided, search names or create a new category (#2522).
*/
nameToX: function(point) {
var explicitCategories = isArray(this.categories),
names = explicitCategories ? this.categories : this.names,
nameX = point.options.x,
x;
point.series.requireSorting = false;
if (!defined(nameX)) {
nameX = this.options.uniqueNames === false ?
point.series.autoIncrement() :
inArray(point.name, names);
}
if (nameX === -1) { // The name is not found in currenct categories
if (!explicitCategories) {
x = names.length;
}
} else {
x = nameX;
}
// Write the last point's name to the names array
if (x !== undefined) {
this.names[x] = point.name;
}
return x;
},
/**
* When changes have been done to series data, update the axis.names.
*/
updateNames: function() {
var axis = this;
if (this.names.length > 0) {
this.names.length = 0;
this.minRange = undefined;
each(this.series || [], function(series) {
// Reset incrementer (#5928)
series.xIncrement = null;
// When adding a series, points are not yet generated
if (!series.points || series.isDirtyData) {
series.processData();
series.generatePoints();
}
each(series.points, function(point, i) {
var x;
if (point.options) {
x = axis.nameToX(point);
if (x !== undefined && x !== point.x) {
point.x = x;
series.xData[i] = x;
}
}
});
});
}
},
/**
* Update translation information
*/
setAxisTranslation: function(saveOld) {
var axis = this,
range = axis.max - axis.min,
pointRange = axis.axisPointRange || 0,
closestPointRange,
minPointOffset = 0,
pointRangePadding = 0,
linkedParent = axis.linkedParent,
ordinalCorrection,
hasCategories = !!axis.categories,
transA = axis.transA,
isXAxis = axis.isXAxis;
// Adjust translation for padding. Y axis with categories need to go through the same (#1784).
if (isXAxis || hasCategories || pointRange) {
// Get the closest points
closestPointRange = axis.getClosest();
if (linkedParent) {
minPointOffset = linkedParent.minPointOffset;
pointRangePadding = linkedParent.pointRangePadding;
} else {
each(axis.series, function(series) {
var seriesPointRange = hasCategories ?
1 :
(isXAxis ?
pick(series.options.pointRange, closestPointRange, 0) :
(axis.axisPointRange || 0)), // #2806
pointPlacement = series.options.pointPlacement;
pointRange = Math.max(pointRange, seriesPointRange);
if (!axis.single) {
// minPointOffset is the value padding to the left of the axis in order to make
// room for points with a pointRange, typically columns. When the pointPlacement option
// is 'between' or 'on', this padding does not apply.
minPointOffset = Math.max(
minPointOffset,
isString(pointPlacement) ? 0 : seriesPointRange / 2
);
// Determine the total padding needed to the length of the axis to make room for the
// pointRange. If the series' pointPlacement is 'on', no padding is added.
pointRangePadding = Math.max(
pointRangePadding,
pointPlacement === 'on' ? 0 : seriesPointRange
);
}
});
}
// Record minPointOffset and pointRangePadding
ordinalCorrection = axis.ordinalSlope && closestPointRange ? axis.ordinalSlope / closestPointRange : 1; // #988, #1853
axis.minPointOffset = minPointOffset = minPointOffset * ordinalCorrection;
axis.pointRangePadding = pointRangePadding = pointRangePadding * ordinalCorrection;
// pointRange means the width reserved for each point, like in a column chart
axis.pointRange = Math.min(pointRange, range);
// closestPointRange means the closest distance between points. In columns
// it is mostly equal to pointRange, but in lines pointRange is 0 while closestPointRange
// is some other value
if (isXAxis) {
axis.closestPointRange = closestPointRange;
}
}
// Secondary values
if (saveOld) {
axis.oldTransA = transA;
}
axis.translationSlope = axis.transA = transA =
axis.options.staticScale ||
axis.len / ((range + pointRangePadding) || 1);
axis.transB = axis.horiz ? axis.left : axis.bottom; // translation addend
axis.minPixelPadding = transA * minPointOffset;
},
minFromRange: function() {
return this.max - this.range;
},
/**
* Set the tick positions to round values and optionally extend the extremes
* to the nearest tick
*/
setTickInterval: function(secondPass) {
var axis = this,
chart = axis.chart,
options = axis.options,
isLog = axis.isLog,
log2lin = axis.log2lin,
isDatetimeAxis = axis.isDatetimeAxis,
isXAxis = axis.isXAxis,
isLinked = axis.isLinked,
maxPadding = options.maxPadding,
minPadding = options.minPadding,
length,
linkedParentExtremes,
tickIntervalOption = options.tickInterval,
minTickInterval,
tickPixelIntervalOption = options.tickPixelInterval,
categories = axis.categories,
threshold = axis.threshold,
softThreshold = axis.softThreshold,
thresholdMin,
thresholdMax,
hardMin,
hardMax;
if (!isDatetimeAxis && !categories && !isLinked) {
this.getTickAmount();
}
// Min or max set either by zooming/setExtremes or initial options
hardMin = pick(axis.userMin, options.min);
hardMax = pick(axis.userMax, options.max);
// Linked axis gets the extremes from the parent axis
if (isLinked) {
axis.linkedParent = chart[axis.coll][options.linkedTo];
linkedParentExtremes = axis.linkedParent.getExtremes();
axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
if (options.type !== axis.linkedParent.options.type) {
H.error(11, 1); // Can't link axes of different type
}
// Initial min and max from the extreme data values
} else {
// Adjust to hard threshold
if (!softThreshold && defined(threshold)) {
if (axis.dataMin >= threshold) {
thresholdMin = threshold;
minPadding = 0;
} else if (axis.dataMax <= threshold) {
thresholdMax = threshold;
maxPadding = 0;
}
}
axis.min = pick(hardMin, thresholdMin, axis.dataMin);
axis.max = pick(hardMax, thresholdMax, axis.dataMax);
}
if (isLog) {
if (
axis.positiveValuesOnly &&
!secondPass &&
Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0
) { // #978
H.error(10, 1); // Can't plot negative values on log axis
}
// The correctFloat cures #934, float errors on full tens. But it
// was too aggressive for #4360 because of conversion back to lin,
// therefore use precision 15.
axis.min = correctFloat(log2lin(axis.min), 15);
axis.max = correctFloat(log2lin(axis.max), 15);
}
// handle zoomed range
if (axis.range && defined(axis.max)) {
axis.userMin = axis.min = hardMin = Math.max(axis.min, axis.minFromRange()); // #618
axis.userMax = hardMax = axis.max;
axis.range = null; // don't use it when running setExtremes
}
// Hook for Highstock Scroller. Consider combining with beforePadding.
fireEvent(axis, 'foundExtremes');
// Hook for adjusting this.min and this.max. Used by bubble series.
if (axis.beforePadding) {
axis.beforePadding();
}
// adjust min and max for the minimum range
axis.adjustForMinRange();
// Pad the values to get clear of the chart's edges. To avoid tickInterval taking the padding
// into account, we do this after computing tick interval (#1337).
if (!categories && !axis.axisPointRange && !axis.usePercentage && !isLinked && defined(axis.min) && defined(axis.max)) {
length = axis.max - axis.min;
if (length) {
if (!defined(hardMin) && minPadding) {
axis.min -= length * minPadding;
}
if (!defined(hardMax) && maxPadding) {
axis.max += length * maxPadding;
}
}
}
// Handle options for floor, ceiling, softMin and softMax (#6359)
if (isNumber(options.softMin)) {
axis.min = Math.min(axis.min, options.softMin);
}
if (isNumber(options.softMax)) {
axis.max = Math.max(axis.max, options.softMax);
}
if (isNumber(options.floor)) {
axis.min = Math.max(axis.min, options.floor);
}
if (isNumber(options.ceiling)) {
axis.max = Math.min(axis.max, options.ceiling);
}
// When the threshold is soft, adjust the extreme value only if
// the data extreme and the padded extreme land on either side of the threshold. For example,
// a series of [0, 1, 2, 3] would make the yAxis add a tick for -1 because of the
// default minPadding and startOnTick options. This is prevented by the softThreshold
// option.
if (softThreshold && defined(axis.dataMin)) {
threshold = threshold || 0;
if (!defined(hardMin) && axis.min < threshold && axis.dataMin >= threshold) {
axis.min = threshold;
} else if (!defined(hardMax) && axis.max > threshold && axis.dataMax <= threshold) {
axis.max = threshold;
}
}
// get tickInterval
if (axis.min === axis.max || axis.min === undefined || axis.max === undefined) {
axis.tickInterval = 1;
} else if (isLinked && !tickIntervalOption &&
tickPixelIntervalOption === axis.linkedParent.options.tickPixelInterval) {
axis.tickInterval = tickIntervalOption = axis.linkedParent.tickInterval;
} else {
axis.tickInterval = pick(
tickIntervalOption,
this.tickAmount ? ((axis.max - axis.min) / Math.max(this.tickAmount - 1, 1)) : undefined,
categories ? // for categoried axis, 1 is default, for linear axis use tickPix
1 :
// don't let it be more than the data range
(axis.max - axis.min) * tickPixelIntervalOption / Math.max(axis.len, tickPixelIntervalOption)
);
}
// Now we're finished detecting min and max, crop and group series data. This
// is in turn needed in order to find tick positions in ordinal axes.
if (isXAxis && !secondPass) {
each(axis.series, function(series) {
series.processData(axis.min !== axis.oldMin || axis.max !== axis.oldMax);
});
}
// set the translation factor used in translate function
axis.setAxisTranslation(true);
// hook for ordinal axes and radial axes
if (axis.beforeSetTickPositions) {
axis.beforeSetTickPositions();
}
// hook for extensions, used in Highstock ordinal axes
if (axis.postProcessTickInterval) {
axis.tickInterval = axis.postProcessTickInterval(axis.tickInterval);
}
// In column-like charts, don't cramp in more ticks than there are points (#1943, #4184)
if (axis.pointRange && !tickIntervalOption) {
axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
}
// Before normalizing the tick interval, handle minimum tick interval. This applies only if tickInterval is not defined.
minTickInterval = pick(options.minTickInterval, axis.isDatetimeAxis && axis.closestPointRange);
if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
axis.tickInterval = minTickInterval;
}
// for linear axes, get magnitude and normalize the interval
if (!isDatetimeAxis && !isLog && !tickIntervalOption) {
axis.tickInterval = normalizeTickInterval(
axis.tickInterval,
null,
getMagnitude(axis.tickInterval),
// If the tick interval is between 0.5 and 5 and the axis max is in the order of
// thousands, chances are we are dealing with years. Don't allow decimals. #3363.
pick(options.allowDecimals, !(axis.tickInterval > 0.5 && axis.tickInterval < 5 && axis.max > 1000 && axis.max < 9999)), !!this.tickAmount
);
}
// Prevent ticks from getting so close that we can't draw the labels
if (!this.tickAmount) {
axis.tickInterval = axis.unsquish();
}
this.setTickPositions();
},
/**
* Now we have computed the normalized tickInterval, get the tick positions
*/
setTickPositions: function() {
var options = this.options,
tickPositions,
tickPositionsOption = options.tickPositions,
tickPositioner = options.tickPositioner,
startOnTick = options.startOnTick,
endOnTick = options.endOnTick;
// Set the tickmarkOffset
this.tickmarkOffset = (this.categories && options.tickmarkPlacement === 'between' &&
this.tickInterval === 1) ? 0.5 : 0; // #3202
// get minorTickInterval
this.minorTickInterval = options.minorTickInterval === 'auto' && this.tickInterval ?
this.tickInterval / 5 : options.minorTickInterval;
// When there is only one point, or all points have the same value on
// this axis, then min and max are equal and tickPositions.length is 0
// or 1. In this case, add some padding in order to center the point,
// but leave it with one tick. #1337.
this.single = this.min === this.max && defined(this.min) &&
!this.tickAmount && options.allowDecimals !== false;
// Find the tick positions
this.tickPositions = tickPositions = tickPositionsOption && tickPositionsOption.slice(); // Work on a copy (#1565)
if (!tickPositions) {
if (this.isDatetimeAxis) {
tickPositions = this.getTimeTicks(
this.normalizeTimeTickInterval(this.tickInterval, options.units),
this.min,
this.max,
options.startOfWeek,
this.ordinalPositions,
this.closestPointRange,
true
);
} else if (this.isLog) {
tickPositions = this.getLogTickPositions(this.tickInterval, this.min, this.max);
} else {
tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
}
// Too dense ticks, keep only the first and last (#4477)
if (tickPositions.length > this.len) {
tickPositions = [tickPositions[0], tickPositions.pop()];
}
this.tickPositions = tickPositions;
// Run the tick positioner callback, that allows modifying auto tick positions.
if (tickPositioner) {
tickPositioner = tickPositioner.apply(this, [this.min, this.max]);
if (tickPositioner) {
this.tickPositions = tickPositions = tickPositioner;
}
}
}
// Reset min/max or remove extremes based on start/end on tick
this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
this.trimTicks(tickPositions, startOnTick, endOnTick);
if (!this.isLinked) {
// Substract half a unit (#2619, #2846, #2515, #3390)
if (this.single) {
this.min -= 0.5;
this.max += 0.5;
}
if (!tickPositionsOption && !tickPositioner) {
this.adjustTickAmount();
}
}
},
/**
* Handle startOnTick and endOnTick by either adapting to padding min/max or rounded min/max
*/
trimTicks: function(tickPositions, startOnTick, endOnTick) {
var roundedMin = tickPositions[0],
roundedMax = tickPositions[tickPositions.length - 1],
minPointOffset = this.minPointOffset || 0;
if (!this.isLinked) {
if (startOnTick && roundedMin !== -Infinity) { // #6502
this.min = roundedMin;
} else {
while (this.min - minPointOffset > tickPositions[0]) {
tickPositions.shift();
}
}
if (endOnTick) {
this.max = roundedMax;
} else {
while (this.max + minPointOffset < tickPositions[tickPositions.length - 1]) {
tickPositions.pop();
}
}
// If no tick are left, set one tick in the middle (#3195)
if (tickPositions.length === 0 && defined(roundedMin)) {
tickPositions.push((roundedMax + roundedMin) / 2);
}
}
},
/**
* Check if there are multiple axes in the same pane
* @returns {Boolean} There are other axes
*/
alignToOthers: function() {
var others = {}, // Whether there is another axis to pair with this one
hasOther,
options = this.options;
if (
// Only if alignTicks is true
this.chart.options.chart.alignTicks !== false &&
options.alignTicks !== false &&
// Don't try to align ticks on a log axis, they are not evenly
// spaced (#6021)
!this.isLog
) {
each(this.chart[this.coll], function(axis) {
var otherOptions = axis.options,
horiz = axis.horiz,
key = [
horiz ? otherOptions.left : otherOptions.top,
otherOptions.width,
otherOptions.height,
otherOptions.pane
].join(',');
if (axis.series.length) { // #4442
if (others[key]) {
hasOther = true; // #4201
} else {
others[key] = 1;
}
}
});
}
return hasOther;
},
/**
* Set the max ticks of either the x and y axis collection
*/
getTickAmount: function() {
var options = this.options,
tickAmount = options.tickAmount,
tickPixelInterval = options.tickPixelInterval;
if (!defined(options.tickInterval) && this.len < tickPixelInterval && !this.isRadial &&
!this.isLog && options.startOnTick && options.endOnTick) {
tickAmount = 2;
}
if (!tickAmount && this.alignToOthers()) {
// Add 1 because 4 tick intervals require 5 ticks (including first and last)
tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
}
// For tick amounts of 2 and 3, compute five ticks and remove the intermediate ones. This
// prevents the axis from adding ticks that are too far away from the data extremes.
if (tickAmount < 4) {
this.finalTickAmt = tickAmount;
tickAmount = 5;
}
this.tickAmount = tickAmount;
},
/**
* When using multiple axes, adjust the number of ticks to match the highest
* number of ticks in that group
*/
adjustTickAmount: function() {
var tickInterval = this.tickInterval,
tickPositions = this.tickPositions,
tickAmount = this.tickAmount,
finalTickAmt = this.finalTickAmt,
currentTickAmount = tickPositions && tickPositions.length,
i,
len;
if (currentTickAmount < tickAmount) {
while (tickPositions.length < tickAmount) {
tickPositions.push(correctFloat(
tickPositions[tickPositions.length - 1] + tickInterval
));
}
this.transA *= (currentTickAmount - 1) / (tickAmount - 1);
this.max = tickPositions[tickPositions.length - 1];
// We have too many ticks, run second pass to try to reduce ticks
} else if (currentTickAmount > tickAmount) {
this.tickInterval *= 2;
this.setTickPositions();
}
// The finalTickAmt property is set in getTickAmount
if (defined(finalTickAmt)) {
i = len = tickPositions.length;
while (i--) {
if (
(finalTickAmt === 3 && i % 2 === 1) || // Remove every other tick
(finalTickAmt <= 2 && i > 0 && i < len - 1) // Remove all but first and last
) {
tickPositions.splice(i, 1);
}
}
this.finalTickAmt = undefined;
}
},
/**
* Set the scale based on data min and max, user set min and max or options
*
*/
setScale: function() {
var axis = this,
isDirtyData,
isDirtyAxisLength;
axis.oldMin = axis.min;
axis.oldMax = axis.max;
axis.oldAxisLength = axis.len;
// set the new axisLength
axis.setAxisSize();
//axisLength = horiz ? axisWidth : axisHeight;
isDirtyAxisLength = axis.len !== axis.oldAxisLength;
// is there new data?
each(axis.series, function(series) {
if (series.isDirtyData || series.isDirty ||
series.xAxis.isDirty) { // when x axis is dirty, we need new data extremes for y as well
isDirtyData = true;
}
});
// do we really need to go through all this?
if (isDirtyAxisLength || isDirtyData || axis.isLinked || axis.forceRedraw ||
axis.userMin !== axis.oldUserMin || axis.userMax !== axis.oldUserMax || axis.alignToOthers()) {
if (axis.resetStacks) {
axis.resetStacks();
}
axis.forceRedraw = false;
// get data extremes if needed
axis.getSeriesExtremes();
// get fixed positions based on tickInterval
axis.setTickInterval();
// record old values to decide whether a rescale is necessary later on (#540)
axis.oldUserMin = axis.userMin;
axis.oldUserMax = axis.userMax;
// Mark as dirty if it is not already set to dirty and extremes have changed. #595.
if (!axis.isDirty) {
axis.isDirty = isDirtyAxisLength || axis.min !== axis.oldMin || axis.max !== axis.oldMax;
}
} else if (axis.cleanStacks) {
axis.cleanStacks();
}
},
/**
* Set the extremes and optionally redraw
* @param {Number} newMin
* @param {Number} newMax
* @param {Boolean} redraw
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
* @param {Object} eventArguments
*
*/
setExtremes: function(newMin, newMax, redraw, animation, eventArguments) {
var axis = this,
chart = axis.chart;
redraw = pick(redraw, true); // defaults to true
each(axis.series, function(serie) {
delete serie.kdTree;
});
// Extend the arguments with min and max
eventArguments = extend(eventArguments, {
min: newMin,
max: newMax
});
// Fire the event
fireEvent(axis, 'setExtremes', eventArguments, function() { // the default event handler
axis.userMin = newMin;
axis.userMax = newMax;
axis.eventArgs = eventArguments;
if (redraw) {
chart.redraw(animation);
}
});
},
/**
* Overridable method for zooming chart. Pulled out in a separate method to allow overriding
* in stock charts.
*/
zoom: function(newMin, newMax) {
var dataMin = this.dataMin,
dataMax = this.dataMax,
options = this.options,
min = Math.min(dataMin, pick(options.min, dataMin)),
max = Math.max(dataMax, pick(options.max, dataMax));
if (newMin !== this.min || newMax !== this.max) { // #5790
// Prevent pinch zooming out of range. Check for defined is for #1946. #1734.
if (!this.allowZoomOutside) {
// #6014, sometimes newMax will be smaller than min (or newMin will be larger than max).
if (defined(dataMin)) {
if (newMin < min) {
newMin = min;
}
if (newMin > max) {
newMin = max;
}
}
if (defined(dataMax)) {
if (newMax < min) {
newMax = min;
}
if (newMax > max) {
newMax = max;
}
}
}
// In full view, displaying the reset zoom button is not required
this.displayBtn = newMin !== undefined || newMax !== undefined;
// Do it
this.setExtremes(
newMin,
newMax,
false,
undefined, {
trigger: 'zoom'
}
);
}
return true;
},
/**
* Update the axis metrics
*/
setAxisSize: function() {
var chart = this.chart,
options = this.options,
offsets = options.offsets || [0, 0, 0, 0], // top / right / bottom / left
horiz = this.horiz,
width = pick(options.width, chart.plotWidth - offsets[3] + offsets[1]),
height = pick(options.height, chart.plotHeight - offsets[0] + offsets[2]),
top = pick(options.top, chart.plotTop + offsets[0]),
left = pick(options.left, chart.plotLeft + offsets[3]),
percentRegex = /%$/;
// Check for percentage based input values. Rounding fixes problems with
// column overflow and plot line filtering (#4898, #4899)
if (percentRegex.test(height)) {
height = Math.round(parseFloat(height) / 100 * chart.plotHeight);
}
if (percentRegex.test(top)) {
top = Math.round(parseFloat(top) / 100 * chart.plotHeight + chart.plotTop);
}
// Expose basic values to use in Series object and navigator
this.left = left;
this.top = top;
this.width = width;
this.height = height;
this.bottom = chart.chartHeight - height - top;
this.right = chart.chartWidth - width - left;
// Direction agnostic properties
this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
this.pos = horiz ? left : top; // distance from SVG origin
},
/**
* Get the actual axis extremes
*/
getExtremes: function() {
var axis = this,
isLog = axis.isLog,
lin2log = axis.lin2log;
return {
min: isLog ? correctFloat(lin2log(axis.min)) : axis.min,
max: isLog ? correctFloat(lin2log(axis.max)) : axis.max,
dataMin: axis.dataMin,
dataMax: axis.dataMax,
userMin: axis.userMin,
userMax: axis.userMax
};
},
/**
* Get the zero plane either based on zero or on the min or max value.
* Used in bar and area plots
*/
getThreshold: function(threshold) {
var axis = this,
isLog = axis.isLog,
lin2log = axis.lin2log,
realMin = isLog ? lin2log(axis.min) : axis.min,
realMax = isLog ? lin2log(axis.max) : axis.max;
if (threshold === null) {
threshold = realMin;
} else if (realMin > threshold) {
threshold = realMin;
} else if (realMax < threshold) {
threshold = realMax;
}
return axis.translate(threshold, 0, 1, 0, 1);
},
/**
* Compute auto alignment for the axis label based on which side the axis is on
* and the given rotation for the label
*/
autoLabelAlign: function(rotation) {
var ret,
angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360;
if (angle > 15 && angle < 165) {
ret = 'right';
} else if (angle > 195 && angle < 345) {
ret = 'left';
} else {
ret = 'center';
}
return ret;
},
/**
* Get the tick length and width for the axis.
* @param {String} prefix 'tick' or 'minorTick'
* @returns {Array} An array of tickLength and tickWidth
*/
tickSize: function(prefix) {
var options = this.options,
tickLength = options[prefix + 'Length'],
tickWidth = pick(options[prefix + 'Width'], prefix === 'tick' && this.isXAxis ? 1 : 0); // X axis defaults to 1
if (tickWidth && tickLength) {
// Negate the length
if (options[prefix + 'Position'] === 'inside') {
tickLength = -tickLength;
}
return [tickLength, tickWidth];
}
},
/**
* Return the size of the labels
*/
labelMetrics: function() {
return this.chart.renderer.fontMetrics(
this.options.labels.style && this.options.labels.style.fontSize,
this.ticks[0] && this.ticks[0].label
);
},
/**
* Prevent the ticks from getting so close we can't draw the labels. On a horizontal
* axis, this is handled by rotating the labels, removing ticks and adding ellipsis.
* On a vertical axis remove ticks and add ellipsis.
*/
unsquish: function() {
var labelOptions = this.options.labels,
horiz = this.horiz,
tickInterval = this.tickInterval,
newTickInterval = tickInterval,
slotSize = this.len / (((this.categories ? 1 : 0) + this.max - this.min) / tickInterval),
rotation,
rotationOption = labelOptions.rotation,
labelMetrics = this.labelMetrics(),
step,
bestScore = Number.MAX_VALUE,
autoRotation,
// Return the multiple of tickInterval that is needed to avoid collision
getStep = function(spaceNeeded) {
var step = spaceNeeded / (slotSize || 1);
step = step > 1 ? Math.ceil(step) : 1;
return step * tickInterval;
};
if (horiz) {
autoRotation = !labelOptions.staggerLines && !labelOptions.step && ( // #3971
defined(rotationOption) ? [rotationOption] :
slotSize < pick(labelOptions.autoRotationLimit, 80) && labelOptions.autoRotation
);
if (autoRotation) {
// Loop over the given autoRotation options, and determine which gives the best score. The
// best score is that with the lowest number of steps and a rotation closest to horizontal.
each(autoRotation, function(rot) {
var score;
if (rot === rotationOption || (rot && rot >= -90 && rot <= 90)) { // #3891
step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
score = step + Math.abs(rot / 360);
if (score < bestScore) {
bestScore = score;
rotation = rot;
newTickInterval = step;
}
}
});
}
} else if (!labelOptions.step) { // #4411
newTickInterval = getStep(labelMetrics.h);
}
this.autoRotation = autoRotation;
this.labelRotation = pick(rotation, rotationOption);
return newTickInterval;
},
/**
* Get the general slot width for this axis. This may change between the pre-render (from Axis.getOffset)
* and the final tick rendering and placement (#5086).
*/
getSlotWidth: function() {
var chart = this.chart,
horiz = this.horiz,
labelOptions = this.options.labels,
slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1),
marginLeft = chart.margin[3];
return (
horiz &&
(labelOptions.step || 0) < 2 &&
!labelOptions.rotation && // #4415
((this.staggerLines || 1) * this.len) / slotCount
) || (!horiz && (
(marginLeft && (marginLeft - chart.spacing[3])) ||
chart.chartWidth * 0.33
)); // #1580, #1931
},
/**
* Render the axis labels and determine whether ellipsis or rotation need to be applied
*/
renderUnsquish: function() {
var chart = this.chart,
renderer = chart.renderer,
tickPositions = this.tickPositions,
ticks = this.ticks,
labelOptions = this.options.labels,
horiz = this.horiz,
slotWidth = this.getSlotWidth(),
innerWidth = Math.max(1, Math.round(slotWidth - 2 * (labelOptions.padding || 5))),
attr = {},
labelMetrics = this.labelMetrics(),
textOverflowOption = labelOptions.style && labelOptions.style.textOverflow,
css,
maxLabelLength = 0,
label,
i,
pos;
// Set rotation option unless it is "auto", like in gauges
if (!isString(labelOptions.rotation)) {
attr.rotation = labelOptions.rotation || 0; // #4443
}
// Get the longest label length
each(tickPositions, function(tick) {
tick = ticks[tick];
if (tick && tick.labelLength > maxLabelLength) {
maxLabelLength = tick.labelLength;
}
});
this.maxLabelLength = maxLabelLength;
// Handle auto rotation on horizontal axis
if (this.autoRotation) {
// Apply rotation only if the label is too wide for the slot, and
// the label is wider than its height.
if (maxLabelLength > innerWidth && maxLabelLength > labelMetrics.h) {
attr.rotation = this.labelRotation;
} else {
this.labelRotation = 0;
}
// Handle word-wrap or ellipsis on vertical axis
} else if (slotWidth) {
// For word-wrap or ellipsis
css = {
width: innerWidth + 'px'
};
if (!textOverflowOption) {
css.textOverflow = 'clip';
// On vertical axis, only allow word wrap if there is room for more lines.
i = tickPositions.length;
while (!horiz && i--) {
pos = tickPositions[i];
label = ticks[pos].label;
if (label) {
// Reset ellipsis in order to get the correct bounding box (#4070)
if (label.styles && label.styles.textOverflow === 'ellipsis') {
label.css({
textOverflow: 'clip'
});
// Set the correct width in order to read the bounding box height (#4678, #5034)
} else if (ticks[pos].labelLength > slotWidth) {
label.css({
width: slotWidth + 'px'
});
}
if (label.getBBox().height > this.len / tickPositions.length - (labelMetrics.h - labelMetrics.f)) {
label.specCss = {
textOverflow: 'ellipsis'
};
}
}
}
}
}
// Add ellipsis if the label length is significantly longer than ideal
if (attr.rotation) {
css = {
width: (maxLabelLength > chart.chartHeight * 0.5 ? chart.chartHeight * 0.33 : chart.chartHeight) + 'px'
};
if (!textOverflowOption) {
css.textOverflow = 'ellipsis';
}
}
// Set the explicit or automatic label alignment
this.labelAlign = labelOptions.align || this.autoLabelAlign(this.labelRotation);
if (this.labelAlign) {
attr.align = this.labelAlign;
}
// Apply general and specific CSS
each(tickPositions, function(pos) {
var tick = ticks[pos],
label = tick && tick.label;
if (label) {
label.attr(attr); // This needs to go before the CSS in old IE (#4502)
if (css) {
label.css(merge(css, label.specCss));
}
delete label.specCss;
tick.rotation = attr.rotation;
}
});
// Note: Why is this not part of getLabelPosition?
this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
},
/**
* Return true if the axis has associated data
*/
hasData: function() {
return this.hasVisibleSeries || (defined(this.min) && defined(this.max) && !!this.tickPositions);
},
/**
* Adds the title defined in axis.options.title.
* @param {Boolean} display - whether or not to display the title
*/
addTitle: function(display) {
var axis = this,
renderer = axis.chart.renderer,
horiz = axis.horiz,
opposite = axis.opposite,
options = axis.options,
axisTitleOptions = options.title,
textAlign;
if (!axis.axisTitle) {
textAlign = axisTitleOptions.textAlign;
if (!textAlign) {
textAlign = (horiz ? {
low: 'left',
middle: 'center',
high: 'right'
} : {
low: opposite ? 'right' : 'left',
middle: 'center',
high: opposite ? 'left' : 'right'
})[axisTitleOptions.align];
}
axis.axisTitle = renderer.text(
axisTitleOptions.text,
0,
0,
axisTitleOptions.useHTML
)
.attr({
zIndex: 7,
rotation: axisTitleOptions.rotation || 0,
align: textAlign
})
.addClass('highcharts-axis-title')
.css(axisTitleOptions.style)
.add(axis.axisGroup);
axis.axisTitle.isNew = true;
}
// hide or show the title depending on whether showEmpty is set
axis.axisTitle[display ? 'show' : 'hide'](true);
},
/**
* Generates a tick for initial positioning.
* @param {number} pos - The tick position in axis values.
* @param {number} i - The index of the tick in axis.tickPositions.
*/
generateTick: function(pos) {
var ticks = this.ticks;
if (!ticks[pos]) {
ticks[pos] = new Tick(this, pos);
} else {
ticks[pos].addLabel(); // update labels depending on tick interval
}
},
/**
* Render the tick labels to a preliminary position to get their sizes
*/
getOffset: function() {
var axis = this,
chart = axis.chart,
renderer = chart.renderer,
options = axis.options,
tickPositions = axis.tickPositions,
ticks = axis.ticks,
horiz = axis.horiz,
side = axis.side,
invertedSide = chart.inverted ? [1, 0, 3, 2][side] : side,
hasData,
showAxis,
titleOffset = 0,
titleOffsetOption,
titleMargin = 0,
axisTitleOptions = options.title,
labelOptions = options.labels,
labelOffset = 0, // reset
labelOffsetPadded,
axisOffset = chart.axisOffset,
clipOffset = chart.clipOffset,
clip,
directionFactor = [-1, 1, 1, -1][side],
n,
className = options.className,
axisParent = axis.axisParent, // Used in color axis
lineHeightCorrection,
tickSize = this.tickSize('tick');
// For reuse in Axis.render
hasData = axis.hasData();
axis.showAxis = showAxis = hasData || pick(options.showEmpty, true);
// Set/reset staggerLines
axis.staggerLines = axis.horiz && labelOptions.staggerLines;
// Create the axisGroup and gridGroup elements on first iteration
if (!axis.axisGroup) {
axis.gridGroup = renderer.g('grid')
.attr({
zIndex: options.gridZIndex || 1
})
.addClass('highcharts-' + this.coll.toLowerCase() + '-grid ' + (className || ''))
.add(axisParent);
axis.axisGroup = renderer.g('axis')
.attr({
zIndex: options.zIndex || 2
})
.addClass('highcharts-' + this.coll.toLowerCase() + ' ' + (className || ''))
.add(axisParent);
axis.labelGroup = renderer.g('axis-labels')
.attr({
zIndex: labelOptions.zIndex || 7
})
.addClass('highcharts-' + axis.coll.toLowerCase() + '-labels ' + (className || ''))
.add(axisParent);
}
if (hasData || axis.isLinked) {
// Generate ticks
each(tickPositions, function(pos, i) {
// i is not used here, but may be used in overrides
axis.generateTick(pos, i);
});
axis.renderUnsquish();
// Left side must be align: right and right side must have align: left for labels
if (labelOptions.reserveSpace !== false && (side === 0 || side === 2 || {
1: 'left',
3: 'right'
}[side] === axis.labelAlign || axis.labelAlign === 'center')) {
each(tickPositions, function(pos) {
// get the highest offset
labelOffset = Math.max(
ticks[pos].getLabelSize(),
labelOffset
);
});
}
if (axis.staggerLines) {
labelOffset *= axis.staggerLines;
axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
}
} else { // doesn't have data
for (n in ticks) {
ticks[n].destroy();
delete ticks[n];
}
}
if (axisTitleOptions && axisTitleOptions.text && axisTitleOptions.enabled !== false) {
axis.addTitle(showAxis);
if (showAxis) {
titleOffset = axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
titleOffsetOption = axisTitleOptions.offset;
titleMargin = defined(titleOffsetOption) ? 0 : pick(axisTitleOptions.margin, horiz ? 5 : 10);
}
}
// Render the axis line
axis.renderLine();
// handle automatic or user set offset
axis.offset = directionFactor * pick(options.offset, axisOffset[side]);
axis.tickRotCorr = axis.tickRotCorr || {
x: 0,
y: 0
}; // polar
if (side === 0) {
lineHeightCorrection = -axis.labelMetrics().h;
} else if (side === 2) {
lineHeightCorrection = axis.tickRotCorr.y;
} else {
lineHeightCorrection = 0;
}
// Find the padded label offset
labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
if (labelOffset) {
labelOffsetPadded -= lineHeightCorrection;
labelOffsetPadded += directionFactor * (horiz ? pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) : labelOptions.x);
}
axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
axisOffset[side] = Math.max(
axisOffset[side],
axis.axisTitleMargin + titleOffset + directionFactor * axis.offset,
labelOffsetPadded, // #3027
hasData && tickPositions.length && tickSize ?
tickSize[0] + directionFactor * axis.offset :
0 // #4866
);
// Decide the clipping needed to keep the graph inside the plot area and axis lines
clip = options.offset ? 0 : Math.floor(axis.axisLine.strokeWidth() / 2) * 2; // #4308, #4371
clipOffset[invertedSide] = Math.max(clipOffset[invertedSide], clip);
},
/**
* Get the path for the axis line
*/
getLinePath: function(lineWidth) {
var chart = this.chart,
opposite = this.opposite,
offset = this.offset,
horiz = this.horiz,
lineLeft = this.left + (opposite ? this.width : 0) + offset,
lineTop = chart.chartHeight - this.bottom - (opposite ? this.height : 0) + offset;
if (opposite) {
lineWidth *= -1; // crispify the other way - #1480, #1687
}
return chart.renderer
.crispLine([
'M',
horiz ?
this.left :
lineLeft,
horiz ?
lineTop :
this.top,
'L',
horiz ?
chart.chartWidth - this.right :
lineLeft,
horiz ?
lineTop :
chart.chartHeight - this.bottom
], lineWidth);
},
/**
* Render the axis line
*/
renderLine: function() {
if (!this.axisLine) {
this.axisLine = this.chart.renderer.path()
.addClass('highcharts-axis-line')
.add(this.axisGroup);
this.axisLine.attr({
stroke: this.options.lineColor,
'stroke-width': this.options.lineWidth,
zIndex: 7
});
}
},
/**
* Position the title
*/
getTitlePosition: function() {
// compute anchor points for each of the title align options
var horiz = this.horiz,
axisLeft = this.left,
axisTop = this.top,
axisLength = this.len,
axisTitleOptions = this.options.title,
margin = horiz ? axisLeft : axisTop,
opposite = this.opposite,
offset = this.offset,
xOption = axisTitleOptions.x || 0,
yOption = axisTitleOptions.y || 0,
fontSize = this.chart.renderer.fontMetrics(axisTitleOptions.style && axisTitleOptions.style.fontSize, this.axisTitle).f,
// the position in the length direction of the axis
alongAxis = {
low: margin + (horiz ? 0 : axisLength),
middle: margin + axisLength / 2,
high: margin + (horiz ? axisLength : 0)
}[axisTitleOptions.align],
// the position in the perpendicular direction of the axis
offAxis = (horiz ? axisTop + this.height : axisLeft) +
(horiz ? 1 : -1) * // horizontal axis reverses the margin
(opposite ? -1 : 1) * // so does opposite axes
this.axisTitleMargin +
(this.side === 2 ? fontSize : 0);
return {
x: horiz ?
alongAxis + xOption : offAxis + (opposite ? this.width : 0) + offset + xOption,
y: horiz ?
offAxis + yOption - (opposite ? this.height : 0) + offset : alongAxis + yOption
};
},
/**
* Render a minor tick into the given position. If a minor tick already
* exists in this position, move it.
* @param {number} pos - The position in axis values.
*/
renderMinorTick: function(pos) {
var slideInTicks = this.chart.hasRendered && isNumber(this.oldMin),
minorTicks = this.minorTicks;
if (!minorTicks[pos]) {
minorTicks[pos] = new Tick(this, pos, 'minor');
}
// Render new ticks in old position
if (slideInTicks && minorTicks[pos].isNew) {
minorTicks[pos].render(null, true);
}
minorTicks[pos].render(null, false, 1);
},
/**
* Render a major tick into the given position. If a tick already exists
* in this position, move it.
* @param {number} pos - The position in axis values
* @param {number} i - The tick index
*/
renderTick: function(pos, i) {
var isLinked = this.isLinked,
ticks = this.ticks,
slideInTicks = this.chart.hasRendered && isNumber(this.oldMin);
// Linked axes need an extra check to find out if
if (!isLinked || (pos >= this.min && pos <= this.max)) {
if (!ticks[pos]) {
ticks[pos] = new Tick(this, pos);
}
// render new ticks in old position
if (slideInTicks && ticks[pos].isNew) {
ticks[pos].render(i, true, 0.1);
}
ticks[pos].render(i);
}
},
/**
* Render the axis
*/
render: function() {
var axis = this,
chart = axis.chart,
renderer = chart.renderer,
options = axis.options,
isLog = axis.isLog,
lin2log = axis.lin2log,
isLinked = axis.isLinked,
tickPositions = axis.tickPositions,
axisTitle = axis.axisTitle,
ticks = axis.ticks,
minorTicks = axis.minorTicks,
alternateBands = axis.alternateBands,
stackLabelOptions = options.stackLabels,
alternateGridColor = options.alternateGridColor,
tickmarkOffset = axis.tickmarkOffset,
axisLine = axis.axisLine,
showAxis = axis.showAxis,
animation = animObject(renderer.globalAnimation),
from,
to;
// Reset
axis.labelEdge.length = 0;
//axis.justifyToPlot = overflow === 'justify';
axis.overlap = false;
// Mark all elements inActive before we go over and mark the active ones
each([ticks, minorTicks, alternateBands], function(coll) {
var pos;
for (pos in coll) {
coll[pos].isActive = false;
}
});
// If the series has data draw the ticks. Else only the line and title
if (axis.hasData() || isLinked) {
// minor ticks
if (axis.minorTickInterval && !axis.categories) {
each(axis.getMinorTickPositions(), function(pos) {
axis.renderMinorTick(pos);
});
}
// Major ticks. Pull out the first item and render it last so that
// we can get the position of the neighbour label. #808.
if (tickPositions.length) { // #1300
each(tickPositions, function(pos, i) {
axis.renderTick(pos, i);
});
// In a categorized axis, the tick marks are displayed between labels. So
// we need to add a tick mark and grid line at the left edge of the X axis.
if (tickmarkOffset && (axis.min === 0 || axis.single)) {
if (!ticks[-1]) {
ticks[-1] = new Tick(axis, -1, null, true);
}
ticks[-1].render(-1);
}
}
// alternate grid color
if (alternateGridColor) {
each(tickPositions, function(pos, i) {
to = tickPositions[i + 1] !== undefined ? tickPositions[i + 1] + tickmarkOffset : axis.max - tickmarkOffset;
if (i % 2 === 0 && pos < axis.max && to <= axis.max + (chart.polar ? -tickmarkOffset : tickmarkOffset)) { // #2248, #4660
if (!alternateBands[pos]) {
alternateBands[pos] = new PlotLineOrBand(axis);
}
from = pos + tickmarkOffset; // #949
alternateBands[pos].options = {
from: isLog ? lin2log(from) : from,
to: isLog ? lin2log(to) : to,
color: alternateGridColor
};
alternateBands[pos].render();
alternateBands[pos].isActive = true;
}
});
}
// custom plot lines and bands
if (!axis._addedPlotLB) { // only first time
each((options.plotLines || []).concat(options.plotBands || []), function(plotLineOptions) {
axis.addPlotBandOrLine(plotLineOptions);
});
axis._addedPlotLB = true;
}
} // end if hasData
// Remove inactive ticks
each([ticks, minorTicks, alternateBands], function(coll) {
var pos,
i,
forDestruction = [],
delay = animation.duration,
destroyInactiveItems = function() {
i = forDestruction.length;
while (i--) {
// When resizing rapidly, the same items may be destroyed in different timeouts,
// or the may be reactivated
if (coll[forDestruction[i]] && !coll[forDestruction[i]].isActive) {
coll[forDestruction[i]].destroy();
delete coll[forDestruction[i]];
}
}
};
for (pos in coll) {
if (!coll[pos].isActive) {
// Render to zero opacity
coll[pos].render(pos, false, 0);
coll[pos].isActive = false;
forDestruction.push(pos);
}
}
// When the objects are finished fading out, destroy them
syncTimeout(
destroyInactiveItems,
coll === alternateBands || !chart.hasRendered || !delay ? 0 : delay
);
});
// Set the axis line path
if (axisLine) {
axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
d: this.getLinePath(axisLine.strokeWidth())
});
axisLine.isPlaced = true;
// Show or hide the line depending on options.showEmpty
axisLine[showAxis ? 'show' : 'hide'](true);
}
if (axisTitle && showAxis) {
axisTitle[axisTitle.isNew ? 'attr' : 'animate'](
axis.getTitlePosition()
);
axisTitle.isNew = false;
}
// Stacked totals:
if (stackLabelOptions && stackLabelOptions.enabled) {
axis.renderStackTotals();
}
// End stacked totals
axis.isDirty = false;
},
/**
* Redraw the axis to reflect changes in the data or axis extremes
*/
redraw: function() {
if (this.visible) {
// render the axis
this.render();
// move plot lines and bands
each(this.plotLinesAndBands, function(plotLine) {
plotLine.render();
});
}
// mark associated series as dirty and ready for redraw
each(this.series, function(series) {
series.isDirty = true;
});
},
// Properties to survive after destroy, needed for Axis.update (#4317,
// #5773, #5881).
keepProps: ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'],
/**
* Destroys an Axis instance.
*/
destroy: function(keepEvents) {
var axis = this,
stacks = axis.stacks,
stackKey,
plotLinesAndBands = axis.plotLinesAndBands,
plotGroup,
i,
n;
// Remove the events
if (!keepEvents) {
removeEvent(axis);
}
// Destroy each stack total
for (stackKey in stacks) {
destroyObjectProperties(stacks[stackKey]);
stacks[stackKey] = null;
}
// Destroy collections
each([axis.ticks, axis.minorTicks, axis.alternateBands], function(coll) {
destroyObjectProperties(coll);
});
if (plotLinesAndBands) {
i = plotLinesAndBands.length;
while (i--) { // #1975
plotLinesAndBands[i].destroy();
}
}
// Destroy local variables
each(['stackTotalGroup', 'axisLine', 'axisTitle', 'axisGroup', 'gridGroup', 'labelGroup', 'cross'], function(prop) {
if (axis[prop]) {
axis[prop] = axis[prop].destroy();
}
});
// Destroy each generated group for plotlines and plotbands
for (plotGroup in axis.plotLinesAndBandsGroups) {
axis.plotLinesAndBandsGroups[plotGroup] = axis.plotLinesAndBandsGroups[plotGroup].destroy();
}
// Delete all properties and fall back to the prototype.
for (n in axis) {
if (axis.hasOwnProperty(n) && inArray(n, axis.keepProps) === -1) {
delete axis[n];
}
}
},
/**
* Draw the crosshair
*
* @param {Object} e The event arguments from the modified pointer event
* @param {Object} point The Point object
*/
drawCrosshair: function(e, point) {
var path,
options = this.crosshair,
snap = pick(options.snap, true),
pos,
categorized,
graphic = this.cross;
// Use last available event when updating non-snapped crosshairs without
// mouse interaction (#5287)
if (!e) {
e = this.cross && this.cross.e;
}
if (
// Disabled in options
!this.crosshair ||
// Snap
((defined(point) || !snap) === false)
) {
this.hideCrosshair();
} else {
// Get the path
if (!snap) {
pos = e && (this.horiz ? e.chartX - this.pos : this.len - e.chartY + this.pos);
} else if (defined(point)) {
pos = this.isXAxis ? point.plotX : this.len - point.plotY; // #3834
}
if (defined(pos)) {
path = this.getPlotLinePath(
// First argument, value, only used on radial
point && (this.isXAxis ? point.x : pick(point.stackY, point.y)),
null,
null,
null,
pos // Translated position
) || null; // #3189
}
if (!defined(path)) {
this.hideCrosshair();
return;
}
categorized = this.categories && !this.isRadial;
// Draw the cross
if (!graphic) {
this.cross = graphic = this.chart.renderer
.path()
.addClass('highcharts-crosshair highcharts-crosshair-' +
(categorized ? 'category ' : 'thin ') + options.className)
.attr({
zIndex: pick(options.zIndex, 2)
})
.add();
// Presentational attributes
graphic.attr({
'stroke': options.color || (categorized ? color('#ccd6eb').setOpacity(0.25).get() : '#cccccc'),
'stroke-width': pick(options.width, 1)
});
if (options.dashStyle) {
graphic.attr({
dashstyle: options.dashStyle
});
}
}
graphic.show().attr({
d: path
});
if (categorized && !options.width) {
graphic.attr({
'stroke-width': this.transA
});
}
this.cross.e = e;
}
},
/**
* Hide the crosshair.
*/
hideCrosshair: function() {
if (this.cross) {
this.cross.hide();
}
}
}; // end Axis
extend(H.Axis.prototype, AxisPlotLineOrBandExtension);
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
getMagnitude = H.getMagnitude,
map = H.map,
normalizeTickInterval = H.normalizeTickInterval,
pick = H.pick;
/**
* Methods defined on the Axis prototype
*/
/**
* Set the tick positions of a logarithmic axis
*/
Axis.prototype.getLogTickPositions = function(interval, min, max, minor) {
var axis = this,
options = axis.options,
axisLength = axis.len,
lin2log = axis.lin2log,
log2lin = axis.log2lin,
// Since we use this method for both major and minor ticks,
// use a local variable and return the result
positions = [];
// Reset
if (!minor) {
axis._minorAutoInterval = null;
}
// First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
if (interval >= 0.5) {
interval = Math.round(interval);
positions = axis.getLinearTickPositions(interval, min, max);
// Second case: We need intermediary ticks. For example
// 1, 2, 4, 6, 8, 10, 20, 40 etc.
} else if (interval >= 0.08) {
var roundedMin = Math.floor(min),
intermediate,
i,
j,
len,
pos,
lastPos,
break2;
if (interval > 0.3) {
intermediate = [1, 2, 4];
} else if (interval > 0.15) { // 0.2 equals five minor ticks per 1, 10, 100 etc
intermediate = [1, 2, 4, 6, 8];
} else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
}
for (i = roundedMin; i < max + 1 && !break2; i++) {
len = intermediate.length;
for (j = 0; j < len && !break2; j++) {
pos = log2lin(lin2log(i) * intermediate[j]);
if (pos > min && (!minor || lastPos <= max) && lastPos !== undefined) { // #1670, lastPos is #3113
positions.push(lastPos);
}
if (lastPos > max) {
break2 = true;
}
lastPos = pos;
}
}
// Third case: We are so deep in between whole logarithmic values that
// we might as well handle the tick positions like a linear axis. For
// example 1.01, 1.02, 1.03, 1.04.
} else {
var realMin = lin2log(min),
realMax = lin2log(max),
tickIntervalOption = options[minor ? 'minorTickInterval' : 'tickInterval'],
filteredTickIntervalOption = tickIntervalOption === 'auto' ? null : tickIntervalOption,
tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1),
totalPixelLength = minor ? axisLength / axis.tickPositions.length : axisLength;
interval = pick(
filteredTickIntervalOption,
axis._minorAutoInterval,
(realMax - realMin) * tickPixelIntervalOption / (totalPixelLength || 1)
);
interval = normalizeTickInterval(
interval,
null,
getMagnitude(interval)
);
positions = map(axis.getLinearTickPositions(
interval,
realMin,
realMax
), log2lin);
if (!minor) {
axis._minorAutoInterval = interval / 5;
}
}
// Set the axis-level tickInterval variable
if (!minor) {
axis.tickInterval = interval;
}
return positions;
};
Axis.prototype.log2lin = function(num) {
return Math.log(num) / Math.LN10;
};
Axis.prototype.lin2log = function(num) {
return Math.pow(10, num);
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var dateFormat = H.dateFormat,
each = H.each,
extend = H.extend,
format = H.format,
isNumber = H.isNumber,
map = H.map,
merge = H.merge,
pick = H.pick,
splat = H.splat,
syncTimeout = H.syncTimeout,
timeUnits = H.timeUnits;
/**
* The tooltip object
* @param {Object} chart The chart instance
* @param {Object} options Tooltip options
*/
H.Tooltip = function() {
this.init.apply(this, arguments);
};
H.Tooltip.prototype = {
init: function(chart, options) {
// Save the chart and options
this.chart = chart;
this.options = options;
// Keep track of the current series
//this.currentSeries = undefined;
// List of crosshairs
this.crosshairs = [];
// Current values of x and y when animating
this.now = {
x: 0,
y: 0
};
// The tooltip is initially hidden
this.isHidden = true;
// Public property for getting the shared state.
this.split = options.split && !chart.inverted;
this.shared = options.shared || this.split;
},
/**
* Destroy the single tooltips in a split tooltip.
* If the tooltip is active then it is not destroyed, unless forced to.
* @param {boolean} force Force destroy all tooltips.
* @return {undefined}
*/
cleanSplit: function(force) {
each(this.chart.series, function(series) {
var tt = series && series.tt;
if (tt) {
if (!tt.isActive || force) {
series.tt = tt.destroy();
} else {
tt.isActive = false;
}
}
});
},
/**
* Create the Tooltip label element if it doesn't exist, then return the
* label.
*/
getLabel: function() {
var renderer = this.chart.renderer,
options = this.options;
if (!this.label) {
// Create the label
if (this.split) {
this.label = renderer.g('tooltip');
} else {
this.label = renderer.label(
'',
0,
0,
options.shape || 'callout',
null,
null,
options.useHTML,
null,
'tooltip'
)
.attr({
padding: options.padding,
r: options.borderRadius
});
this.label
.attr({
'fill': options.backgroundColor,
'stroke-width': options.borderWidth
})
// #2301, #2657
.css(options.style)
.shadow(options.shadow);
}
this.label
.attr({
zIndex: 8
})
.add();
}
return this.label;
},
update: function(options) {
this.destroy();
this.init(this.chart, merge(true, this.options, options));
},
/**
* Destroy the tooltip and its elements.
*/
destroy: function() {
// Destroy and clear local variables
if (this.label) {
this.label = this.label.destroy();
}
if (this.split && this.tt) {
this.cleanSplit(this.chart, true);
this.tt = this.tt.destroy();
}
clearTimeout(this.hideTimer);
clearTimeout(this.tooltipTimeout);
},
/**
* Provide a soft movement for the tooltip
*
* @param {Number} x
* @param {Number} y
* @private
*/
move: function(x, y, anchorX, anchorY) {
var tooltip = this,
now = tooltip.now,
animate = tooltip.options.animation !== false && !tooltip.isHidden &&
// When we get close to the target position, abort animation and land on the right place (#3056)
(Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
skipAnchor = tooltip.followPointer || tooltip.len > 1;
// Get intermediate values for animation
extend(now, {
x: animate ? (2 * now.x + x) / 3 : x,
y: animate ? (now.y + y) / 2 : y,
anchorX: skipAnchor ? undefined : animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
anchorY: skipAnchor ? undefined : animate ? (now.anchorY + anchorY) / 2 : anchorY
});
// Move to the intermediate value
tooltip.getLabel().attr(now);
// Run on next tick of the mouse tracker
if (animate) {
// Never allow two timeouts
clearTimeout(this.tooltipTimeout);
// Set the fixed interval ticking for the smooth tooltip
this.tooltipTimeout = setTimeout(function() {
// The interval function may still be running during destroy,
// so check that the chart is really there before calling.
if (tooltip) {
tooltip.move(x, y, anchorX, anchorY);
}
}, 32);
}
},
/**
* Hide the tooltip
*/
hide: function(delay) {
var tooltip = this;
clearTimeout(this.hideTimer); // disallow duplicate timers (#1728, #1766)
delay = pick(delay, this.options.hideDelay, 500);
if (!this.isHidden) {
this.hideTimer = syncTimeout(function() {
tooltip.getLabel()[delay ? 'fadeOut' : 'hide']();
tooltip.isHidden = true;
}, delay);
}
},
/**
* Extendable method to get the anchor position of the tooltip
* from a point or set of points
*/
getAnchor: function(points, mouseEvent) {
var ret,
chart = this.chart,
inverted = chart.inverted,
plotTop = chart.plotTop,
plotLeft = chart.plotLeft,
plotX = 0,
plotY = 0,
yAxis,
xAxis;
points = splat(points);
// Pie uses a special tooltipPos
ret = points[0].tooltipPos;
// When tooltip follows mouse, relate the position to the mouse
if (this.followPointer && mouseEvent) {
if (mouseEvent.chartX === undefined) {
mouseEvent = chart.pointer.normalize(mouseEvent);
}
ret = [
mouseEvent.chartX - chart.plotLeft,
mouseEvent.chartY - plotTop
];
}
// When shared, use the average position
if (!ret) {
each(points, function(point) {
yAxis = point.series.yAxis;
xAxis = point.series.xAxis;
plotX += point.plotX + (!inverted && xAxis ? xAxis.left - plotLeft : 0);
plotY += (point.plotLow ? (point.plotLow + point.plotHigh) / 2 : point.plotY) +
(!inverted && yAxis ? yAxis.top - plotTop : 0); // #1151
});
plotX /= points.length;
plotY /= points.length;
ret = [
inverted ? chart.plotWidth - plotY : plotX,
this.shared && !inverted && points.length > 1 && mouseEvent ?
mouseEvent.chartY - plotTop : // place shared tooltip next to the mouse (#424)
inverted ? chart.plotHeight - plotX : plotY
];
}
return map(ret, Math.round);
},
/**
* Place the tooltip in a chart without spilling over
* and not covering the point it self.
*/
getPosition: function(boxWidth, boxHeight, point) {
var chart = this.chart,
distance = this.distance,
ret = {},
h = point.h || 0, // #4117
swapped,
first = ['y', chart.chartHeight, boxHeight,
point.plotY + chart.plotTop, chart.plotTop,
chart.plotTop + chart.plotHeight
],
second = ['x', chart.chartWidth, boxWidth,
point.plotX + chart.plotLeft, chart.plotLeft,
chart.plotLeft + chart.plotWidth
],
// The far side is right or bottom
preferFarSide = !this.followPointer && pick(point.ttBelow, !chart.inverted === !!point.negative), // #4984
/**
* Handle the preferred dimension. When the preferred dimension is tooltip
* on top or bottom of the point, it will look for space there.
*/
firstDimension = function(dim, outerSize, innerSize, point, min, max) {
var roomLeft = innerSize < point - distance,
roomRight = point + distance + innerSize < outerSize,
alignedLeft = point - distance - innerSize,
alignedRight = point + distance;
if (preferFarSide && roomRight) {
ret[dim] = alignedRight;
} else if (!preferFarSide && roomLeft) {
ret[dim] = alignedLeft;
} else if (roomLeft) {
ret[dim] = Math.min(max - innerSize, alignedLeft - h < 0 ? alignedLeft : alignedLeft - h);
} else if (roomRight) {
ret[dim] = Math.max(
min,
alignedRight + h + innerSize > outerSize ?
alignedRight :
alignedRight + h
);
} else {
return false;
}
},
/**
* Handle the secondary dimension. If the preferred dimension is tooltip
* on top or bottom of the point, the second dimension is to align the tooltip
* above the point, trying to align center but allowing left or right
* align within the chart box.
*/
secondDimension = function(dim, outerSize, innerSize, point) {
var retVal;
// Too close to the edge, return false and swap dimensions
if (point < distance || point > outerSize - distance) {
retVal = false;
// Align left/top
} else if (point < innerSize / 2) {
ret[dim] = 1;
// Align right/bottom
} else if (point > outerSize - innerSize / 2) {
ret[dim] = outerSize - innerSize - 2;
// Align center
} else {
ret[dim] = point - innerSize / 2;
}
return retVal;
},
/**
* Swap the dimensions
*/
swap = function(count) {
var temp = first;
first = second;
second = temp;
swapped = count;
},
run = function() {
if (firstDimension.apply(0, first) !== false) {
if (secondDimension.apply(0, second) === false && !swapped) {
swap(true);
run();
}
} else if (!swapped) {
swap(true);
run();
} else {
ret.x = ret.y = 0;
}
};
// Under these conditions, prefer the tooltip on the side of the point
if (chart.inverted || this.len > 1) {
swap();
}
run();
return ret;
},
/**
* In case no user defined formatter is given, this will be used. Note that the context
* here is an object holding point, series, x, y etc.
*
* @returns {String|Array<String>}
*/
defaultFormatter: function(tooltip) {
var items = this.points || splat(this),
s;
// Build the header
s = [tooltip.tooltipFooterHeaderFormatter(items[0])];
// build the values
s = s.concat(tooltip.bodyFormatter(items));
// footer
s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));
return s;
},
/**
* Refresh the tooltip's text and position.
* @param {Object|Array} pointOrPoints Rither a point or an array of points
*/
refresh: function(pointOrPoints, mouseEvent) {
var tooltip = this,
label,
options = tooltip.options,
x,
y,
point = pointOrPoints,
anchor,
textConfig = {},
text,
pointConfig = [],
formatter = options.formatter || tooltip.defaultFormatter,
shared = tooltip.shared,
currentSeries;
clearTimeout(this.hideTimer);
// get the reference point coordinates (pie charts use tooltipPos)
tooltip.followPointer = splat(point)[0].series.tooltipOptions.followPointer;
anchor = tooltip.getAnchor(point, mouseEvent);
x = anchor[0];
y = anchor[1];
// shared tooltip, array is sent over
if (shared && !(point.series && point.series.noSharedTooltip)) {
each(point, function(item) {
item.setState('hover');
pointConfig.push(item.getLabelConfig());
});
textConfig = {
x: point[0].category,
y: point[0].y
};
textConfig.points = pointConfig;
point = point[0];
// single point tooltip
} else {
textConfig = point.getLabelConfig();
}
this.len = pointConfig.length; // #6128
text = formatter.call(textConfig, tooltip);
// register the current series
currentSeries = point.series;
this.distance = pick(currentSeries.tooltipOptions.distance, 16);
// update the inner HTML
if (text === false) {
this.hide();
} else {
label = tooltip.getLabel();
// show it
if (tooltip.isHidden) {
label.attr({
opacity: 1
}).show();
}
// update text
if (tooltip.split) {
this.renderSplit(text, pointOrPoints);
} else {
label.attr({
text: text && text.join ? text.join('') : text
});
// Set the stroke color of the box to reflect the point
label.removeClass(/highcharts-color-[\d]+/g)
.addClass('highcharts-color-' + pick(point.colorIndex, currentSeries.colorIndex));
label.attr({
stroke: options.borderColor || point.color || currentSeries.color || '#666666'
});
tooltip.updatePosition({
plotX: x,
plotY: y,
negative: point.negative,
ttBelow: point.ttBelow,
h: anchor[2] || 0
});
}
this.isHidden = false;
}
},
/**
* Render the split tooltip. Loops over each point's text and adds
* a label next to the point, then uses the distribute function to
* find best non-overlapping positions.
*/
renderSplit: function(labels, points) {
var tooltip = this,
boxes = [],
chart = this.chart,
ren = chart.renderer,
rightAligned = true,
options = this.options,
headerHeight,
tooltipLabel = this.getLabel();
// Create the individual labels for header and points, ignore footer
each(labels.slice(0, points.length + 1), function(str, i) {
var point = points[i - 1] ||
// Item 0 is the header. Instead of this, we could also use the crosshair label
{
isHeader: true,
plotX: points[0].plotX
},
owner = point.series || tooltip,
tt = owner.tt,
series = point.series || {},
colorClass = 'highcharts-color-' + pick(point.colorIndex, series.colorIndex, 'none'),
target,
x,
bBox,
boxWidth;
// Store the tooltip referance on the series
if (!tt) {
owner.tt = tt = ren.label(null, null, null, 'callout')
.addClass('highcharts-tooltip-box ' + colorClass)
.attr({
'padding': options.padding,
'r': options.borderRadius,
'fill': options.backgroundColor,
'stroke': point.color || series.color || '#333333',
'stroke-width': options.borderWidth
})
.add(tooltipLabel);
}
tt.isActive = true;
tt.attr({
text: str
});
tt.css(options.style);
// Get X position now, so we can move all to the other side in case of overflow
bBox = tt.getBBox();
boxWidth = bBox.width + tt.strokeWidth();
if (point.isHeader) {
headerHeight = bBox.height;
x = Math.max(
0, // No left overflow
Math.min(
point.plotX + chart.plotLeft - boxWidth / 2,
chart.chartWidth - boxWidth // No right overflow (#5794)
)
);
} else {
x = point.plotX + chart.plotLeft - pick(options.distance, 16) -
boxWidth;
}
// If overflow left, we don't use this x in the next loop
if (x < 0) {
rightAligned = false;
}
// Prepare for distribution
target = (point.series && point.series.yAxis && point.series.yAxis.pos) + (point.plotY || 0);
target -= chart.plotTop;
boxes.push({
target: point.isHeader ? chart.plotHeight + headerHeight : target,
rank: point.isHeader ? 1 : 0,
size: owner.tt.getBBox().height + 1,
point: point,
x: x,
tt: tt
});
});
// Clean previous run (for missing points)
this.cleanSplit();
// Distribute and put in place
H.distribute(boxes, chart.plotHeight + headerHeight);
each(boxes, function(box) {
var point = box.point,
series = point.series;
// Put the label in place
box.tt.attr({
visibility: box.pos === undefined ? 'hidden' : 'inherit',
x: (rightAligned || point.isHeader ?
box.x :
point.plotX + chart.plotLeft + pick(options.distance, 16)),
y: box.pos + chart.plotTop,
anchorX: point.isHeader ?
point.plotX + chart.plotLeft : point.plotX + series.xAxis.pos,
anchorY: point.isHeader ?
box.pos + chart.plotTop - 15 : point.plotY + series.yAxis.pos
});
});
},
/**
* Find the new position and perform the move
*/
updatePosition: function(point) {
var chart = this.chart,
label = this.getLabel(),
pos = (this.options.positioner || this.getPosition).call(
this,
label.width,
label.height,
point
);
// do the move
this.move(
Math.round(pos.x),
Math.round(pos.y || 0), // can be undefined (#3977)
point.plotX + chart.plotLeft,
point.plotY + chart.plotTop
);
},
/**
* Get the optimal date format for a point, based on a range.
* @param {number} range - The time range
* @param {number|Date} date - The date of the point in question
* @param {number} startOfWeek - An integer representing the first day of
* the week, where 0 is Sunday
* @param {Object} dateTimeLabelFormats - A map of time units to formats
* @return {string} - the optimal date format for a point
*/
getDateFormat: function(range, date, startOfWeek, dateTimeLabelFormats) {
var dateStr = dateFormat('%m-%d %H:%M:%S.%L', date),
format,
n,
blank = '01-01 00:00:00.000',
strpos = {
millisecond: 15,
second: 12,
minute: 9,
hour: 6,
day: 3
},
lastN = 'millisecond'; // for sub-millisecond data, #4223
for (n in timeUnits) {
// If the range is exactly one week and we're looking at a Sunday/Monday, go for the week format
if (range === timeUnits.week && +dateFormat('%w', date) === startOfWeek &&
dateStr.substr(6) === blank.substr(6)) {
n = 'week';
break;
}
// The first format that is too great for the range
if (timeUnits[n] > range) {
n = lastN;
break;
}
// If the point is placed every day at 23:59, we need to show
// the minutes as well. #2637.
if (strpos[n] && dateStr.substr(strpos[n]) !== blank.substr(strpos[n])) {
break;
}
// Weeks are outside the hierarchy, only apply them on Mondays/Sundays like in the first condition
if (n !== 'week') {
lastN = n;
}
}
if (n) {
format = dateTimeLabelFormats[n];
}
return format;
},
/**
* Get the best X date format based on the closest point range on the axis.
*/
getXDateFormat: function(point, options, xAxis) {
var xDateFormat,
dateTimeLabelFormats = options.dateTimeLabelFormats,
closestPointRange = xAxis && xAxis.closestPointRange;
if (closestPointRange) {
xDateFormat = this.getDateFormat(
closestPointRange,
point.x,
xAxis.options.startOfWeek,
dateTimeLabelFormats
);
} else {
xDateFormat = dateTimeLabelFormats.day;
}
return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
},
/**
* Format the footer/header of the tooltip
* #3397: abstraction to enable formatting of footer and header
*/
tooltipFooterHeaderFormatter: function(labelConfig, isFooter) {
var footOrHead = isFooter ? 'footer' : 'header',
series = labelConfig.series,
tooltipOptions = series.tooltipOptions,
xDateFormat = tooltipOptions.xDateFormat,
xAxis = series.xAxis,
isDateTime = xAxis && xAxis.options.type === 'datetime' && isNumber(labelConfig.key),
formatString = tooltipOptions[footOrHead + 'Format'];
// Guess the best date format based on the closest point distance (#568, #3418)
if (isDateTime && !xDateFormat) {
xDateFormat = this.getXDateFormat(labelConfig, tooltipOptions, xAxis);
}
// Insert the footer date format if any
if (isDateTime && xDateFormat) {
formatString = formatString.replace('{point.key}', '{point.key:' + xDateFormat + '}');
}
return format(formatString, {
point: labelConfig,
series: series
});
},
/**
* Build the body (lines) of the tooltip by iterating over the items and returning one entry for each item,
* abstracting this functionality allows to easily overwrite and extend it.
*/
bodyFormatter: function(items) {
return map(items, function(item) {
var tooltipOptions = item.series.tooltipOptions;
return (tooltipOptions.pointFormatter || item.point.tooltipFormatter)
.call(item.point, tooltipOptions.pointFormat);
});
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
attr = H.attr,
charts = H.charts,
color = H.color,
css = H.css,
defined = H.defined,
doc = H.doc,
each = H.each,
extend = H.extend,
fireEvent = H.fireEvent,
offset = H.offset,
pick = H.pick,
removeEvent = H.removeEvent,
splat = H.splat,
Tooltip = H.Tooltip,
win = H.win;
/**
* The mouse tracker object. All methods starting with "on" are primary DOM
* event handlers. Subsequent methods should be named differently from what they
* are doing.
*
* @constructor Pointer
* @param {Object} chart The Chart instance
* @param {Object} options The root options object
*/
H.Pointer = function(chart, options) {
this.init(chart, options);
};
H.Pointer.prototype = {
/**
* Initialize Pointer
*/
init: function(chart, options) {
// Store references
this.options = options;
this.chart = chart;
// Do we need to handle click on a touch device?
this.runChartClick = options.chart.events && !!options.chart.events.click;
this.pinchDown = [];
this.lastValidTouch = {};
if (Tooltip && options.tooltip.enabled) {
chart.tooltip = new Tooltip(chart, options.tooltip);
this.followTouchMove = pick(options.tooltip.followTouchMove, true);
}
this.setDOMEvents();
},
/**
* Resolve the zoomType option, this is reset on all touch start and mouse
* down events.
*/
zoomOption: function(e) {
var chart = this.chart,
options = chart.options.chart,
zoomType = options.zoomType || '',
inverted = chart.inverted,
zoomX,
zoomY;
// Look for the pinchType option
if (/touch/.test(e.type)) {
zoomType = pick(options.pinchType, zoomType);
}
this.zoomX = zoomX = /x/.test(zoomType);
this.zoomY = zoomY = /y/.test(zoomType);
this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
this.hasZoom = zoomX || zoomY;
},
/**
* Add crossbrowser support for chartX and chartY
* @param {Object} e The event object in standard browsers
*/
normalize: function(e, chartPosition) {
var chartX,
chartY,
ePos;
// IE normalizing
e = e || win.event;
if (!e.target) {
e.target = e.srcElement;
}
// iOS (#2757)
ePos = e.touches ? (e.touches.length ? e.touches.item(0) : e.changedTouches[0]) : e;
// Get mouse position
if (!chartPosition) {
this.chartPosition = chartPosition = offset(this.chart.container);
}
// chartX and chartY
if (ePos.pageX === undefined) { // IE < 9. #886.
chartX = Math.max(e.x, e.clientX - chartPosition.left); // #2005, #2129: the second case is
// for IE10 quirks mode within framesets
chartY = e.y;
} else {
chartX = ePos.pageX - chartPosition.left;
chartY = ePos.pageY - chartPosition.top;
}
return extend(e, {
chartX: Math.round(chartX),
chartY: Math.round(chartY)
});
},
/**
* Get the click position in terms of axis values.
*
* @param {Object} e A pointer event
*/
getCoordinates: function(e) {
var coordinates = {
xAxis: [],
yAxis: []
};
each(this.chart.axes, function(axis) {
coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
axis: axis,
value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
});
});
return coordinates;
},
/**
* Collects the points closest to a mouseEvent
* @param {Array} series Array of series to gather points from
* @param {Boolean} shared True if shared tooltip, otherwise false
* @param {Object} e Mouse event which possess a position to compare against
* @return {Array} KDPoints sorted by distance
*/
getKDPoints: function(series, shared, e) {
var kdpoints = [],
noSharedTooltip,
directTouch,
kdpointT,
i;
// Find nearest points on all series
each(series, function(s) {
// Skip hidden series
noSharedTooltip = s.noSharedTooltip && shared;
directTouch = !shared && s.directTouch;
if (s.visible && !directTouch && pick(s.options.enableMouseTracking, true)) { // #3821
// #3828
kdpointT = s.searchPoint(
e, !noSharedTooltip && s.options.findNearestPointBy.indexOf('y') < 0
);
if (kdpointT && kdpointT.series) { // Point.series becomes null when reset and before redraw (#5197)
kdpoints.push(kdpointT);
}
}
});
// Sort kdpoints by distance to mouse pointer
kdpoints.sort(function(p1, p2) {
var isCloserX = p1.distX - p2.distX,
isCloser = p1.dist - p2.dist,
isAbove =
(p2.series.group && p2.series.group.zIndex) -
(p1.series.group && p1.series.group.zIndex),
result;
// We have two points which are not in the same place on xAxis and shared tooltip:
if (isCloserX !== 0 && shared) { // #5721
result = isCloserX;
// Points are not exactly in the same place on x/yAxis:
} else if (isCloser !== 0) {
result = isCloser;
// The same xAxis and yAxis position, sort by z-index:
} else if (isAbove !== 0) {
result = isAbove;
// The same zIndex, sort by array index:
} else {
result = p1.series.index > p2.series.index ? -1 : 1;
}
return result;
});
// Remove points with different x-positions, required for shared tooltip and crosshairs (#4645):
if (shared && kdpoints[0] && !kdpoints[0].series.noSharedTooltip) {
i = kdpoints.length;
while (i--) {
if (kdpoints[i].x !== kdpoints[0].x || kdpoints[i].series.noSharedTooltip) {
kdpoints.splice(i, 1);
}
}
}
return kdpoints;
},
getPointFromEvent: function(e) {
var target = e.target,
point;
while (target && !point) {
point = target.point;
target = target.parentNode;
}
return point;
},
getHoverData: function(existingHoverPoint, existingHoverSeries, series, isDirectTouch, shared, e) {
var hoverPoint = existingHoverPoint,
hoverSeries = existingHoverSeries,
searchSeries,
hoverPoints;
// If it has a hoverPoint and that series requires direct touch (like columns, #3899), or we're on
// a noSharedTooltip series among shared tooltip series (#4546), use the hoverPoint . Otherwise,
// search the k-d tree.
// Handle shared tooltip or cases where a series is not yet hovered
if (isDirectTouch) {
if (shared) {
hoverPoints = [];
each(series, function(s) {
// Skip hidden series
var noSharedTooltip = s.noSharedTooltip && shared,
directTouch = !shared && s.directTouch,
kdpointT;
if (s.visible && !noSharedTooltip && !directTouch && pick(s.options.enableMouseTracking, true)) { // #3821
kdpointT = s.searchKDTree({
clientX: hoverPoint.clientX,
plotY: hoverPoint.plotY
}, !noSharedTooltip && s.kdDimensions === 1);
if (kdpointT && kdpointT.series) { // Point.series becomes null when reset and before redraw (#5197)
hoverPoints.push(kdpointT);
}
}
});
// If kdTree is not built
if (hoverPoints.length === 0) {
hoverPoints = [hoverPoint];
}
} else {
hoverPoints = [hoverPoint];
}
// When the hovered series has stickyTracking false.
} else if (hoverSeries && !hoverSeries.stickyTracking) {
if (!shared) {
series = [hoverSeries];
}
hoverPoints = this.getKDPoints(series, shared, e);
hoverPoint = H.find(hoverPoints, function(p) {
return p.series === hoverSeries;
});
// When the hoverSeries has stickyTracking or there is no series hovered.
} else {
// Avoid series with stickyTracking
searchSeries = H.grep(series, function(s) {
return s.stickyTracking;
});
hoverPoints = this.getKDPoints(searchSeries, shared, e);
hoverPoint = hoverPoints[0];
hoverSeries = hoverPoint && hoverPoint.series;
// If
if (shared) {
hoverPoints = this.getKDPoints(series, shared, e);
}
}
// Keep the order of series in tooltip
// Must be done after assigning of hoverPoint
hoverPoints.sort(function(p1, p2) {
return p1.series.index - p2.series.index;
});
return {
hoverPoint: hoverPoint,
hoverSeries: hoverSeries,
hoverPoints: hoverPoints
};
},
/**
* With line type charts with a single tracker, get the point closest to the mouse.
* Run Point.onMouseOver and display tooltip for the point or points.
*/
runPointActions: function(e, p) {
var pointer = this,
chart = pointer.chart,
series = chart.series,
tooltip = chart.tooltip,
shared = tooltip ? tooltip.shared : false,
hoverPoint = p || chart.hoverPoint,
hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries,
// onMouseOver or already hovering a series with directTouch
isDirectTouch = !!p || (!shared && hoverSeries && hoverSeries.directTouch),
hoverData = this.getHoverData(hoverPoint, hoverSeries, series, isDirectTouch, shared, e),
useSharedTooltip,
followPointer,
anchor,
points;
// Update variables from hoverData.
hoverPoint = hoverData.hoverPoint;
hoverSeries = hoverData.hoverSeries;
followPointer = hoverSeries && hoverSeries.tooltipOptions.followPointer;
useSharedTooltip = shared && hoverPoint && !hoverPoint.series.noSharedTooltip;
points = (useSharedTooltip ?
hoverData.hoverPoints :
(hoverPoint ? [hoverPoint] : [])
);
// Refresh tooltip for kdpoint if new hover point or tooltip was hidden // #3926, #4200
if (
hoverPoint &&
// !(hoverSeries && hoverSeries.directTouch) &&
(hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))
) {
each(chart.hoverPoints || [], function(p) {
if (H.inArray(p, points) === -1) {
p.setState();
}
});
// Do mouseover on all points (#3919, #3985, #4410, #5622)
each(points || [], function(p) {
p.setState('hover');
});
// set normal state to previous series
if (chart.hoverSeries !== hoverSeries) {
hoverSeries.onMouseOver();
}
// If tracking is on series in stead of on each point,
// fire mouseOver on hover point.
if (hoverSeries && !hoverSeries.directTouch) { // #4448
if (chart.hoverPoint) {
chart.hoverPoint.firePointEvent('mouseOut');
}
hoverPoint.firePointEvent('mouseOver');
}
chart.hoverPoints = points;
chart.hoverPoint = hoverPoint;
// Draw tooltip if necessary
if (tooltip) {
tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
}
// Update positions (regardless of kdpoint or hoverPoint)
} else if (followPointer && tooltip && !tooltip.isHidden) {
anchor = tooltip.getAnchor([{}], e);
tooltip.updatePosition({
plotX: anchor[0],
plotY: anchor[1]
});
}
// Start the event listener to pick up the tooltip and crosshairs
if (!pointer.unDocMouseMove) {
pointer.unDocMouseMove = addEvent(doc, 'mousemove', function(e) {
var chart = charts[H.hoverChartIndex];
if (chart) {
chart.pointer.onDocumentMouseMove(e);
}
});
}
// Draw crosshairs (#4927, #5269 #5066, #5658)
each(chart.axes, function drawAxisCrosshair(axis) {
// Snap is true. For each hover point, loop over the axes and draw a
// crosshair if that point belongs to the axis.
// @todo Consider only one crosshair per axis.
if (pick(axis.crosshair.snap, true)) {
each(points, function(p) {
if (p.series[axis.coll] === axis) {
axis.drawCrosshair(e, p);
}
});
} else {
axis.drawCrosshair(e);
}
});
},
/**
* Reset the tracking by hiding the tooltip, the hover series state and the hover point
*
* @param allowMove {Boolean} Instead of destroying the tooltip altogether, allow moving it if possible
*/
reset: function(allowMove, delay) {
var pointer = this,
chart = pointer.chart,
hoverSeries = chart.hoverSeries,
hoverPoint = chart.hoverPoint,
hoverPoints = chart.hoverPoints,
tooltip = chart.tooltip,
tooltipPoints = tooltip && tooltip.shared ? hoverPoints : hoverPoint;
// Check if the points have moved outside the plot area (#1003, #4736, #5101)
if (allowMove && tooltipPoints) {
each(splat(tooltipPoints), function(point) {
if (point.series.isCartesian && point.plotX === undefined) {
allowMove = false;
}
});
}
// Just move the tooltip, #349
if (allowMove) {
if (tooltip && tooltipPoints) {
tooltip.refresh(tooltipPoints);
if (hoverPoint) { // #2500
hoverPoint.setState(hoverPoint.state, true);
each(chart.axes, function(axis) {
if (axis.crosshair) {
axis.drawCrosshair(null, hoverPoint);
}
});
}
}
// Full reset
} else {
if (hoverPoint) {
hoverPoint.onMouseOut();
}
if (hoverPoints) {
each(hoverPoints, function(point) {
point.setState();
});
}
if (hoverSeries) {
hoverSeries.onMouseOut();
}
if (tooltip) {
tooltip.hide(delay);
}
if (pointer.unDocMouseMove) {
pointer.unDocMouseMove = pointer.unDocMouseMove();
}
// Remove crosshairs
each(chart.axes, function(axis) {
axis.hideCrosshair();
});
pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
}
},
/**
* Scale series groups to a certain scale and translation
*/
scaleGroups: function(attribs, clip) {
var chart = this.chart,
seriesAttribs;
// Scale each series
each(chart.series, function(series) {
seriesAttribs = attribs || series.getPlotBox(); // #1701
if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
series.group.attr(seriesAttribs);
if (series.markerGroup) {
series.markerGroup.attr(seriesAttribs);
series.markerGroup.clip(clip ? chart.clipRect : null);
}
if (series.dataLabelsGroup) {
series.dataLabelsGroup.attr(seriesAttribs);
}
}
});
// Clip
chart.clipRect.attr(clip || chart.clipBox);
},
/**
* Start a drag operation
*/
dragStart: function(e) {
var chart = this.chart;
// Record the start position
chart.mouseIsDown = e.type;
chart.cancelClick = false;
chart.mouseDownX = this.mouseDownX = e.chartX;
chart.mouseDownY = this.mouseDownY = e.chartY;
},
/**
* Perform a drag operation in response to a mousemove event while the mouse is down
*/
drag: function(e) {
var chart = this.chart,
chartOptions = chart.options.chart,
chartX = e.chartX,
chartY = e.chartY,
zoomHor = this.zoomHor,
zoomVert = this.zoomVert,
plotLeft = chart.plotLeft,
plotTop = chart.plotTop,
plotWidth = chart.plotWidth,
plotHeight = chart.plotHeight,
clickedInside,
size,
selectionMarker = this.selectionMarker,
mouseDownX = this.mouseDownX,
mouseDownY = this.mouseDownY,
panKey = chartOptions.panKey && e[chartOptions.panKey + 'Key'];
// If the device supports both touch and mouse (like IE11), and we are touch-dragging
// inside the plot area, don't handle the mouse event. #4339.
if (selectionMarker && selectionMarker.touch) {
return;
}
// If the mouse is outside the plot area, adjust to cooordinates
// inside to prevent the selection marker from going outside
if (chartX < plotLeft) {
chartX = plotLeft;
} else if (chartX > plotLeft + plotWidth) {
chartX = plotLeft + plotWidth;
}
if (chartY < plotTop) {
chartY = plotTop;
} else if (chartY > plotTop + plotHeight) {
chartY = plotTop + plotHeight;
}
// determine if the mouse has moved more than 10px
this.hasDragged = Math.sqrt(
Math.pow(mouseDownX - chartX, 2) +
Math.pow(mouseDownY - chartY, 2)
);
if (this.hasDragged > 10) {
clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop);
// make a selection
if (chart.hasCartesianSeries && (this.zoomX || this.zoomY) && clickedInside && !panKey) {
if (!selectionMarker) {
this.selectionMarker = selectionMarker = chart.renderer.rect(
plotLeft,
plotTop,
zoomHor ? 1 : plotWidth,
zoomVert ? 1 : plotHeight,
0
)
.attr({
fill: chartOptions.selectionMarkerFill || color('#335cad').setOpacity(0.25).get(),
'class': 'highcharts-selection-marker',
'zIndex': 7
})
.add();
}
}
// adjust the width of the selection marker
if (selectionMarker && zoomHor) {
size = chartX - mouseDownX;
selectionMarker.attr({
width: Math.abs(size),
x: (size > 0 ? 0 : size) + mouseDownX
});
}
// adjust the height of the selection marker
if (selectionMarker && zoomVert) {
size = chartY - mouseDownY;
selectionMarker.attr({
height: Math.abs(size),
y: (size > 0 ? 0 : size) + mouseDownY
});
}
// panning
if (clickedInside && !selectionMarker && chartOptions.panning) {
chart.pan(e, chartOptions.panning);
}
}
},
/**
* On mouse up or touch end across the entire document, drop the selection.
*/
drop: function(e) {
var pointer = this,
chart = this.chart,
hasPinched = this.hasPinched;
if (this.selectionMarker) {
var selectionData = {
originalEvent: e, // #4890
xAxis: [],
yAxis: []
},
selectionBox = this.selectionMarker,
selectionLeft = selectionBox.attr ? selectionBox.attr('x') : selectionBox.x,
selectionTop = selectionBox.attr ? selectionBox.attr('y') : selectionBox.y,
selectionWidth = selectionBox.attr ? selectionBox.attr('width') : selectionBox.width,
selectionHeight = selectionBox.attr ? selectionBox.attr('height') : selectionBox.height,
runZoom;
// a selection has been made
if (this.hasDragged || hasPinched) {
// record each axis' min and max
each(chart.axes, function(axis) {
if (axis.zoomEnabled && defined(axis.min) && (hasPinched || pointer[{
xAxis: 'zoomX',
yAxis: 'zoomY'
}[axis.coll]])) { // #859, #3569
var horiz = axis.horiz,
minPixelPadding = e.type === 'touchend' ? axis.minPixelPadding : 0, // #1207, #3075
selectionMin = axis.toValue((horiz ? selectionLeft : selectionTop) + minPixelPadding),
selectionMax = axis.toValue((horiz ? selectionLeft + selectionWidth : selectionTop + selectionHeight) - minPixelPadding);
selectionData[axis.coll].push({
axis: axis,
min: Math.min(selectionMin, selectionMax), // for reversed axes
max: Math.max(selectionMin, selectionMax)
});
runZoom = true;
}
});
if (runZoom) {
fireEvent(chart, 'selection', selectionData, function(args) {
chart.zoom(extend(args, hasPinched ? {
animation: false
} : null));
});
}
}
this.selectionMarker = this.selectionMarker.destroy();
// Reset scaling preview
if (hasPinched) {
this.scaleGroups();
}
}
// Reset all
if (chart) { // it may be destroyed on mouse up - #877
css(chart.container, {
cursor: chart._cursor
});
chart.cancelClick = this.hasDragged > 10; // #370
chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
this.pinchDown = [];
}
},
onContainerMouseDown: function(e) {
e = this.normalize(e);
this.zoomOption(e);
// issue #295, dragging not always working in Firefox
if (e.preventDefault) {
e.preventDefault();
}
this.dragStart(e);
},
onDocumentMouseUp: function(e) {
if (charts[H.hoverChartIndex]) {
charts[H.hoverChartIndex].pointer.drop(e);
}
},
/**
* Special handler for mouse move that will hide the tooltip when the mouse leaves the plotarea.
* Issue #149 workaround. The mouseleave event does not always fire.
*/
onDocumentMouseMove: function(e) {
var chart = this.chart,
chartPosition = this.chartPosition;
e = this.normalize(e, chartPosition);
// If we're outside, hide the tooltip
if (chartPosition && !this.inClass(e.target, 'highcharts-tracker') &&
!chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
this.reset();
}
},
/**
* When mouse leaves the container, hide the tooltip.
*/
onContainerMouseLeave: function(e) {
var chart = charts[H.hoverChartIndex];
if (chart && (e.relatedTarget || e.toElement)) { // #4886, MS Touch end fires mouseleave but with no related target
chart.pointer.reset();
chart.pointer.chartPosition = null; // also reset the chart position, used in #149 fix
}
},
// The mousemove, touchmove and touchstart event handler
onContainerMouseMove: function(e) {
var chart = this.chart;
if (!defined(H.hoverChartIndex) || !charts[H.hoverChartIndex] || !charts[H.hoverChartIndex].mouseIsDown) {
H.hoverChartIndex = chart.index;
}
e = this.normalize(e);
e.returnValue = false; // #2251, #3224
if (chart.mouseIsDown === 'mousedown') {
this.drag(e);
}
// Show the tooltip and run mouse over events (#977)
if ((this.inClass(e.target, 'highcharts-tracker') ||
chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) && !chart.openMenu) {
this.runPointActions(e);
}
},
/**
* Utility to detect whether an element has, or has a parent with, a specific
* class name. Used on detection of tracker objects and on deciding whether
* hovering the tooltip should cause the active series to mouse out.
*/
inClass: function(element, className) {
var elemClassName;
while (element) {
elemClassName = attr(element, 'class');
if (elemClassName) {
if (elemClassName.indexOf(className) !== -1) {
return true;
}
if (elemClassName.indexOf('highcharts-container') !== -1) {
return false;
}
}
element = element.parentNode;
}
},
onTrackerMouseOut: function(e) {
var series = this.chart.hoverSeries,
relatedTarget = e.relatedTarget || e.toElement;
if (series && relatedTarget && !series.stickyTracking &&
!this.inClass(relatedTarget, 'highcharts-tooltip') &&
(!this.inClass(relatedTarget, 'highcharts-series-' + series.index) || // #2499, #4465
!this.inClass(relatedTarget, 'highcharts-tracker') // #5553
)
) {
series.onMouseOut();
}
},
onContainerClick: function(e) {
var chart = this.chart,
hoverPoint = chart.hoverPoint,
plotLeft = chart.plotLeft,
plotTop = chart.plotTop;
e = this.normalize(e);
if (!chart.cancelClick) {
// On tracker click, fire the series and point events. #783, #1583
if (hoverPoint && this.inClass(e.target, 'highcharts-tracker')) {
// the series click event
fireEvent(hoverPoint.series, 'click', extend(e, {
point: hoverPoint
}));
// the point click event
if (chart.hoverPoint) { // it may be destroyed (#1844)
hoverPoint.firePointEvent('click', e);
}
// When clicking outside a tracker, fire a chart event
} else {
extend(e, this.getCoordinates(e));
// fire a click event in the chart
if (chart.isInsidePlot(e.chartX - plotLeft, e.chartY - plotTop)) {
fireEvent(chart, 'click', e);
}
}
}
},
/**
* Set the JS DOM events on the container and document. This method should contain
* a one-to-one assignment between methods and their handlers. Any advanced logic should
* be moved to the handler reflecting the event's name.
*/
setDOMEvents: function() {
var pointer = this,
container = pointer.chart.container;
container.onmousedown = function(e) {
pointer.onContainerMouseDown(e);
};
container.onmousemove = function(e) {
pointer.onContainerMouseMove(e);
};
container.onclick = function(e) {
pointer.onContainerClick(e);
};
addEvent(container, 'mouseleave', pointer.onContainerMouseLeave);
if (H.chartCount === 1) {
addEvent(doc, 'mouseup', pointer.onDocumentMouseUp);
}
if (H.hasTouch) {
container.ontouchstart = function(e) {
pointer.onContainerTouchStart(e);
};
container.ontouchmove = function(e) {
pointer.onContainerTouchMove(e);
};
if (H.chartCount === 1) {
addEvent(doc, 'touchend', pointer.onDocumentTouchEnd);
}
}
},
/**
* Destroys the Pointer object and disconnects DOM events.
*/
destroy: function() {
var prop;
if (this.unDocMouseMove) {
this.unDocMouseMove();
}
removeEvent(
this.chart.container,
'mouseleave',
this.onContainerMouseLeave
);
if (!H.chartCount) {
removeEvent(doc, 'mouseup', this.onDocumentMouseUp);
removeEvent(doc, 'touchend', this.onDocumentTouchEnd);
}
// memory and CPU leak
clearInterval(this.tooltipTimeout);
for (prop in this) {
this[prop] = null;
}
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var charts = H.charts,
each = H.each,
extend = H.extend,
map = H.map,
noop = H.noop,
pick = H.pick,
Pointer = H.Pointer;
/* Support for touch devices */
extend(Pointer.prototype, /** @lends Pointer.prototype */ {
/**
* Run translation operations
*/
pinchTranslate: function(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
if (this.zoomHor) {
this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
}
if (this.zoomVert) {
this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
}
},
/**
* Run translation operations for each direction (horizontal and vertical) independently
*/
pinchTranslateDirection: function(horiz, pinchDown, touches, transform,
selectionMarker, clip, lastValidTouch, forcedScale) {
var chart = this.chart,
xy = horiz ? 'x' : 'y',
XY = horiz ? 'X' : 'Y',
sChartXY = 'chart' + XY,
wh = horiz ? 'width' : 'height',
plotLeftTop = chart['plot' + (horiz ? 'Left' : 'Top')],
selectionWH,
selectionXY,
clipXY,
scale = forcedScale || 1,
inverted = chart.inverted,
bounds = chart.bounds[horiz ? 'h' : 'v'],
singleTouch = pinchDown.length === 1,
touch0Start = pinchDown[0][sChartXY],
touch0Now = touches[0][sChartXY],
touch1Start = !singleTouch && pinchDown[1][sChartXY],
touch1Now = !singleTouch && touches[1][sChartXY],
outOfBounds,
transformScale,
scaleKey,
setScale = function() {
// Don't zoom if fingers are too close on this axis
if (!singleTouch && Math.abs(touch0Start - touch1Start) > 20) {
scale = forcedScale || Math.abs(touch0Now - touch1Now) / Math.abs(touch0Start - touch1Start);
}
clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale;
};
// Set the scale, first pass
setScale();
selectionXY = clipXY; // the clip position (x or y) is altered if out of bounds, the selection position is not
// Out of bounds
if (selectionXY < bounds.min) {
selectionXY = bounds.min;
outOfBounds = true;
} else if (selectionXY + selectionWH > bounds.max) {
selectionXY = bounds.max - selectionWH;
outOfBounds = true;
}
// Is the chart dragged off its bounds, determined by dataMin and dataMax?
if (outOfBounds) {
// Modify the touchNow position in order to create an elastic drag movement. This indicates
// to the user that the chart is responsive but can't be dragged further.
touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
if (!singleTouch) {
touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
}
// Set the scale, second pass to adapt to the modified touchNow positions
setScale();
} else {
lastValidTouch[xy] = [touch0Now, touch1Now];
}
// Set geometry for clipping, selection and transformation
if (!inverted) {
clip[xy] = clipXY - plotLeftTop;
clip[wh] = selectionWH;
}
scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
transformScale = inverted ? 1 / scale : scale;
selectionMarker[wh] = selectionWH;
selectionMarker[xy] = selectionXY;
transform[scaleKey] = scale;
transform['translate' + XY] = (transformScale * plotLeftTop) + (touch0Now - (transformScale * touch0Start));
},
/**
* Handle touch events with two touches
*/
pinch: function(e) {
var self = this,
chart = self.chart,
pinchDown = self.pinchDown,
touches = e.touches,
touchesLength = touches.length,
lastValidTouch = self.lastValidTouch,
hasZoom = self.hasZoom,
selectionMarker = self.selectionMarker,
transform = {},
fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, 'highcharts-tracker') &&
chart.runTrackerClick) || self.runChartClick),
clip = {};
// Don't initiate panning until the user has pinched. This prevents us from
// blocking page scrolling as users scroll down a long page (#4210).
if (touchesLength > 1) {
self.initiated = true;
}
// On touch devices, only proceed to trigger click if a handler is defined
if (hasZoom && self.initiated && !fireClickEvent) {
e.preventDefault();
}
// Normalize each touch
map(touches, function(e) {
return self.normalize(e);
});
// Register the touch start position
if (e.type === 'touchstart') {
each(touches, function(e, i) {
pinchDown[i] = {
chartX: e.chartX,
chartY: e.chartY
};
});
lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] && pinchDown[1].chartX];
lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] && pinchDown[1].chartY];
// Identify the data bounds in pixels
each(chart.axes, function(axis) {
if (axis.zoomEnabled) {
var bounds = chart.bounds[axis.horiz ? 'h' : 'v'],
minPixelPadding = axis.minPixelPadding,
min = axis.toPixels(pick(axis.options.min, axis.dataMin)),
max = axis.toPixels(pick(axis.options.max, axis.dataMax)),
absMin = Math.min(min, max),
absMax = Math.max(min, max);
// Store the bounds for use in the touchmove handler
bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
bounds.max = Math.max(axis.pos + axis.len, absMax + minPixelPadding);
}
});
self.res = true; // reset on next move
// Optionally move the tooltip on touchmove
} else if (self.followTouchMove && touchesLength === 1) {
this.runPointActions(self.normalize(e));
// Event type is touchmove, handle panning and pinching
} else if (pinchDown.length) { // can be 0 when releasing, if touchend fires first
// Set the marker
if (!selectionMarker) {
self.selectionMarker = selectionMarker = extend({
destroy: noop,
touch: true
}, chart.plotBox);
}
self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
self.hasPinched = hasZoom;
// Scale and translate the groups to provide visual feedback during pinching
self.scaleGroups(transform, clip);
if (self.res) {
self.res = false;
this.reset(false, 0);
}
}
},
/**
* General touch handler shared by touchstart and touchmove.
*/
touch: function(e, start) {
var chart = this.chart,
hasMoved,
pinchDown,
isInside;
if (chart.index !== H.hoverChartIndex) {
this.onContainerMouseLeave({
relatedTarget: true
});
}
H.hoverChartIndex = chart.index;
if (e.touches.length === 1) {
e = this.normalize(e);
isInside = chart.isInsidePlot(
e.chartX - chart.plotLeft,
e.chartY - chart.plotTop
);
if (isInside && !chart.openMenu) {
// Run mouse events and display tooltip etc
if (start) {
this.runPointActions(e);
}
// Android fires touchmove events after the touchstart even if the
// finger hasn't moved, or moved only a pixel or two. In iOS however,
// the touchmove doesn't fire unless the finger moves more than ~4px.
// So we emulate this behaviour in Android by checking how much it
// moved, and cancelling on small distances. #3450.
if (e.type === 'touchmove') {
pinchDown = this.pinchDown;
hasMoved = pinchDown[0] ? Math.sqrt( // #5266
Math.pow(pinchDown[0].chartX - e.chartX, 2) +
Math.pow(pinchDown[0].chartY - e.chartY, 2)
) >= 4 : false;
}
if (pick(hasMoved, true)) {
this.pinch(e);
}
} else if (start) {
// Hide the tooltip on touching outside the plot area (#1203)
this.reset();
}
} else if (e.touches.length === 2) {
this.pinch(e);
}
},
onContainerTouchStart: function(e) {
this.zoomOption(e);
this.touch(e, true);
},
onContainerTouchMove: function(e) {
this.touch(e);
},
onDocumentTouchEnd: function(e) {
if (charts[H.hoverChartIndex]) {
charts[H.hoverChartIndex].pointer.drop(e);
}
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
charts = H.charts,
css = H.css,
doc = H.doc,
extend = H.extend,
noop = H.noop,
Pointer = H.Pointer,
removeEvent = H.removeEvent,
win = H.win,
wrap = H.wrap;
if (win.PointerEvent || win.MSPointerEvent) {
// The touches object keeps track of the points being touched at all times
var touches = {},
hasPointerEvent = !!win.PointerEvent,
getWebkitTouches = function() {
var key,
fake = [];
fake.item = function(i) {
return this[i];
};
for (key in touches) {
if (touches.hasOwnProperty(key)) {
fake.push({
pageX: touches[key].pageX,
pageY: touches[key].pageY,
target: touches[key].target
});
}
}
return fake;
},
translateMSPointer = function(e, method, wktype, func) {
var p;
if ((e.pointerType === 'touch' || e.pointerType === e.MSPOINTER_TYPE_TOUCH) && charts[H.hoverChartIndex]) {
func(e);
p = charts[H.hoverChartIndex].pointer;
p[method]({
type: wktype,
target: e.currentTarget,
preventDefault: noop,
touches: getWebkitTouches()
});
}
};
/**
* Extend the Pointer prototype with methods for each event handler and more
*/
extend(Pointer.prototype, /** @lends Pointer.prototype */ {
onContainerPointerDown: function(e) {
translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function(e) {
touches[e.pointerId] = {
pageX: e.pageX,
pageY: e.pageY,
target: e.currentTarget
};
});
},
onContainerPointerMove: function(e) {
translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function(e) {
touches[e.pointerId] = {
pageX: e.pageX,
pageY: e.pageY
};
if (!touches[e.pointerId].target) {
touches[e.pointerId].target = e.currentTarget;
}
});
},
onDocumentPointerUp: function(e) {
translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function(e) {
delete touches[e.pointerId];
});
},
/**
* Add or remove the MS Pointer specific events
*/
batchMSEvents: function(fn) {
fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
}
});
// Disable default IE actions for pinch and such on chart element
wrap(Pointer.prototype, 'init', function(proceed, chart, options) {
proceed.call(this, chart, options);
if (this.hasZoom) { // #4014
css(chart.container, {
'-ms-touch-action': 'none',
'touch-action': 'none'
});
}
});
// Add IE specific touch events to chart
wrap(Pointer.prototype, 'setDOMEvents', function(proceed) {
proceed.apply(this);
if (this.hasZoom || this.followTouchMove) {
this.batchMSEvents(addEvent);
}
});
// Destroy MS events also
wrap(Pointer.prototype, 'destroy', function(proceed) {
this.batchMSEvents(removeEvent);
proceed.call(this);
});
}
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Legend,
addEvent = H.addEvent,
css = H.css,
discardElement = H.discardElement,
defined = H.defined,
each = H.each,
isFirefox = H.isFirefox,
marginNames = H.marginNames,
merge = H.merge,
pick = H.pick,
setAnimation = H.setAnimation,
stableSort = H.stableSort,
win = H.win,
wrap = H.wrap;
/**
* The overview of the chart's series.
* @class
*/
Legend = H.Legend = function(chart, options) {
this.init(chart, options);
};
Legend.prototype = {
/**
* Initialize the legend
*/
init: function(chart, options) {
this.chart = chart;
this.setOptions(options);
if (options.enabled) {
// Render it
this.render();
// move checkboxes
addEvent(this.chart, 'endResize', function() {
this.legend.positionCheckboxes();
});
}
},
setOptions: function(options) {
var padding = pick(options.padding, 8);
this.options = options;
this.itemStyle = options.itemStyle;
this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
this.itemMarginTop = options.itemMarginTop || 0;
this.padding = padding;
this.initialItemY = padding - 5; // 5 is pixels above the text
this.maxItemWidth = 0;
this.itemHeight = 0;
this.symbolWidth = pick(options.symbolWidth, 16);
this.pages = [];
},
/**
* Update the legend with new options. Equivalent to running chart.update
* with a legend configuration option.
* @param {Object} options Legend options
* @param {Boolean} redraw Whether to redraw the chart, defaults to true.
*/
update: function(options, redraw) {
var chart = this.chart;
this.setOptions(merge(true, this.options, options));
this.destroy();
chart.isDirtyLegend = chart.isDirtyBox = true;
if (pick(redraw, true)) {
chart.redraw();
}
},
/**
* Set the colors for the legend item
* @param {Object} item A Series or Point instance
* @param {Object} visible Dimmed or colored
*/
colorizeItem: function(item, visible) {
item.legendGroup[visible ? 'removeClass' : 'addClass'](
'highcharts-legend-item-hidden'
);
var legend = this,
options = legend.options,
legendItem = item.legendItem,
legendLine = item.legendLine,
legendSymbol = item.legendSymbol,
hiddenColor = legend.itemHiddenStyle.color,
textColor = visible ? options.itemStyle.color : hiddenColor,
symbolColor = visible ? (item.color || hiddenColor) : hiddenColor,
markerOptions = item.options && item.options.marker,
symbolAttr = {
fill: symbolColor
},
key;
if (legendItem) {
legendItem.css({
fill: textColor,
color: textColor // #1553, oldIE
});
}
if (legendLine) {
legendLine.attr({
stroke: symbolColor
});
}
if (legendSymbol) {
// Apply marker options
if (markerOptions && legendSymbol.isMarker) { // #585
//symbolAttr.stroke = symbolColor;
symbolAttr = item.pointAttribs();
if (!visible) {
for (key in symbolAttr) {
symbolAttr[key] = hiddenColor;
}
}
}
legendSymbol.attr(symbolAttr);
}
},
/**
* Position the legend item
* @param {Object} item A Series or Point instance
*/
positionItem: function(item) {
var legend = this,
options = legend.options,
symbolPadding = options.symbolPadding,
ltr = !options.rtl,
legendItemPos = item._legendItemPos,
itemX = legendItemPos[0],
itemY = legendItemPos[1],
checkbox = item.checkbox,
legendGroup = item.legendGroup;
if (legendGroup && legendGroup.element) {
legendGroup.translate(
ltr ?
itemX :
legend.legendWidth - itemX - 2 * symbolPadding - 4,
itemY
);
}
if (checkbox) {
checkbox.x = itemX;
checkbox.y = itemY;
}
},
/**
* Destroy a single legend item
* @param {Object} item The series or point
*/
destroyItem: function(item) {
var checkbox = item.checkbox;
// destroy SVG elements
each(
['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'],
function(key) {
if (item[key]) {
item[key] = item[key].destroy();
}
}
);
if (checkbox) {
discardElement(item.checkbox);
}
},
/**
* Destroys the legend.
*/
destroy: function() {
function destroyItems(key) {
if (this[key]) {
this[key] = this[key].destroy();
}
}
// Destroy items
each(this.getAllItems(), function(item) {
each(['legendItem', 'legendGroup'], destroyItems, item);
});
// Destroy legend elements
each([
'clipRect',
'up',
'down',
'pager',
'nav',
'box',
'title',
'group'
], destroyItems, this);
this.display = null; // Reset in .render on update.
},
/**
* Position the checkboxes after the width is determined
*/
positionCheckboxes: function(scrollOffset) {
var alignAttr = this.group && this.group.alignAttr,
translateY,
clipHeight = this.clipHeight || this.legendHeight,
titleHeight = this.titleHeight;
if (alignAttr) {
translateY = alignAttr.translateY;
each(this.allItems, function(item) {
var checkbox = item.checkbox,
top;
if (checkbox) {
top = translateY + titleHeight + checkbox.y +
(scrollOffset || 0) + 3;
css(checkbox, {
left: (alignAttr.translateX + item.checkboxOffset +
checkbox.x - 20) + 'px',
top: top + 'px',
display: top > translateY - 6 && top < translateY +
clipHeight - 6 ? '' : 'none'
});
}
});
}
},
/**
* Render the legend title on top of the legend
*/
renderTitle: function() {
var options = this.options,
padding = this.padding,
titleOptions = options.title,
titleHeight = 0,
bBox;
if (titleOptions.text) {
if (!this.title) {
this.title = this.chart.renderer.label(
titleOptions.text,
padding - 3,
padding - 4,
null,
null,
null,
null,
null,
'legend-title'
)
.attr({
zIndex: 1
})
.css(titleOptions.style)
.add(this.group);
}
bBox = this.title.getBBox();
titleHeight = bBox.height;
this.offsetWidth = bBox.width; // #1717
this.contentGroup.attr({
translateY: titleHeight
});
}
this.titleHeight = titleHeight;
},
/**
* Set the legend item text
*/
setText: function(item) {
var options = this.options;
item.legendItem.attr({
text: options.labelFormat ?
H.format(options.labelFormat, item) : options.labelFormatter.call(item)
});
},
/**
* Render a single specific legend item
* @param {Object} item A series or point
*/
renderItem: function(item) {
var legend = this,
chart = legend.chart,
renderer = chart.renderer,
options = legend.options,
horizontal = options.layout === 'horizontal',
symbolWidth = legend.symbolWidth,
symbolPadding = options.symbolPadding,
itemStyle = legend.itemStyle,
itemHiddenStyle = legend.itemHiddenStyle,
padding = legend.padding,
itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
ltr = !options.rtl,
itemHeight,
widthOption = options.width,
itemMarginBottom = options.itemMarginBottom || 0,
itemMarginTop = legend.itemMarginTop,
bBox,
itemWidth,
li = item.legendItem,
isSeries = !item.series,
series = !isSeries && item.series.drawLegendSymbol ?
item.series :
item,
seriesOptions = series.options,
showCheckbox = legend.createCheckboxForItem &&
seriesOptions &&
seriesOptions.showCheckbox,
useHTML = options.useHTML,
fontSize = 12,
itemClassName = item.options.className;
if (!li) { // generate it once, later move it
// Generate the group box, a group to hold the symbol and text. Text
// is to be appended in Legend class.
item.legendGroup = renderer.g('legend-item')
.addClass(
'highcharts-' + series.type + '-series ' +
'highcharts-color-' + item.colorIndex +
(itemClassName ? ' ' + itemClassName : '') +
(isSeries ? ' highcharts-series-' + item.index : '')
)
.attr({
zIndex: 1
})
.add(legend.scrollGroup);
// Generate the list item text and add it to the group
item.legendItem = li = renderer.text(
'',
ltr ? symbolWidth + symbolPadding : -symbolPadding,
legend.baseline || 0,
useHTML
)
// merge to prevent modifying original (#1021)
.css(merge(item.visible ? itemStyle : itemHiddenStyle))
.attr({
align: ltr ? 'left' : 'right',
zIndex: 2
})
.add(item.legendGroup);
// Get the baseline for the first item - the font size is equal for
// all
if (!legend.baseline) {
fontSize = itemStyle.fontSize;
legend.fontMetrics = renderer.fontMetrics(
fontSize,
li
);
legend.baseline = legend.fontMetrics.f + 3 + itemMarginTop;
li.attr('y', legend.baseline);
}
// Draw the legend symbol inside the group box
legend.symbolHeight = options.symbolHeight || legend.fontMetrics.f;
series.drawLegendSymbol(legend, item);
if (legend.setItemEvents) {
legend.setItemEvents(item, li, useHTML);
}
// add the HTML checkbox on top
if (showCheckbox) {
legend.createCheckboxForItem(item);
}
}
// Colorize the items
legend.colorizeItem(item, item.visible);
// Always update the text
legend.setText(item);
// calculate the positions for the next line
bBox = li.getBBox();
itemWidth = item.checkboxOffset =
options.itemWidth ||
item.legendItemWidth ||
symbolWidth + symbolPadding + bBox.width + itemDistance +
(showCheckbox ? 20 : 0);
legend.itemHeight = itemHeight = Math.round(
item.legendItemHeight || bBox.height || legend.symbolHeight
);
// If the item exceeds the width, start a new line
if (
horizontal &&
legend.itemX - padding + itemWidth > (
widthOption || (
chart.spacingBox.width - 2 * padding - options.x
)
)
) {
legend.itemX = padding;
legend.itemY += itemMarginTop + legend.lastLineHeight +
itemMarginBottom;
legend.lastLineHeight = 0; // reset for next line (#915, #3976)
}
// If the item exceeds the height, start a new column
/*if (!horizontal && legend.itemY + options.y +
itemHeight > chart.chartHeight - spacingTop - spacingBottom) {
legend.itemY = legend.initialItemY;
legend.itemX += legend.maxItemWidth;
legend.maxItemWidth = 0;
}*/
// Set the edge positions
legend.maxItemWidth = Math.max(legend.maxItemWidth, itemWidth);
legend.lastItemY = itemMarginTop + legend.itemY + itemMarginBottom;
legend.lastLineHeight = Math.max( // #915
itemHeight,
legend.lastLineHeight
);
// cache the position of the newly generated or reordered items
item._legendItemPos = [legend.itemX, legend.itemY];
// advance
if (horizontal) {
legend.itemX += itemWidth;
} else {
legend.itemY += itemMarginTop + itemHeight + itemMarginBottom;
legend.lastLineHeight = itemHeight;
}
// the width of the widest item
legend.offsetWidth = widthOption || Math.max(
(horizontal ? legend.itemX - padding - itemDistance : itemWidth) +
padding,
legend.offsetWidth
);
},
/**
* Get all items, which is one item per series for normal series and one
* item per point for pie series.
*/
getAllItems: function() {
var allItems = [];
each(this.chart.series, function(series) {
var seriesOptions = series && series.options;
// Handle showInLegend. If the series is linked to another series,
// defaults to false.
if (series && pick(
seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? undefined : false, true
)) {
// Use points or series for the legend item depending on
// legendType
allItems = allItems.concat(
series.legendItems ||
(
seriesOptions.legendType === 'point' ?
series.data :
series
)
);
}
});
return allItems;
},
/**
* Adjust the chart margins by reserving space for the legend on only one
* side of the chart. If the position is set to a corner, top or bottom is
* reserved for horizontal legends and left or right for vertical ones.
*/
adjustMargins: function(margin, spacing) {
var chart = this.chart,
options = this.options,
// Use the first letter of each alignment option in order to detect
// the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
alignment = options.align.charAt(0) +
options.verticalAlign.charAt(0) +
options.layout.charAt(0);
if (!options.floating) {
each([
/(lth|ct|rth)/,
/(rtv|rm|rbv)/,
/(rbh|cb|lbh)/,
/(lbv|lm|ltv)/
], function(alignments, side) {
if (alignments.test(alignment) && !defined(margin[side])) {
// Now we have detected on which side of the chart we should
// reserve space for the legend
chart[marginNames[side]] = Math.max(
chart[marginNames[side]],
(
chart.legend[
(side + 1) % 2 ? 'legendHeight' : 'legendWidth'
] + [1, -1, -1, 1][side] * options[
(side % 2) ? 'x' : 'y'
] +
pick(options.margin, 12) +
spacing[side]
)
);
}
});
}
},
/**
* Render the legend. This method can be called both before and after
* chart.render. If called after, it will only rearrange items instead
* of creating new ones.
*/
render: function() {
var legend = this,
chart = legend.chart,
renderer = chart.renderer,
legendGroup = legend.group,
allItems,
display,
legendWidth,
legendHeight,
box = legend.box,
options = legend.options,
padding = legend.padding;
legend.itemX = padding;
legend.itemY = legend.initialItemY;
legend.offsetWidth = 0;
legend.lastItemY = 0;
if (!legendGroup) {
legend.group = legendGroup = renderer.g('legend')
.attr({
zIndex: 7
})
.add();
legend.contentGroup = renderer.g()
.attr({
zIndex: 1
}) // above background
.add(legendGroup);
legend.scrollGroup = renderer.g()
.add(legend.contentGroup);
}
legend.renderTitle();
// add each series or point
allItems = legend.getAllItems();
// sort by legendIndex
stableSort(allItems, function(a, b) {
return ((a.options && a.options.legendIndex) || 0) -
((b.options && b.options.legendIndex) || 0);
});
// reversed legend
if (options.reversed) {
allItems.reverse();
}
legend.allItems = allItems;
legend.display = display = !!allItems.length;
// render the items
legend.lastLineHeight = 0;
each(allItems, function(item) {
legend.renderItem(item);
});
// Get the box
legendWidth = (options.width || legend.offsetWidth) + padding;
legendHeight = legend.lastItemY + legend.lastLineHeight +
legend.titleHeight;
legendHeight = legend.handleOverflow(legendHeight);
legendHeight += padding;
// Draw the border and/or background
if (!box) {
legend.box = box = renderer.rect()
.addClass('highcharts-legend-box')
.attr({
r: options.borderRadius
})
.add(legendGroup);
box.isNew = true;
}
// Presentational
box
.attr({
stroke: options.borderColor,
'stroke-width': options.borderWidth || 0,
fill: options.backgroundColor || 'none'
})
.shadow(options.shadow);
if (legendWidth > 0 && legendHeight > 0) {
box[box.isNew ? 'attr' : 'animate'](
box.crisp({
x: 0,
y: 0,
width: legendWidth,
height: legendHeight
}, box.strokeWidth())
);
box.isNew = false;
}
// hide the border if no items
box[display ? 'show' : 'hide']();
legend.legendWidth = legendWidth;
legend.legendHeight = legendHeight;
// Now that the legend width and height are established, put the items
// in the final position
each(allItems, function(item) {
legend.positionItem(item);
});
// 1.x compatibility: positioning based on style
/*var props = ['left', 'right', 'top', 'bottom'],
prop,
i = 4;
while (i--) {
prop = props[i];
if (options.style[prop] && options.style[prop] !== 'auto') {
options[i < 2 ? 'align' : 'verticalAlign'] = prop;
options[i < 2 ? 'x' : 'y'] =
pInt(options.style[prop]) * (i % 2 ? -1 : 1);
}
}*/
if (display) {
legendGroup.align(merge(options, {
width: legendWidth,
height: legendHeight
}), true, 'spacingBox');
}
if (!chart.isResizing) {
this.positionCheckboxes();
}
},
/**
* Set up the overflow handling by adding navigation with up and down arrows
* below the legend.
*/
handleOverflow: function(legendHeight) {
var legend = this,
chart = this.chart,
renderer = chart.renderer,
options = this.options,
optionsY = options.y,
alignTop = options.verticalAlign === 'top',
padding = this.padding,
spaceHeight = chart.spacingBox.height +
(alignTop ? -optionsY : optionsY) - padding,
maxHeight = options.maxHeight,
clipHeight,
clipRect = this.clipRect,
navOptions = options.navigation,
animation = pick(navOptions.animation, true),
arrowSize = navOptions.arrowSize || 12,
nav = this.nav,
pages = this.pages,
lastY,
allItems = this.allItems,
clipToHeight = function(height) {
if (height) {
clipRect.attr({
height: height
});
} else if (clipRect) { // Reset (#5912)
legend.clipRect = clipRect.destroy();
legend.contentGroup.clip();
}
// useHTML
if (legend.contentGroup.div) {
legend.contentGroup.div.style.clip = height ?
'rect(' + padding + 'px,9999px,' +
(padding + height) + 'px,0)' :
'auto';
}
};
// Adjust the height
if (
options.layout === 'horizontal' &&
options.verticalAlign !== 'middle' &&
!options.floating
) {
spaceHeight /= 2;
}
if (maxHeight) {
spaceHeight = Math.min(spaceHeight, maxHeight);
}
// Reset the legend height and adjust the clipping rectangle
pages.length = 0;
if (legendHeight > spaceHeight && navOptions.enabled !== false) {
this.clipHeight = clipHeight =
Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
this.currentPage = pick(this.currentPage, 1);
this.fullHeight = legendHeight;
// Fill pages with Y positions so that the top of each a legend item
// defines the scroll top for each page (#2098)
each(allItems, function(item, i) {
var y = item._legendItemPos[1],
h = Math.round(item.legendItem.getBBox().height),
len = pages.length;
if (!len || (y - pages[len - 1] > clipHeight &&
(lastY || y) !== pages[len - 1])) {
pages.push(lastY || y);
len++;
}
if (i === allItems.length - 1 &&
y + h - pages[len - 1] > clipHeight) {
pages.push(y);
}
if (y !== lastY) {
lastY = y;
}
});
// Only apply clipping if needed. Clipping causes blurred legend in
// PDF export (#1787)
if (!clipRect) {
clipRect = legend.clipRect =
renderer.clipRect(0, padding, 9999, 0);
legend.contentGroup.clip(clipRect);
}
clipToHeight(clipHeight);
// Add navigation elements
if (!nav) {
this.nav = nav = renderer.g()
.attr({
zIndex: 1
})
.add(this.group);
this.up = renderer
.symbol(
'triangle',
0,
0,
arrowSize,
arrowSize
)
.on('click', function() {
legend.scroll(-1, animation);
})
.add(nav);
this.pager = renderer.text('', 15, 10)
.addClass('highcharts-legend-navigation')
.css(navOptions.style)
.add(nav);
this.down = renderer
.symbol(
'triangle-down',
0,
0,
arrowSize,
arrowSize
)
.on('click', function() {
legend.scroll(1, animation);
})
.add(nav);
}
// Set initial position
legend.scroll(0);
legendHeight = spaceHeight;
// Reset
} else if (nav) {
clipToHeight();
this.nav = nav.destroy(); // #6322
this.scrollGroup.attr({
translateY: 1
});
this.clipHeight = 0; // #1379
}
return legendHeight;
},
/**
* Scroll the legend by a number of pages
* @param {Object} scrollBy
* @param {Object} animation
*/
scroll: function(scrollBy, animation) {
var pages = this.pages,
pageCount = pages.length,
currentPage = this.currentPage + scrollBy,
clipHeight = this.clipHeight,
navOptions = this.options.navigation,
pager = this.pager,
padding = this.padding,
scrollOffset;
// When resizing while looking at the last page
if (currentPage > pageCount) {
currentPage = pageCount;
}
if (currentPage > 0) {
if (animation !== undefined) {
setAnimation(animation, this.chart);
}
this.nav.attr({
translateX: padding,
translateY: clipHeight + this.padding + 7 + this.titleHeight,
visibility: 'visible'
});
this.up.attr({
'class': currentPage === 1 ?
'highcharts-legend-nav-inactive' : 'highcharts-legend-nav-active'
});
pager.attr({
text: currentPage + '/' + pageCount
});
this.down.attr({
'x': 18 + this.pager.getBBox().width, // adjust to text width
'class': currentPage === pageCount ?
'highcharts-legend-nav-inactive' : 'highcharts-legend-nav-active'
});
this.up
.attr({
fill: currentPage === 1 ?
navOptions.inactiveColor : navOptions.activeColor
})
.css({
cursor: currentPage === 1 ? 'default' : 'pointer'
});
this.down
.attr({
fill: currentPage === pageCount ?
navOptions.inactiveColor : navOptions.activeColor
})
.css({
cursor: currentPage === pageCount ? 'default' : 'pointer'
});
scrollOffset = -pages[currentPage - 1] + this.initialItemY;
this.scrollGroup.animate({
translateY: scrollOffset
});
this.currentPage = currentPage;
this.positionCheckboxes(scrollOffset);
}
}
};
/*
* LegendSymbolMixin
*/
H.LegendSymbolMixin = {
/**
* Get the series' symbol in the legend
*
* @param {Object} legend The legend object
* @param {Object} item The series (this) or point
*/
drawRectangle: function(legend, item) {
var options = legend.options,
symbolHeight = legend.symbolHeight,
square = options.squareSymbol,
symbolWidth = square ? symbolHeight : legend.symbolWidth;
item.legendSymbol = this.chart.renderer.rect(
square ? (legend.symbolWidth - symbolHeight) / 2 : 0,
legend.baseline - symbolHeight + 1, // #3988
symbolWidth,
symbolHeight,
pick(legend.options.symbolRadius, symbolHeight / 2)
)
.addClass('highcharts-point')
.attr({
zIndex: 3
}).add(item.legendGroup);
},
/**
* Get the series' symbol in the legend. This method should be overridable
* to create custom symbols through
* Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
*
* @param {Object} legend The legend object
*/
drawLineMarker: function(legend) {
var options = this.options,
markerOptions = options.marker,
radius,
legendSymbol,
symbolWidth = legend.symbolWidth,
symbolHeight = legend.symbolHeight,
generalRadius = symbolHeight / 2,
renderer = this.chart.renderer,
legendItemGroup = this.legendGroup,
verticalCenter = legend.baseline -
Math.round(legend.fontMetrics.b * 0.3),
attr = {};
// Draw the line
attr = {
'stroke-width': options.lineWidth || 0
};
if (options.dashStyle) {
attr.dashstyle = options.dashStyle;
}
this.legendLine = renderer.path([
'M',
0,
verticalCenter,
'L',
symbolWidth,
verticalCenter
])
.addClass('highcharts-graph')
.attr(attr)
.add(legendItemGroup);
// Draw the marker
if (markerOptions && markerOptions.enabled !== false) {
// Do not allow the marker to be larger than the symbolHeight
radius = Math.min(
pick(markerOptions.radius, generalRadius),
generalRadius
);
// Restrict symbol markers size
if (this.symbol.indexOf('url') === 0) {
markerOptions = merge(markerOptions, {
width: symbolHeight,
height: symbolHeight
});
radius = 0;
}
this.legendSymbol = legendSymbol = renderer.symbol(
this.symbol,
(symbolWidth / 2) - radius,
verticalCenter - radius,
2 * radius,
2 * radius,
markerOptions
)
.addClass('highcharts-point')
.add(legendItemGroup);
legendSymbol.isMarker = true;
}
}
};
// Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
// and for #2580, a similar drawing flaw in Firefox 26.
// Explore if there's a general cause for this. The problem may be related
// to nested group elements, as the legend item texts are within 4 group
// elements.
if (/Trident\/7\.0/.test(win.navigator.userAgent) || isFirefox) {
wrap(Legend.prototype, 'positionItem', function(proceed, item) {
var legend = this,
// If chart destroyed in sync, this is undefined (#2030)
runPositionItem = function() {
if (item._legendItemPos) {
proceed.call(legend, item);
}
};
// Do it now, for export and to get checkbox placement
runPositionItem();
// Do it after to work around the core issue
setTimeout(runPositionItem);
});
}
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animate = H.animate,
animObject = H.animObject,
attr = H.attr,
doc = H.doc,
Axis = H.Axis, // @todo add as requirement
createElement = H.createElement,
defaultOptions = H.defaultOptions,
discardElement = H.discardElement,
charts = H.charts,
css = H.css,
defined = H.defined,
each = H.each,
extend = H.extend,
find = H.find,
fireEvent = H.fireEvent,
getStyle = H.getStyle,
grep = H.grep,
isNumber = H.isNumber,
isObject = H.isObject,
isString = H.isString,
Legend = H.Legend, // @todo add as requirement
marginNames = H.marginNames,
merge = H.merge,
Pointer = H.Pointer, // @todo add as requirement
pick = H.pick,
pInt = H.pInt,
removeEvent = H.removeEvent,
seriesTypes = H.seriesTypes,
splat = H.splat,
svg = H.svg,
syncTimeout = H.syncTimeout,
win = H.win,
Renderer = H.Renderer;
/**
* The Chart class.
* @class Highcharts.Chart
* @memberOf Highcharts
* @param {String|HTMLDOMElement} renderTo - The DOM element to render to, or its
* id.
* @param {ChartOptions} options - The chart options structure.
* @param {Function} callback - Function to run when the chart has loaded.
*/
var Chart = H.Chart = function() {
this.getArgs.apply(this, arguments);
};
H.chart = function(a, b, c) {
return new Chart(a, b, c);
};
Chart.prototype = {
/**
* Hook for modules
*/
callbacks: [],
/**
* Handle the arguments passed to the constructor
* @returns {Array} Arguments without renderTo
*/
getArgs: function() {
var args = [].slice.call(arguments);
// Remove the optional first argument, renderTo, and
// set it on this.
if (isString(args[0]) || args[0].nodeName) {
this.renderTo = args.shift();
}
this.init(args[0], args[1]);
},
/**
* Initialize the chart
*/
init: function(userOptions, callback) {
// Handle regular options
var options,
seriesOptions = userOptions.series; // skip merging data points to increase performance
userOptions.series = null;
options = merge(defaultOptions, userOptions); // do the merge
options.series = userOptions.series = seriesOptions; // set back the series data
this.userOptions = userOptions;
var optionsChart = options.chart;
var chartEvents = optionsChart.events;
this.margin = [];
this.spacing = [];
//this.runChartClick = chartEvents && !!chartEvents.click;
this.bounds = {
h: {},
v: {}
}; // Pixel data bounds for touch zoom
this.callback = callback;
this.isResizing = 0;
this.options = options;
//chartTitleOptions = undefined;
//chartSubtitleOptions = undefined;
this.axes = [];
this.series = [];
this.hasCartesianSeries = optionsChart.showAxes;
//this.axisOffset = undefined;
//this.inverted = undefined;
//this.loadingShown = undefined;
//this.container = undefined;
//this.chartWidth = undefined;
//this.chartHeight = undefined;
//this.marginRight = undefined;
//this.marginBottom = undefined;
//this.containerWidth = undefined;
//this.containerHeight = undefined;
//this.oldChartWidth = undefined;
//this.oldChartHeight = undefined;
//this.renderTo = undefined;
//this.renderToClone = undefined;
//this.spacingBox = undefined
//this.legend = undefined;
// Elements
//this.chartBackground = undefined;
//this.plotBackground = undefined;
//this.plotBGImage = undefined;
//this.plotBorder = undefined;
//this.loadingDiv = undefined;
//this.loadingSpan = undefined;
var chart = this,
eventType;
// Add the chart to the global lookup
chart.index = charts.length;
charts.push(chart);
H.chartCount++;
// Chart event handlers
if (chartEvents) {
for (eventType in chartEvents) {
addEvent(chart, eventType, chartEvents[eventType]);
}
}
chart.xAxis = [];
chart.yAxis = [];
chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;
chart.firstRender();
},
/**
* Initialize an individual series, called internally before render time
*/
initSeries: function(options) {
var chart = this,
optionsChart = chart.options.chart,
type = options.type || optionsChart.type || optionsChart.defaultSeriesType,
series,
Constr = seriesTypes[type];
// No such series type
if (!Constr) {
H.error(17, true);
}
series = new Constr();
series.init(this, options);
return series;
},
/**
* Order all series above a given index. When series are added and ordered
* by configuration, only the last series is handled (#248, #1123, #2456,
* #6112). This function is called on series initialization and destroy.
*
* @param {number} fromIndex - If this is given, only the series above this
* index are handled.
*/
orderSeries: function(fromIndex) {
var series = this.series,
i = fromIndex || 0;
for (; i < series.length; i++) {
if (series[i]) {
series[i].index = i;
series[i].name = series[i].name ||
'Series ' + (series[i].index + 1);
}
}
},
/**
* Check whether a given point is within the plot area
*
* @param {Number} plotX Pixel x relative to the plot area
* @param {Number} plotY Pixel y relative to the plot area
* @param {Boolean} inverted Whether the chart is inverted
*/
isInsidePlot: function(plotX, plotY, inverted) {
var x = inverted ? plotY : plotX,
y = inverted ? plotX : plotY;
return x >= 0 &&
x <= this.plotWidth &&
y >= 0 &&
y <= this.plotHeight;
},
/**
* Redraw legend, axes or series based on updated data
*
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
redraw: function(animation) {
var chart = this,
axes = chart.axes,
series = chart.series,
pointer = chart.pointer,
legend = chart.legend,
redrawLegend = chart.isDirtyLegend,
hasStackedSeries,
hasDirtyStacks,
hasCartesianSeries = chart.hasCartesianSeries,
isDirtyBox = chart.isDirtyBox,
i,
serie,
renderer = chart.renderer,
isHiddenChart = renderer.isHidden(),
afterRedraw = [];
// Handle responsive rules, not only on resize (#6130)
if (chart.setResponsive) {
chart.setResponsive(false);
}
H.setAnimation(animation, chart);
if (isHiddenChart) {
chart.cloneRenderTo();
}
// Adjust title layout (reflow multiline text)
chart.layOutTitles();
// link stacked series
i = series.length;
while (i--) {
serie = series[i];
if (serie.options.stacking) {
hasStackedSeries = true;
if (serie.isDirty) {
hasDirtyStacks = true;
break;
}
}
}
if (hasDirtyStacks) { // mark others as dirty
i = series.length;
while (i--) {
serie = series[i];
if (serie.options.stacking) {
serie.isDirty = true;
}
}
}
// Handle updated data in the series
each(series, function(serie) {
if (serie.isDirty) {
if (serie.options.legendType === 'point') {
if (serie.updateTotals) {
serie.updateTotals();
}
redrawLegend = true;
}
}
if (serie.isDirtyData) {
fireEvent(serie, 'updatedData');
}
});
// handle added or removed series
if (redrawLegend && legend.options.enabled) { // series or pie points are added or removed
// draw legend graphics
legend.render();
chart.isDirtyLegend = false;
}
// reset stacks
if (hasStackedSeries) {
chart.getStacks();
}
if (hasCartesianSeries) {
// set axes scales
each(axes, function(axis) {
axis.updateNames();
axis.setScale();
});
}
chart.getMargins(); // #3098
if (hasCartesianSeries) {
// If one axis is dirty, all axes must be redrawn (#792, #2169)
each(axes, function(axis) {
if (axis.isDirty) {
isDirtyBox = true;
}
});
// redraw axes
each(axes, function(axis) {
// Fire 'afterSetExtremes' only if extremes are set
var key = axis.min + ',' + axis.max;
if (axis.extKey !== key) { // #821, #4452
axis.extKey = key;
afterRedraw.push(function() { // prevent a recursive call to chart.redraw() (#1119)
fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
delete axis.eventArgs;
});
}
if (isDirtyBox || hasStackedSeries) {
axis.redraw();
}
});
}
// the plot areas size has changed
if (isDirtyBox) {
chart.drawChartBox();
}
// Fire an event before redrawing series, used by the boost module to
// clear previous series renderings.
fireEvent(chart, 'predraw');
// redraw affected series
each(series, function(serie) {
if ((isDirtyBox || serie.isDirty) && serie.visible) {
serie.redraw();
}
// Set it here, otherwise we will have unlimited 'updatedData' calls
// for a hidden series after setData(). Fixes #6012
serie.isDirtyData = false;
});
// move tooltip or reset
if (pointer) {
pointer.reset(true);
}
// redraw if canvas
renderer.draw();
// Fire the events
fireEvent(chart, 'redraw');
fireEvent(chart, 'render');
if (isHiddenChart) {
chart.cloneRenderTo(true);
}
// Fire callbacks that are put on hold until after the redraw
each(afterRedraw, function(callback) {
callback.call();
});
},
/**
* Get an axis, series or point object by id.
* @param id {String} The id as given in the configuration options
*/
get: function(id) {
var ret,
series = this.series,
i;
function itemById(item) {
return item.id === id || (item.options && item.options.id === id);
}
ret =
// Search axes
find(this.axes, itemById) ||
// Search series
find(this.series, itemById);
// Search points
for (i = 0; !ret && i < series.length; i++) {
ret = find(series[i].points || [], itemById);
}
return ret;
},
/**
* Create the Axis instances based on the config options
*/
getAxes: function() {
var chart = this,
options = this.options,
xAxisOptions = options.xAxis = splat(options.xAxis || {}),
yAxisOptions = options.yAxis = splat(options.yAxis || {}),
optionsArray;
// make sure the options are arrays and add some members
each(xAxisOptions, function(axis, i) {
axis.index = i;
axis.isX = true;
});
each(yAxisOptions, function(axis, i) {
axis.index = i;
});
// concatenate all axis options into one array
optionsArray = xAxisOptions.concat(yAxisOptions);
each(optionsArray, function(axisOptions) {
new Axis(chart, axisOptions); // eslint-disable-line no-new
});
},
/**
* Get the currently selected points from all series
*/
getSelectedPoints: function() {
var points = [];
each(this.series, function(serie) {
points = points.concat(grep(serie.points || [], function(point) {
return point.selected;
}));
});
return points;
},
/**
* Get the currently selected series
*/
getSelectedSeries: function() {
return grep(this.series, function(serie) {
return serie.selected;
});
},
/**
* Show the title and subtitle of the chart
*
* @param titleOptions {Object} New title options
* @param subtitleOptions {Object} New subtitle options
*
*/
setTitle: function(titleOptions, subtitleOptions, redraw) {
var chart = this,
options = chart.options,
chartTitleOptions,
chartSubtitleOptions;
chartTitleOptions = options.title = merge(
// Default styles
{
style: {
color: '#333333',
fontSize: options.isStock ? '16px' : '18px' // #2944
}
},
options.title,
titleOptions
);
chartSubtitleOptions = options.subtitle = merge(
// Default styles
{
style: {
color: '#666666'
}
},
options.subtitle,
subtitleOptions
);
// add title and subtitle
each([
['title', titleOptions, chartTitleOptions],
['subtitle', subtitleOptions, chartSubtitleOptions]
], function(arr, i) {
var name = arr[0],
title = chart[name],
titleOptions = arr[1],
chartTitleOptions = arr[2];
if (title && titleOptions) {
chart[name] = title = title.destroy(); // remove old
}
if (chartTitleOptions && chartTitleOptions.text && !title) {
chart[name] = chart.renderer.text(
chartTitleOptions.text,
0,
0,
chartTitleOptions.useHTML
)
.attr({
align: chartTitleOptions.align,
'class': 'highcharts-' + name,
zIndex: chartTitleOptions.zIndex || 4
})
.add();
// Update methods, shortcut to Chart.setTitle
chart[name].update = function(o) {
chart.setTitle(!i && o, i && o);
};
// Presentational
chart[name].css(chartTitleOptions.style);
}
});
chart.layOutTitles(redraw);
},
/**
* Lay out the chart titles and cache the full offset height for use
* in getMargins
*/
layOutTitles: function(redraw) {
var titleOffset = 0,
requiresDirtyBox,
renderer = this.renderer,
spacingBox = this.spacingBox;
// Lay out the title and the subtitle respectively
each(['title', 'subtitle'], function(key) {
var title = this[key],
titleOptions = this.options[key],
titleSize;
if (title) {
titleSize = titleOptions.style.fontSize;
titleSize = renderer.fontMetrics(titleSize, title).b;
title
.css({
width: (titleOptions.width ||
spacingBox.width + titleOptions.widthAdjust) + 'px'
})
.align(extend({
y: titleOffset + titleSize + (key === 'title' ? -3 : 2)
}, titleOptions), false, 'spacingBox');
if (!titleOptions.floating && !titleOptions.verticalAlign) {
titleOffset = Math.ceil(
titleOffset +
// Skip the cache for HTML (#3481)
title.getBBox(titleOptions.useHTML).height
);
}
}
}, this);
requiresDirtyBox = this.titleOffset !== titleOffset;
this.titleOffset = titleOffset; // used in getMargins
if (!this.isDirtyBox && requiresDirtyBox) {
this.isDirtyBox = requiresDirtyBox;
// Redraw if necessary (#2719, #2744)
if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
this.redraw();
}
}
},
/**
* Get chart width and height according to options and container size
*/
getChartSize: function() {
var chart = this,
optionsChart = chart.options.chart,
widthOption = optionsChart.width,
heightOption = optionsChart.height,
renderTo = chart.renderToClone || chart.renderTo;
// Get inner width and height
if (!defined(widthOption)) {
chart.containerWidth = getStyle(renderTo, 'width');
}
if (!defined(heightOption)) {
chart.containerHeight = getStyle(renderTo, 'height');
}
chart.chartWidth = Math.max( // #1393
0,
widthOption || chart.containerWidth || 600 // #1460
);
chart.chartHeight = Math.max(
0,
H.relativeLength(
heightOption,
chart.chartWidth
) || chart.containerHeight || 400
);
},
/**
* Create a clone of the chart's renderTo div and place it outside the viewport to allow
* size computation on chart.render and chart.redraw
*/
cloneRenderTo: function(revert) {
var clone = this.renderToClone,
container = this.container;
// Destroy the clone and bring the container back to the real renderTo div
if (revert) {
if (clone) {
while (clone.childNodes.length) { // #5231
this.renderTo.appendChild(clone.firstChild);
}
discardElement(clone);
delete this.renderToClone;
}
// Set up the clone
} else {
if (container && container.parentNode === this.renderTo) {
this.renderTo.removeChild(container); // do not clone this
}
this.renderToClone = clone = this.renderTo.cloneNode(0);
css(clone, {
position: 'absolute',
top: '-9999px',
display: 'block' // #833
});
if (clone.style.setProperty) { // #2631
clone.style.setProperty('display', 'block', 'important');
}
doc.body.appendChild(clone);
if (container) {
clone.appendChild(container);
}
}
},
/**
* Setter for the chart class name
*/
setClassName: function(className) {
this.container.className = 'highcharts-container ' + (className || '');
},
/**
* Get the containing element, determine the size and create the inner container
* div to hold the chart
*/
getContainer: function() {
var chart = this,
container,
options = chart.options,
optionsChart = options.chart,
chartWidth,
chartHeight,
renderTo = chart.renderTo,
indexAttrName = 'data-highcharts-chart',
oldChartIndex,
Ren,
containerId = H.uniqueKey(),
containerStyle,
key;
if (!renderTo) {
chart.renderTo = renderTo = optionsChart.renderTo;
}
if (isString(renderTo)) {
chart.renderTo = renderTo = doc.getElementById(renderTo);
}
// Display an error if the renderTo is wrong
if (!renderTo) {
H.error(13, true);
}
// If the container already holds a chart, destroy it. The check for hasRendered is there
// because web pages that are saved to disk from the browser, will preserve the data-highcharts-chart
// attribute and the SVG contents, but not an interactive chart. So in this case,
// charts[oldChartIndex] will point to the wrong chart if any (#2609).
oldChartIndex = pInt(attr(renderTo, indexAttrName));
if (isNumber(oldChartIndex) && charts[oldChartIndex] && charts[oldChartIndex].hasRendered) {
charts[oldChartIndex].destroy();
}
// Make a reference to the chart from the div
attr(renderTo, indexAttrName, chart.index);
// remove previous chart
renderTo.innerHTML = '';
// If the container doesn't have an offsetWidth, it has or is a child of
// a node that has display:none. We need to temporarily move it out to a
// visible state to determine the size, else the legend and tooltips
// won't render properly. The skipClone option is used in sparklines as
// a micro optimization, saving about 1-2 ms each chart.
if (!optionsChart.skipClone && !renderTo.offsetWidth) {
chart.cloneRenderTo();
}
// get the width and height
chart.getChartSize();
chartWidth = chart.chartWidth;
chartHeight = chart.chartHeight;
// Create the inner container
containerStyle = extend({
position: 'relative',
overflow: 'hidden', // needed for context menu (avoid scrollbars) and
// content overflow in IE
width: chartWidth + 'px',
height: chartHeight + 'px',
textAlign: 'left',
lineHeight: 'normal', // #427
zIndex: 0, // #1072
'-webkit-tap-highlight-color': 'rgba(0,0,0,0)'
}, optionsChart.style);
chart.container = container = createElement(
'div', {
id: containerId
},
containerStyle,
chart.renderToClone || renderTo
);
// cache the cursor (#1650)
chart._cursor = container.style.cursor;
// Initialize the renderer
Ren = H[optionsChart.renderer] || Renderer;
chart.renderer = new Ren(
container,
chartWidth,
chartHeight,
null,
optionsChart.forExport,
options.exporting && options.exporting.allowHTML
);
chart.setClassName(optionsChart.className);
chart.renderer.setStyle(optionsChart.style);
// Add a reference to the charts index
chart.renderer.chartIndex = chart.index;
},
/**
* Calculate margins by rendering axis labels in a preliminary position. Title,
* subtitle and legend have already been rendered at this stage, but will be
* moved into their final positions
*/
getMargins: function(skipAxes) {
var chart = this,
spacing = chart.spacing,
margin = chart.margin,
titleOffset = chart.titleOffset;
chart.resetMargins();
// Adjust for title and subtitle
if (titleOffset && !defined(margin[0])) {
chart.plotTop = Math.max(chart.plotTop, titleOffset + chart.options.title.margin + spacing[0]);
}
// Adjust for legend
if (chart.legend.display) {
chart.legend.adjustMargins(margin, spacing);
}
// adjust for scroller
if (chart.extraMargin) {
chart[chart.extraMargin.type] = (chart[chart.extraMargin.type] || 0) + chart.extraMargin.value;
}
if (chart.extraTopMargin) {
chart.plotTop += chart.extraTopMargin;
}
if (!skipAxes) {
this.getAxisMargins();
}
},
getAxisMargins: function() {
var chart = this,
axisOffset = chart.axisOffset = [0, 0, 0, 0], // top, right, bottom, left
margin = chart.margin;
// pre-render axes to get labels offset width
if (chart.hasCartesianSeries) {
each(chart.axes, function(axis) {
if (axis.visible) {
axis.getOffset();
}
});
}
// Add the axis offsets
each(marginNames, function(m, side) {
if (!defined(margin[side])) {
chart[m] += axisOffset[side];
}
});
chart.setChartSize();
},
/**
* Resize the chart to its container if size is not explicitly set
*/
reflow: function(e) {
var chart = this,
optionsChart = chart.options.chart,
renderTo = chart.renderTo,
hasUserWidth = defined(optionsChart.width),
width = optionsChart.width || getStyle(renderTo, 'width'),
height = optionsChart.height || getStyle(renderTo, 'height'),
target = e ? e.target : win;
// Width and height checks for display:none. Target is doc in IE8 and Opera,
// win in Firefox, Chrome and IE9.
if (!hasUserWidth && !chart.isPrinting && width && height && (target === win || target === doc)) { // #1093
if (width !== chart.containerWidth || height !== chart.containerHeight) {
clearTimeout(chart.reflowTimeout);
// When called from window.resize, e is set, else it's called directly (#2224)
chart.reflowTimeout = syncTimeout(function() {
if (chart.container) { // It may have been destroyed in the meantime (#1257)
chart.setSize(undefined, undefined, false);
}
}, e ? 100 : 0);
}
chart.containerWidth = width;
chart.containerHeight = height;
}
},
/**
* Add the event handlers necessary for auto resizing
*/
initReflow: function() {
var chart = this,
unbind;
unbind = addEvent(win, 'resize', function(e) {
chart.reflow(e);
});
addEvent(chart, 'destroy', unbind);
// The following will add listeners to re-fit the chart before and after
// printing (#2284). However it only works in WebKit. Should have worked
// in Firefox, but not supported in IE.
/*
if (win.matchMedia) {
win.matchMedia('print').addListener(function reflow() {
chart.reflow();
});
}
*/
},
/**
* Resize the chart to a given width and height
* @param {Number} width
* @param {Number} height
* @param {Object|Boolean} animation
*/
setSize: function(width, height, animation) {
var chart = this,
renderer = chart.renderer,
globalAnimation;
// Handle the isResizing counter
chart.isResizing += 1;
// set the animation for the current process
H.setAnimation(animation, chart);
chart.oldChartHeight = chart.chartHeight;
chart.oldChartWidth = chart.chartWidth;
if (width !== undefined) {
chart.options.chart.width = width;
}
if (height !== undefined) {
chart.options.chart.height = height;
}
chart.getChartSize();
// Resize the container with the global animation applied if enabled (#2503)
globalAnimation = renderer.globalAnimation;
(globalAnimation ? animate : css)(chart.container, {
width: chart.chartWidth + 'px',
height: chart.chartHeight + 'px'
}, globalAnimation);
chart.setChartSize(true);
renderer.setSize(chart.chartWidth, chart.chartHeight, animation);
// handle axes
each(chart.axes, function(axis) {
axis.isDirty = true;
axis.setScale();
});
chart.isDirtyLegend = true; // force legend redraw
chart.isDirtyBox = true; // force redraw of plot and chart border
chart.layOutTitles(); // #2857
chart.getMargins();
chart.redraw(animation);
chart.oldChartHeight = null;
fireEvent(chart, 'resize');
// Fire endResize and set isResizing back. If animation is disabled, fire without delay
syncTimeout(function() {
if (chart) {
fireEvent(chart, 'endResize', null, function() {
chart.isResizing -= 1;
});
}
}, animObject(globalAnimation).duration);
},
/**
* Set the public chart properties. This is done before and after the pre-render
* to determine margin sizes
*/
setChartSize: function(skipAxes) {
var chart = this,
inverted = chart.inverted,
renderer = chart.renderer,
chartWidth = chart.chartWidth,
chartHeight = chart.chartHeight,
optionsChart = chart.options.chart,
spacing = chart.spacing,
clipOffset = chart.clipOffset,
clipX,
clipY,
plotLeft,
plotTop,
plotWidth,
plotHeight,
plotBorderWidth;
chart.plotLeft = plotLeft = Math.round(chart.plotLeft);
chart.plotTop = plotTop = Math.round(chart.plotTop);
chart.plotWidth = plotWidth = Math.max(0, Math.round(chartWidth - plotLeft - chart.marginRight));
chart.plotHeight = plotHeight = Math.max(0, Math.round(chartHeight - plotTop - chart.marginBottom));
chart.plotSizeX = inverted ? plotHeight : plotWidth;
chart.plotSizeY = inverted ? plotWidth : plotHeight;
chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;
// Set boxes used for alignment
chart.spacingBox = renderer.spacingBox = {
x: spacing[3],
y: spacing[0],
width: chartWidth - spacing[3] - spacing[1],
height: chartHeight - spacing[0] - spacing[2]
};
chart.plotBox = renderer.plotBox = {
x: plotLeft,
y: plotTop,
width: plotWidth,
height: plotHeight
};
plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2);
clipX = Math.ceil(Math.max(plotBorderWidth, clipOffset[3]) / 2);
clipY = Math.ceil(Math.max(plotBorderWidth, clipOffset[0]) / 2);
chart.clipBox = {
x: clipX,
y: clipY,
width: Math.floor(chart.plotSizeX - Math.max(plotBorderWidth, clipOffset[1]) / 2 - clipX),
height: Math.max(0, Math.floor(chart.plotSizeY - Math.max(plotBorderWidth, clipOffset[2]) / 2 - clipY))
};
if (!skipAxes) {
each(chart.axes, function(axis) {
axis.setAxisSize();
axis.setAxisTranslation();
});
}
},
/**
* Initial margins before auto size margins are applied
*/
resetMargins: function() {
var chart = this,
chartOptions = chart.options.chart;
// Create margin and spacing array
each(['margin', 'spacing'], function splashArrays(target) {
var value = chartOptions[target],
values = isObject(value) ? value : [value, value, value, value];
each(['Top', 'Right', 'Bottom', 'Left'], function(sideName, side) {
chart[target][side] = pick(chartOptions[target + sideName], values[side]);
});
});
// Set margin names like chart.plotTop, chart.plotLeft, chart.marginRight, chart.marginBottom.
each(marginNames, function(m, side) {
chart[m] = pick(chart.margin[side], chart.spacing[side]);
});
chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
chart.clipOffset = [0, 0, 0, 0];
},
/**
* Draw the borders and backgrounds for chart and plot area
*/
drawChartBox: function() {
var chart = this,
optionsChart = chart.options.chart,
renderer = chart.renderer,
chartWidth = chart.chartWidth,
chartHeight = chart.chartHeight,
chartBackground = chart.chartBackground,
plotBackground = chart.plotBackground,
plotBorder = chart.plotBorder,
chartBorderWidth,
plotBGImage = chart.plotBGImage,
chartBackgroundColor = optionsChart.backgroundColor,
plotBackgroundColor = optionsChart.plotBackgroundColor,
plotBackgroundImage = optionsChart.plotBackgroundImage,
mgn,
bgAttr,
plotLeft = chart.plotLeft,
plotTop = chart.plotTop,
plotWidth = chart.plotWidth,
plotHeight = chart.plotHeight,
plotBox = chart.plotBox,
clipRect = chart.clipRect,
clipBox = chart.clipBox,
verb = 'animate';
// Chart area
if (!chartBackground) {
chart.chartBackground = chartBackground = renderer.rect()
.addClass('highcharts-background')
.add();
verb = 'attr';
}
// Presentational
chartBorderWidth = optionsChart.borderWidth || 0;
mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
bgAttr = {
fill: chartBackgroundColor || 'none'
};
if (chartBorderWidth || chartBackground['stroke-width']) { // #980
bgAttr.stroke = optionsChart.borderColor;
bgAttr['stroke-width'] = chartBorderWidth;
}
chartBackground
.attr(bgAttr)
.shadow(optionsChart.shadow);
chartBackground[verb]({
x: mgn / 2,
y: mgn / 2,
width: chartWidth - mgn - chartBorderWidth % 2,
height: chartHeight - mgn - chartBorderWidth % 2,
r: optionsChart.borderRadius
});
// Plot background
verb = 'animate';
if (!plotBackground) {
verb = 'attr';
chart.plotBackground = plotBackground = renderer.rect()
.addClass('highcharts-plot-background')
.add();
}
plotBackground[verb](plotBox);
// Presentational attributes for the background
plotBackground
.attr({
fill: plotBackgroundColor || 'none'
})
.shadow(optionsChart.plotShadow);
// Create the background image
if (plotBackgroundImage) {
if (!plotBGImage) {
chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight)
.add();
} else {
plotBGImage.animate(plotBox);
}
}
// Plot clip
if (!clipRect) {
chart.clipRect = renderer.clipRect(clipBox);
} else {
clipRect.animate({
width: clipBox.width,
height: clipBox.height
});
}
// Plot area border
verb = 'animate';
if (!plotBorder) {
verb = 'attr';
chart.plotBorder = plotBorder = renderer.rect()
.addClass('highcharts-plot-border')
.attr({
zIndex: 1 // Above the grid
})
.add();
}
// Presentational
plotBorder.attr({
stroke: optionsChart.plotBorderColor,
'stroke-width': optionsChart.plotBorderWidth || 0,
fill: 'none'
});
plotBorder[verb](plotBorder.crisp({
x: plotLeft,
y: plotTop,
width: plotWidth,
height: plotHeight
}, -plotBorder.strokeWidth())); //#3282 plotBorder should be negative;
// reset
chart.isDirtyBox = false;
},
/**
* Detect whether a certain chart property is needed based on inspecting its options
* and series. This mainly applies to the chart.inverted property, and in extensions to
* the chart.angular and chart.polar properties.
*/
propFromSeries: function() {
var chart = this,
optionsChart = chart.options.chart,
klass,
seriesOptions = chart.options.series,
i,
value;
each(['inverted', 'angular', 'polar'], function(key) {
// The default series type's class
klass = seriesTypes[optionsChart.type || optionsChart.defaultSeriesType];
// Get the value from available chart-wide properties
value =
optionsChart[key] || // It is set in the options
(klass && klass.prototype[key]); // The default series class requires it
// 4. Check if any the chart's series require it
i = seriesOptions && seriesOptions.length;
while (!value && i--) {
klass = seriesTypes[seriesOptions[i].type];
if (klass && klass.prototype[key]) {
value = true;
}
}
// Set the chart property
chart[key] = value;
});
},
/**
* Link two or more series together. This is done initially from Chart.render,
* and after Chart.addSeries and Series.remove.
*/
linkSeries: function() {
var chart = this,
chartSeries = chart.series;
// Reset links
each(chartSeries, function(series) {
series.linkedSeries.length = 0;
});
// Apply new links
each(chartSeries, function(series) {
var linkedTo = series.options.linkedTo;
if (isString(linkedTo)) {
if (linkedTo === ':previous') {
linkedTo = chart.series[series.index - 1];
} else {
linkedTo = chart.get(linkedTo);
}
if (linkedTo && linkedTo.linkedParent !== series) { // #3341 avoid mutual linking
linkedTo.linkedSeries.push(series);
series.linkedParent = linkedTo;
series.visible = pick(series.options.visible, linkedTo.options.visible, series.visible); // #3879
}
}
});
},
/**
* Render series for the chart
*/
renderSeries: function() {
each(this.series, function(serie) {
serie.translate();
serie.render();
});
},
/**
* Render labels for the chart
*/
renderLabels: function() {
var chart = this,
labels = chart.options.labels;
if (labels.items) {
each(labels.items, function(label) {
var style = extend(labels.style, label.style),
x = pInt(style.left) + chart.plotLeft,
y = pInt(style.top) + chart.plotTop + 12;
// delete to prevent rewriting in IE
delete style.left;
delete style.top;
chart.renderer.text(
label.html,
x,
y
)
.attr({
zIndex: 2
})
.css(style)
.add();
});
}
},
/**
* Render all graphics for the chart
*/
render: function() {
var chart = this,
axes = chart.axes,
renderer = chart.renderer,
options = chart.options,
tempWidth,
tempHeight,
redoHorizontal,
redoVertical;
// Title
chart.setTitle();
// Legend
chart.legend = new Legend(chart, options.legend);
// Get stacks
if (chart.getStacks) {
chart.getStacks();
}
// Get chart margins
chart.getMargins(true);
chart.setChartSize();
// Record preliminary dimensions for later comparison
tempWidth = chart.plotWidth;
tempHeight = chart.plotHeight = chart.plotHeight - 21; // 21 is the most common correction for X axis labels
// Get margins by pre-rendering axes
each(axes, function(axis) {
axis.setScale();
});
chart.getAxisMargins();
// If the plot area size has changed significantly, calculate tick positions again
redoHorizontal = tempWidth / chart.plotWidth > 1.1;
redoVertical = tempHeight / chart.plotHeight > 1.05; // Height is more sensitive
if (redoHorizontal || redoVertical) {
each(axes, function(axis) {
if ((axis.horiz && redoHorizontal) || (!axis.horiz && redoVertical)) {
axis.setTickInterval(true); // update to reflect the new margins
}
});
chart.getMargins(); // second pass to check for new labels
}
// Draw the borders and backgrounds
chart.drawChartBox();
// Axes
if (chart.hasCartesianSeries) {
each(axes, function(axis) {
if (axis.visible) {
axis.render();
}
});
}
// The series
if (!chart.seriesGroup) {
chart.seriesGroup = renderer.g('series-group')
.attr({
zIndex: 3
})
.add();
}
chart.renderSeries();
// Labels
chart.renderLabels();
// Credits
chart.addCredits();
// Handle responsiveness
if (chart.setResponsive) {
chart.setResponsive();
}
// Set flag
chart.hasRendered = true;
},
/**
* Show chart credits based on config options
*/
addCredits: function(credits) {
var chart = this;
credits = merge(true, this.options.credits, credits);
if (credits.enabled && !this.credits) {
this.credits = this.renderer.text(
credits.text + (this.mapCredits || ''),
0,
0
)
.addClass('highcharts-credits')
.on('click', function() {
if (credits.href) {
win.location.href = credits.href;
}
})
.attr({
align: credits.position.align,
zIndex: 8
})
.css(credits.style)
.add()
.align(credits.position);
// Dynamically update
this.credits.update = function(options) {
chart.credits = chart.credits.destroy();
chart.addCredits(options);
};
}
},
/**
* Clean up memory usage
*/
destroy: function() {
var chart = this,
axes = chart.axes,
series = chart.series,
container = chart.container,
i,
parentNode = container && container.parentNode;
// fire the chart.destoy event
fireEvent(chart, 'destroy');
// Delete the chart from charts lookup array
charts[chart.index] = undefined;
H.chartCount--;
chart.renderTo.removeAttribute('data-highcharts-chart');
// remove events
removeEvent(chart);
// ==== Destroy collections:
// Destroy axes
i = axes.length;
while (i--) {
axes[i] = axes[i].destroy();
}
// Destroy scroller & scroller series before destroying base series
if (this.scroller && this.scroller.destroy) {
this.scroller.destroy();
}
// Destroy each series
i = series.length;
while (i--) {
series[i] = series[i].destroy();
}
// ==== Destroy chart properties:
each([
'title', 'subtitle', 'chartBackground', 'plotBackground',
'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
'renderer'
], function(name) {
var prop = chart[name];
if (prop && prop.destroy) {
chart[name] = prop.destroy();
}
});
// remove container and all SVG
if (container) { // can break in IE when destroyed before finished loading
container.innerHTML = '';
removeEvent(container);
if (parentNode) {
discardElement(container);
}
}
// clean it all up
for (i in chart) {
delete chart[i];
}
},
/**
* VML namespaces can't be added until after complete. Listening
* for Perini's doScroll hack is not enough.
*/
isReadyToRender: function() {
var chart = this;
// Note: win == win.top is required
if ((!svg && (win == win.top && doc.readyState !== 'complete'))) { // eslint-disable-line eqeqeq
doc.attachEvent('onreadystatechange', function() {
doc.detachEvent('onreadystatechange', chart.firstRender);
if (doc.readyState === 'complete') {
chart.firstRender();
}
});
return false;
}
return true;
},
/**
* Prepare for first rendering after all data are loaded
*/
firstRender: function() {
var chart = this,
options = chart.options;
// Check whether the chart is ready to render
if (!chart.isReadyToRender()) {
return;
}
// Create the container
chart.getContainer();
// Run an early event after the container and renderer are established
fireEvent(chart, 'init');
chart.resetMargins();
chart.setChartSize();
// Set the common chart properties (mainly invert) from the given series
chart.propFromSeries();
// get axes
chart.getAxes();
// Initialize the series
each(options.series || [], function(serieOptions) {
chart.initSeries(serieOptions);
});
chart.linkSeries();
// Run an event after axes and series are initialized, but before render. At this stage,
// the series data is indexed and cached in the xData and yData arrays, so we can access
// those before rendering. Used in Highstock.
fireEvent(chart, 'beforeRender');
// depends on inverted and on margins being set
if (Pointer) {
chart.pointer = new Pointer(chart, options);
}
chart.render();
// Fire the load event if there are no external images
if (!chart.renderer.imgCount && chart.onload) {
chart.onload();
}
// If the chart was rendered outside the top container, put it back in (#3679)
chart.cloneRenderTo(true);
},
/**
* On chart load
*/
onload: function() {
// Run callbacks
each([this.callback].concat(this.callbacks), function(fn) {
if (fn && this.index !== undefined) { // Chart destroyed in its own callback (#3600)
fn.apply(this, [this]);
}
}, this);
fireEvent(this, 'load');
fireEvent(this, 'render');
// Set up auto resize, check for not destroyed (#6068)
if (defined(this.index) && this.options.chart.reflow !== false) {
this.initReflow();
}
// Don't run again
this.onload = null;
}
}; // end Chart
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Point,
each = H.each,
extend = H.extend,
erase = H.erase,
fireEvent = H.fireEvent,
format = H.format,
isArray = H.isArray,
isNumber = H.isNumber,
pick = H.pick,
removeEvent = H.removeEvent;
/**
* The Point object. The point objects are generated from the series.data
* configuration objects or raw numbers. They can be accessed from the
* Series.points array.
* @constructor Point
*/
Point = H.Point = function() {};
Point.prototype = {
/**
* Initialize the point. Called internally based on the series.data option.
* @function #init
* @memberOf Point
* @param {Object} series The series object containing this point.
* @param {Object} options The data in either number, array or object
* format.
* @param {Number} x Optionally, the X value of the.
* @returns {Object} The Point instance.
*/
init: function(series, options, x) {
var point = this,
colors,
colorCount = series.chart.options.chart.colorCount,
colorIndex;
point.series = series;
point.color = series.color; // #3445
point.applyOptions(options, x);
if (series.options.colorByPoint) {
colors = series.options.colors || series.chart.options.colors;
point.color = point.color || colors[series.colorCounter];
colorCount = colors.length;
colorIndex = series.colorCounter;
series.colorCounter++;
// loop back to zero
if (series.colorCounter === colorCount) {
series.colorCounter = 0;
}
} else {
colorIndex = series.colorIndex;
}
point.colorIndex = pick(point.colorIndex, colorIndex);
series.chart.pointCount++;
return point;
},
/**
* Apply the options containing the x and y data and possible some extra
* properties. Called on point init or from point.update.
*
* @function #applyOptions
* @memberOf Point
* @param {Object} options The point options as defined in series.data.
* @param {Number} x Optionally, the X value.
* @returns {Object} The Point instance.
*/
applyOptions: function(options, x) {
var point = this,
series = point.series,
pointValKey = series.options.pointValKey || series.pointValKey;
options = Point.prototype.optionsToObject.call(this, options);
// copy options directly to point
extend(point, options);
point.options = point.options ? extend(point.options, options) : options;
// Since options are copied into the Point instance, some accidental options must be shielded (#5681)
if (options.group) {
delete point.group;
}
// For higher dimension series types. For instance, for ranges, point.y is mapped to point.low.
if (pointValKey) {
point.y = point[pointValKey];
}
point.isNull = pick(
point.isValid && !point.isValid(),
point.x === null || !isNumber(point.y, true)
); // #3571, check for NaN
// The point is initially selected by options (#5777)
if (point.selected) {
point.state = 'select';
}
// If no x is set by now, get auto incremented value. All points must have an
// x value, however the y value can be null to create a gap in the series
if ('name' in point && x === undefined && series.xAxis && series.xAxis.hasNames) {
point.x = series.xAxis.nameToX(point);
}
if (point.x === undefined && series) {
if (x === undefined) {
point.x = series.autoIncrement(point);
} else {
point.x = x;
}
}
return point;
},
/**
* Transform number or array configs into objects
*/
optionsToObject: function(options) {
var ret = {},
series = this.series,
keys = series.options.keys,
pointArrayMap = keys || series.pointArrayMap || ['y'],
valueCount = pointArrayMap.length,
firstItemType,
i = 0,
j = 0;
if (isNumber(options) || options === null) {
ret[pointArrayMap[0]] = options;
} else if (isArray(options)) {
// with leading x value
if (!keys && options.length > valueCount) {
firstItemType = typeof options[0];
if (firstItemType === 'string') {
ret.name = options[0];
} else if (firstItemType === 'number') {
ret.x = options[0];
}
i++;
}
while (j < valueCount) {
if (!keys || options[i] !== undefined) { // Skip undefined positions for keys
ret[pointArrayMap[j]] = options[i];
}
i++;
j++;
}
} else if (typeof options === 'object') {
ret = options;
// This is the fastest way to detect if there are individual point dataLabels that need
// to be considered in drawDataLabels. These can only occur in object configs.
if (options.dataLabels) {
series._hasPointLabels = true;
}
// Same approach as above for markers
if (options.marker) {
series._hasPointMarkers = true;
}
}
return ret;
},
/**
* Get the CSS class names for individual points
* @returns {String} The class name
*/
getClassName: function() {
return 'highcharts-point' +
(this.selected ? ' highcharts-point-select' : '') +
(this.negative ? ' highcharts-negative' : '') +
(this.isNull ? ' highcharts-null-point' : '') +
(this.colorIndex !== undefined ? ' highcharts-color-' +
this.colorIndex : '') +
(this.options.className ? ' ' + this.options.className : '') +
(this.zone && this.zone.className ? ' ' +
this.zone.className.replace('highcharts-negative', '') : '');
},
/**
* Return the zone that the point belongs to
*/
getZone: function() {
var series = this.series,
zones = series.zones,
zoneAxis = series.zoneAxis || 'y',
i = 0,
zone;
zone = zones[i];
while (this[zoneAxis] >= zone.value) {
zone = zones[++i];
}
if (zone && zone.color && !this.options.color) {
this.color = zone.color;
}
return zone;
},
/**
* Destroy a point to clear memory. Its reference still stays in series.data.
*/
destroy: function() {
var point = this,
series = point.series,
chart = series.chart,
hoverPoints = chart.hoverPoints,
prop;
chart.pointCount--;
if (hoverPoints) {
point.setState();
erase(hoverPoints, point);
if (!hoverPoints.length) {
chart.hoverPoints = null;
}
}
if (point === chart.hoverPoint) {
point.onMouseOut();
}
// remove all events
if (point.graphic || point.dataLabel) { // removeEvent and destroyElements are performance expensive
removeEvent(point);
point.destroyElements();
}
if (point.legendItem) { // pies have legend items
chart.legend.destroyItem(point);
}
for (prop in point) {
point[prop] = null;
}
},
/**
* Destroy SVG elements associated with the point
*/
destroyElements: function() {
var point = this,
props = ['graphic', 'dataLabel', 'dataLabelUpper', 'connector', 'shadowGroup'],
prop,
i = 6;
while (i--) {
prop = props[i];
if (point[prop]) {
point[prop] = point[prop].destroy();
}
}
},
/**
* Return the configuration hash needed for the data label and tooltip formatters
*/
getLabelConfig: function() {
return {
x: this.category,
y: this.y,
color: this.color,
colorIndex: this.colorIndex,
key: this.name || this.category,
series: this.series,
point: this,
percentage: this.percentage,
total: this.total || this.stackTotal
};
},
/**
* Extendable method for formatting each point's tooltip line
*
* @return {String} A string to be concatenated in to the common tooltip text
*/
tooltipFormatter: function(pointFormat) {
// Insert options for valueDecimals, valuePrefix, and valueSuffix
var series = this.series,
seriesTooltipOptions = series.tooltipOptions,
valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''),
valuePrefix = seriesTooltipOptions.valuePrefix || '',
valueSuffix = seriesTooltipOptions.valueSuffix || '';
// Loop over the point array map and replace unformatted values with sprintf formatting markup
each(series.pointArrayMap || ['y'], function(key) {
key = '{point.' + key; // without the closing bracket
if (valuePrefix || valueSuffix) {
pointFormat = pointFormat.replace(key + '}', valuePrefix + key + '}' + valueSuffix);
}
pointFormat = pointFormat.replace(key + '}', key + ':,.' + valueDecimals + 'f}');
});
return format(pointFormat, {
point: this,
series: this.series
});
},
/**
* Fire an event on the Point object.
* @param {String} eventType
* @param {Object} eventArgs Additional event arguments
* @param {Function} defaultFunction Default event handler
*/
firePointEvent: function(eventType, eventArgs, defaultFunction) {
var point = this,
series = this.series,
seriesOptions = series.options;
// load event handlers on demand to save time on mouseover/out
if (seriesOptions.point.events[eventType] || (point.options && point.options.events && point.options.events[eventType])) {
this.importEvents();
}
// add default handler if in selection mode
if (eventType === 'click' && seriesOptions.allowPointSelect) {
defaultFunction = function(event) {
// Control key is for Windows, meta (= Cmd key) for Mac, Shift for Opera
if (point.select) { // Could be destroyed by prior event handlers (#2911)
point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
}
};
}
fireEvent(this, eventType, eventArgs, defaultFunction);
},
visible: true
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animObject = H.animObject,
arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
correctFloat = H.correctFloat,
Date = H.Date,
defaultOptions = H.defaultOptions,
defaultPlotOptions = H.defaultPlotOptions,
defined = H.defined,
each = H.each,
erase = H.erase,
extend = H.extend,
fireEvent = H.fireEvent,
grep = H.grep,
isArray = H.isArray,
isNumber = H.isNumber,
isString = H.isString,
LegendSymbolMixin = H.LegendSymbolMixin, // @todo add as a requirement
merge = H.merge,
pick = H.pick,
Point = H.Point, // @todo add as a requirement
removeEvent = H.removeEvent,
splat = H.splat,
SVGElement = H.SVGElement,
syncTimeout = H.syncTimeout,
win = H.win;
/**
* The base function which all other series types inherit from. The data in the series is stored
* in various arrays.
*
* - First, series.options.data contains all the original config options for
* each point whether added by options or methods like series.addPoint.
* - Next, series.data contains those values converted to points, but in case the series data length
* exceeds the cropThreshold, or if the data is grouped, series.data doesn't contain all the points. It
* only contains the points that have been created on demand.
* - Then there's series.points that contains all currently visible point objects. In case of cropping,
* the cropped-away points are not part of this array. The series.points array starts at series.cropStart
* compared to series.data and series.options.data. If however the series data is grouped, these can't
* be correlated one to one.
* - series.xData and series.processedXData contain clean x values, equivalent to series.data and series.points.
* - series.yData and series.processedYData contain clean y values, equivalent to series.data and series.points.
*
* @constructor Series
* @param {Object} chart - The chart instance.
* @param {Object} options - The series options.
*/
H.Series = H.seriesType('line', null, { // base series options
//cursor: 'default',
//dashStyle: null,
//linecap: 'round',
lineWidth: 2,
//shadow: false,
allowPointSelect: false,
showCheckbox: false,
animation: {
duration: 1000
},
//clip: true,
//connectNulls: false,
//enableMouseTracking: true,
events: {},
//legendIndex: 0,
// stacking: null,
marker: {
lineWidth: 0,
lineColor: '#ffffff',
//fillColor: null,
//enabled: true,
//symbol: null,
radius: 4,
states: { // states for a single point
hover: {
animation: {
duration: 50
},
enabled: true,
radiusPlus: 2,
lineWidthPlus: 1
},
select: {
fillColor: '#cccccc',
lineColor: '#000000',
lineWidth: 2
}
}
},
point: {
events: {}
},
dataLabels: {
align: 'center',
// defer: true,
// enabled: false,
formatter: function() {
return this.y === null ? '' : H.numberFormat(this.y, -1);
},
style: {
fontSize: '11px',
fontWeight: 'bold',
color: 'contrast',
textOutline: '1px contrast'
},
// backgroundColor: undefined,
// borderColor: undefined,
// borderWidth: undefined,
// shadow: false
verticalAlign: 'bottom', // above singular point
x: 0,
y: 0,
// borderRadius: undefined,
padding: 5
},
cropThreshold: 300, // draw points outside the plot area when the number of points is less than this
pointRange: 0,
//pointStart: 0,
//pointInterval: 1,
//showInLegend: null, // auto: true for standalone series, false for linked series
softThreshold: true,
states: { // states for the entire series
hover: {
//enabled: false,
animation: {
duration: 50
},
lineWidthPlus: 1,
marker: {
// lineWidth: base + 1,
// radius: base + 1
},
halo: {
size: 10,
opacity: 0.25
}
},
select: {
marker: {}
}
},
stickyTracking: true,
//tooltip: {
//pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b>'
//valueDecimals: null,
//xDateFormat: '%A, %b %e, %Y',
//valuePrefix: '',
//ySuffix: ''
//}
turboThreshold: 1000,
// zIndex: null
findNearestPointBy: 'x'
}, /** @lends Series.prototype */ {
isCartesian: true,
pointClass: Point,
sorted: true, // requires the data to be sorted
requireSorting: true,
directTouch: false,
axisTypes: ['xAxis', 'yAxis'],
colorCounter: 0,
parallelArrays: ['x', 'y'], // each point's x and y values are stored in this.xData and this.yData
coll: 'series',
init: function(chart, options) {
var series = this,
eventType,
events,
chartSeries = chart.series,
lastSeries;
series.chart = chart;
series.options = options = series.setOptions(options); // merge with plotOptions
series.linkedSeries = [];
// bind the axes
series.bindAxes();
// set some variables
extend(series, {
name: options.name,
state: '',
visible: options.visible !== false, // true by default
selected: options.selected === true // false by default
});
// register event listeners
events = options.events;
for (eventType in events) {
addEvent(series, eventType, events[eventType]);
}
if (
(events && events.click) ||
(options.point && options.point.events && options.point.events.click) ||
options.allowPointSelect
) {
chart.runTrackerClick = true;
}
series.getColor();
series.getSymbol();
// Set the data
each(series.parallelArrays, function(key) {
series[key + 'Data'] = [];
});
series.setData(options.data, false);
// Mark cartesian
if (series.isCartesian) {
chart.hasCartesianSeries = true;
}
// Get the index and register the series in the chart. The index is one
// more than the current latest series index (#5960).
if (chartSeries.length) {
lastSeries = chartSeries[chartSeries.length - 1];
}
series._i = pick(lastSeries && lastSeries._i, -1) + 1;
// Insert the series and re-order all series above the insertion point.
chart.orderSeries(this.insert(chartSeries));
},
/**
* Insert the series in a collection with other series, either the chart
* series or yAxis series, in the correct order according to the index
* option.
* @param {Array} collection A collection of series.
* @returns {Number} The index of the series in the collection.
*/
insert: function(collection) {
var indexOption = this.options.index,
i;
// Insert by index option
if (isNumber(indexOption)) {
i = collection.length;
while (i--) {
// Loop down until the interted element has higher index
if (indexOption >=
pick(collection[i].options.index, collection[i]._i)) {
collection.splice(i + 1, 0, this);
break;
}
}
if (i === -1) {
collection.unshift(this);
}
i = i + 1;
// Or just push it to the end
} else {
collection.push(this);
}
return pick(i, collection.length - 1);
},
/**
* Set the xAxis and yAxis properties of cartesian series, and register the
* series in the `axis.series` array.
*
* @function #bindAxes
* @memberOf Series
* @returns {void}
*/
bindAxes: function() {
var series = this,
seriesOptions = series.options,
chart = series.chart,
axisOptions;
each(series.axisTypes || [], function(AXIS) { // repeat for xAxis and yAxis
each(chart[AXIS], function(axis) { // loop through the chart's axis objects
axisOptions = axis.options;
// apply if the series xAxis or yAxis option mathches the number of the
// axis, or if undefined, use the first axis
if ((seriesOptions[AXIS] === axisOptions.index) ||
(seriesOptions[AXIS] !== undefined && seriesOptions[AXIS] === axisOptions.id) ||
(seriesOptions[AXIS] === undefined && axisOptions.index === 0)) {
// register this series in the axis.series lookup
series.insert(axis.series);
// set this series.xAxis or series.yAxis reference
series[AXIS] = axis;
// mark dirty for redraw
axis.isDirty = true;
}
});
// The series needs an X and an Y axis
if (!series[AXIS] && series.optionalAxis !== AXIS) {
H.error(18, true);
}
});
},
/**
* For simple series types like line and column, the data values are held in arrays like
* xData and yData for quick lookup to find extremes and more. For multidimensional series
* like bubble and map, this can be extended with arrays like zData and valueData by
* adding to the series.parallelArrays array.
*/
updateParallelArrays: function(point, i) {
var series = point.series,
args = arguments,
fn = isNumber(i) ?
// Insert the value in the given position
function(key) {
var val = key === 'y' && series.toYData ? series.toYData(point) : point[key];
series[key + 'Data'][i] = val;
} :
// Apply the method specified in i with the following arguments as arguments
function(key) {
Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
};
each(series.parallelArrays, fn);
},
/**
* Return an auto incremented x value based on the pointStart and pointInterval options.
* This is only used if an x value is not given for the point that calls autoIncrement.
*/
autoIncrement: function() {
var options = this.options,
xIncrement = this.xIncrement,
date,
pointInterval,
pointIntervalUnit = options.pointIntervalUnit;
xIncrement = pick(xIncrement, options.pointStart, 0);
this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
// Added code for pointInterval strings
if (pointIntervalUnit) {
date = new Date(xIncrement);
if (pointIntervalUnit === 'day') {
date = +date[Date.hcSetDate](date[Date.hcGetDate]() + pointInterval);
} else if (pointIntervalUnit === 'month') {
date = +date[Date.hcSetMonth](date[Date.hcGetMonth]() + pointInterval);
} else if (pointIntervalUnit === 'year') {
date = +date[Date.hcSetFullYear](date[Date.hcGetFullYear]() + pointInterval);
}
pointInterval = date - xIncrement;
}
this.xIncrement = xIncrement + pointInterval;
return xIncrement;
},
/**
* Set the series options by merging from the options tree
* @param {Object} itemOptions
*/
setOptions: function(itemOptions) {
var chart = this.chart,
chartOptions = chart.options,
plotOptions = chartOptions.plotOptions,
userOptions = chart.userOptions || {},
userPlotOptions = userOptions.plotOptions || {},
typeOptions = plotOptions[this.type],
options,
zones;
this.userOptions = itemOptions;
// General series options take precedence over type options because otherwise, default
// type options like column.animation would be overwritten by the general option.
// But issues have been raised here (#3881), and the solution may be to distinguish
// between default option and userOptions like in the tooltip below.
options = merge(
typeOptions,
plotOptions.series,
itemOptions
);
// The tooltip options are merged between global and series specific options
this.tooltipOptions = merge(
defaultOptions.tooltip,
defaultOptions.plotOptions[this.type].tooltip,
userOptions.tooltip,
userPlotOptions.series && userPlotOptions.series.tooltip,
userPlotOptions[this.type] && userPlotOptions[this.type].tooltip,
itemOptions.tooltip
);
// When shared tooltip, stickyTracking is true by default,
// unless user says otherwise.
this.stickyTracking = pick(
itemOptions.stickyTracking,
userPlotOptions[this.type] && userPlotOptions[this.type].stickyTracking,
userPlotOptions.series && userPlotOptions.series.stickyTracking,
(
this.tooltipOptions.shared && !this.noSharedTooltip ?
true :
options.stickyTracking
)
);
// Delete marker object if not allowed (#1125)
if (typeOptions.marker === null) {
delete options.marker;
}
// Handle color zones
this.zoneAxis = options.zoneAxis;
zones = this.zones = (options.zones || []).slice();
if ((options.negativeColor || options.negativeFillColor) && !options.zones) {
zones.push({
value: options[this.zoneAxis + 'Threshold'] || options.threshold || 0,
className: 'highcharts-negative',
color: options.negativeColor,
fillColor: options.negativeFillColor
});
}
if (zones.length) { // Push one extra zone for the rest
if (defined(zones[zones.length - 1].value)) {
zones.push({
color: this.color,
fillColor: this.fillColor
});
}
}
return options;
},
getCyclic: function(prop, value, defaults) {
var i,
chart = this.chart,
userOptions = this.userOptions,
indexName = prop + 'Index',
counterName = prop + 'Counter',
len = defaults ? defaults.length : pick(
chart.options.chart[prop + 'Count'],
chart[prop + 'Count']
),
setting;
if (!value) {
// Pick up either the colorIndex option, or the _colorIndex after Series.update()
setting = pick(userOptions[indexName], userOptions['_' + indexName]);
if (defined(setting)) { // after Series.update()
i = setting;
} else {
// #6138
if (!chart.series.length) {
chart[counterName] = 0;
}
userOptions['_' + indexName] = i = chart[counterName] % len;
chart[counterName] += 1;
}
if (defaults) {
value = defaults[i];
}
}
// Set the colorIndex
if (i !== undefined) {
this[indexName] = i;
}
this[prop] = value;
},
/**
* Get the series' color
*/
getColor: function() {
if (this.options.colorByPoint) {
this.options.color = null; // #4359, selected slice got series.color even when colorByPoint was set.
} else {
this.getCyclic('color', this.options.color || defaultPlotOptions[this.type].color, this.chart.options.colors);
}
},
/**
* Get the series' symbol
*/
getSymbol: function() {
var seriesMarkerOption = this.options.marker;
this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
},
drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
/**
* Replace the series data with a new set of data
* @param {Object} data
* @param {Object} redraw
*/
setData: function(data, redraw, animation, updatePoints) {
var series = this,
oldData = series.points,
oldDataLength = (oldData && oldData.length) || 0,
dataLength,
options = series.options,
chart = series.chart,
firstPoint = null,
xAxis = series.xAxis,
i,
turboThreshold = options.turboThreshold,
pt,
xData = this.xData,
yData = this.yData,
pointArrayMap = series.pointArrayMap,
valueCount = pointArrayMap && pointArrayMap.length;
data = data || [];
dataLength = data.length;
redraw = pick(redraw, true);
// If the point count is the same as is was, just run Point.update which is
// cheaper, allows animation, and keeps references to points.
if (updatePoints !== false && dataLength && oldDataLength === dataLength && !series.cropped && !series.hasGroupedData && series.visible) {
each(data, function(point, i) {
// .update doesn't exist on a linked, hidden series (#3709)
if (oldData[i].update && point !== options.data[i]) {
oldData[i].update(point, false, null, false);
}
});
} else {
// Reset properties
series.xIncrement = null;
series.colorCounter = 0; // for series with colorByPoint (#1547)
// Update parallel arrays
each(this.parallelArrays, function(key) {
series[key + 'Data'].length = 0;
});
// In turbo mode, only one- or twodimensional arrays of numbers are allowed. The
// first value is tested, and we assume that all the rest are defined the same
// way. Although the 'for' loops are similar, they are repeated inside each
// if-else conditional for max performance.
if (turboThreshold && dataLength > turboThreshold) {
// find the first non-null point
i = 0;
while (firstPoint === null && i < dataLength) {
firstPoint = data[i];
i++;
}
if (isNumber(firstPoint)) { // assume all points are numbers
for (i = 0; i < dataLength; i++) {
xData[i] = this.autoIncrement();
yData[i] = data[i];
}
} else if (isArray(firstPoint)) { // assume all points are arrays
if (valueCount) { // [x, low, high] or [x, o, h, l, c]
for (i = 0; i < dataLength; i++) {
pt = data[i];
xData[i] = pt[0];
yData[i] = pt.slice(1, valueCount + 1);
}
} else { // [x, y]
for (i = 0; i < dataLength; i++) {
pt = data[i];
xData[i] = pt[0];
yData[i] = pt[1];
}
}
} else {
H.error(12); // Highcharts expects configs to be numbers or arrays in turbo mode
}
} else {
for (i = 0; i < dataLength; i++) {
if (data[i] !== undefined) { // stray commas in oldIE
pt = {
series: series
};
series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
series.updateParallelArrays(pt, i);
}
}
}
// Forgetting to cast strings to numbers is a common caveat when handling CSV or JSON
if (isString(yData[0])) {
H.error(14, true);
}
series.data = [];
series.options.data = series.userOptions.data = data;
// destroy old points
i = oldDataLength;
while (i--) {
if (oldData[i] && oldData[i].destroy) {
oldData[i].destroy();
}
}
// reset minRange (#878)
if (xAxis) {
xAxis.minRange = xAxis.userMinRange;
}
// redraw
series.isDirty = chart.isDirtyBox = true;
series.isDirtyData = !!oldData;
animation = false;
}
// Typically for pie series, points need to be processed and generated
// prior to rendering the legend
if (options.legendType === 'point') {
this.processData();
this.generatePoints();
}
if (redraw) {
chart.redraw(animation);
}
},
/**
* Process the data by cropping away unused data points if the series is longer
* than the crop threshold. This saves computing time for large series.
*/
processData: function(force) {
var series = this,
processedXData = series.xData, // copied during slice operation below
processedYData = series.yData,
dataLength = processedXData.length,
croppedData,
cropStart = 0,
cropped,
distance,
closestPointRange,
xAxis = series.xAxis,
i, // loop variable
options = series.options,
cropThreshold = options.cropThreshold,
getExtremesFromAll = series.getExtremesFromAll || options.getExtremesFromAll, // #4599
isCartesian = series.isCartesian,
xExtremes,
val2lin = xAxis && xAxis.val2lin,
isLog = xAxis && xAxis.isLog,
min,
max;
// If the series data or axes haven't changed, don't go through this. Return false to pass
// the message on to override methods like in data grouping.
if (isCartesian && !series.isDirty && !xAxis.isDirty && !series.yAxis.isDirty && !force) {
return false;
}
if (xAxis) {
xExtremes = xAxis.getExtremes(); // corrected for log axis (#3053)
min = xExtremes.min;
max = xExtremes.max;
}
// optionally filter out points outside the plot area
if (isCartesian && series.sorted && !getExtremesFromAll && (!cropThreshold || dataLength > cropThreshold || series.forceCrop)) {
// it's outside current extremes
if (processedXData[dataLength - 1] < min || processedXData[0] > max) {
processedXData = [];
processedYData = [];
// only crop if it's actually spilling out
} else if (processedXData[0] < min || processedXData[dataLength - 1] > max) {
croppedData = this.cropData(series.xData, series.yData, min, max);
processedXData = croppedData.xData;
processedYData = croppedData.yData;
cropStart = croppedData.start;
cropped = true;
}
}
// Find the closest distance between processed points
i = processedXData.length || 1;
while (--i) {
distance = isLog ?
val2lin(processedXData[i]) - val2lin(processedXData[i - 1]) :
processedXData[i] - processedXData[i - 1];
if (distance > 0 && (closestPointRange === undefined || distance < closestPointRange)) {
closestPointRange = distance;
// Unsorted data is not supported by the line tooltip, as well as data grouping and
// navigation in Stock charts (#725) and width calculation of columns (#1900)
} else if (distance < 0 && series.requireSorting) {
H.error(15);
}
}
// Record the properties
series.cropped = cropped; // undefined or true
series.cropStart = cropStart;
series.processedXData = processedXData;
series.processedYData = processedYData;
series.closestPointRange = closestPointRange;
},
/**
* Iterate over xData and crop values between min and max. Returns object containing crop start/end
* cropped xData with corresponding part of yData, dataMin and dataMax within the cropped range
*/
cropData: function(xData, yData, min, max) {
var dataLength = xData.length,
cropStart = 0,
cropEnd = dataLength,
cropShoulder = pick(this.cropShoulder, 1), // line-type series need one point outside
i,
j;
// iterate up to find slice start
for (i = 0; i < dataLength; i++) {
if (xData[i] >= min) {
cropStart = Math.max(0, i - cropShoulder);
break;
}
}
// proceed to find slice end
for (j = i; j < dataLength; j++) {
if (xData[j] > max) {
cropEnd = j + cropShoulder;
break;
}
}
return {
xData: xData.slice(cropStart, cropEnd),
yData: yData.slice(cropStart, cropEnd),
start: cropStart,
end: cropEnd
};
},
/**
* Generate the data point after the data has been processed by cropping away
* unused points and optionally grouped in Highcharts Stock.
*/
generatePoints: function() {
var series = this,
options = series.options,
dataOptions = options.data,
data = series.data,
dataLength,
processedXData = series.processedXData,
processedYData = series.processedYData,
PointClass = series.pointClass,
processedDataLength = processedXData.length,
cropStart = series.cropStart || 0,
cursor,
hasGroupedData = series.hasGroupedData,
point,
points = [],
i;
if (!data && !hasGroupedData) {
var arr = [];
arr.length = dataOptions.length;
data = series.data = arr;
}
for (i = 0; i < processedDataLength; i++) {
cursor = cropStart + i;
if (!hasGroupedData) {
point = data[cursor];
if (!point && dataOptions[cursor] !== undefined) { // #970
data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
}
} else {
// splat the y data in case of ohlc data array
point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
point.dataGroup = series.groupMap[i];
}
if (point) { // #6279
point.index = cursor; // For faster access in Point.update
points[i] = point;
}
}
// Hide cropped-away points - this only runs when the number of points is above cropThreshold, or when
// swithching view from non-grouped data to grouped data (#637)
if (data && (processedDataLength !== (dataLength = data.length) || hasGroupedData)) {
for (i = 0; i < dataLength; i++) {
if (i === cropStart && !hasGroupedData) { // when has grouped data, clear all points
i += processedDataLength;
}
if (data[i]) {
data[i].destroyElements();
data[i].plotX = undefined; // #1003
}
}
}
series.data = data;
series.points = points;
},
/**
* Calculate Y extremes for visible data
*/
getExtremes: function(yData) {
var xAxis = this.xAxis,
yAxis = this.yAxis,
xData = this.processedXData,
yDataLength,
activeYData = [],
activeCounter = 0,
xExtremes = xAxis.getExtremes(), // #2117, need to compensate for log X axis
xMin = xExtremes.min,
xMax = xExtremes.max,
validValue,
withinRange,
x,
y,
i,
j;
yData = yData || this.stackedYData || this.processedYData || [];
yDataLength = yData.length;
for (i = 0; i < yDataLength; i++) {
x = xData[i];
y = yData[i];
// For points within the visible range, including the first point outside the
// visible range, consider y extremes
validValue = (isNumber(y, true) || isArray(y)) && (!yAxis.positiveValuesOnly || (y.length || y > 0));
withinRange = this.getExtremesFromAll || this.options.getExtremesFromAll || this.cropped ||
((xData[i] || x) >= xMin && (xData[i] || x) <= xMax);
if (validValue && withinRange) {
j = y.length;
if (j) { // array, like ohlc or range data
while (j--) {
if (y[j] !== null) {
activeYData[activeCounter++] = y[j];
}
}
} else {
activeYData[activeCounter++] = y;
}
}
}
this.dataMin = arrayMin(activeYData);
this.dataMax = arrayMax(activeYData);
},
/**
* Translate data points from raw data values to chart specific positioning
* data needed later in drawPoints, drawGraph and drawTracker.
*
* @function #translate
* @memberOf Series
* @returns {void}
*/
translate: function() {
if (!this.processedXData) { // hidden series
this.processData();
}
this.generatePoints();
var series = this,
options = series.options,
stacking = options.stacking,
xAxis = series.xAxis,
categories = xAxis.categories,
yAxis = series.yAxis,
points = series.points,
dataLength = points.length,
hasModifyValue = !!series.modifyValue,
i,
pointPlacement = options.pointPlacement,
dynamicallyPlaced = pointPlacement === 'between' || isNumber(pointPlacement),
threshold = options.threshold,
stackThreshold = options.startFromThreshold ? threshold : 0,
plotX,
plotY,
lastPlotX,
stackIndicator,
closestPointRangePx = Number.MAX_VALUE;
// Point placement is relative to each series pointRange (#5889)
if (pointPlacement === 'between') {
pointPlacement = 0.5;
}
if (isNumber(pointPlacement)) {
pointPlacement *= pick(options.pointRange || xAxis.pointRange);
}
// Translate each point
for (i = 0; i < dataLength; i++) {
var point = points[i],
xValue = point.x,
yValue = point.y,
yBottom = point.low,
stack = stacking && yAxis.stacks[(series.negStacks && yValue < (stackThreshold ? 0 : threshold) ? '-' : '') + series.stackKey],
pointStack,
stackValues;
// Discard disallowed y values for log axes (#3434)
if (yAxis.positiveValuesOnly && yValue !== null && yValue <= 0) {
point.isNull = true;
}
// Get the plotX translation
point.plotX = plotX = correctFloat( // #5236
Math.min(Math.max(-1e5, xAxis.translate(
xValue,
0,
0,
0,
1,
pointPlacement,
this.type === 'flags'
)), 1e5) // #3923
);
// Calculate the bottom y value for stacked series
if (stacking && series.visible && !point.isNull && stack && stack[xValue]) {
stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
pointStack = stack[xValue];
stackValues = pointStack.points[stackIndicator.key];
yBottom = stackValues[0];
yValue = stackValues[1];
if (yBottom === stackThreshold && stackIndicator.key === stack[xValue].base) {
yBottom = pick(threshold, yAxis.min);
}
if (yAxis.positiveValuesOnly && yBottom <= 0) { // #1200, #1232
yBottom = null;
}
point.total = point.stackTotal = pointStack.total;
point.percentage = pointStack.total && (point.y / pointStack.total * 100);
point.stackY = yValue;
// Place the stack label
pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
}
// Set translated yBottom or remove it
point.yBottom = defined(yBottom) ?
yAxis.translate(yBottom, 0, 1, 0, 1) :
null;
// general hook, used for Highstock compare mode
if (hasModifyValue) {
yValue = series.modifyValue(yValue, point);
}
// Set the the plotY value, reset it for redraws
point.plotY = plotY = (typeof yValue === 'number' && yValue !== Infinity) ?
Math.min(Math.max(-1e5, yAxis.translate(yValue, 0, 1, 0, 1)), 1e5) : // #3201
undefined;
point.isInside = plotY !== undefined && plotY >= 0 && plotY <= yAxis.len && // #3519
plotX >= 0 && plotX <= xAxis.len;
// Set client related positions for mouse tracking
point.clientX = dynamicallyPlaced ? correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) : plotX; // #1514, #5383, #5518
point.negative = point.y < (threshold || 0);
// some API data
point.category = categories && categories[point.x] !== undefined ?
categories[point.x] : point.x;
// Determine auto enabling of markers (#3635, #5099)
if (!point.isNull) {
if (lastPlotX !== undefined) {
closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
}
lastPlotX = plotX;
}
// Find point zone
point.zone = this.zones.length && point.getZone();
}
series.closestPointRangePx = closestPointRangePx;
},
/**
* Return the series points with null points filtered out
*/
getValidPoints: function(points, insideOnly) {
var chart = this.chart;
return grep(points || this.points || [], function isValidPoint(point) { // #3916, #5029
if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, chart.inverted)) { // #5085
return false;
}
return !point.isNull;
});
},
/**
* Set the clipping for the series. For animated series it is called twice, first to initiate
* animating the clip then the second time without the animation to set the final clip.
*/
setClip: function(animation) {
var chart = this.chart,
options = this.options,
renderer = chart.renderer,
inverted = chart.inverted,
seriesClipBox = this.clipBox,
clipBox = seriesClipBox || chart.clipBox,
sharedClipKey = this.sharedClipKey || ['_sharedClip', animation && animation.duration, animation && animation.easing, clipBox.height, options.xAxis, options.yAxis].join(','), // #4526
clipRect = chart[sharedClipKey],
markerClipRect = chart[sharedClipKey + 'm'];
// If a clipping rectangle with the same properties is currently present in the chart, use that.
if (!clipRect) {
// When animation is set, prepare the initial positions
if (animation) {
clipBox.width = 0;
chart[sharedClipKey + 'm'] = markerClipRect = renderer.clipRect(-99, // include the width of the first marker
inverted ? -chart.plotLeft : -chart.plotTop,
99,
inverted ? chart.chartWidth : chart.chartHeight
);
}
chart[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
// Create hashmap for series indexes
clipRect.count = {
length: 0
};
}
if (animation) {
if (!clipRect.count[this.index]) {
clipRect.count[this.index] = true;
clipRect.count.length += 1;
}
}
if (options.clip !== false) {
this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
this.markerGroup.clip(markerClipRect);
this.sharedClipKey = sharedClipKey;
}
// Remove the shared clipping rectangle when all series are shown
if (!animation) {
if (clipRect.count[this.index]) {
delete clipRect.count[this.index];
clipRect.count.length -= 1;
}
if (clipRect.count.length === 0 && sharedClipKey && chart[sharedClipKey]) {
if (!seriesClipBox) {
chart[sharedClipKey] = chart[sharedClipKey].destroy();
}
if (chart[sharedClipKey + 'm']) {
chart[sharedClipKey + 'm'] = chart[sharedClipKey + 'm'].destroy();
}
}
}
},
/**
* Animate in the series
*/
animate: function(init) {
var series = this,
chart = series.chart,
clipRect,
animation = animObject(series.options.animation),
sharedClipKey;
// Initialize the animation. Set up the clipping rectangle.
if (init) {
series.setClip(animation);
// Run the animation
} else {
sharedClipKey = this.sharedClipKey;
clipRect = chart[sharedClipKey];
if (clipRect) {
clipRect.animate({
width: chart.plotSizeX
}, animation);
}
if (chart[sharedClipKey + 'm']) {
chart[sharedClipKey + 'm'].animate({
width: chart.plotSizeX + 99
}, animation);
}
// Delete this function to allow it only once
series.animate = null;
}
},
/**
* This runs after animation to land on the final plot clipping
*/
afterAnimate: function() {
this.setClip();
fireEvent(this, 'afterAnimate');
},
/**
* Draw the markers.
*
* @function #drawPoints
* @memberOf Series
* @returns {void}
*/
drawPoints: function() {
var series = this,
points = series.points,
chart = series.chart,
plotY,
i,
point,
symbol,
graphic,
options = series.options,
seriesMarkerOptions = options.marker,
pointMarkerOptions,
hasPointMarker,
enabled,
isInside,
markerGroup = series.markerGroup,
xAxis = series.xAxis,
markerAttribs,
globallyEnabled = pick(
seriesMarkerOptions.enabled,
xAxis.isRadial ? true : null,
// Use larger or equal as radius is null in bubbles (#6321)
series.closestPointRangePx >= 2 * seriesMarkerOptions.radius
);
if (seriesMarkerOptions.enabled !== false || series._hasPointMarkers) {
for (i = 0; i < points.length; i++) {
point = points[i];
plotY = point.plotY;
graphic = point.graphic;
pointMarkerOptions = point.marker || {};
hasPointMarker = !!point.marker;
enabled = (globallyEnabled && pointMarkerOptions.enabled === undefined) || pointMarkerOptions.enabled;
isInside = point.isInside;
// only draw the point if y is defined
if (enabled && isNumber(plotY) && point.y !== null) {
// Shortcuts
symbol = pick(pointMarkerOptions.symbol, series.symbol);
point.hasImage = symbol.indexOf('url') === 0;
markerAttribs = series.markerAttribs(
point,
point.selected && 'select'
);
if (graphic) { // update
graphic[isInside ? 'show' : 'hide'](true) // Since the marker group isn't clipped, each individual marker must be toggled
.animate(markerAttribs);
} else if (isInside && (markerAttribs.width > 0 || point.hasImage)) {
point.graphic = graphic = chart.renderer.symbol(
symbol,
markerAttribs.x,
markerAttribs.y,
markerAttribs.width,
markerAttribs.height,
hasPointMarker ? pointMarkerOptions : seriesMarkerOptions
)
.add(markerGroup);
}
// Presentational attributes
if (graphic) {
graphic.attr(series.pointAttribs(point, point.selected && 'select'));
}
if (graphic) {
graphic.addClass(point.getClassName(), true);
}
} else if (graphic) {
point.graphic = graphic.destroy(); // #1269
}
}
}
},
/**
* Get non-presentational attributes for the point.
*/
markerAttribs: function(point, state) {
var seriesMarkerOptions = this.options.marker,
seriesStateOptions,
pointMarkerOptions = point.marker || {},
pointStateOptions,
radius = pick(
pointMarkerOptions.radius,
seriesMarkerOptions.radius
),
attribs;
// Handle hover and select states
if (state) {
seriesStateOptions = seriesMarkerOptions.states[state];
pointStateOptions = pointMarkerOptions.states &&
pointMarkerOptions.states[state];
radius = pick(
pointStateOptions && pointStateOptions.radius,
seriesStateOptions && seriesStateOptions.radius,
radius + (seriesStateOptions && seriesStateOptions.radiusPlus || 0)
);
}
if (point.hasImage) {
radius = 0; // and subsequently width and height is not set
}
attribs = {
x: Math.floor(point.plotX) - radius, // Math.floor for #1843
y: point.plotY - radius
};
if (radius) {
attribs.width = attribs.height = 2 * radius;
}
return attribs;
},
/**
* Get presentational attributes for marker-based series (line, spline, scatter, bubble, mappoint...)
*/
pointAttribs: function(point, state) {
var seriesMarkerOptions = this.options.marker,
seriesStateOptions,
pointOptions = point && point.options,
pointMarkerOptions = (pointOptions && pointOptions.marker) || {},
pointStateOptions,
color = this.color,
pointColorOption = pointOptions && pointOptions.color,
pointColor = point && point.color,
strokeWidth = pick(
pointMarkerOptions.lineWidth,
seriesMarkerOptions.lineWidth
),
zoneColor = point && point.zone && point.zone.color,
fill,
stroke;
color = pointColorOption || zoneColor || pointColor || color;
fill = pointMarkerOptions.fillColor || seriesMarkerOptions.fillColor || color;
stroke = pointMarkerOptions.lineColor || seriesMarkerOptions.lineColor || color;
// Handle hover and select states
if (state) {
seriesStateOptions = seriesMarkerOptions.states[state];
pointStateOptions = (pointMarkerOptions.states && pointMarkerOptions.states[state]) || {};
strokeWidth = pick(
pointStateOptions.lineWidth,
seriesStateOptions.lineWidth,
strokeWidth + pick(
pointStateOptions.lineWidthPlus,
seriesStateOptions.lineWidthPlus,
0
)
);
fill = pointStateOptions.fillColor || seriesStateOptions.fillColor || fill;
stroke = pointStateOptions.lineColor || seriesStateOptions.lineColor || stroke;
}
return {
'stroke': stroke,
'stroke-width': strokeWidth,
'fill': fill
};
},
/**
* Clear DOM objects and free up memory
*/
destroy: function() {
var series = this,
chart = series.chart,
issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent),
destroy,
i,
data = series.data || [],
point,
prop,
axis;
// add event hook
fireEvent(series, 'destroy');
// remove all events
removeEvent(series);
// erase from axes
each(series.axisTypes || [], function(AXIS) {
axis = series[AXIS];
if (axis && axis.series) {
erase(axis.series, series);
axis.isDirty = axis.forceRedraw = true;
}
});
// remove legend items
if (series.legendItem) {
series.chart.legend.destroyItem(series);
}
// destroy all points with their elements
i = data.length;
while (i--) {
point = data[i];
if (point && point.destroy) {
point.destroy();
}
}
series.points = null;
// Clear the animation timeout if we are destroying the series during initial animation
clearTimeout(series.animationTimeout);
// Destroy all SVGElements associated to the series
for (prop in series) {
if (series[prop] instanceof SVGElement && !series[prop].survive) { // Survive provides a hook for not destroying
// issue 134 workaround
destroy = issue134 && prop === 'group' ?
'hide' :
'destroy';
series[prop][destroy]();
}
}
// remove from hoverSeries
if (chart.hoverSeries === series) {
chart.hoverSeries = null;
}
erase(chart.series, series);
chart.orderSeries();
// clear all members
for (prop in series) {
delete series[prop];
}
},
/**
* Get the graph path
*/
getGraphPath: function(points, nullsAsZeroes, connectCliffs) {
var series = this,
options = series.options,
step = options.step,
reversed,
graphPath = [],
xMap = [],
gap;
points = points || series.points;
// Bottom of a stack is reversed
reversed = points.reversed;
if (reversed) {
points.reverse();
}
// Reverse the steps (#5004)
step = {
right: 1,
center: 2
}[step] || (step && 3);
if (step && reversed) {
step = 4 - step;
}
// Remove invalid points, especially in spline (#5015)
if (options.connectNulls && !nullsAsZeroes && !connectCliffs) {
points = this.getValidPoints(points);
}
// Build the line
each(points, function(point, i) {
var plotX = point.plotX,
plotY = point.plotY,
lastPoint = points[i - 1],
pathToPoint; // the path to this point from the previous
if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) && !connectCliffs) {
gap = true; // ... and continue
}
// Line series, nullsAsZeroes is not handled
if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
gap = !options.connectNulls;
// Area series, nullsAsZeroes is set
} else if (point.isNull && !nullsAsZeroes) {
gap = true;
} else {
if (i === 0 || gap) {
pathToPoint = ['M', point.plotX, point.plotY];
} else if (series.getPointSpline) { // generate the spline as defined in the SplineSeries object
pathToPoint = series.getPointSpline(points, point, i);
} else if (step) {
if (step === 1) { // right
pathToPoint = [
'L',
lastPoint.plotX,
plotY
];
} else if (step === 2) { // center
pathToPoint = [
'L',
(lastPoint.plotX + plotX) / 2,
lastPoint.plotY,
'L',
(lastPoint.plotX + plotX) / 2,
plotY
];
} else {
pathToPoint = [
'L',
plotX,
lastPoint.plotY
];
}
pathToPoint.push('L', plotX, plotY);
} else {
// normal line to next point
pathToPoint = [
'L',
plotX,
plotY
];
}
// Prepare for animation. When step is enabled, there are two path nodes for each x value.
xMap.push(point.x);
if (step) {
xMap.push(point.x);
}
graphPath.push.apply(graphPath, pathToPoint);
gap = false;
}
});
graphPath.xMap = xMap;
series.graphPath = graphPath;
return graphPath;
},
/**
* Draw the actual graph
*/
drawGraph: function() {
var series = this,
options = this.options,
graphPath = (this.gappedPath || this.getGraphPath).call(this),
props = [
[
'graph',
'highcharts-graph',
options.lineColor || this.color,
options.dashStyle
]
];
// Add the zone properties if any
each(this.zones, function(zone, i) {
props.push([
'zone-graph-' + i,
'highcharts-graph highcharts-zone-graph-' + i + ' ' + (zone.className || ''),
zone.color || series.color,
zone.dashStyle || options.dashStyle
]);
});
// Draw the graph
each(props, function(prop, i) {
var graphKey = prop[0],
graph = series[graphKey],
attribs;
if (graph) {
graph.endX = graphPath.xMap;
graph.animate({
d: graphPath
});
} else if (graphPath.length) { // #1487
series[graphKey] = series.chart.renderer.path(graphPath)
.addClass(prop[1])
.attr({
zIndex: 1
}) // #1069
.add(series.group);
attribs = {
'stroke': prop[2],
'stroke-width': options.lineWidth,
'fill': (series.fillGraph && series.color) || 'none' // Polygon series use filled graph
};
if (prop[3]) {
attribs.dashstyle = prop[3];
} else if (options.linecap !== 'square') {
attribs['stroke-linecap'] = attribs['stroke-linejoin'] = 'round';
}
graph = series[graphKey]
.attr(attribs)
.shadow((i < 2) && options.shadow); // add shadow to normal series (0) or to first zone (1) #3932
}
// Helpers for animation
if (graph) {
graph.startX = graphPath.xMap;
//graph.shiftUnit = options.step ? 2 : 1;
graph.isArea = graphPath.isArea; // For arearange animation
}
});
},
/**
* Clip the graphs into the positive and negative coloured graphs
*/
applyZones: function() {
var series = this,
chart = this.chart,
renderer = chart.renderer,
zones = this.zones,
translatedFrom,
translatedTo,
clips = this.clips || [],
clipAttr,
graph = this.graph,
area = this.area,
chartSizeMax = Math.max(chart.chartWidth, chart.chartHeight),
axis = this[(this.zoneAxis || 'y') + 'Axis'],
extremes,
reversed,
inverted = chart.inverted,
horiz,
pxRange,
pxPosMin,
pxPosMax,
ignoreZones = false;
if (zones.length && (graph || area) && axis && axis.min !== undefined) {
reversed = axis.reversed;
horiz = axis.horiz;
// The use of the Color Threshold assumes there are no gaps
// so it is safe to hide the original graph and area
if (graph) {
graph.hide();
}
if (area) {
area.hide();
}
// Create the clips
extremes = axis.getExtremes();
each(zones, function(threshold, i) {
translatedFrom = reversed ?
(horiz ? chart.plotWidth : 0) :
(horiz ? 0 : axis.toPixels(extremes.min));
translatedFrom = Math.min(Math.max(pick(translatedTo, translatedFrom), 0), chartSizeMax);
translatedTo = Math.min(Math.max(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true)), 0), chartSizeMax);
if (ignoreZones) {
translatedFrom = translatedTo = axis.toPixels(extremes.max);
}
pxRange = Math.abs(translatedFrom - translatedTo);
pxPosMin = Math.min(translatedFrom, translatedTo);
pxPosMax = Math.max(translatedFrom, translatedTo);
if (axis.isXAxis) {
clipAttr = {
x: inverted ? pxPosMax : pxPosMin,
y: 0,
width: pxRange,
height: chartSizeMax
};
if (!horiz) {
clipAttr.x = chart.plotHeight - clipAttr.x;
}
} else {
clipAttr = {
x: 0,
y: inverted ? pxPosMax : pxPosMin,
width: chartSizeMax,
height: pxRange
};
if (horiz) {
clipAttr.y = chart.plotWidth - clipAttr.y;
}
}
/// VML SUPPPORT
if (inverted && renderer.isVML) {
if (axis.isXAxis) {
clipAttr = {
x: 0,
y: reversed ? pxPosMin : pxPosMax,
height: clipAttr.width,
width: chart.chartWidth
};
} else {
clipAttr = {
x: clipAttr.y - chart.plotLeft - chart.spacingBox.x,
y: 0,
width: clipAttr.height,
height: chart.chartHeight
};
}
}
/// END OF VML SUPPORT
if (clips[i]) {
clips[i].animate(clipAttr);
} else {
clips[i] = renderer.clipRect(clipAttr);
if (graph) {
series['zone-graph-' + i].clip(clips[i]);
}
if (area) {
series['zone-area-' + i].clip(clips[i]);
}
}
// if this zone extends out of the axis, ignore the others
ignoreZones = threshold.value > extremes.max;
});
this.clips = clips;
}
},
/**
* Initialize and perform group inversion on series.group and series.markerGroup
*/
invertGroups: function(inverted) {
var series = this,
chart = series.chart,
remover;
function setInvert() {
each(['group', 'markerGroup'], function(groupName) {
if (series[groupName]) {
// VML/HTML needs explicit attributes for flipping
if (chart.renderer.isVML) {
series[groupName].attr({
width: series.yAxis.len,
height: series.xAxis.len
});
}
series[groupName].width = series.yAxis.len;
series[groupName].height = series.xAxis.len;
series[groupName].invert(inverted);
}
});
}
// Pie, go away (#1736)
if (!series.xAxis) {
return;
}
// A fixed size is needed for inversion to work
remover = addEvent(chart, 'resize', setInvert);
addEvent(series, 'destroy', remover);
// Do it now
setInvert(inverted); // do it now
// On subsequent render and redraw, just do setInvert without setting up events again
series.invertGroups = setInvert;
},
/**
* General abstraction for creating plot groups like series.group, series.dataLabelsGroup and
* series.markerGroup. On subsequent calls, the group will only be adjusted to the updated plot size.
*/
plotGroup: function(prop, name, visibility, zIndex, parent) {
var group = this[prop],
isNew = !group;
// Generate it on first call
if (isNew) {
this[prop] = group = this.chart.renderer.g(name)
.attr({
zIndex: zIndex || 0.1 // IE8 and pointer logic use this
})
.add(parent);
group.addClass('highcharts-series-' + this.index + ' highcharts-' + this.type + '-series highcharts-color-' + this.colorIndex +
' ' + (this.options.className || ''));
}
// Place it on first and subsequent (redraw) calls
group.attr({
visibility: visibility
})[isNew ? 'attr' : 'animate'](this.getPlotBox());
return group;
},
/**
* Get the translation and scale for the plot area of this series
*/
getPlotBox: function() {
var chart = this.chart,
xAxis = this.xAxis,
yAxis = this.yAxis;
// Swap axes for inverted (#2339)
if (chart.inverted) {
xAxis = yAxis;
yAxis = this.xAxis;
}
return {
translateX: xAxis ? xAxis.left : chart.plotLeft,
translateY: yAxis ? yAxis.top : chart.plotTop,
scaleX: 1, // #1623
scaleY: 1
};
},
/**
* Render the graph and markers
*/
render: function() {
var series = this,
chart = series.chart,
group,
options = series.options,
// Animation doesn't work in IE8 quirks when the group div is hidden,
// and looks bad in other oldIE
animDuration = !!series.animate && chart.renderer.isSVG && animObject(options.animation).duration,
visibility = series.visible ? 'inherit' : 'hidden', // #2597
zIndex = options.zIndex,
hasRendered = series.hasRendered,
chartSeriesGroup = chart.seriesGroup,
inverted = chart.inverted;
// the group
group = series.plotGroup(
'group',
'series',
visibility,
zIndex,
chartSeriesGroup
);
series.markerGroup = series.plotGroup(
'markerGroup',
'markers',
visibility,
zIndex,
chartSeriesGroup
);
// initiate the animation
if (animDuration) {
series.animate(true);
}
// SVGRenderer needs to know this before drawing elements (#1089, #1795)
group.inverted = series.isCartesian ? inverted : false;
// draw the graph if any
if (series.drawGraph) {
series.drawGraph();
series.applyZones();
}
/* each(series.points, function (point) {
if (point.redraw) {
point.redraw();
}
});*/
// draw the data labels (inn pies they go before the points)
if (series.drawDataLabels) {
series.drawDataLabels();
}
// draw the points
if (series.visible) {
series.drawPoints();
}
// draw the mouse tracking area
if (series.drawTracker && series.options.enableMouseTracking !== false) {
series.drawTracker();
}
// Handle inverted series and tracker groups
series.invertGroups(inverted);
// Initial clipping, must be defined after inverting groups for VML. Applies to columns etc. (#3839).
if (options.clip !== false && !series.sharedClipKey && !hasRendered) {
group.clip(chart.clipRect);
}
// Run the animation
if (animDuration) {
series.animate();
}
// Call the afterAnimate function on animation complete (but don't overwrite the animation.complete option
// which should be available to the user).
if (!hasRendered) {
series.animationTimeout = syncTimeout(function() {
series.afterAnimate();
}, animDuration);
}
series.isDirty = false; // means data is in accordance with what you see
// (See #322) series.isDirty = series.isDirtyData = false; // means data is in accordance with what you see
series.hasRendered = true;
},
/**
* Redraw the series after an update in the axes.
*/
redraw: function() {
var series = this,
chart = series.chart,
wasDirty = series.isDirty || series.isDirtyData, // cache it here as it is set to false in render, but used after
group = series.group,
xAxis = series.xAxis,
yAxis = series.yAxis;
// reposition on resize
if (group) {
if (chart.inverted) {
group.attr({
width: chart.plotWidth,
height: chart.plotHeight
});
}
group.animate({
translateX: pick(xAxis && xAxis.left, chart.plotLeft),
translateY: pick(yAxis && yAxis.top, chart.plotTop)
});
}
series.translate();
series.render();
if (wasDirty) { // #3868, #3945
delete this.kdTree;
}
},
/**
* KD Tree && PointSearching Implementation
*/
kdAxisArray: ['clientX', 'plotY'],
searchPoint: function(e, compareX) {
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis,
inverted = series.chart.inverted;
return this.searchKDTree({
clientX: inverted ? xAxis.len - e.chartY + xAxis.pos : e.chartX - xAxis.pos,
plotY: inverted ? yAxis.len - e.chartX + yAxis.pos : e.chartY - yAxis.pos
}, compareX);
},
/**
* Build the k-d-tree that is used by mouse and touch interaction to get the
* closest point. Line-like series typically have a one-dimensional tree
* where points are searched along the X axis, while scatter-like series
* typically search in two dimensions, X and Y.
*/
buildKDTree: function() {
// Prevent multiple k-d-trees from being built simultaneously (#6235)
this.buildingKdTree = true;
var series = this,
dimensions = series.options.findNearestPointBy.indexOf('y') > -1 ?
2 : 1;
// Internal function
function _kdtree(points, depth, dimensions) {
var axis,
median,
length = points && points.length;
if (length) {
// alternate between the axis
axis = series.kdAxisArray[depth % dimensions];
// sort point array
points.sort(function(a, b) {
return a[axis] - b[axis];
});
median = Math.floor(length / 2);
// build and return nod
return {
point: points[median],
left: _kdtree(points.slice(0, median), depth + 1, dimensions),
right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
};
}
}
// Start the recursive build process with a clone of the points array and null points filtered out (#3873)
function startRecursive() {
series.kdTree = _kdtree(
series.getValidPoints(
null, !series.directTouch // For line-type series restrict to plot area, but column-type series not (#3916, #4511)
),
dimensions,
dimensions
);
series.buildingKdTree = false;
}
delete series.kdTree;
// For testing tooltips, don't build async
syncTimeout(startRecursive, series.options.kdNow ? 0 : 1);
},
searchKDTree: function(point, compareX) {
var series = this,
kdX = this.kdAxisArray[0],
kdY = this.kdAxisArray[1],
kdComparer = compareX ? 'distX' : 'dist',
kdDimensions = series.options.findNearestPointBy.indexOf('y') > -1 ?
2 : 1;
// Set the one and two dimensional distance on the point object
function setDistance(p1, p2) {
var x = (defined(p1[kdX]) && defined(p2[kdX])) ? Math.pow(p1[kdX] - p2[kdX], 2) : null,
y = (defined(p1[kdY]) && defined(p2[kdY])) ? Math.pow(p1[kdY] - p2[kdY], 2) : null,
r = (x || 0) + (y || 0);
p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
}
function _search(search, tree, depth, dimensions) {
var point = tree.point,
axis = series.kdAxisArray[depth % dimensions],
tdist,
sideA,
sideB,
ret = point,
nPoint1,
nPoint2;
setDistance(search, point);
// Pick side based on distance to splitting point
tdist = search[axis] - point[axis];
sideA = tdist < 0 ? 'left' : 'right';
sideB = tdist < 0 ? 'right' : 'left';
// End of tree
if (tree[sideA]) {
nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
ret = (nPoint1[kdComparer] < ret[kdComparer] ? nPoint1 : point);
}
if (tree[sideB]) {
// compare distance to current best to splitting point to decide wether to check side B or not
if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
ret = (nPoint2[kdComparer] < ret[kdComparer] ? nPoint2 : ret);
}
}
return ret;
}
if (!this.kdTree && !this.buildingKdTree) {
this.buildKDTree();
}
if (this.kdTree) {
return _search(point, this.kdTree, kdDimensions, kdDimensions);
}
}
}); // end Series prototype
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animate = H.animate,
Axis = H.Axis,
Chart = H.Chart,
createElement = H.createElement,
css = H.css,
defined = H.defined,
each = H.each,
erase = H.erase,
extend = H.extend,
fireEvent = H.fireEvent,
inArray = H.inArray,
isNumber = H.isNumber,
isObject = H.isObject,
merge = H.merge,
pick = H.pick,
Point = H.Point,
Series = H.Series,
seriesTypes = H.seriesTypes,
setAnimation = H.setAnimation,
splat = H.splat;
// Extend the Chart prototype for dynamic methods
extend(Chart.prototype, /** @lends Highcharts.Chart.prototype */ {
/**
* Add a series dynamically after time
*
* @param {Object} options The config options
* @param {Boolean} redraw Whether to redraw the chart after adding. Defaults to true.
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*
* @return {Object} series The newly created series object
*/
addSeries: function(options, redraw, animation) {
var series,
chart = this;
if (options) {
redraw = pick(redraw, true); // defaults to true
fireEvent(chart, 'addSeries', {
options: options
}, function() {
series = chart.initSeries(options);
chart.isDirtyLegend = true; // the series array is out of sync with the display
chart.linkSeries();
if (redraw) {
chart.redraw(animation);
}
});
}
return series;
},
/**
* Add an axis to the chart
* @param {Object} options The axis option
* @param {Boolean} isX Whether it is an X axis or a value axis
*/
addAxis: function(options, isX, redraw, animation) {
var key = isX ? 'xAxis' : 'yAxis',
chartOptions = this.options,
userOptions = merge(options, {
index: this[key].length,
isX: isX
});
new Axis(this, userOptions); // eslint-disable-line no-new
// Push the new axis options to the chart options
chartOptions[key] = splat(chartOptions[key] || {});
chartOptions[key].push(userOptions);
if (pick(redraw, true)) {
this.redraw(animation);
}
},
/**
* Dim the chart and show a loading text or symbol
* @param {String} str An optional text to show in the loading label instead of the default one
*/
showLoading: function(str) {
var chart = this,
options = chart.options,
loadingDiv = chart.loadingDiv,
loadingOptions = options.loading,
setLoadingSize = function() {
if (loadingDiv) {
css(loadingDiv, {
left: chart.plotLeft + 'px',
top: chart.plotTop + 'px',
width: chart.plotWidth + 'px',
height: chart.plotHeight + 'px'
});
}
};
// create the layer at the first call
if (!loadingDiv) {
chart.loadingDiv = loadingDiv = createElement('div', {
className: 'highcharts-loading highcharts-loading-hidden'
}, null, chart.container);
chart.loadingSpan = createElement(
'span', {
className: 'highcharts-loading-inner'
},
null,
loadingDiv
);
addEvent(chart, 'redraw', setLoadingSize); // #1080
}
loadingDiv.className = 'highcharts-loading';
// Update text
chart.loadingSpan.innerHTML = str || options.lang.loading;
// Update visuals
css(loadingDiv, extend(loadingOptions.style, {
zIndex: 10
}));
css(chart.loadingSpan, loadingOptions.labelStyle);
// Show it
if (!chart.loadingShown) {
css(loadingDiv, {
opacity: 0,
display: ''
});
animate(loadingDiv, {
opacity: loadingOptions.style.opacity || 0.5
}, {
duration: loadingOptions.showDuration || 0
});
}
chart.loadingShown = true;
setLoadingSize();
},
/**
* Hide the loading layer
*/
hideLoading: function() {
var options = this.options,
loadingDiv = this.loadingDiv;
if (loadingDiv) {
loadingDiv.className = 'highcharts-loading highcharts-loading-hidden';
animate(loadingDiv, {
opacity: 0
}, {
duration: options.loading.hideDuration || 100,
complete: function() {
css(loadingDiv, {
display: 'none'
});
}
});
}
this.loadingShown = false;
},
/**
* These properties cause isDirtyBox to be set to true when updating. Can be extended from plugins.
*/
propsRequireDirtyBox: ['backgroundColor', 'borderColor', 'borderWidth', 'margin', 'marginTop', 'marginRight',
'marginBottom', 'marginLeft', 'spacing', 'spacingTop', 'spacingRight', 'spacingBottom', 'spacingLeft',
'borderRadius', 'plotBackgroundColor', 'plotBackgroundImage', 'plotBorderColor', 'plotBorderWidth',
'plotShadow', 'shadow'
],
/**
* These properties cause all series to be updated when updating. Can be
* extended from plugins.
*/
propsRequireUpdateSeries: ['chart.inverted', 'chart.polar',
'chart.ignoreHiddenSeries', 'chart.type', 'colors', 'plotOptions'
],
/**
* Chart.update function that takes the whole options stucture.
*/
update: function(options, redraw) {
var key,
adders = {
credits: 'addCredits',
title: 'setTitle',
subtitle: 'setSubtitle'
},
optionsChart = options.chart,
updateAllAxes,
updateAllSeries,
newWidth,
newHeight;
// If the top-level chart option is present, some special updates are required
if (optionsChart) {
merge(true, this.options.chart, optionsChart);
// Setter function
if ('className' in optionsChart) {
this.setClassName(optionsChart.className);
}
if ('inverted' in optionsChart || 'polar' in optionsChart) {
// Parse options.chart.inverted and options.chart.polar together
// with the available series.
this.propFromSeries();
updateAllAxes = true;
}
if ('alignTicks' in optionsChart) { // #6452
updateAllAxes = true;
}
for (key in optionsChart) {
if (optionsChart.hasOwnProperty(key)) {
if (inArray('chart.' + key, this.propsRequireUpdateSeries) !== -1) {
updateAllSeries = true;
}
// Only dirty box
if (inArray(key, this.propsRequireDirtyBox) !== -1) {
this.isDirtyBox = true;
}
}
}
if ('style' in optionsChart) {
this.renderer.setStyle(optionsChart.style);
}
}
// Some option stuctures correspond one-to-one to chart objects that have
// update methods, for example
// options.credits => chart.credits
// options.legend => chart.legend
// options.title => chart.title
// options.tooltip => chart.tooltip
// options.subtitle => chart.subtitle
// options.mapNavigation => chart.mapNavigation
// options.navigator => chart.navigator
// options.scrollbar => chart.scrollbar
for (key in options) {
if (this[key] && typeof this[key].update === 'function') {
this[key].update(options[key], false);
// If a one-to-one object does not exist, look for an adder function
} else if (typeof this[adders[key]] === 'function') {
this[adders[key]](options[key]);
}
if (key !== 'chart' && inArray(key, this.propsRequireUpdateSeries) !== -1) {
updateAllSeries = true;
}
}
if (options.colors) {
this.options.colors = options.colors;
}
if (options.plotOptions) {
merge(true, this.options.plotOptions, options.plotOptions);
}
// Setters for collections. For axes and series, each item is referred
// by an id. If the id is not found, it defaults to the corresponding
// item in the collection, so setting one series without an id, will
// update the first series in the chart. Setting two series without
// an id will update the first and the second respectively (#6019)
// chart.update and responsive.
each(['xAxis', 'yAxis', 'series', 'colorAxis', 'pane'], function(coll) {
if (options[coll]) {
each(splat(options[coll]), function(newOptions, i) {
var item = (
defined(newOptions.id) &&
this.get(newOptions.id)
) || this[coll][i];
if (item && item.coll === coll) {
item.update(newOptions, false);
}
}, this);
}
}, this);
if (updateAllAxes) {
each(this.axes, function(axis) {
axis.update({}, false);
});
}
// Certain options require the whole series structure to be thrown away
// and rebuilt
if (updateAllSeries) {
each(this.series, function(series) {
series.update({}, false);
});
}
// For loading, just update the options, do not redraw
if (options.loading) {
merge(true, this.options.loading, options.loading);
}
// Update size. Redraw is forced.
newWidth = optionsChart && optionsChart.width;
newHeight = optionsChart && optionsChart.height;
if ((isNumber(newWidth) && newWidth !== this.chartWidth) ||
(isNumber(newHeight) && newHeight !== this.chartHeight)) {
this.setSize(newWidth, newHeight);
} else if (pick(redraw, true)) {
this.redraw();
}
},
/**
* Setter function to allow use from chart.update
*/
setSubtitle: function(options) {
this.setTitle(undefined, options);
}
});
// extend the Point prototype for dynamic methods
extend(Point.prototype, /** @lends Point.prototype */ {
/**
* Point.update with new options (typically x/y data) and optionally redraw the series.
*
* @param {Object} options Point options as defined in the series.data array
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
update: function(options, redraw, animation, runEvent) {
var point = this,
series = point.series,
graphic = point.graphic,
i,
chart = series.chart,
seriesOptions = series.options;
redraw = pick(redraw, true);
function update() {
point.applyOptions(options);
// Update visuals
if (point.y === null && graphic) { // #4146
point.graphic = graphic.destroy();
}
if (isObject(options, true)) {
// Destroy so we can get new elements
if (graphic && graphic.element) {
if (options && options.marker && options.marker.symbol) {
point.graphic = graphic.destroy();
}
}
if (options && options.dataLabels && point.dataLabel) { // #2468
point.dataLabel = point.dataLabel.destroy();
}
}
// record changes in the parallel arrays
i = point.index;
series.updateParallelArrays(point, i);
// Record the options to options.data. If the old or the new config
// is an object, use point options, otherwise use raw options
// (#4701, #4916).
seriesOptions.data[i] = (
isObject(seriesOptions.data[i], true) ||
isObject(options, true)
) ?
point.options :
options;
// redraw
series.isDirty = series.isDirtyData = true;
if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
chart.isDirtyBox = true;
}
if (seriesOptions.legendType === 'point') { // #1831, #1885
chart.isDirtyLegend = true;
}
if (redraw) {
chart.redraw(animation);
}
}
// Fire the event with a default handler of doing the update
if (runEvent === false) { // When called from setData
update();
} else {
point.firePointEvent('update', {
options: options
}, update);
}
},
/**
* Remove a point and optionally redraw the series and if necessary the axes
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
remove: function(redraw, animation) {
this.series.removePoint(inArray(this, this.series.data), redraw, animation);
}
});
// Extend the series prototype for dynamic methods
extend(Series.prototype, /** @lends Series.prototype */ {
/**
* Add a point dynamically after chart load time
* @param {Object} options Point options as given in series.data
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean} shift If shift is true, a point is shifted off the start
* of the series as one is appended to the end.
* @param {Boolean|AnimationOptions} animation Whether to apply animation, and optionally animation
* configuration
*/
addPoint: function(options, redraw, shift, animation) {
var series = this,
seriesOptions = series.options,
data = series.data,
chart = series.chart,
xAxis = series.xAxis,
names = xAxis && xAxis.hasNames && xAxis.names,
dataOptions = seriesOptions.data,
point,
isInTheMiddle,
xData = series.xData,
i,
x;
// Optional redraw, defaults to true
redraw = pick(redraw, true);
// Get options and push the point to xData, yData and series.options. In series.generatePoints
// the Point instance will be created on demand and pushed to the series.data array.
point = {
series: series
};
series.pointClass.prototype.applyOptions.apply(point, [options]);
x = point.x;
// Get the insertion point
i = xData.length;
if (series.requireSorting && x < xData[i - 1]) {
isInTheMiddle = true;
while (i && xData[i - 1] > x) {
i--;
}
}
series.updateParallelArrays(point, 'splice', i, 0, 0); // insert undefined item
series.updateParallelArrays(point, i); // update it
if (names && point.name) {
names[x] = point.name;
}
dataOptions.splice(i, 0, options);
if (isInTheMiddle) {
series.data.splice(i, 0, null);
series.processData();
}
// Generate points to be added to the legend (#1329)
if (seriesOptions.legendType === 'point') {
series.generatePoints();
}
// Shift the first point off the parallel arrays
if (shift) {
if (data[0] && data[0].remove) {
data[0].remove(false);
} else {
data.shift();
series.updateParallelArrays(point, 'shift');
dataOptions.shift();
}
}
// redraw
series.isDirty = true;
series.isDirtyData = true;
if (redraw) {
chart.redraw(animation); // Animation is set anyway on redraw, #5665
}
},
/**
* Remove a point (rendered or not), by index
*/
removePoint: function(i, redraw, animation) {
var series = this,
data = series.data,
point = data[i],
points = series.points,
chart = series.chart,
remove = function() {
if (points && points.length === data.length) { // #4935
points.splice(i, 1);
}
data.splice(i, 1);
series.options.data.splice(i, 1);
series.updateParallelArrays(point || {
series: series
}, 'splice', i, 1);
if (point) {
point.destroy();
}
// redraw
series.isDirty = true;
series.isDirtyData = true;
if (redraw) {
chart.redraw();
}
};
setAnimation(animation, chart);
redraw = pick(redraw, true);
// Fire the event with a default handler of removing the point
if (point) {
point.firePointEvent('remove', null, remove);
} else {
remove();
}
},
/**
* Remove a series and optionally redraw the chart
*
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
remove: function(redraw, animation, withEvent) {
var series = this,
chart = series.chart;
function remove() {
// Destroy elements
series.destroy();
// Redraw
chart.isDirtyLegend = chart.isDirtyBox = true;
chart.linkSeries();
if (pick(redraw, true)) {
chart.redraw(animation);
}
}
// Fire the event with a default handler of removing the point
if (withEvent !== false) {
fireEvent(series, 'remove', null, remove);
} else {
remove();
}
},
/**
* Series.update with a new set of options
*/
update: function(newOptions, redraw) {
var series = this,
chart = this.chart,
// must use user options when changing type because this.options is merged
// in with type specific plotOptions
oldOptions = this.userOptions,
oldType = this.oldType || this.type,
newType = newOptions.type || oldOptions.type || chart.options.chart.type,
proto = seriesTypes[oldType].prototype,
preserve = ['group', 'markerGroup', 'dataLabelsGroup'],
n;
// If we're changing type or zIndex, create new groups (#3380, #3404)
if ((newType && newType !== oldType) || newOptions.zIndex !== undefined) {
preserve.length = 0;
}
// Make sure groups are not destroyed (#3094)
each(preserve, function(prop) {
preserve[prop] = series[prop];
delete series[prop];
});
// Do the merge, with some forced options
newOptions = merge(oldOptions, {
animation: false,
index: this.index,
pointStart: this.xData[0] // when updating after addPoint
}, {
data: this.options.data
}, newOptions);
// Destroy the series and delete all properties. Reinsert all methods
// and properties from the new type prototype (#2270, #3719)
this.remove(false, null, false);
for (n in proto) {
this[n] = undefined;
}
extend(this, seriesTypes[newType || oldType].prototype);
// Re-register groups (#3094)
each(preserve, function(prop) {
series[prop] = preserve[prop];
});
this.init(chart, newOptions);
this.oldType = oldType;
chart.linkSeries(); // Links are lost in this.remove (#3028)
if (pick(redraw, true)) {
chart.redraw(false);
}
}
});
// Extend the Axis.prototype for dynamic methods
extend(Axis.prototype, /** @lends Axis.prototype */ {
/**
* Axis.update with a new options structure
*/
update: function(newOptions, redraw) {
var chart = this.chart;
newOptions = chart.options[this.coll][this.options.index] = merge(this.userOptions, newOptions);
this.destroy(true);
this.init(chart, extend(newOptions, {
events: undefined
}));
chart.isDirtyBox = true;
if (pick(redraw, true)) {
chart.redraw();
}
},
/**
* Remove the axis from the chart
*/
remove: function(redraw) {
var chart = this.chart,
key = this.coll, // xAxis or yAxis
axisSeries = this.series,
i = axisSeries.length;
// Remove associated series (#2687)
while (i--) {
if (axisSeries[i]) {
axisSeries[i].remove(false);
}
}
// Remove the axis
erase(chart.axes, this);
erase(chart[key], this);
chart.options[key].splice(this.options.index, 1);
each(chart[key], function(axis, i) { // Re-index, #1706
axis.options.index = i;
});
this.destroy();
chart.isDirtyBox = true;
if (pick(redraw, true)) {
chart.redraw();
}
},
/**
* Update the axis title by options
*/
setTitle: function(newTitleOptions, redraw) {
this.update({
title: newTitleOptions
}, redraw);
},
/**
* Set new axis categories and optionally redraw
* @param {Array} categories
* @param {Boolean} redraw
*/
setCategories: function(categories, redraw) {
this.update({
categories: categories
}, redraw);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var animObject = H.animObject,
color = H.color,
each = H.each,
extend = H.extend,
isNumber = H.isNumber,
LegendSymbolMixin = H.LegendSymbolMixin,
merge = H.merge,
noop = H.noop,
pick = H.pick,
Series = H.Series,
seriesType = H.seriesType,
svg = H.svg;
/**
* The column series type.
*
* @constructor seriesTypes.column
* @augments Series
*/
seriesType('column', 'line', {
borderRadius: 0,
//colorByPoint: undefined,
crisp: true,
groupPadding: 0.2,
//grouping: true,
marker: null, // point options are specified in the base options
pointPadding: 0.1,
//pointWidth: null,
minPointLength: 0,
cropThreshold: 50, // when there are more points, they will not animate out of the chart on xAxis.setExtremes
pointRange: null, // null means auto, meaning 1 in a categorized axis and least distance between points if not categories
states: {
hover: {
halo: false,
brightness: 0.1,
shadow: false
},
select: {
color: '#cccccc',
borderColor: '#000000',
shadow: false
}
},
dataLabels: {
align: null, // auto
verticalAlign: null, // auto
y: null
},
softThreshold: false,
startFromThreshold: true, // false doesn't work well: http://jsfiddle.net/highcharts/hz8fopan/14/
stickyTracking: false,
tooltip: {
distance: 6
},
threshold: 0,
borderColor: '#ffffff'
// borderWidth: 1
}, /** @lends seriesTypes.column.prototype */ {
cropShoulder: 0,
directTouch: true, // When tooltip is not shared, this series (and derivatives) requires direct touch/hover. KD-tree does not apply.
trackerGroups: ['group', 'dataLabelsGroup'],
negStacks: true, // use separate negative stacks, unlike area stacks where a negative
// point is substracted from previous (#1910)
/**
* Initialize the series. Extends the basic Series.init method by
* marking other series of the same type as dirty.
*
* @function #init
* @memberOf seriesTypes.column
* @returns {void}
*/
init: function() {
Series.prototype.init.apply(this, arguments);
var series = this,
chart = series.chart;
// if the series is added dynamically, force redraw of other
// series affected by a new column
if (chart.hasRendered) {
each(chart.series, function(otherSeries) {
if (otherSeries.type === series.type) {
otherSeries.isDirty = true;
}
});
}
},
/**
* Return the width and x offset of the columns adjusted for grouping, groupPadding, pointPadding,
* pointWidth etc.
*/
getColumnMetrics: function() {
var series = this,
options = series.options,
xAxis = series.xAxis,
yAxis = series.yAxis,
reversedXAxis = xAxis.reversed,
stackKey,
stackGroups = {},
columnCount = 0;
// Get the total number of column type series.
// This is called on every series. Consider moving this logic to a
// chart.orderStacks() function and call it on init, addSeries and removeSeries
if (options.grouping === false) {
columnCount = 1;
} else {
each(series.chart.series, function(otherSeries) {
var otherOptions = otherSeries.options,
otherYAxis = otherSeries.yAxis,
columnIndex;
if (otherSeries.type === series.type && otherSeries.visible &&
yAxis.len === otherYAxis.len && yAxis.pos === otherYAxis.pos) { // #642, #2086
if (otherOptions.stacking) {
stackKey = otherSeries.stackKey;
if (stackGroups[stackKey] === undefined) {
stackGroups[stackKey] = columnCount++;
}
columnIndex = stackGroups[stackKey];
} else if (otherOptions.grouping !== false) { // #1162
columnIndex = columnCount++;
}
otherSeries.columnIndex = columnIndex;
}
});
}
var categoryWidth = Math.min(
Math.abs(xAxis.transA) * (xAxis.ordinalSlope || options.pointRange || xAxis.closestPointRange || xAxis.tickInterval || 1), // #2610
xAxis.len // #1535
),
groupPadding = categoryWidth * options.groupPadding,
groupWidth = categoryWidth - 2 * groupPadding,
pointOffsetWidth = groupWidth / (columnCount || 1),
pointWidth = Math.min(
options.maxPointWidth || xAxis.len,
pick(options.pointWidth, pointOffsetWidth * (1 - 2 * options.pointPadding))
),
pointPadding = (pointOffsetWidth - pointWidth) / 2,
colIndex = (series.columnIndex || 0) + (reversedXAxis ? 1 : 0), // #1251, #3737
pointXOffset = pointPadding + (groupPadding + colIndex *
pointOffsetWidth - (categoryWidth / 2)) *
(reversedXAxis ? -1 : 1);
// Save it for reading in linked series (Error bars particularly)
series.columnMetrics = {
width: pointWidth,
offset: pointXOffset
};
return series.columnMetrics;
},
/**
* Make the columns crisp. The edges are rounded to the nearest full pixel.
*/
crispCol: function(x, y, w, h) {
var chart = this.chart,
borderWidth = this.borderWidth,
xCrisp = -(borderWidth % 2 ? 0.5 : 0),
yCrisp = borderWidth % 2 ? 0.5 : 1,
right,
bottom,
fromTop;
if (chart.inverted && chart.renderer.isVML) {
yCrisp += 1;
}
// Horizontal. We need to first compute the exact right edge, then round it
// and compute the width from there.
if (this.options.crisp) {
right = Math.round(x + w) + xCrisp;
x = Math.round(x) + xCrisp;
w = right - x;
}
// Vertical
bottom = Math.round(y + h) + yCrisp;
fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
y = Math.round(y) + yCrisp;
h = bottom - y;
// Top edges are exceptions
if (fromTop && h) { // #5146
y -= 1;
h += 1;
}
return {
x: x,
y: y,
width: w,
height: h
};
},
/**
* Translate each point to the plot area coordinate system and find shape positions
*/
translate: function() {
var series = this,
chart = series.chart,
options = series.options,
dense = series.dense = series.closestPointRange * series.xAxis.transA < 2,
borderWidth = series.borderWidth = pick(
options.borderWidth,
dense ? 0 : 1 // #3635
),
yAxis = series.yAxis,
threshold = options.threshold,
translatedThreshold = series.translatedThreshold = yAxis.getThreshold(threshold),
minPointLength = pick(options.minPointLength, 5),
metrics = series.getColumnMetrics(),
pointWidth = metrics.width,
seriesBarW = series.barW = Math.max(pointWidth, 1 + 2 * borderWidth), // postprocessed for border width
pointXOffset = series.pointXOffset = metrics.offset;
if (chart.inverted) {
translatedThreshold -= 0.5; // #3355
}
// When the pointPadding is 0, we want the columns to be packed tightly, so we allow individual
// columns to have individual sizes. When pointPadding is greater, we strive for equal-width
// columns (#2694).
if (options.pointPadding) {
seriesBarW = Math.ceil(seriesBarW);
}
Series.prototype.translate.apply(series);
// Record the new values
each(series.points, function(point) {
var yBottom = pick(point.yBottom, translatedThreshold),
safeDistance = 999 + Math.abs(yBottom),
plotY = Math.min(Math.max(-safeDistance, point.plotY), yAxis.len + safeDistance), // Don't draw too far outside plot area (#1303, #2241, #4264)
barX = point.plotX + pointXOffset,
barW = seriesBarW,
barY = Math.min(plotY, yBottom),
up,
barH = Math.max(plotY, yBottom) - barY;
// Handle options.minPointLength
if (Math.abs(barH) < minPointLength) {
if (minPointLength) {
barH = minPointLength;
up = (!yAxis.reversed && !point.negative) || (yAxis.reversed && point.negative);
barY = Math.abs(barY - translatedThreshold) > minPointLength ? // stacked
yBottom - minPointLength : // keep position
translatedThreshold - (up ? minPointLength : 0); // #1485, #4051
}
}
// Cache for access in polar
point.barX = barX;
point.pointWidth = pointWidth;
// Fix the tooltip on center of grouped columns (#1216, #424, #3648)
point.tooltipPos = chart.inverted ? [yAxis.len + yAxis.pos - chart.plotLeft - plotY, series.xAxis.len - barX - barW / 2, barH] : [barX + barW / 2, plotY + yAxis.pos - chart.plotTop, barH];
// Register shape type and arguments to be used in drawPoints
point.shapeType = 'rect';
point.shapeArgs = series.crispCol.apply(
series,
point.isNull ? [point.plotX, yAxis.len / 2, 0, 0] : // #3169, drilldown from null must have a position to work from
[barX, barY, barW, barH]
);
});
},
getSymbol: noop,
/**
* Use a solid rectangle like the area series types
*/
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
/**
* Columns have no graph
*/
drawGraph: function() {
this.group[this.dense ? 'addClass' : 'removeClass']('highcharts-dense-data');
},
/**
* Get presentational attributes
*/
pointAttribs: function(point, state) {
var options = this.options,
stateOptions,
ret,
p2o = this.pointAttrToOptions || {},
strokeOption = p2o.stroke || 'borderColor',
strokeWidthOption = p2o['stroke-width'] || 'borderWidth',
fill = (point && point.color) || this.color,
stroke = point[strokeOption] || options[strokeOption] ||
this.color || fill, // set to fill when borderColor null
strokeWidth = point[strokeWidthOption] ||
options[strokeWidthOption] || this[strokeWidthOption] || 0,
dashstyle = options.dashStyle,
zone,
brightness;
// Handle zone colors
if (point && this.zones.length) {
zone = point.getZone();
fill = (zone && zone.color) || point.options.color || this.color; // When zones are present, don't use point.color (#4267)
}
// Select or hover states
if (state) {
stateOptions = merge(
options.states[state],
point.options.states && point.options.states[state] || {} // #6401
);
brightness = stateOptions.brightness;
fill = stateOptions.color ||
(brightness !== undefined && color(fill).brighten(stateOptions.brightness).get()) ||
fill;
stroke = stateOptions[strokeOption] || stroke;
strokeWidth = stateOptions[strokeWidthOption] || strokeWidth;
dashstyle = stateOptions.dashStyle || dashstyle;
}
ret = {
'fill': fill,
'stroke': stroke,
'stroke-width': strokeWidth
};
if (options.borderRadius) {
ret.r = options.borderRadius;
}
if (dashstyle) {
ret.dashstyle = dashstyle;
}
return ret;
},
/**
* Draw the columns. For bars, the series.group is rotated, so the same coordinates
* apply for columns and bars. This method is inherited by scatter series.
*
*/
drawPoints: function() {
var series = this,
chart = this.chart,
options = series.options,
renderer = chart.renderer,
animationLimit = options.animationLimit || 250,
shapeArgs;
// draw the columns
each(series.points, function(point) {
var plotY = point.plotY,
graphic = point.graphic;
if (isNumber(plotY) && point.y !== null) {
shapeArgs = point.shapeArgs;
if (graphic) { // update
graphic[chart.pointCount < animationLimit ? 'animate' : 'attr'](
merge(shapeArgs)
);
} else {
point.graphic = graphic = renderer[point.shapeType](shapeArgs)
.add(point.group || series.group);
}
// Presentational
graphic
.attr(series.pointAttribs(point, point.selected && 'select'))
.shadow(options.shadow, null, options.stacking && !options.borderRadius);
graphic.addClass(point.getClassName(), true);
} else if (graphic) {
point.graphic = graphic.destroy(); // #1269
}
});
},
/**
* Animate the column heights one by one from zero
* @param {Boolean} init Whether to initialize the animation or run it
*/
animate: function(init) {
var series = this,
yAxis = this.yAxis,
options = series.options,
inverted = this.chart.inverted,
attr = {},
translatedThreshold;
if (svg) { // VML is too slow anyway
if (init) {
attr.scaleY = 0.001;
translatedThreshold = Math.min(yAxis.pos + yAxis.len, Math.max(yAxis.pos, yAxis.toPixels(options.threshold)));
if (inverted) {
attr.translateX = translatedThreshold - yAxis.len;
} else {
attr.translateY = translatedThreshold;
}
series.group.attr(attr);
} else { // run the animation
attr[inverted ? 'translateX' : 'translateY'] = yAxis.pos;
series.group.animate(attr, extend(animObject(series.options.animation), {
// Do the scale synchronously to ensure smooth updating (#5030)
step: function(val, fx) {
series.group.attr({
scaleY: Math.max(0.001, fx.pos) // #5250
});
}
}));
// delete this function to allow it only once
series.animate = null;
}
}
},
/**
* Remove this series from the chart
*/
remove: function() {
var series = this,
chart = series.chart;
// column and bar series affects other series of the same type
// as they are either stacked or grouped
if (chart.hasRendered) {
each(chart.series, function(otherSeries) {
if (otherSeries.type === series.type) {
otherSeries.isDirty = true;
}
});
}
Series.prototype.remove.apply(series, arguments);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Series = H.Series,
seriesType = H.seriesType;
/**
* The scatter series type
*/
seriesType('scatter', 'line', {
lineWidth: 0,
findNearestPointBy: 'xy',
marker: {
enabled: true // Overrides auto-enabling in line series (#3647)
},
tooltip: {
headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
'<span style="font-size: 0.85em"> {series.name}</span><br/>',
pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
}
// Prototype members
}, {
sorted: false,
requireSorting: false,
noSharedTooltip: true,
trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
takeOrdinalPosition: false, // #2342
drawGraph: function() {
if (this.options.lineWidth) {
Series.prototype.drawGraph.call(this);
}
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
arrayMax = H.arrayMax,
defined = H.defined,
each = H.each,
extend = H.extend,
format = H.format,
map = H.map,
merge = H.merge,
noop = H.noop,
pick = H.pick,
relativeLength = H.relativeLength,
Series = H.Series,
seriesTypes = H.seriesTypes,
stableSort = H.stableSort;
/**
* Generatl distribution algorithm for distributing labels of differing size along a
* confined length in two dimensions. The algorithm takes an array of objects containing
* a size, a target and a rank. It will place the labels as close as possible to their
* targets, skipping the lowest ranked labels if necessary.
*/
H.distribute = function(boxes, len) {
var i,
overlapping = true,
origBoxes = boxes, // Original array will be altered with added .pos
restBoxes = [], // The outranked overshoot
box,
target,
total = 0;
function sortByTarget(a, b) {
return a.target - b.target;
}
// If the total size exceeds the len, remove those boxes with the lowest rank
i = boxes.length;
while (i--) {
total += boxes[i].size;
}
// Sort by rank, then slice away overshoot
if (total > len) {
stableSort(boxes, function(a, b) {
return (b.rank || 0) - (a.rank || 0);
});
i = 0;
total = 0;
while (total <= len) {
total += boxes[i].size;
i++;
}
restBoxes = boxes.splice(i - 1, boxes.length);
}
// Order by target
stableSort(boxes, sortByTarget);
// So far we have been mutating the original array. Now
// create a copy with target arrays
boxes = map(boxes, function(box) {
return {
size: box.size,
targets: [box.target]
};
});
while (overlapping) {
// Initial positions: target centered in box
i = boxes.length;
while (i--) {
box = boxes[i];
// Composite box, average of targets
target = (Math.min.apply(0, box.targets) + Math.max.apply(0, box.targets)) / 2;
box.pos = Math.min(Math.max(0, target - box.size / 2), len - box.size);
}
// Detect overlap and join boxes
i = boxes.length;
overlapping = false;
while (i--) {
if (i > 0 && boxes[i - 1].pos + boxes[i - 1].size > boxes[i].pos) { // Overlap
boxes[i - 1].size += boxes[i].size; // Add this size to the previous box
boxes[i - 1].targets = boxes[i - 1].targets.concat(boxes[i].targets);
// Overlapping right, push left
if (boxes[i - 1].pos + boxes[i - 1].size > len) {
boxes[i - 1].pos = len - boxes[i - 1].size;
}
boxes.splice(i, 1); // Remove this item
overlapping = true;
}
}
}
// Now the composite boxes are placed, we need to put the original boxes within them
i = 0;
each(boxes, function(box) {
var posInCompositeBox = 0;
each(box.targets, function() {
origBoxes[i].pos = box.pos + posInCompositeBox;
posInCompositeBox += origBoxes[i].size;
i++;
});
});
// Add the rest (hidden) boxes and sort by target
origBoxes.push.apply(origBoxes, restBoxes);
stableSort(origBoxes, sortByTarget);
};
/**
* Draw the data labels
*/
Series.prototype.drawDataLabels = function() {
var series = this,
seriesOptions = series.options,
options = seriesOptions.dataLabels,
points = series.points,
pointOptions,
generalOptions,
hasRendered = series.hasRendered || 0,
str,
dataLabelsGroup,
defer = pick(options.defer, true),
renderer = series.chart.renderer;
if (options.enabled || series._hasPointLabels) {
// Process default alignment of data labels for columns
if (series.dlProcessOptions) {
series.dlProcessOptions(options);
}
// Create a separate group for the data labels to avoid rotation
dataLabelsGroup = series.plotGroup(
'dataLabelsGroup',
'data-labels',
defer && !hasRendered ? 'hidden' : 'visible', // #5133
options.zIndex || 6
);
if (defer) {
dataLabelsGroup.attr({
opacity: +hasRendered
}); // #3300
if (!hasRendered) {
addEvent(series, 'afterAnimate', function() {
if (series.visible) { // #2597, #3023, #3024
dataLabelsGroup.show(true);
}
dataLabelsGroup[seriesOptions.animation ? 'animate' : 'attr']({
opacity: 1
}, {
duration: 200
});
});
}
}
// Make the labels for each point
generalOptions = options;
each(points, function(point) {
var enabled,
dataLabel = point.dataLabel,
labelConfig,
attr,
name,
rotation,
connector = point.connector,
isNew = !dataLabel,
style;
// Determine if each data label is enabled
// @note dataLabelAttribs (like pointAttribs) would eradicate
// the need for dlOptions, and simplify the section below.
pointOptions = point.dlOptions || (point.options && point.options.dataLabels); // dlOptions is used in treemaps
enabled = pick(pointOptions && pointOptions.enabled, generalOptions.enabled) && point.y !== null; // #2282, #4641
if (enabled) {
// Create individual options structure that can be extended without
// affecting others
options = merge(generalOptions, pointOptions);
labelConfig = point.getLabelConfig();
str = options.format ?
format(options.format, labelConfig) :
options.formatter.call(labelConfig, options);
style = options.style;
rotation = options.rotation;
// Determine the color
style.color = pick(options.color, style.color, series.color, '#000000');
// Get automated contrast color
if (style.color === 'contrast') {
point.contrastColor = renderer.getContrast(point.color || series.color);
style.color = options.inside || options.distance < 0 || !!seriesOptions.stacking ?
point.contrastColor : '#000000';
}
if (seriesOptions.cursor) {
style.cursor = seriesOptions.cursor;
}
attr = {
//align: align,
fill: options.backgroundColor,
stroke: options.borderColor,
'stroke-width': options.borderWidth,
r: options.borderRadius || 0,
rotation: rotation,
padding: options.padding,
zIndex: 1
};
// Remove unused attributes (#947)
for (name in attr) {
if (attr[name] === undefined) {
delete attr[name];
}
}
}
// If the point is outside the plot area, destroy it. #678, #820
if (dataLabel && (!enabled || !defined(str))) {
point.dataLabel = dataLabel = dataLabel.destroy();
if (connector) {
point.connector = connector.destroy();
}
// Individual labels are disabled if the are explicitly disabled
// in the point options, or if they fall outside the plot area.
} else if (enabled && defined(str)) {
// create new label
if (!dataLabel) {
dataLabel = point.dataLabel = renderer[rotation ? 'text' : 'label']( // labels don't support rotation
str,
0, -9999,
options.shape,
null,
null,
options.useHTML,
null,
'data-label'
);
dataLabel.addClass(
'highcharts-data-label-color-' + point.colorIndex +
' ' + (options.className || '') +
(options.useHTML ? 'highcharts-tracker' : '') // #3398
);
} else {
attr.text = str;
}
dataLabel.attr(attr);
// Styles must be applied before add in order to read text bounding box
dataLabel.css(style).shadow(options.shadow);
if (!dataLabel.added) {
dataLabel.add(dataLabelsGroup);
}
// Now the data label is created and placed at 0,0, so we need to align it
series.alignDataLabel(point, dataLabel, options, null, isNew);
}
});
}
};
/**
* Align each individual data label
*/
Series.prototype.alignDataLabel = function(point, dataLabel, options, alignTo, isNew) {
var chart = this.chart,
inverted = chart.inverted,
plotX = pick(point.plotX, -9999),
plotY = pick(point.plotY, -9999),
bBox = dataLabel.getBBox(),
fontSize,
baseline,
rotation = options.rotation,
normRotation,
negRotation,
align = options.align,
rotCorr, // rotation correction
// Math.round for rounding errors (#2683), alignTo to allow column labels (#2700)
visible =
this.visible &&
(
point.series.forceDL ||
chart.isInsidePlot(plotX, Math.round(plotY), inverted) ||
(
alignTo && chart.isInsidePlot(
plotX,
inverted ? alignTo.x + 1 : alignTo.y + alignTo.height - 1,
inverted
)
)
),
alignAttr, // the final position;
justify = pick(options.overflow, 'justify') === 'justify';
if (visible) {
fontSize = options.style.fontSize;
baseline = chart.renderer.fontMetrics(fontSize, dataLabel).b;
// The alignment box is a singular point
alignTo = extend({
x: inverted ? chart.plotWidth - plotY : plotX,
y: Math.round(inverted ? chart.plotHeight - plotX : plotY),
width: 0,
height: 0
}, alignTo);
// Add the text size for alignment calculation
extend(options, {
width: bBox.width,
height: bBox.height
});
// Allow a hook for changing alignment in the last moment, then do the alignment
if (rotation) {
justify = false; // Not supported for rotated text
rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
alignAttr = {
x: alignTo.x + options.x + alignTo.width / 2 + rotCorr.x,
y: alignTo.y + options.y + {
top: 0,
middle: 0.5,
bottom: 1
}[options.verticalAlign] * alignTo.height
};
dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
.attr({ // #3003
align: align
});
// Compensate for the rotated label sticking out on the sides
normRotation = (rotation + 720) % 360;
negRotation = normRotation > 180 && normRotation < 360;
if (align === 'left') {
alignAttr.y -= negRotation ? bBox.height : 0;
} else if (align === 'center') {
alignAttr.x -= bBox.width / 2;
alignAttr.y -= bBox.height / 2;
} else if (align === 'right') {
alignAttr.x -= bBox.width;
alignAttr.y -= negRotation ? 0 : bBox.height;
}
} else {
dataLabel.align(options, null, alignTo);
alignAttr = dataLabel.alignAttr;
}
// Handle justify or crop
if (justify) {
point.isLabelJustified = this.justifyDataLabel(
dataLabel,
options,
alignAttr,
bBox,
alignTo,
isNew
);
// Now check that the data label is within the plot area
} else if (pick(options.crop, true)) {
visible = chart.isInsidePlot(alignAttr.x, alignAttr.y) && chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height);
}
// When we're using a shape, make it possible with a connector or an arrow pointing to thie point
if (options.shape && !rotation) {
dataLabel.attr({
anchorX: point.plotX,
anchorY: point.plotY
});
}
}
// Show or hide based on the final aligned position
if (!visible) {
dataLabel.attr({
y: -9999
});
dataLabel.placed = false; // don't animate back in
}
};
/**
* If data labels fall partly outside the plot area, align them back in, in a way that
* doesn't hide the point.
*/
Series.prototype.justifyDataLabel = function(dataLabel, options, alignAttr, bBox, alignTo, isNew) {
var chart = this.chart,
align = options.align,
verticalAlign = options.verticalAlign,
off,
justified,
padding = dataLabel.box ? 0 : (dataLabel.padding || 0);
// Off left
off = alignAttr.x + padding;
if (off < 0) {
if (align === 'right') {
options.align = 'left';
} else {
options.x = -off;
}
justified = true;
}
// Off right
off = alignAttr.x + bBox.width - padding;
if (off > chart.plotWidth) {
if (align === 'left') {
options.align = 'right';
} else {
options.x = chart.plotWidth - off;
}
justified = true;
}
// Off top
off = alignAttr.y + padding;
if (off < 0) {
if (verticalAlign === 'bottom') {
options.verticalAlign = 'top';
} else {
options.y = -off;
}
justified = true;
}
// Off bottom
off = alignAttr.y + bBox.height - padding;
if (off > chart.plotHeight) {
if (verticalAlign === 'top') {
options.verticalAlign = 'bottom';
} else {
options.y = chart.plotHeight - off;
}
justified = true;
}
if (justified) {
dataLabel.placed = !isNew;
dataLabel.align(options, null, alignTo);
}
return justified;
};
/**
* Override the base drawDataLabels method by pie specific functionality
*/
if (seriesTypes.pie) {
seriesTypes.pie.prototype.drawDataLabels = function() {
var series = this,
data = series.data,
point,
chart = series.chart,
options = series.options.dataLabels,
connectorPadding = pick(options.connectorPadding, 10),
connectorWidth = pick(options.connectorWidth, 1),
plotWidth = chart.plotWidth,
plotHeight = chart.plotHeight,
connector,
distanceOption = options.distance,
seriesCenter = series.center,
radius = seriesCenter[2] / 2,
centerY = seriesCenter[1],
outside = distanceOption > 0,
dataLabel,
dataLabelWidth,
labelPos,
labelHeight,
halves = [ // divide the points into right and left halves for anti collision
[], // right
[] // left
],
x,
y,
visibility,
j,
overflow = [0, 0, 0, 0]; // top, right, bottom, left
// get out if not enabled
if (!series.visible || (!options.enabled && !series._hasPointLabels)) {
return;
}
// Reset all labels that have been shortened
each(data, function(point) {
if (point.dataLabel && point.visible && point.dataLabel.shortened) {
point.dataLabel
.attr({
width: 'auto'
}).css({
width: 'auto',
textOverflow: 'clip'
});
point.dataLabel.shortened = false;
}
});
// run parent method
Series.prototype.drawDataLabels.apply(series);
each(data, function(point) {
if (point.dataLabel && point.visible) { // #407, #2510
// Arrange points for detection collision
halves[point.half].push(point);
// Reset positions (#4905)
point.dataLabel._pos = null;
}
});
/* Loop over the points in each half, starting from the top and bottom
* of the pie to detect overlapping labels.
*/
each(halves, function(points, i) {
var top,
bottom,
length = points.length,
positions,
naturalY,
sideOverflow,
size;
if (!length) {
return;
}
// Sort by angle
series.sortByAngle(points, i - 0.5);
// Only do anti-collision when we are outside the pie and have connectors (#856)
if (distanceOption > 0) {
top = Math.max(0, centerY - radius - distanceOption);
bottom = Math.min(centerY + radius + distanceOption, chart.plotHeight);
positions = map(points, function(point) {
if (point.dataLabel) {
size = point.dataLabel.getBBox().height || 21;
return {
target: point.labelPos[1] - top + size / 2,
size: size,
rank: point.y
};
}
});
H.distribute(positions, bottom + size - top);
}
// now the used slots are sorted, fill them up sequentially
for (j = 0; j < length; j++) {
point = points[j];
labelPos = point.labelPos;
dataLabel = point.dataLabel;
visibility = point.visible === false ? 'hidden' : 'inherit';
naturalY = labelPos[1];
if (positions) {
if (positions[j].pos === undefined) {
visibility = 'hidden';
} else {
labelHeight = positions[j].size;
y = top + positions[j].pos;
}
} else {
y = naturalY;
}
// get the x - use the natural x position for labels near the top and bottom, to prevent the top
// and botton slice connectors from touching each other on either side
if (options.justify) {
x = seriesCenter[0] + (i ? -1 : 1) * (radius + distanceOption);
} else {
x = series.getX(y < top + 2 || y > bottom - 2 ? naturalY : y, i);
}
// Record the placement and visibility
dataLabel._attr = {
visibility: visibility,
align: labelPos[6]
};
dataLabel._pos = {
x: x + options.x +
({
left: connectorPadding,
right: -connectorPadding
}[labelPos[6]] || 0),
y: y + options.y - 10 // 10 is for the baseline (label vs text)
};
labelPos.x = x;
labelPos.y = y;
// Detect overflowing data labels
if (series.options.size === null) {
dataLabelWidth = dataLabel.getBBox().width;
sideOverflow = null;
// Overflow left
if (x - dataLabelWidth < connectorPadding) {
sideOverflow = Math.round(
dataLabelWidth - x + connectorPadding
);
overflow[3] = Math.max(sideOverflow, overflow[3]);
// Overflow right
} else if (x + dataLabelWidth > plotWidth - connectorPadding) {
sideOverflow = Math.round(
x + dataLabelWidth - plotWidth + connectorPadding
);
overflow[1] = Math.max(sideOverflow, overflow[1]);
}
// Overflow top
if (y - labelHeight / 2 < 0) {
overflow[0] = Math.max(
Math.round(-y + labelHeight / 2),
overflow[0]
);
// Overflow left
} else if (y + labelHeight / 2 > plotHeight) {
overflow[2] = Math.max(
Math.round(y + labelHeight / 2 - plotHeight),
overflow[2]
);
}
dataLabel.sideOverflow = sideOverflow;
}
} // for each point
}); // for each half
// Do not apply the final placement and draw the connectors until we have verified
// that labels are not spilling over.
if (arrayMax(overflow) === 0 || this.verifyDataLabelOverflow(overflow)) {
// Place the labels in the final position
this.placeDataLabels();
// Draw the connectors
if (outside && connectorWidth) {
each(this.points, function(point) {
var isNew;
connector = point.connector;
dataLabel = point.dataLabel;
if (dataLabel && dataLabel._pos && point.visible) {
visibility = dataLabel._attr.visibility;
isNew = !connector;
if (isNew) {
point.connector = connector = chart.renderer.path()
.addClass('highcharts-data-label-connector highcharts-color-' + point.colorIndex)
.add(series.dataLabelsGroup);
connector.attr({
'stroke-width': connectorWidth,
'stroke': options.connectorColor || point.color || '#666666'
});
}
connector[isNew ? 'attr' : 'animate']({
d: series.connectorPath(point.labelPos)
});
connector.attr('visibility', visibility);
} else if (connector) {
point.connector = connector.destroy();
}
});
}
}
};
/**
* Extendable method for getting the path of the connector between the data label
* and the pie slice.
*/
seriesTypes.pie.prototype.connectorPath = function(labelPos) {
var x = labelPos.x,
y = labelPos.y;
return pick(this.options.dataLabels.softConnector, true) ? [
'M',
x + (labelPos[6] === 'left' ? 5 : -5), y, // end of the string at the label
'C',
x, y, // first break, next to the label
2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
labelPos[2], labelPos[3], // second break
'L',
labelPos[4], labelPos[5] // base
] : [
'M',
x + (labelPos[6] === 'left' ? 5 : -5), y, // end of the string at the label
'L',
labelPos[2], labelPos[3], // second break
'L',
labelPos[4], labelPos[5] // base
];
};
/**
* Perform the final placement of the data labels after we have verified that they
* fall within the plot area.
*/
seriesTypes.pie.prototype.placeDataLabels = function() {
each(this.points, function(point) {
var dataLabel = point.dataLabel,
_pos;
if (dataLabel && point.visible) {
_pos = dataLabel._pos;
if (_pos) {
// Shorten data labels with ellipsis if they still overflow
// after the pie has reached minSize (#223).
if (dataLabel.sideOverflow) {
dataLabel._attr.width =
dataLabel.getBBox().width - dataLabel.sideOverflow;
dataLabel.css({
width: dataLabel._attr.width + 'px',
textOverflow: 'ellipsis'
});
dataLabel.shortened = true;
}
dataLabel.attr(dataLabel._attr);
dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
dataLabel.moved = true;
} else if (dataLabel) {
dataLabel.attr({
y: -9999
});
}
}
}, this);
};
seriesTypes.pie.prototype.alignDataLabel = noop;
/**
* Verify whether the data labels are allowed to draw, or we should run more translation and data
* label positioning to keep them inside the plot area. Returns true when data labels are ready
* to draw.
*/
seriesTypes.pie.prototype.verifyDataLabelOverflow = function(overflow) {
var center = this.center,
options = this.options,
centerOption = options.center,
minSize = options.minSize || 80,
newSize = minSize,
ret;
// Handle horizontal size and center
if (centerOption[0] !== null) { // Fixed center
newSize = Math.max(center[2] - Math.max(overflow[1], overflow[3]), minSize);
} else { // Auto center
newSize = Math.max(
center[2] - overflow[1] - overflow[3], // horizontal overflow
minSize
);
center[0] += (overflow[3] - overflow[1]) / 2; // horizontal center
}
// Handle vertical size and center
if (centerOption[1] !== null) { // Fixed center
newSize = Math.max(Math.min(newSize, center[2] - Math.max(overflow[0], overflow[2])), minSize);
} else { // Auto center
newSize = Math.max(
Math.min(
newSize,
center[2] - overflow[0] - overflow[2] // vertical overflow
),
minSize
);
center[1] += (overflow[0] - overflow[2]) / 2; // vertical center
}
// If the size must be decreased, we need to run translate and drawDataLabels again
if (newSize < center[2]) {
center[2] = newSize;
center[3] = Math.min(relativeLength(options.innerSize || 0, newSize), newSize); // #3632
this.translate(center);
if (this.drawDataLabels) {
this.drawDataLabels();
}
// Else, return true to indicate that the pie and its labels is within the plot area
} else {
ret = true;
}
return ret;
};
}
if (seriesTypes.column) {
/**
* Override the basic data label alignment by adjusting for the position of the column
*/
seriesTypes.column.prototype.alignDataLabel = function(point, dataLabel, options, alignTo, isNew) {
var inverted = this.chart.inverted,
series = point.series,
dlBox = point.dlBox || point.shapeArgs, // data label box for alignment
below = pick(point.below, point.plotY > pick(this.translatedThreshold, series.yAxis.len)), // point.below is used in range series
inside = pick(options.inside, !!this.options.stacking), // draw it inside the box?
overshoot;
// Align to the column itself, or the top of it
if (dlBox) { // Area range uses this method but not alignTo
alignTo = merge(dlBox);
if (alignTo.y < 0) {
alignTo.height += alignTo.y;
alignTo.y = 0;
}
overshoot = alignTo.y + alignTo.height - series.yAxis.len;
if (overshoot > 0) {
alignTo.height -= overshoot;
}
if (inverted) {
alignTo = {
x: series.yAxis.len - alignTo.y - alignTo.height,
y: series.xAxis.len - alignTo.x - alignTo.width,
width: alignTo.height,
height: alignTo.width
};
}
// Compute the alignment box
if (!inside) {
if (inverted) {
alignTo.x += below ? 0 : alignTo.width;
alignTo.width = 0;
} else {
alignTo.y += below ? alignTo.height : 0;
alignTo.height = 0;
}
}
}
// When alignment is undefined (typically columns and bars), display the individual
// point below or above the point depending on the threshold
options.align = pick(
options.align, !inverted || inside ? 'center' : below ? 'right' : 'left'
);
options.verticalAlign = pick(
options.verticalAlign,
inverted || inside ? 'middle' : below ? 'top' : 'bottom'
);
// Call the parent method
Series.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
// If label was justified and we have contrast, set it:
if (point.isLabelJustified && point.contrastColor) {
point.dataLabel.css({
color: point.contrastColor
});
}
};
}
}(Highcharts));
(function(H) {
/**
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/**
* Highcharts module to hide overlapping data labels. This module is included in
* Highcharts.
*/
var Chart = H.Chart,
each = H.each,
pick = H.pick,
addEvent = H.addEvent;
// Collect potensial overlapping data labels. Stack labels probably don't need
// to be considered because they are usually accompanied by data labels that lie
// inside the columns.
Chart.prototype.callbacks.push(function(chart) {
function collectAndHide() {
var labels = [];
each(chart.series || [], function(series) {
var dlOptions = series.options.dataLabels,
// Range series have two collections
collections = series.dataLabelCollections || ['dataLabel'];
if (
(dlOptions.enabled || series._hasPointLabels) &&
!dlOptions.allowOverlap &&
series.visible
) { // #3866
each(collections, function(coll) {
each(series.points, function(point) {
if (point[coll]) {
point[coll].labelrank = pick(
point.labelrank,
point.shapeArgs && point.shapeArgs.height
); // #4118
labels.push(point[coll]);
}
});
});
}
});
chart.hideOverlappingLabels(labels);
}
// Do it now ...
collectAndHide();
// ... and after each chart redraw
addEvent(chart, 'redraw', collectAndHide);
});
/**
* Hide overlapping labels. Labels are moved and faded in and out on zoom to
* provide a smooth visual imression.
*/
Chart.prototype.hideOverlappingLabels = function(labels) {
var len = labels.length,
label,
i,
j,
label1,
label2,
isIntersecting,
pos1,
pos2,
parent1,
parent2,
padding,
intersectRect = function(x1, y1, w1, h1, x2, y2, w2, h2) {
return !(
x2 > x1 + w1 ||
x2 + w2 < x1 ||
y2 > y1 + h1 ||
y2 + h2 < y1
);
};
// Mark with initial opacity
for (i = 0; i < len; i++) {
label = labels[i];
if (label) {
label.oldOpacity = label.opacity;
label.newOpacity = 1;
}
}
// Prevent a situation in a gradually rising slope, that each label will
// hide the previous one because the previous one always has lower rank.
labels.sort(function(a, b) {
return (b.labelrank || 0) - (a.labelrank || 0);
});
// Detect overlapping labels
for (i = 0; i < len; i++) {
label1 = labels[i];
for (j = i + 1; j < len; ++j) {
label2 = labels[j];
if (
label1 && label2 &&
label1 !== label2 && // #6465, polar chart with connectEnds
label1.placed && label2.placed &&
label1.newOpacity !== 0 && label2.newOpacity !== 0
) {
pos1 = label1.alignAttr;
pos2 = label2.alignAttr;
// Different panes have different positions
parent1 = label1.parentGroup;
parent2 = label2.parentGroup;
// Substract the padding if no background or border (#4333)
padding = 2 * (label1.box ? 0 : label1.padding);
isIntersecting = intersectRect(
pos1.x + parent1.translateX,
pos1.y + parent1.translateY,
label1.width - padding,
label1.height - padding,
pos2.x + parent2.translateX,
pos2.y + parent2.translateY,
label2.width - padding,
label2.height - padding
);
if (isIntersecting) {
(label1.labelrank < label2.labelrank ? label1 : label2)
.newOpacity = 0;
}
}
}
}
// Hide or show
each(labels, function(label) {
var complete,
newOpacity;
if (label) {
newOpacity = label.newOpacity;
if (label.oldOpacity !== newOpacity && label.placed) {
// Make sure the label is completely hidden to avoid catching
// clicks (#4362)
if (newOpacity) {
label.show(true);
} else {
complete = function() {
label.hide();
};
}
// Animate or set the opacity
label.alignAttr.opacity = newOpacity;
label[label.isOld ? 'animate' : 'attr'](
label.alignAttr,
null,
complete
);
}
label.isOld = true;
}
});
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
Chart = H.Chart,
createElement = H.createElement,
css = H.css,
defaultOptions = H.defaultOptions,
defaultPlotOptions = H.defaultPlotOptions,
each = H.each,
extend = H.extend,
fireEvent = H.fireEvent,
hasTouch = H.hasTouch,
inArray = H.inArray,
isObject = H.isObject,
Legend = H.Legend,
merge = H.merge,
pick = H.pick,
Point = H.Point,
Series = H.Series,
seriesTypes = H.seriesTypes,
svg = H.svg,
TrackerMixin;
/**
* TrackerMixin for points and graphs.
*
* @mixin
*/
TrackerMixin = H.TrackerMixin = {
/**
* Draw the tracker for a point.
*/
drawTrackerPoint: function() {
var series = this,
chart = series.chart,
pointer = chart.pointer,
onMouseOver = function(e) {
var point = pointer.getPointFromEvent(e);
// undefined on graph in scatterchart
if (point !== undefined) {
point.onMouseOver(e);
}
};
// Add reference to the point
each(series.points, function(point) {
if (point.graphic) {
point.graphic.element.point = point;
}
if (point.dataLabel) {
if (point.dataLabel.div) {
point.dataLabel.div.point = point;
} else {
point.dataLabel.element.point = point;
}
}
});
// Add the event listeners, we need to do this only once
if (!series._hasTracking) {
each(series.trackerGroups, function(key) {
if (series[key]) { // we don't always have dataLabelsGroup
series[key]
.addClass('highcharts-tracker')
.on('mouseover', onMouseOver)
.on('mouseout', function(e) {
pointer.onTrackerMouseOut(e);
});
if (hasTouch) {
series[key].on('touchstart', onMouseOver);
}
if (series.options.cursor) {
series[key]
.css(css)
.css({
cursor: series.options.cursor
});
}
}
});
series._hasTracking = true;
}
},
/**
* Draw the tracker object that sits above all data labels and markers to
* track mouse events on the graph or points. For the line type charts
* the tracker uses the same graphPath, but with a greater stroke width
* for better control.
*/
drawTrackerGraph: function() {
var series = this,
options = series.options,
trackByArea = options.trackByArea,
trackerPath = [].concat(trackByArea ? series.areaPath : series.graphPath),
trackerPathLength = trackerPath.length,
chart = series.chart,
pointer = chart.pointer,
renderer = chart.renderer,
snap = chart.options.tooltip.snap,
tracker = series.tracker,
i,
onMouseOver = function() {
if (chart.hoverSeries !== series) {
series.onMouseOver();
}
},
/*
* Empirical lowest possible opacities for TRACKER_FILL for an element to stay invisible but clickable
* IE6: 0.002
* IE7: 0.002
* IE8: 0.002
* IE9: 0.00000000001 (unlimited)
* IE10: 0.0001 (exporting only)
* FF: 0.00000000001 (unlimited)
* Chrome: 0.000001
* Safari: 0.000001
* Opera: 0.00000000001 (unlimited)
*/
TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';
// Extend end points. A better way would be to use round linecaps,
// but those are not clickable in VML.
if (trackerPathLength && !trackByArea) {
i = trackerPathLength + 1;
while (i--) {
if (trackerPath[i] === 'M') { // extend left side
trackerPath.splice(i + 1, 0, trackerPath[i + 1] - snap, trackerPath[i + 2], 'L');
}
if ((i && trackerPath[i] === 'M') || i === trackerPathLength) { // extend right side
trackerPath.splice(i, 0, 'L', trackerPath[i - 2] + snap, trackerPath[i - 1]);
}
}
}
// handle single points
/*for (i = 0; i < singlePoints.length; i++) {
singlePoint = singlePoints[i];
trackerPath.push(M, singlePoint.plotX - snap, singlePoint.plotY,
L, singlePoint.plotX + snap, singlePoint.plotY);
}*/
// draw the tracker
if (tracker) {
tracker.attr({
d: trackerPath
});
} else if (series.graph) { // create
series.tracker = renderer.path(trackerPath)
.attr({
'stroke-linejoin': 'round', // #1225
visibility: series.visible ? 'visible' : 'hidden',
stroke: TRACKER_FILL,
fill: trackByArea ? TRACKER_FILL : 'none',
'stroke-width': series.graph.strokeWidth() + (trackByArea ? 0 : 2 * snap),
zIndex: 2
})
.add(series.group);
// The tracker is added to the series group, which is clipped, but is covered
// by the marker group. So the marker group also needs to capture events.
each([series.tracker, series.markerGroup], function(tracker) {
tracker.addClass('highcharts-tracker')
.on('mouseover', onMouseOver)
.on('mouseout', function(e) {
pointer.onTrackerMouseOut(e);
});
if (options.cursor) {
tracker.css({
cursor: options.cursor
});
}
if (hasTouch) {
tracker.on('touchstart', onMouseOver);
}
});
}
}
};
/* End TrackerMixin */
/**
* Add tracking event listener to the series group, so the point graphics
* themselves act as trackers
*/
if (seriesTypes.column) {
seriesTypes.column.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
}
if (seriesTypes.pie) {
seriesTypes.pie.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
}
if (seriesTypes.scatter) {
seriesTypes.scatter.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
}
/*
* Extend Legend for item events
*/
extend(Legend.prototype, {
setItemEvents: function(item, legendItem, useHTML) {
var legend = this,
boxWrapper = legend.chart.renderer.boxWrapper,
activeClass = 'highcharts-legend-' + (item.series ? 'point' : 'series') + '-active';
// Set the events on the item group, or in case of useHTML, the item itself (#1249)
(useHTML ? legendItem : item.legendGroup).on('mouseover', function() {
item.setState('hover');
// A CSS class to dim or hide other than the hovered series
boxWrapper.addClass(activeClass);
legendItem.css(legend.options.itemHoverStyle);
})
.on('mouseout', function() {
legendItem.css(item.visible ? legend.itemStyle : legend.itemHiddenStyle);
// A CSS class to dim or hide other than the hovered series
boxWrapper.removeClass(activeClass);
item.setState();
})
.on('click', function(event) {
var strLegendItemClick = 'legendItemClick',
fnLegendItemClick = function() {
if (item.setVisible) {
item.setVisible();
}
};
// Pass over the click/touch event. #4.
event = {
browserEvent: event
};
// click the name or symbol
if (item.firePointEvent) { // point
item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
} else {
fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
}
});
},
createCheckboxForItem: function(item) {
var legend = this;
item.checkbox = createElement('input', {
type: 'checkbox',
checked: item.selected,
defaultChecked: item.selected // required by IE7
}, legend.options.itemCheckboxStyle, legend.chart.container);
addEvent(item.checkbox, 'click', function(event) {
var target = event.target;
fireEvent(
item.series || item,
'checkboxClick', { // #3712
checked: target.checked,
item: item
},
function() {
item.select();
}
);
});
}
});
// Add pointer cursor to legend itemstyle in defaultOptions
defaultOptions.legend.itemStyle.cursor = 'pointer';
/*
* Extend the Chart object with interaction
*/
extend(Chart.prototype, /** @lends Chart.prototype */ {
/**
* Display the zoom button
*/
showResetZoom: function() {
var chart = this,
lang = defaultOptions.lang,
btnOptions = chart.options.chart.resetZoomButton,
theme = btnOptions.theme,
states = theme.states,
alignTo = btnOptions.relativeTo === 'chart' ? null : 'plotBox';
function zoomOut() {
chart.zoomOut();
}
this.resetZoomButton = chart.renderer.button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
.attr({
align: btnOptions.position.align,
title: lang.resetZoomTitle
})
.addClass('highcharts-reset-zoom')
.add()
.align(btnOptions.position, false, alignTo);
},
/**
* Zoom out to 1:1
*/
zoomOut: function() {
var chart = this;
fireEvent(chart, 'selection', {
resetSelection: true
}, function() {
chart.zoom();
});
},
/**
* Zoom into a given portion of the chart given by axis coordinates
* @param {Object} event
*/
zoom: function(event) {
var chart = this,
hasZoomed,
pointer = chart.pointer,
displayButton = false,
resetZoomButton;
// If zoom is called with no arguments, reset the axes
if (!event || event.resetSelection) {
each(chart.axes, function(axis) {
hasZoomed = axis.zoom();
});
} else { // else, zoom in on all axes
each(event.xAxis.concat(event.yAxis), function(axisData) {
var axis = axisData.axis,
isXAxis = axis.isXAxis;
// don't zoom more than minRange
if (pointer[isXAxis ? 'zoomX' : 'zoomY']) {
hasZoomed = axis.zoom(axisData.min, axisData.max);
if (axis.displayBtn) {
displayButton = true;
}
}
});
}
// Show or hide the Reset zoom button
resetZoomButton = chart.resetZoomButton;
if (displayButton && !resetZoomButton) {
chart.showResetZoom();
} else if (!displayButton && isObject(resetZoomButton)) {
chart.resetZoomButton = resetZoomButton.destroy();
}
// Redraw
if (hasZoomed) {
chart.redraw(
pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100) // animation
);
}
},
/**
* Pan the chart by dragging the mouse across the pane. This function is called
* on mouse move, and the distance to pan is computed from chartX compared to
* the first chartX position in the dragging operation.
*/
pan: function(e, panning) {
var chart = this,
hoverPoints = chart.hoverPoints,
doRedraw;
// remove active points for shared tooltip
if (hoverPoints) {
each(hoverPoints, function(point) {
point.setState();
});
}
each(panning === 'xy' ? [1, 0] : [1], function(isX) { // xy is used in maps
var axis = chart[isX ? 'xAxis' : 'yAxis'][0],
horiz = axis.horiz,
mousePos = e[horiz ? 'chartX' : 'chartY'],
mouseDown = horiz ? 'mouseDownX' : 'mouseDownY',
startPos = chart[mouseDown],
halfPointRange = (axis.pointRange || 0) / 2,
extremes = axis.getExtremes(),
panMin = axis.toValue(startPos - mousePos, true) +
halfPointRange,
panMax = axis.toValue(startPos + axis.len - mousePos, true) -
halfPointRange,
flipped = panMax < panMin,
newMin = flipped ? panMax : panMin,
newMax = flipped ? panMin : panMax,
paddedMin = axis.toValue(
axis.toPixels(extremes.min) - axis.minPixelPadding
),
paddedMax = axis.toValue(
axis.toPixels(extremes.max) + axis.minPixelPadding
),
distMin = Math.min(extremes.dataMin, paddedMin) - newMin,
distMax = newMax - Math.max(extremes.dataMax, paddedMax);
// Negative distMin and distMax means that we're still inside the
// data range.
if (axis.series.length && distMin < 0 && distMax < 0) {
axis.setExtremes(
newMin,
newMax,
false,
false, {
trigger: 'pan'
}
);
doRedraw = true;
}
chart[mouseDown] = mousePos; // set new reference for next run
});
if (doRedraw) {
chart.redraw(false);
}
css(chart.container, {
cursor: 'move'
});
}
});
/*
* Extend the Point object with interaction
*/
extend(Point.prototype, /** @lends Point.prototype */ {
/**
* Toggle the selection status of a point
* @param {Boolean} selected Whether to select or unselect the point.
* @param {Boolean} accumulate Whether to add to the previous selection. By default,
* this happens if the control key (Cmd on Mac) was pressed during clicking.
*/
select: function(selected, accumulate) {
var point = this,
series = point.series,
chart = series.chart;
selected = pick(selected, !point.selected);
// fire the event with the default handler
point.firePointEvent(selected ? 'select' : 'unselect', {
accumulate: accumulate
}, function() {
point.selected = point.options.selected = selected;
series.options.data[inArray(point, series.data)] = point.options;
point.setState(selected && 'select');
// unselect all other points unless Ctrl or Cmd + click
if (!accumulate) {
each(chart.getSelectedPoints(), function(loopPoint) {
if (loopPoint.selected && loopPoint !== point) {
loopPoint.selected = loopPoint.options.selected = false;
series.options.data[inArray(loopPoint, series.data)] = loopPoint.options;
loopPoint.setState('');
loopPoint.firePointEvent('unselect');
}
});
}
});
},
/**
* Runs on mouse over the point
*
* @param {Object} e The event arguments
*/
onMouseOver: function(e) {
var point = this,
series = point.series,
chart = series.chart,
pointer = chart.pointer;
point.firePointEvent('mouseOver');
pointer.runPointActions(e, point);
},
/**
* Runs on mouse out from the point
*/
onMouseOut: function() {
var point = this,
chart = point.series.chart;
point.firePointEvent('mouseOut');
each(chart.hoverPoints || [], function(p) {
p.setState();
});
chart.hoverPoints = chart.hoverPoint = null;
},
/**
* Import events from the series' and point's options. Only do it on
* demand, to save processing time on hovering.
*/
importEvents: function() {
if (!this.hasImportedEvents) {
var point = this,
options = merge(point.series.options.point, point.options),
events = options.events,
eventType;
point.events = events;
for (eventType in events) {
addEvent(point, eventType, events[eventType]);
}
this.hasImportedEvents = true;
}
},
/**
* Set the point's state
* @param {String} state
*/
setState: function(state, move) {
var point = this,
plotX = Math.floor(point.plotX), // #4586
plotY = point.plotY,
series = point.series,
stateOptions = series.options.states[state] || {},
markerOptions = defaultPlotOptions[series.type].marker &&
series.options.marker,
normalDisabled = markerOptions && markerOptions.enabled === false,
markerStateOptions = (markerOptions && markerOptions.states &&
markerOptions.states[state]) || {},
stateDisabled = markerStateOptions.enabled === false,
stateMarkerGraphic = series.stateMarkerGraphic,
pointMarker = point.marker || {},
chart = series.chart,
halo = series.halo,
haloOptions,
markerAttribs,
hasMarkers = markerOptions && series.markerAttribs,
newSymbol;
state = state || ''; // empty string
if (
// already has this state
(state === point.state && !move) ||
// selected points don't respond to hover
(point.selected && state !== 'select') ||
// series' state options is disabled
(stateOptions.enabled === false) ||
// general point marker's state options is disabled
(state && (stateDisabled || (normalDisabled && markerStateOptions.enabled === false))) ||
// individual point marker's state options is disabled
(state && pointMarker.states && pointMarker.states[state] && pointMarker.states[state].enabled === false) // #1610
) {
return;
}
if (hasMarkers) {
markerAttribs = series.markerAttribs(point, state);
}
// Apply hover styles to the existing point
if (point.graphic) {
if (point.state) {
point.graphic.removeClass('highcharts-point-' + point.state);
}
if (state) {
point.graphic.addClass('highcharts-point-' + state);
}
/*attribs = radius ? { // new symbol attributes (#507, #612)
x: plotX - radius,
y: plotY - radius,
width: 2 * radius,
height: 2 * radius
} : {};*/
//attribs = merge(series.pointAttribs(point, state), attribs);
point.graphic.attr(series.pointAttribs(point, state));
if (markerAttribs) {
point.graphic.animate(
markerAttribs,
pick(
chart.options.chart.animation, // Turn off globally
markerStateOptions.animation,
markerOptions.animation
)
);
}
// Zooming in from a range with no markers to a range with markers
if (stateMarkerGraphic) {
stateMarkerGraphic.hide();
}
} else {
// if a graphic is not applied to each point in the normal state, create a shared
// graphic for the hover state
if (state && markerStateOptions) {
newSymbol = pointMarker.symbol || series.symbol;
// If the point has another symbol than the previous one, throw away the
// state marker graphic and force a new one (#1459)
if (stateMarkerGraphic && stateMarkerGraphic.currentSymbol !== newSymbol) {
stateMarkerGraphic = stateMarkerGraphic.destroy();
}
// Add a new state marker graphic
if (!stateMarkerGraphic) {
if (newSymbol) {
series.stateMarkerGraphic = stateMarkerGraphic = chart.renderer.symbol(
newSymbol,
markerAttribs.x,
markerAttribs.y,
markerAttribs.width,
markerAttribs.height
)
.add(series.markerGroup);
stateMarkerGraphic.currentSymbol = newSymbol;
}
// Move the existing graphic
} else {
stateMarkerGraphic[move ? 'animate' : 'attr']({ // #1054
x: markerAttribs.x,
y: markerAttribs.y
});
}
if (stateMarkerGraphic) {
stateMarkerGraphic.attr(series.pointAttribs(point, state));
}
}
if (stateMarkerGraphic) {
stateMarkerGraphic[state && chart.isInsidePlot(plotX, plotY, chart.inverted) ? 'show' : 'hide'](); // #2450
stateMarkerGraphic.element.point = point; // #4310
}
}
// Show me your halo
haloOptions = stateOptions.halo;
if (haloOptions && haloOptions.size) {
if (!halo) {
series.halo = halo = chart.renderer.path()
// #5818, #5903
.add(hasMarkers ? series.markerGroup : series.group);
}
halo[move ? 'animate' : 'attr']({
d: point.haloPath(haloOptions.size)
});
halo.attr({
'class': 'highcharts-halo highcharts-color-' +
pick(point.colorIndex, series.colorIndex)
});
halo.point = point; // #6055
halo.attr(extend({
'fill': point.color || series.color,
'fill-opacity': haloOptions.opacity,
'zIndex': -1 // #4929, IE8 added halo above everything
}, haloOptions.attributes));
} else if (halo && halo.point && halo.point.haloPath) {
// Animate back to 0 on the current halo point (#6055)
halo.animate({
d: halo.point.haloPath(0)
});
}
point.state = state;
},
/**
* Get the circular path definition for the halo
* @param {Number} size The radius of the circular halo.
* @returns {Array} The path definition
*/
haloPath: function(size) {
var series = this.series,
chart = series.chart;
return chart.renderer.symbols.circle(
Math.floor(this.plotX) - size,
this.plotY - size,
size * 2,
size * 2
);
}
});
/*
* Extend the Series object with interaction
*/
extend(Series.prototype, /** @lends Series.prototype */ {
/**
* Series mouse over handler
*/
onMouseOver: function() {
var series = this,
chart = series.chart,
hoverSeries = chart.hoverSeries;
// set normal state to previous series
if (hoverSeries && hoverSeries !== series) {
hoverSeries.onMouseOut();
}
// trigger the event, but to save processing time,
// only if defined
if (series.options.events.mouseOver) {
fireEvent(series, 'mouseOver');
}
// hover this
series.setState('hover');
chart.hoverSeries = series;
},
/**
* Series mouse out handler
*/
onMouseOut: function() {
// trigger the event only if listeners exist
var series = this,
options = series.options,
chart = series.chart,
tooltip = chart.tooltip,
hoverPoint = chart.hoverPoint;
chart.hoverSeries = null; // #182, set to null before the mouseOut event fires
// trigger mouse out on the point, which must be in this series
if (hoverPoint) {
hoverPoint.onMouseOut();
}
// fire the mouse out event
if (series && options.events.mouseOut) {
fireEvent(series, 'mouseOut');
}
// hide the tooltip
if (tooltip && !series.stickyTracking && (!tooltip.shared || series.noSharedTooltip)) {
tooltip.hide();
}
// set normal state
series.setState();
},
/**
* Set the state of the graph
*/
setState: function(state) {
var series = this,
options = series.options,
graph = series.graph,
stateOptions = options.states,
lineWidth = options.lineWidth,
attribs,
i = 0;
state = state || '';
if (series.state !== state) {
// Toggle class names
each([
series.group,
series.markerGroup,
series.dataLabelsGroup
], function(group) {
if (group) {
// Old state
if (series.state) {
group.removeClass('highcharts-series-' + series.state);
}
// New state
if (state) {
group.addClass('highcharts-series-' + state);
}
}
});
series.state = state;
if (stateOptions[state] && stateOptions[state].enabled === false) {
return;
}
if (state) {
lineWidth = stateOptions[state].lineWidth || lineWidth + (stateOptions[state].lineWidthPlus || 0); // #4035
}
if (graph && !graph.dashstyle) { // hover is turned off for dashed lines in VML
attribs = {
'stroke-width': lineWidth
};
// Animate the graph stroke-width. By default a quick animation
// to hover, slower to un-hover.
graph.animate(
attribs,
pick(
series.chart.options.chart.animation,
stateOptions[state] && stateOptions[state].animation
)
);
while (series['zone-graph-' + i]) {
series['zone-graph-' + i].attr(attribs);
i = i + 1;
}
}
}
},
/**
* Set the visibility of the graph
*
* @param vis {Boolean} True to show the series, false to hide. If undefined,
* the visibility is toggled.
*/
setVisible: function(vis, redraw) {
var series = this,
chart = series.chart,
legendItem = series.legendItem,
showOrHide,
ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
oldVisibility = series.visible;
// if called without an argument, toggle visibility
series.visible = vis = series.options.visible = series.userOptions.visible = vis === undefined ? !oldVisibility : vis; // #5618
showOrHide = vis ? 'show' : 'hide';
// show or hide elements
each(['group', 'dataLabelsGroup', 'markerGroup', 'tracker', 'tt'], function(key) {
if (series[key]) {
series[key][showOrHide]();
}
});
// hide tooltip (#1361)
if (chart.hoverSeries === series || (chart.hoverPoint && chart.hoverPoint.series) === series) {
series.onMouseOut();
}
if (legendItem) {
chart.legend.colorizeItem(series, vis);
}
// rescale or adapt to resized chart
series.isDirty = true;
// in a stack, all other series are affected
if (series.options.stacking) {
each(chart.series, function(otherSeries) {
if (otherSeries.options.stacking && otherSeries.visible) {
otherSeries.isDirty = true;
}
});
}
// show or hide linked series
each(series.linkedSeries, function(otherSeries) {
otherSeries.setVisible(vis, false);
});
if (ignoreHiddenSeries) {
chart.isDirtyBox = true;
}
if (redraw !== false) {
chart.redraw();
}
fireEvent(series, showOrHide);
},
/**
* Show the graph
*/
show: function() {
this.setVisible(true);
},
/**
* Hide the graph
*/
hide: function() {
this.setVisible(false);
},
/**
* Set the selected state of the graph
*
* @param selected {Boolean} True to select the series, false to unselect. If
* undefined, the selection state is toggled.
*/
select: function(selected) {
var series = this;
// if called without an argument, toggle
series.selected = selected = (selected === undefined) ? !series.selected : selected;
if (series.checkbox) {
series.checkbox.checked = selected;
}
fireEvent(series, selected ? 'select' : 'unselect');
},
drawTracker: TrackerMixin.drawTrackerGraph
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Chart = H.Chart,
each = H.each,
inArray = H.inArray,
isArray = H.isArray,
isObject = H.isObject,
pick = H.pick,
splat = H.splat;
/**
* Update the chart based on the current chart/document size and options for
* responsiveness.
*/
Chart.prototype.setResponsive = function(redraw) {
var options = this.options.responsive,
ruleIds = [],
currentResponsive = this.currentResponsive,
currentRuleIds;
if (options && options.rules) {
each(options.rules, function(rule) {
if (rule._id === undefined) {
rule._id = H.uniqueKey();
}
this.matchResponsiveRule(rule, ruleIds, redraw);
}, this);
}
// Merge matching rules
var mergedOptions = H.merge.apply(0, H.map(ruleIds, function(ruleId) {
return H.find(options.rules, function(rule) {
return rule._id === ruleId;
}).chartOptions;
}));
// Stringified key for the rules that currently apply.
ruleIds = ruleIds.toString() || undefined;
currentRuleIds = currentResponsive && currentResponsive.ruleIds;
// Changes in what rules apply
if (ruleIds !== currentRuleIds) {
// Undo previous rules. Before we apply a new set of rules, we need to
// roll back completely to base options (#6291).
if (currentResponsive) {
this.update(currentResponsive.undoOptions, redraw);
}
if (ruleIds) {
// Get undo-options for matching rules
this.currentResponsive = {
ruleIds: ruleIds,
mergedOptions: mergedOptions,
undoOptions: this.currentOptions(mergedOptions)
};
this.update(mergedOptions, redraw);
} else {
this.currentResponsive = undefined;
}
}
};
/**
* Handle a single responsiveness rule
*/
Chart.prototype.matchResponsiveRule = function(rule, matches) {
var condition = rule.condition,
fn = condition.callback || function() {
return this.chartWidth <= pick(condition.maxWidth, Number.MAX_VALUE) &&
this.chartHeight <= pick(condition.maxHeight, Number.MAX_VALUE) &&
this.chartWidth >= pick(condition.minWidth, 0) &&
this.chartHeight >= pick(condition.minHeight, 0);
};
if (fn.call(this)) {
matches.push(rule._id);
}
};
/**
* Get the current values for a given set of options. Used before we update
* the chart with a new responsiveness rule.
* TODO: Restore axis options (by id?)
*/
Chart.prototype.currentOptions = function(options) {
var ret = {};
/**
* Recurse over a set of options and its current values,
* and store the current values in the ret object.
*/
function getCurrent(options, curr, ret, depth) {
var key, i;
for (key in options) {
if (!depth && inArray(key, ['series', 'xAxis', 'yAxis']) > -1) {
options[key] = splat(options[key]);
ret[key] = [];
// Iterate over collections like series, xAxis or yAxis and map
// the items by index.
for (i = 0; i < options[key].length; i++) {
if (curr[key][i]) { // Item exists in current data (#6347)
ret[key][i] = {};
getCurrent(
options[key][i],
curr[key][i],
ret[key][i],
depth + 1
);
}
}
} else if (isObject(options[key])) {
ret[key] = isArray(options[key]) ? [] : {};
getCurrent(
options[key],
curr[key] || {},
ret[key],
depth + 1
);
} else {
ret[key] = curr[key] || null;
}
}
}
getCurrent(options, this.options, ret, 0);
return ret;
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
each = H.each,
pick = H.pick,
wrap = H.wrap;
/**
* Override to use the extreme coordinates from the SVG shape, not the
* data values
*/
wrap(Axis.prototype, 'getSeriesExtremes', function(proceed) {
var isXAxis = this.isXAxis,
dataMin,
dataMax,
xData = [],
useMapGeometry;
// Remove the xData array and cache it locally so that the proceed method doesn't use it
if (isXAxis) {
each(this.series, function(series, i) {
if (series.useMapGeometry) {
xData[i] = series.xData;
series.xData = [];
}
});
}
// Call base to reach normal cartesian series (like mappoint)
proceed.call(this);
// Run extremes logic for map and mapline
if (isXAxis) {
dataMin = pick(this.dataMin, Number.MAX_VALUE);
dataMax = pick(this.dataMax, -Number.MAX_VALUE);
each(this.series, function(series, i) {
if (series.useMapGeometry) {
dataMin = Math.min(dataMin, pick(series.minX, dataMin));
dataMax = Math.max(dataMax, pick(series.maxX, dataMin));
series.xData = xData[i]; // Reset xData array
useMapGeometry = true;
}
});
if (useMapGeometry) {
this.dataMin = dataMin;
this.dataMax = dataMax;
}
}
});
/**
* Override axis translation to make sure the aspect ratio is always kept
*/
wrap(Axis.prototype, 'setAxisTranslation', function(proceed) {
var chart = this.chart,
mapRatio,
plotRatio = chart.plotWidth / chart.plotHeight,
adjustedAxisLength,
xAxis = chart.xAxis[0],
padAxis,
fixTo,
fixDiff,
preserveAspectRatio;
// Run the parent method
proceed.call(this);
// Check for map-like series
if (this.coll === 'yAxis' && xAxis.transA !== undefined) {
each(this.series, function(series) {
if (series.preserveAspectRatio) {
preserveAspectRatio = true;
}
});
}
// On Y axis, handle both
if (preserveAspectRatio) {
// Use the same translation for both axes
this.transA = xAxis.transA = Math.min(this.transA, xAxis.transA);
mapRatio = plotRatio / ((xAxis.max - xAxis.min) / (this.max - this.min));
// What axis to pad to put the map in the middle
padAxis = mapRatio < 1 ? this : xAxis;
// Pad it
adjustedAxisLength = (padAxis.max - padAxis.min) * padAxis.transA;
padAxis.pixelPadding = padAxis.len - adjustedAxisLength;
padAxis.minPixelPadding = padAxis.pixelPadding / 2;
fixTo = padAxis.fixTo;
if (fixTo) {
fixDiff = fixTo[1] - padAxis.toValue(fixTo[0], true);
fixDiff *= padAxis.transA;
if (Math.abs(fixDiff) > padAxis.minPixelPadding || (padAxis.min === padAxis.dataMin && padAxis.max === padAxis.dataMax)) { // zooming out again, keep within restricted area
fixDiff = 0;
}
padAxis.minPixelPadding -= fixDiff;
}
}
});
/**
* Override Axis.render in order to delete the fixTo prop
*/
wrap(Axis.prototype, 'render', function(proceed) {
proceed.call(this);
this.fixTo = null;
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
Chart = H.Chart,
color = H.color,
ColorAxis,
each = H.each,
extend = H.extend,
isNumber = H.isNumber,
Legend = H.Legend,
LegendSymbolMixin = H.LegendSymbolMixin,
noop = H.noop,
merge = H.merge,
pick = H.pick,
wrap = H.wrap;
/**
* The ColorAxis object for inclusion in gradient legends
*/
ColorAxis = H.ColorAxis = function() {
this.init.apply(this, arguments);
};
extend(ColorAxis.prototype, Axis.prototype);
extend(ColorAxis.prototype, {
defaultColorAxisOptions: {
lineWidth: 0,
minPadding: 0,
maxPadding: 0,
gridLineWidth: 1,
tickPixelInterval: 72,
startOnTick: true,
endOnTick: true,
offset: 0,
marker: {
animation: {
duration: 50
},
width: 0.01,
color: '#999999'
},
labels: {
overflow: 'justify',
rotation: 0
},
minColor: '#e6ebf5',
maxColor: '#003399',
tickLength: 5,
showInLegend: true
},
// Properties to preserve after destroy, for Axis.update (#5881, #6025)
keepProps: [
'legendGroup',
'legendItemHeight',
'legendItemWidth',
'legendItem',
'legendSymbol'
].concat(Axis.prototype.keepProps),
/**
* Initialize the color axis
*/
init: function(chart, userOptions) {
var horiz = chart.options.legend.layout !== 'vertical',
options;
this.coll = 'colorAxis';
// Build the options
options = merge(this.defaultColorAxisOptions, {
side: horiz ? 2 : 1,
reversed: !horiz
}, userOptions, {
opposite: !horiz,
showEmpty: false,
title: null
});
Axis.prototype.init.call(this, chart, options);
// Base init() pushes it to the xAxis array, now pop it again
//chart[this.isXAxis ? 'xAxis' : 'yAxis'].pop();
// Prepare data classes
if (userOptions.dataClasses) {
this.initDataClasses(userOptions);
}
this.initStops(userOptions);
// Override original axis properties
this.horiz = horiz;
this.zoomEnabled = false;
// Add default values
this.defaultLegendLength = 200;
},
/*
* Return an intermediate color between two colors, according to pos where 0
* is the from color and 1 is the to color.
* NOTE: Changes here should be copied
* to the same function in drilldown.src.js and solid-gauge-src.js.
*/
tweenColors: function(from, to, pos) {
// Check for has alpha, because rgba colors perform worse due to lack of
// support in WebKit.
var hasAlpha,
ret;
// Unsupported color, return to-color (#3920)
if (!to.rgba.length || !from.rgba.length) {
ret = to.input || 'none';
// Interpolate
} else {
from = from.rgba;
to = to.rgba;
hasAlpha = (to[3] !== 1 || from[3] !== 1);
ret = (hasAlpha ? 'rgba(' : 'rgb(') +
Math.round(to[0] + (from[0] - to[0]) * (1 - pos)) + ',' +
Math.round(to[1] + (from[1] - to[1]) * (1 - pos)) + ',' +
Math.round(to[2] + (from[2] - to[2]) * (1 - pos)) +
(hasAlpha ? (',' + (to[3] + (from[3] - to[3]) * (1 - pos))) : '') + ')';
}
return ret;
},
initDataClasses: function(userOptions) {
var axis = this,
chart = this.chart,
dataClasses,
colorCounter = 0,
colorCount = chart.options.chart.colorCount,
options = this.options,
len = userOptions.dataClasses.length;
this.dataClasses = dataClasses = [];
this.legendItems = [];
each(userOptions.dataClasses, function(dataClass, i) {
var colors;
dataClass = merge(dataClass);
dataClasses.push(dataClass);
if (!dataClass.color) {
if (options.dataClassColor === 'category') {
colors = chart.options.colors;
colorCount = colors.length;
dataClass.color = colors[colorCounter];
dataClass.colorIndex = colorCounter;
// increase and loop back to zero
colorCounter++;
if (colorCounter === colorCount) {
colorCounter = 0;
}
} else {
dataClass.color = axis.tweenColors(
color(options.minColor),
color(options.maxColor),
len < 2 ? 0.5 : i / (len - 1) // #3219
);
}
}
});
},
initStops: function(userOptions) {
this.stops = userOptions.stops || [
[0, this.options.minColor],
[1, this.options.maxColor]
];
each(this.stops, function(stop) {
stop.color = color(stop[1]);
});
},
/**
* Extend the setOptions method to process extreme colors and color
* stops.
*/
setOptions: function(userOptions) {
Axis.prototype.setOptions.call(this, userOptions);
this.options.crosshair = this.options.marker;
},
setAxisSize: function() {
var symbol = this.legendSymbol,
chart = this.chart,
legendOptions = chart.options.legend || {},
x,
y,
width,
height;
if (symbol) {
this.left = x = symbol.attr('x');
this.top = y = symbol.attr('y');
this.width = width = symbol.attr('width');
this.height = height = symbol.attr('height');
this.right = chart.chartWidth - x - width;
this.bottom = chart.chartHeight - y - height;
this.len = this.horiz ? width : height;
this.pos = this.horiz ? x : y;
} else {
// Fake length for disabled legend to avoid tick issues and such (#5205)
this.len = (this.horiz ? legendOptions.symbolWidth : legendOptions.symbolHeight) || this.defaultLegendLength;
}
},
/**
* Translate from a value to a color
*/
toColor: function(value, point) {
var pos,
stops = this.stops,
from,
to,
color,
dataClasses = this.dataClasses,
dataClass,
i;
if (dataClasses) {
i = dataClasses.length;
while (i--) {
dataClass = dataClasses[i];
from = dataClass.from;
to = dataClass.to;
if ((from === undefined || value >= from) && (to === undefined || value <= to)) {
color = dataClass.color;
if (point) {
point.dataClass = i;
point.colorIndex = dataClass.colorIndex;
}
break;
}
}
} else {
if (this.isLog) {
value = this.val2lin(value);
}
pos = 1 - ((this.max - value) / ((this.max - this.min) || 1));
i = stops.length;
while (i--) {
if (pos > stops[i][0]) {
break;
}
}
from = stops[i] || stops[i + 1];
to = stops[i + 1] || from;
// The position within the gradient
pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1);
color = this.tweenColors(
from.color,
to.color,
pos
);
}
return color;
},
/**
* Override the getOffset method to add the whole axis groups inside the legend.
*/
getOffset: function() {
var group = this.legendGroup,
sideOffset = this.chart.axisOffset[this.side];
if (group) {
// Hook for the getOffset method to add groups to this parent group
this.axisParent = group;
// Call the base
Axis.prototype.getOffset.call(this);
// First time only
if (!this.added) {
this.added = true;
this.labelLeft = 0;
this.labelRight = this.width;
}
// Reset it to avoid color axis reserving space
this.chart.axisOffset[this.side] = sideOffset;
}
},
/**
* Create the color gradient
*/
setLegendColor: function() {
var grad,
horiz = this.horiz,
options = this.options,
reversed = this.reversed,
one = reversed ? 1 : 0,
zero = reversed ? 0 : 1;
grad = horiz ? [one, 0, zero, 0] : [0, zero, 0, one]; // #3190
this.legendColor = {
linearGradient: {
x1: grad[0],
y1: grad[1],
x2: grad[2],
y2: grad[3]
},
stops: options.stops || [
[0, options.minColor],
[1, options.maxColor]
]
};
},
/**
* The color axis appears inside the legend and has its own legend symbol
*/
drawLegendSymbol: function(legend, item) {
var padding = legend.padding,
legendOptions = legend.options,
horiz = this.horiz,
width = pick(legendOptions.symbolWidth, horiz ? this.defaultLegendLength : 12),
height = pick(legendOptions.symbolHeight, horiz ? 12 : this.defaultLegendLength),
labelPadding = pick(legendOptions.labelPadding, horiz ? 16 : 30),
itemDistance = pick(legendOptions.itemDistance, 10);
this.setLegendColor();
// Create the gradient
item.legendSymbol = this.chart.renderer.rect(
0,
legend.baseline - 11,
width,
height
).attr({
zIndex: 1
}).add(item.legendGroup);
// Set how much space this legend item takes up
this.legendItemWidth = width + padding + (horiz ? itemDistance : labelPadding);
this.legendItemHeight = height + padding + (horiz ? labelPadding : 0);
},
/**
* Fool the legend
*/
setState: noop,
visible: true,
setVisible: noop,
getSeriesExtremes: function() {
var series = this.series,
i = series.length;
this.dataMin = Infinity;
this.dataMax = -Infinity;
while (i--) {
if (series[i].valueMin !== undefined) {
this.dataMin = Math.min(this.dataMin, series[i].valueMin);
this.dataMax = Math.max(this.dataMax, series[i].valueMax);
}
}
},
drawCrosshair: function(e, point) {
var plotX = point && point.plotX,
plotY = point && point.plotY,
crossPos,
axisPos = this.pos,
axisLen = this.len;
if (point) {
crossPos = this.toPixels(point[point.series.colorKey]);
if (crossPos < axisPos) {
crossPos = axisPos - 2;
} else if (crossPos > axisPos + axisLen) {
crossPos = axisPos + axisLen + 2;
}
point.plotX = crossPos;
point.plotY = this.len - crossPos;
Axis.prototype.drawCrosshair.call(this, e, point);
point.plotX = plotX;
point.plotY = plotY;
if (this.cross) {
this.cross
.addClass('highcharts-coloraxis-marker')
.add(this.legendGroup);
this.cross.attr({
fill: this.crosshair.color
});
}
}
},
getPlotLinePath: function(a, b, c, d, pos) {
return isNumber(pos) ? // crosshairs only // #3969 pos can be 0 !!
(this.horiz ? ['M', pos - 4, this.top - 6, 'L', pos + 4, this.top - 6, pos, this.top, 'Z'] : ['M', this.left, pos, 'L', this.left - 6, pos + 6, this.left - 6, pos - 6, 'Z']) :
Axis.prototype.getPlotLinePath.call(this, a, b, c, d);
},
update: function(newOptions, redraw) {
var chart = this.chart,
legend = chart.legend;
each(this.series, function(series) {
series.isDirtyData = true; // Needed for Axis.update when choropleth colors change
});
// When updating data classes, destroy old items and make sure new ones are created (#3207)
if (newOptions.dataClasses && legend.allItems) {
each(legend.allItems, function(item) {
if (item.isDataClass) {
item.legendGroup.destroy();
}
});
chart.isDirtyLegend = true;
}
// Keep the options structure updated for export. Unlike xAxis and yAxis, the colorAxis is
// not an array. (#3207)
chart.options[this.coll] = merge(this.userOptions, newOptions);
Axis.prototype.update.call(this, newOptions, redraw);
if (this.legendItem) {
this.setLegendColor();
legend.colorizeItem(this, true);
}
},
/**
* Get the legend item symbols for data classes
*/
getDataClassLegendSymbols: function() {
var axis = this,
chart = this.chart,
legendItems = this.legendItems,
legendOptions = chart.options.legend,
valueDecimals = legendOptions.valueDecimals,
valueSuffix = legendOptions.valueSuffix || '',
name;
if (!legendItems.length) {
each(this.dataClasses, function(dataClass, i) {
var vis = true,
from = dataClass.from,
to = dataClass.to;
// Assemble the default name. This can be overridden by legend.options.labelFormatter
name = '';
if (from === undefined) {
name = '< ';
} else if (to === undefined) {
name = '> ';
}
if (from !== undefined) {
name += H.numberFormat(from, valueDecimals) + valueSuffix;
}
if (from !== undefined && to !== undefined) {
name += ' - ';
}
if (to !== undefined) {
name += H.numberFormat(to, valueDecimals) + valueSuffix;
}
// Add a mock object to the legend items
legendItems.push(extend({
chart: chart,
name: name,
options: {},
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
visible: true,
setState: noop,
isDataClass: true,
setVisible: function() {
vis = this.visible = !vis;
each(axis.series, function(series) {
each(series.points, function(point) {
if (point.dataClass === i) {
point.setVisible(vis);
}
});
});
chart.legend.colorizeItem(this, vis);
}
}, dataClass));
});
}
return legendItems;
},
name: '' // Prevents 'undefined' in legend in IE8
});
/**
* Handle animation of the color attributes directly
*/
each(['fill', 'stroke'], function(prop) {
H.Fx.prototype[prop + 'Setter'] = function() {
this.elem.attr(
prop,
ColorAxis.prototype.tweenColors(
color(this.start),
color(this.end),
this.pos
),
null,
true
);
};
});
/**
* Extend the chart getAxes method to also get the color axis
*/
wrap(Chart.prototype, 'getAxes', function(proceed) {
var options = this.options,
colorAxisOptions = options.colorAxis;
proceed.call(this);
this.colorAxis = [];
if (colorAxisOptions) {
new ColorAxis(this, colorAxisOptions); // eslint-disable-line no-new
}
});
/**
* Wrap the legend getAllItems method to add the color axis. This also removes the
* axis' own series to prevent them from showing up individually.
*/
wrap(Legend.prototype, 'getAllItems', function(proceed) {
var allItems = [],
colorAxis = this.chart.colorAxis[0];
if (colorAxis && colorAxis.options) {
if (colorAxis.options.showInLegend) {
// Data classes
if (colorAxis.options.dataClasses) {
allItems = allItems.concat(colorAxis.getDataClassLegendSymbols());
// Gradient legend
} else {
// Add this axis on top
allItems.push(colorAxis);
}
}
// Don't add the color axis' series
each(colorAxis.series, function(series) {
series.options.showInLegend = false;
});
}
return allItems.concat(proceed.call(this));
});
wrap(Legend.prototype, 'colorizeItem', function(proceed, item, visible) {
proceed.call(this, item, visible);
if (visible && item.legendColor) {
item.legendSymbol.attr({
fill: item.legendColor
});
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var defined = H.defined,
each = H.each,
noop = H.noop,
seriesTypes = H.seriesTypes;
/**
* Mixin for maps and heatmaps
*/
H.colorPointMixin = {
/**
* Color points have a value option that determines whether or not it is a null point
*/
isValid: function() {
return this.value !== null;
},
/**
* Set the visibility of a single point
*/
setVisible: function(vis) {
var point = this,
method = vis ? 'show' : 'hide';
// Show and hide associated elements
each(['graphic', 'dataLabel'], function(key) {
if (point[key]) {
point[key][method]();
}
});
},
setState: function(state) {
H.Point.prototype.setState.call(this, state);
if (this.graphic) {
this.graphic.attr({
zIndex: state === 'hover' ? 1 : 0
});
}
}
};
H.colorSeriesMixin = {
pointArrayMap: ['value'],
axisTypes: ['xAxis', 'yAxis', 'colorAxis'],
optionalAxis: 'colorAxis',
trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
getSymbol: noop,
parallelArrays: ['x', 'y', 'value'],
colorKey: 'value',
pointAttribs: seriesTypes.column.prototype.pointAttribs,
/**
* In choropleth maps, the color is a result of the value, so this needs translation too
*/
translateColors: function() {
var series = this,
nullColor = this.options.nullColor,
colorAxis = this.colorAxis,
colorKey = this.colorKey;
each(this.data, function(point) {
var value = point[colorKey],
color;
color = point.options.color ||
(point.isNull ? nullColor : (colorAxis && value !== undefined) ? colorAxis.toColor(value, point) : point.color || series.color);
if (color) {
point.color = color;
}
});
},
/**
* Get the color attibutes to apply on the graphic
*/
colorAttribs: function(point) {
var ret = {};
if (defined(point.color)) {
ret[this.colorProp || 'fill'] = point.color;
}
return ret;
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
Chart = H.Chart,
doc = H.doc,
each = H.each,
extend = H.extend,
merge = H.merge,
pick = H.pick,
wrap = H.wrap;
function stopEvent(e) {
if (e) {
if (e.preventDefault) {
e.preventDefault();
}
if (e.stopPropagation) {
e.stopPropagation();
}
e.cancelBubble = true;
}
}
/**
* The MapNavigation handles buttons for navigation in addition to mousewheel
* and doubleclick handlers for chart zooming.
* @param {Chart} chart The Chart instance.
* @class
*/
function MapNavigation(chart) {
this.init(chart);
}
/**
* Initiator function.
* @param {Chart} chart The Chart instance.
*/
MapNavigation.prototype.init = function(chart) {
this.chart = chart;
chart.mapNavButtons = [];
};
/**
* Update the map navigation with new options. Calling this is the same as
* calling `chart.update({ mapNavigation: {} })`.
* @param {Object} options New options for the map navigation.
*/
MapNavigation.prototype.update = function(options) {
var chart = this.chart,
o = chart.options.mapNavigation,
buttons,
n,
button,
buttonOptions,
attr,
states,
hoverStates,
selectStates,
outerHandler = function(e) {
this.handler.call(chart, e);
stopEvent(e); // Stop default click event (#4444)
},
mapNavButtons = chart.mapNavButtons;
// Merge in new options in case of update, and register back to chart
// options.
if (options) {
o = chart.options.mapNavigation =
merge(chart.options.mapNavigation, options);
}
// Destroy buttons in case of dynamic update
while (mapNavButtons.length) {
mapNavButtons.pop().destroy();
}
if (pick(o.enableButtons, o.enabled) && !chart.renderer.forExport) {
buttons = o.buttons;
for (n in buttons) {
if (buttons.hasOwnProperty(n)) {
buttonOptions = merge(o.buttonOptions, buttons[n]);
// Presentational
attr = buttonOptions.theme;
attr.style = merge(
buttonOptions.theme.style,
buttonOptions.style // #3203
);
states = attr.states;
hoverStates = states && states.hover;
selectStates = states && states.select;
button = chart.renderer.button(
buttonOptions.text,
0,
0,
outerHandler,
attr,
hoverStates,
selectStates,
0,
n === 'zoomIn' ? 'topbutton' : 'bottombutton'
)
.addClass('highcharts-map-navigation')
.attr({
width: buttonOptions.width,
height: buttonOptions.height,
title: chart.options.lang[n],
padding: buttonOptions.padding,
zIndex: 5
})
.add();
button.handler = buttonOptions.onclick;
button.align(
extend(buttonOptions, {
width: button.width,
height: 2 * button.height
}),
null,
buttonOptions.alignTo
);
// Stop double click event (#4444)
addEvent(button.element, 'dblclick', stopEvent);
mapNavButtons.push(button);
}
}
}
this.updateEvents(o);
};
/**
* Update events, called internally from the update function. Add new event
* handlers, or unbinds events if disabled.
* @param {Object} options Options for map navigation.
*/
MapNavigation.prototype.updateEvents = function(options) {
var chart = this.chart;
// Add the double click event
if (
pick(options.enableDoubleClickZoom, options.enabled) ||
options.enableDoubleClickZoomTo
) {
this.unbindDblClick = this.unbindDblClick || addEvent(
chart.container,
'dblclick',
function(e) {
chart.pointer.onContainerDblClick(e);
}
);
} else if (this.unbindDblClick) {
// Unbind and set unbinder to undefined
this.unbindDblClick = this.unbindDblClick();
}
// Add the mousewheel event
if (pick(options.enableMouseWheelZoom, options.enabled)) {
this.unbindMouseWheel = this.unbindMouseWheel || addEvent(
chart.container,
doc.onmousewheel === undefined ? 'DOMMouseScroll' : 'mousewheel',
function(e) {
chart.pointer.onContainerMouseWheel(e);
// Issue #5011, returning false from non-jQuery event does
// not prevent default
stopEvent(e);
return false;
}
);
} else if (this.unbindMouseWheel) {
// Unbind and set unbinder to undefined
this.unbindMouseWheel = this.unbindMouseWheel();
}
};
// Add events to the Chart object itself
extend(Chart.prototype, {
/**
* Fit an inner box to an outer. If the inner box overflows left or right, align it to the sides of the
* outer. If it overflows both sides, fit it within the outer. This is a pattern that occurs more places
* in Highcharts, perhaps it should be elevated to a common utility function.
*/
fitToBox: function(inner, outer) {
each([
['x', 'width'],
['y', 'height']
], function(dim) {
var pos = dim[0],
size = dim[1];
if (inner[pos] + inner[size] > outer[pos] + outer[size]) { // right overflow
if (inner[size] > outer[size]) { // the general size is greater, fit fully to outer
inner[size] = outer[size];
inner[pos] = outer[pos];
} else { // align right
inner[pos] = outer[pos] + outer[size] - inner[size];
}
}
if (inner[size] > outer[size]) {
inner[size] = outer[size];
}
if (inner[pos] < outer[pos]) {
inner[pos] = outer[pos];
}
});
return inner;
},
/**
* Zoom the map in or out by a certain amount. Less than 1 zooms in, greater than 1 zooms out.
*/
mapZoom: function(howMuch, centerXArg, centerYArg, mouseX, mouseY) {
/*if (this.isMapZooming) {
this.mapZoomQueue = arguments;
return;
}*/
var chart = this,
xAxis = chart.xAxis[0],
xRange = xAxis.max - xAxis.min,
centerX = pick(centerXArg, xAxis.min + xRange / 2),
newXRange = xRange * howMuch,
yAxis = chart.yAxis[0],
yRange = yAxis.max - yAxis.min,
centerY = pick(centerYArg, yAxis.min + yRange / 2),
newYRange = yRange * howMuch,
fixToX = mouseX ? ((mouseX - xAxis.pos) / xAxis.len) : 0.5,
fixToY = mouseY ? ((mouseY - yAxis.pos) / yAxis.len) : 0.5,
newXMin = centerX - newXRange * fixToX,
newYMin = centerY - newYRange * fixToY,
newExt = chart.fitToBox({
x: newXMin,
y: newYMin,
width: newXRange,
height: newYRange
}, {
x: xAxis.dataMin,
y: yAxis.dataMin,
width: xAxis.dataMax - xAxis.dataMin,
height: yAxis.dataMax - yAxis.dataMin
}),
zoomOut = newExt.x <= xAxis.dataMin &&
newExt.width >= xAxis.dataMax - xAxis.dataMin &&
newExt.y <= yAxis.dataMin &&
newExt.height >= yAxis.dataMax - yAxis.dataMin;
// When mousewheel zooming, fix the point under the mouse
if (mouseX) {
xAxis.fixTo = [mouseX - xAxis.pos, centerXArg];
}
if (mouseY) {
yAxis.fixTo = [mouseY - yAxis.pos, centerYArg];
}
// Zoom
if (howMuch !== undefined && !zoomOut) {
xAxis.setExtremes(newExt.x, newExt.x + newExt.width, false);
yAxis.setExtremes(newExt.y, newExt.y + newExt.height, false);
// Reset zoom
} else {
xAxis.setExtremes(undefined, undefined, false);
yAxis.setExtremes(undefined, undefined, false);
}
// Prevent zooming until this one is finished animating
/*chart.holdMapZoom = true;
setTimeout(function () {
chart.holdMapZoom = false;
}, 200);*/
/*delay = animation ? animation.duration || 500 : 0;
if (delay) {
chart.isMapZooming = true;
setTimeout(function () {
chart.isMapZooming = false;
if (chart.mapZoomQueue) {
chart.mapZoom.apply(chart, chart.mapZoomQueue);
}
chart.mapZoomQueue = null;
}, delay);
}*/
chart.redraw();
}
});
/**
* Extend the Chart.render method to add zooming and panning
*/
wrap(Chart.prototype, 'render', function(proceed) {
// Render the plus and minus buttons. Doing this before the shapes makes getBBox much quicker, at least in Chrome.
this.mapNavigation = new MapNavigation(this);
this.mapNavigation.update();
proceed.call(this);
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var extend = H.extend,
pick = H.pick,
Pointer = H.Pointer,
wrap = H.wrap;
// Extend the Pointer
extend(Pointer.prototype, {
/**
* The event handler for the doubleclick event
*/
onContainerDblClick: function(e) {
var chart = this.chart;
e = this.normalize(e);
if (chart.options.mapNavigation.enableDoubleClickZoomTo) {
if (chart.pointer.inClass(e.target, 'highcharts-tracker') && chart.hoverPoint) {
chart.hoverPoint.zoomTo();
}
} else if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
chart.mapZoom(
0.5,
chart.xAxis[0].toValue(e.chartX),
chart.yAxis[0].toValue(e.chartY),
e.chartX,
e.chartY
);
}
},
/**
* The event handler for the mouse scroll event
*/
onContainerMouseWheel: function(e) {
var chart = this.chart,
delta;
e = this.normalize(e);
// Firefox uses e.detail, WebKit and IE uses wheelDelta
delta = e.detail || -(e.wheelDelta / 120);
if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
chart.mapZoom(
Math.pow(chart.options.mapNavigation.mouseWheelSensitivity, delta),
chart.xAxis[0].toValue(e.chartX),
chart.yAxis[0].toValue(e.chartY),
e.chartX,
e.chartY
);
}
}
});
// The pinchType is inferred from mapNavigation options.
wrap(Pointer.prototype, 'zoomOption', function(proceed) {
var mapNavigation = this.chart.options.mapNavigation;
// Pinch status
if (pick(mapNavigation.enableTouchZoom, mapNavigation.enabled)) {
this.chart.options.chart.pinchType = 'xy';
}
proceed.apply(this, [].slice.call(arguments, 1));
});
// Extend the pinchTranslate method to preserve fixed ratio when zooming
wrap(Pointer.prototype, 'pinchTranslate', function(proceed, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
var xBigger;
proceed.call(this, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
// Keep ratio
if (this.chart.options.chart.type === 'map' && this.hasZoom) {
xBigger = transform.scaleX > transform.scaleY;
this.pinchTranslateDirection(!xBigger,
pinchDown,
touches,
transform,
selectionMarker,
clip,
lastValidTouch,
xBigger ? transform.scaleX : transform.scaleY
);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var color = H.color,
ColorAxis = H.ColorAxis,
colorPointMixin = H.colorPointMixin,
colorSeriesMixin = H.colorSeriesMixin,
doc = H.doc,
each = H.each,
extend = H.extend,
isNumber = H.isNumber,
LegendSymbolMixin = H.LegendSymbolMixin,
map = H.map,
merge = H.merge,
noop = H.noop,
pick = H.pick,
isArray = H.isArray,
Point = H.Point,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes,
splat = H.splat;
// The vector-effect attribute is not supported in IE <= 11 (at least), so we need
// diffent logic (#3218)
var supportsVectorEffect = doc.documentElement.style.vectorEffect !== undefined;
/**
* The MapAreaPoint object
*/
/**
* Add the map series type
*/
seriesType('map', 'scatter', {
allAreas: true,
animation: false, // makes the complex shapes slow
nullColor: '#f7f7f7',
borderColor: '#cccccc',
borderWidth: 1,
marker: null,
stickyTracking: false,
joinBy: 'hc-key',
dataLabels: {
formatter: function() { // #2945
return this.point.value;
},
inside: true, // for the color
verticalAlign: 'middle',
crop: false,
overflow: false,
padding: 0
},
turboThreshold: 0,
tooltip: {
followPointer: true,
pointFormat: '{point.name}: {point.value}<br/>'
},
states: {
normal: {
animation: true
},
hover: {
brightness: 0.2,
halo: null
},
select: {
color: '#cccccc'
}
}
// Prototype members
}, merge(colorSeriesMixin, {
type: 'map',
supportsDrilldown: true,
getExtremesFromAll: true,
useMapGeometry: true, // get axis extremes from paths, not values
forceDL: true,
searchPoint: noop,
directTouch: true, // When tooltip is not shared, this series (and derivatives) requires direct touch/hover. KD-tree does not apply.
preserveAspectRatio: true, // X axis and Y axis must have same translation slope
pointArrayMap: ['value'],
/**
* Get the bounding box of all paths in the map combined.
*/
getBox: function(paths) {
var MAX_VALUE = Number.MAX_VALUE,
maxX = -MAX_VALUE,
minX = MAX_VALUE,
maxY = -MAX_VALUE,
minY = MAX_VALUE,
minRange = MAX_VALUE,
xAxis = this.xAxis,
yAxis = this.yAxis,
hasBox;
// Find the bounding box
each(paths || [], function(point) {
if (point.path) {
if (typeof point.path === 'string') {
point.path = H.splitPath(point.path);
}
var path = point.path || [],
i = path.length,
even = false, // while loop reads from the end
pointMaxX = -MAX_VALUE,
pointMinX = MAX_VALUE,
pointMaxY = -MAX_VALUE,
pointMinY = MAX_VALUE,
properties = point.properties;
// The first time a map point is used, analyze its box
if (!point._foundBox) {
while (i--) {
if (isNumber(path[i])) {
if (even) { // even = x
pointMaxX = Math.max(pointMaxX, path[i]);
pointMinX = Math.min(pointMinX, path[i]);
} else { // odd = Y
pointMaxY = Math.max(pointMaxY, path[i]);
pointMinY = Math.min(pointMinY, path[i]);
}
even = !even;
}
}
// Cache point bounding box for use to position data labels, bubbles etc
point._midX = pointMinX + (pointMaxX - pointMinX) *
(point.middleX || (properties && properties['hc-middle-x']) || 0.5); // pick is slower and very marginally needed
point._midY = pointMinY + (pointMaxY - pointMinY) *
(point.middleY || (properties && properties['hc-middle-y']) || 0.5);
point._maxX = pointMaxX;
point._minX = pointMinX;
point._maxY = pointMaxY;
point._minY = pointMinY;
point.labelrank = pick(point.labelrank, (pointMaxX - pointMinX) * (pointMaxY - pointMinY));
point._foundBox = true;
}
maxX = Math.max(maxX, point._maxX);
minX = Math.min(minX, point._minX);
maxY = Math.max(maxY, point._maxY);
minY = Math.min(minY, point._minY);
minRange = Math.min(point._maxX - point._minX, point._maxY - point._minY, minRange);
hasBox = true;
}
});
// Set the box for the whole series
if (hasBox) {
this.minY = Math.min(minY, pick(this.minY, MAX_VALUE));
this.maxY = Math.max(maxY, pick(this.maxY, -MAX_VALUE));
this.minX = Math.min(minX, pick(this.minX, MAX_VALUE));
this.maxX = Math.max(maxX, pick(this.maxX, -MAX_VALUE));
// If no minRange option is set, set the default minimum zooming range to 5 times the
// size of the smallest element
if (xAxis && xAxis.options.minRange === undefined) {
xAxis.minRange = Math.min(5 * minRange, (this.maxX - this.minX) / 5, xAxis.minRange || MAX_VALUE);
}
if (yAxis && yAxis.options.minRange === undefined) {
yAxis.minRange = Math.min(5 * minRange, (this.maxY - this.minY) / 5, yAxis.minRange || MAX_VALUE);
}
}
},
getExtremes: function() {
// Get the actual value extremes for colors
Series.prototype.getExtremes.call(this, this.valueData);
// Recalculate box on updated data
if (this.chart.hasRendered && this.isDirtyData) {
this.getBox(this.options.data);
}
this.valueMin = this.dataMin;
this.valueMax = this.dataMax;
// Extremes for the mock Y axis
this.dataMin = this.minY;
this.dataMax = this.maxY;
},
/**
* Translate the path so that it automatically fits into the plot area box
* @param {Object} path
*/
translatePath: function(path) {
var series = this,
even = false, // while loop reads from the end
xAxis = series.xAxis,
yAxis = series.yAxis,
xMin = xAxis.min,
xTransA = xAxis.transA,
xMinPixelPadding = xAxis.minPixelPadding,
yMin = yAxis.min,
yTransA = yAxis.transA,
yMinPixelPadding = yAxis.minPixelPadding,
i,
ret = []; // Preserve the original
// Do the translation
if (path) {
i = path.length;
while (i--) {
if (isNumber(path[i])) {
ret[i] = even ?
(path[i] - xMin) * xTransA + xMinPixelPadding :
(path[i] - yMin) * yTransA + yMinPixelPadding;
even = !even;
} else {
ret[i] = path[i];
}
}
}
return ret;
},
/**
* Extend setData to join in mapData. If the allAreas option is true, all areas
* from the mapData are used, and those that don't correspond to a data value
* are given null values.
*/
setData: function(data, redraw, animation, updatePoints) {
var options = this.options,
chartOptions = this.chart.options.chart,
globalMapData = chartOptions && chartOptions.map,
mapData = options.mapData,
joinBy = options.joinBy,
joinByNull = joinBy === null,
pointArrayMap = options.keys || this.pointArrayMap,
dataUsed = [],
mapMap = {},
mapPoint,
transform,
mapTransforms = this.chart.mapTransforms,
props,
i;
// Collect mapData from chart options if not defined on series
if (!mapData && globalMapData) {
mapData = typeof globalMapData === 'string' ? H.maps[globalMapData] : globalMapData;
}
if (joinByNull) {
joinBy = '_i';
}
joinBy = this.joinBy = splat(joinBy);
if (!joinBy[1]) {
joinBy[1] = joinBy[0];
}
// Pick up numeric values, add index
// Convert Array point definitions to objects using pointArrayMap
if (data) {
each(data, function(val, i) {
var ix = 0;
if (isNumber(val)) {
data[i] = {
value: val
};
} else if (isArray(val)) {
data[i] = {};
// Automatically copy first item to hc-key if there is an extra leading string
if (!options.keys && val.length > pointArrayMap.length && typeof val[0] === 'string') {
data[i]['hc-key'] = val[0];
++ix;
}
// Run through pointArrayMap and what's left of the point data array in parallel, copying over the values
for (var j = 0; j < pointArrayMap.length; ++j, ++ix) {
if (pointArrayMap[j]) {
data[i][pointArrayMap[j]] = val[ix];
}
}
}
if (joinByNull) {
data[i]._i = i;
}
});
}
this.getBox(data);
// Pick up transform definitions for chart
this.chart.mapTransforms = mapTransforms = chartOptions && chartOptions.mapTransforms || mapData && mapData['hc-transform'] || mapTransforms;
// Cache cos/sin of transform rotation angle
if (mapTransforms) {
for (transform in mapTransforms) {
if (mapTransforms.hasOwnProperty(transform) && transform.rotation) {
transform.cosAngle = Math.cos(transform.rotation);
transform.sinAngle = Math.sin(transform.rotation);
}
}
}
if (mapData) {
if (mapData.type === 'FeatureCollection') {
this.mapTitle = mapData.title;
mapData = H.geojson(mapData, this.type, this);
}
this.mapData = mapData;
this.mapMap = {};
for (i = 0; i < mapData.length; i++) {
mapPoint = mapData[i];
props = mapPoint.properties;
mapPoint._i = i;
// Copy the property over to root for faster access
if (joinBy[0] && props && props[joinBy[0]]) {
mapPoint[joinBy[0]] = props[joinBy[0]];
}
mapMap[mapPoint[joinBy[0]]] = mapPoint;
}
this.mapMap = mapMap;
// Registered the point codes that actually hold data
if (data && joinBy[1]) {
each(data, function(point) {
if (mapMap[point[joinBy[1]]]) {
dataUsed.push(mapMap[point[joinBy[1]]]);
}
});
}
if (options.allAreas) {
this.getBox(mapData);
data = data || [];
// Registered the point codes that actually hold data
if (joinBy[1]) {
each(data, function(point) {
dataUsed.push(point[joinBy[1]]);
});
}
// Add those map points that don't correspond to data, which will be drawn as null points
dataUsed = '|' + map(dataUsed, function(point) {
return point && point[joinBy[0]];
}).join('|') + '|'; // String search is faster than array.indexOf
each(mapData, function(mapPoint) {
if (!joinBy[0] || dataUsed.indexOf('|' + mapPoint[joinBy[0]] + '|') === -1) {
data.push(merge(mapPoint, {
value: null
}));
updatePoints = false; // #5050 - adding all areas causes the update optimization of setData to kick in, even though the point order has changed
}
});
} else {
this.getBox(dataUsed); // Issue #4784
}
}
Series.prototype.setData.call(this, data, redraw, animation, updatePoints);
},
/**
* No graph for the map series
*/
drawGraph: noop,
/**
* We need the points' bounding boxes in order to draw the data labels, so
* we skip it now and call it from drawPoints instead.
*/
drawDataLabels: noop,
/**
* Allow a quick redraw by just translating the area group. Used for zooming and panning
* in capable browsers.
*/
doFullTranslate: function() {
return this.isDirtyData || this.chart.isResizing || this.chart.renderer.isVML || !this.baseTrans;
},
/**
* Add the path option for data points. Find the max value for color calculation.
*/
translate: function() {
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis,
doFullTranslate = series.doFullTranslate();
series.generatePoints();
each(series.data, function(point) {
// Record the middle point (loosely based on centroid), determined
// by the middleX and middleY options.
point.plotX = xAxis.toPixels(point._midX, true);
point.plotY = yAxis.toPixels(point._midY, true);
if (doFullTranslate) {
point.shapeType = 'path';
point.shapeArgs = {
d: series.translatePath(point.path)
};
}
});
series.translateColors();
},
/**
* Get presentational attributes. In the maps series this runs in both
* styled and non-styled mode, because colors hold data when a colorAxis
* is used.
*/
pointAttribs: function(point, state) {
var attr;
attr = seriesTypes.column.prototype.pointAttribs.call(
this, point, state
);
// Prevent flickering whan called from setState
if (point.isFading) {
delete attr.fill;
}
// If vector-effect is not supported, we set the stroke-width on the group element
// and let all point graphics inherit. That way we don't have to iterate over all
// points to update the stroke-width on zooming. TODO: Check unstyled
if (supportsVectorEffect) {
attr['vector-effect'] = 'non-scaling-stroke';
} else {
attr['stroke-width'] = 'inherit';
}
return attr;
},
/**
* Use the drawPoints method of column, that is able to handle simple shapeArgs.
* Extend it by assigning the tooltip position.
*/
drawPoints: function() {
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis,
group = series.group,
chart = series.chart,
renderer = chart.renderer,
scaleX,
scaleY,
translateX,
translateY,
baseTrans = this.baseTrans,
transformGroup,
startTranslateX,
startTranslateY,
startScaleX,
startScaleY;
// Set a group that handles transform during zooming and panning in order to preserve clipping
// on series.group
if (!series.transformGroup) {
series.transformGroup = renderer.g()
.attr({
scaleX: 1,
scaleY: 1
})
.add(group);
series.transformGroup.survive = true;
}
// Draw the shapes again
if (series.doFullTranslate()) {
// Individual point actions. TODO: Check unstyled.
if (chart.hasRendered) {
each(series.points, function(point) {
// Restore state color on update/redraw (#3529)
if (point.shapeArgs) {
point.shapeArgs.fill = series.pointAttribs(point, point.state).fill;
}
});
}
// Draw them in transformGroup
series.group = series.transformGroup;
seriesTypes.column.prototype.drawPoints.apply(series);
series.group = group; // Reset
// Add class names
each(series.points, function(point) {
if (point.graphic) {
if (point.name) {
point.graphic.addClass('highcharts-name-' + point.name.replace(/ /g, '-').toLowerCase());
}
if (point.properties && point.properties['hc-key']) {
point.graphic.addClass('highcharts-key-' + point.properties['hc-key'].toLowerCase());
}
}
});
// Set the base for later scale-zooming. The originX and originY properties are the
// axis values in the plot area's upper left corner.
this.baseTrans = {
originX: xAxis.min - xAxis.minPixelPadding / xAxis.transA,
originY: yAxis.min - yAxis.minPixelPadding / yAxis.transA + (yAxis.reversed ? 0 : yAxis.len / yAxis.transA),
transAX: xAxis.transA,
transAY: yAxis.transA
};
// Reset transformation in case we're doing a full translate (#3789)
this.transformGroup.animate({
translateX: 0,
translateY: 0,
scaleX: 1,
scaleY: 1
});
// Just update the scale and transform for better performance
} else {
scaleX = xAxis.transA / baseTrans.transAX;
scaleY = yAxis.transA / baseTrans.transAY;
translateX = xAxis.toPixels(baseTrans.originX, true);
translateY = yAxis.toPixels(baseTrans.originY, true);
// Handle rounding errors in normal view (#3789)
if (scaleX > 0.99 && scaleX < 1.01 && scaleY > 0.99 && scaleY < 1.01) {
scaleX = 1;
scaleY = 1;
translateX = Math.round(translateX);
translateY = Math.round(translateY);
}
// Animate or move to the new zoom level. In order to prevent
// flickering as the different transform components are set out of
// sync (#5991), we run a fake animator attribute and set scale and
// translation synchronously in the same step.
// A possible improvement to the API would be to handle this in the
// renderer or animation engine itself, to ensure that when we are
// animating multiple properties, we make sure that each step for
// each property is performed in the same step. Also, for symbols
// and for transform properties, it should induce a single
// updateTransform and symbolAttr call.
transformGroup = this.transformGroup;
if (chart.renderer.globalAnimation) {
startTranslateX = transformGroup.attr('translateX');
startTranslateY = transformGroup.attr('translateY');
startScaleX = transformGroup.attr('scaleX');
startScaleY = transformGroup.attr('scaleY');
transformGroup
.attr({
animator: 0
})
.animate({
animator: 1
}, {
step: function(now, fx) {
transformGroup.attr({
translateX: startTranslateX +
(translateX - startTranslateX) * fx.pos,
translateY: startTranslateY +
(translateY - startTranslateY) * fx.pos,
scaleX: startScaleX +
(scaleX - startScaleX) * fx.pos,
scaleY: startScaleY +
(scaleY - startScaleY) * fx.pos
});
}
});
// When dragging, animation is off.
} else {
transformGroup.attr({
translateX: translateX,
translateY: translateY,
scaleX: scaleX,
scaleY: scaleY
});
}
}
// Set the stroke-width directly on the group element so the children inherit it. We need to use
// setAttribute directly, because the stroke-widthSetter method expects a stroke color also to be
// set.
if (!supportsVectorEffect) {
series.group.element.setAttribute(
'stroke-width',
series.options[
(series.pointAttrToOptions && series.pointAttrToOptions['stroke-width']) || 'borderWidth'
] / (scaleX || 1)
);
}
this.drawMapDataLabels();
},
/**
* Draw the data labels. Special for maps is the time that the data labels are drawn (after points),
* and the clipping of the dataLabelsGroup.
*/
drawMapDataLabels: function() {
Series.prototype.drawDataLabels.call(this);
if (this.dataLabelsGroup) {
this.dataLabelsGroup.clip(this.chart.clipRect);
}
},
/**
* Override render to throw in an async call in IE8. Otherwise it chokes on the US counties demo.
*/
render: function() {
var series = this,
render = Series.prototype.render;
// Give IE8 some time to breathe.
if (series.chart.renderer.isVML && series.data.length > 3000) {
setTimeout(function() {
render.call(series);
});
} else {
render.call(series);
}
},
/**
* The initial animation for the map series. By default, animation is disabled.
* Animation of map shapes is not at all supported in VML browsers.
*/
animate: function(init) {
var chart = this.chart,
animation = this.options.animation,
group = this.group,
xAxis = this.xAxis,
yAxis = this.yAxis,
left = xAxis.pos,
top = yAxis.pos;
if (chart.renderer.isSVG) {
if (animation === true) {
animation = {
duration: 1000
};
}
// Initialize the animation
if (init) {
// Scale down the group and place it in the center
group.attr({
translateX: left + xAxis.len / 2,
translateY: top + yAxis.len / 2,
scaleX: 0.001, // #1499
scaleY: 0.001
});
// Run the animation
} else {
group.animate({
translateX: left,
translateY: top,
scaleX: 1,
scaleY: 1
}, animation);
// Delete this function to allow it only once
this.animate = null;
}
}
},
/**
* Animate in the new series from the clicked point in the old series.
* Depends on the drilldown.js module
*/
animateDrilldown: function(init) {
var toBox = this.chart.plotBox,
level = this.chart.drilldownLevels[this.chart.drilldownLevels.length - 1],
fromBox = level.bBox,
animationOptions = this.chart.options.drilldown.animation,
scale;
if (!init) {
scale = Math.min(fromBox.width / toBox.width, fromBox.height / toBox.height);
level.shapeArgs = {
scaleX: scale,
scaleY: scale,
translateX: fromBox.x,
translateY: fromBox.y
};
each(this.points, function(point) {
if (point.graphic) {
point.graphic
.attr(level.shapeArgs)
.animate({
scaleX: 1,
scaleY: 1,
translateX: 0,
translateY: 0
}, animationOptions);
}
});
this.animate = null;
}
},
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
/**
* When drilling up, pull out the individual point graphics from the lower series
* and animate them into the origin point in the upper series.
*/
animateDrillupFrom: function(level) {
seriesTypes.column.prototype.animateDrillupFrom.call(this, level);
},
/**
* When drilling up, keep the upper series invisible until the lower series has
* moved into place
*/
animateDrillupTo: function(init) {
seriesTypes.column.prototype.animateDrillupTo.call(this, init);
}
// Point class
}), extend({
/**
* Extend the Point object to split paths
*/
applyOptions: function(options, x) {
var point = Point.prototype.applyOptions.call(this, options, x),
series = this.series,
joinBy = series.joinBy,
mapPoint;
if (series.mapData) {
mapPoint = point[joinBy[1]] !== undefined && series.mapMap[point[joinBy[1]]];
if (mapPoint) {
// This applies only to bubbles
if (series.xyFromShape) {
point.x = mapPoint._midX;
point.y = mapPoint._midY;
}
extend(point, mapPoint); // copy over properties
} else {
point.value = point.value || null;
}
}
return point;
},
/**
* Stop the fade-out
*/
onMouseOver: function(e) {
clearTimeout(this.colorInterval);
if (this.value !== null) {
Point.prototype.onMouseOver.call(this, e);
} else { //#3401 Tooltip doesn't hide when hovering over null points
this.series.onMouseOut(e);
}
},
// Todo: check unstyled
/**
* Custom animation for tweening out the colors. Animation reduces blinking when hovering
* over islands and coast lines. We run a custom implementation of animation becuase we
* need to be able to run this independently from other animations like zoom redraw. Also,
* adding color animation to the adapters would introduce almost the same amount of code.
*/
onMouseOut: function() {
var point = this,
start = +new Date(),
normalColor = color(this.series.pointAttribs(point).fill),
hoverColor = color(this.series.pointAttribs(point, 'hover').fill),
animation = point.series.options.states.normal.animation,
duration = animation && (animation.duration || 500);
if (duration && normalColor.rgba.length === 4 && hoverColor.rgba.length === 4 && point.state !== 'select') {
clearTimeout(point.colorInterval);
point.colorInterval = setInterval(function() {
var pos = (new Date() - start) / duration,
graphic = point.graphic;
if (pos > 1) {
pos = 1;
}
if (graphic) {
graphic.attr('fill', ColorAxis.prototype.tweenColors.call(0, hoverColor, normalColor, pos));
}
if (pos >= 1) {
clearTimeout(point.colorInterval);
}
}, 13);
point.isFading = true;
}
Point.prototype.onMouseOut.call(point);
point.isFading = null;
},
/**
* Zoom the chart to view a specific area point
*/
zoomTo: function() {
var point = this,
series = point.series;
series.xAxis.setExtremes(
point._minX,
point._maxX,
false
);
series.yAxis.setExtremes(
point._minY,
point._maxY,
false
);
series.chart.redraw();
}
}, colorPointMixin));
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
// The mapline series type
seriesType('mapline', 'map', {
lineWidth: 1,
fillColor: 'none'
}, {
type: 'mapline',
colorProp: 'stroke',
pointAttrToOptions: {
'stroke': 'color',
'stroke-width': 'lineWidth'
},
/**
* Get presentational attributes
*/
pointAttribs: function(point, state) {
var attr = seriesTypes.map.prototype.pointAttribs.call(this, point, state);
// The difference from a map series is that the stroke takes the point color
attr.fill = this.options.fillColor;
return attr;
},
drawLegendSymbol: seriesTypes.line.prototype.drawLegendSymbol
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var merge = H.merge,
Point = H.Point,
seriesType = H.seriesType;
// The mappoint series type
seriesType('mappoint', 'scatter', {
dataLabels: {
enabled: true,
formatter: function() { // #2945
return this.point.name;
},
crop: false,
defer: false,
overflow: false,
style: {
color: '#000000'
}
}
// Prototype members
}, {
type: 'mappoint',
forceDL: true
// Point class
}, {
applyOptions: function(options, x) {
var mergedOptions = options.lat !== undefined && options.lon !== undefined ? merge(options, this.series.chart.fromLatLonToPoint(options)) : options;
return Point.prototype.applyOptions.call(this, mergedOptions, x);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
Axis = H.Axis,
color = H.color,
each = H.each,
isNumber = H.isNumber,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
Point = H.Point,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/* ****************************************************************************
* Start Bubble series code *
*****************************************************************************/
seriesType('bubble', 'scatter', {
dataLabels: {
formatter: function() { // #2945
return this.point.z;
},
inside: true,
verticalAlign: 'middle'
},
// displayNegative: true,
marker: {
// fillOpacity: 0.5,
lineColor: null, // inherit from series.color
lineWidth: 1,
// Avoid offset in Point.setState
radius: null,
states: {
hover: {
radiusPlus: 0
}
},
symbol: 'circle'
},
minSize: 8,
maxSize: '20%',
// negativeColor: null,
// sizeBy: 'area'
softThreshold: false,
states: {
hover: {
halo: {
size: 5
}
}
},
tooltip: {
pointFormat: '({point.x}, {point.y}), Size: {point.z}'
},
turboThreshold: 0,
zThreshold: 0,
zoneAxis: 'z'
// Prototype members
}, {
pointArrayMap: ['y', 'z'],
parallelArrays: ['x', 'y', 'z'],
trackerGroups: ['markerGroup', 'dataLabelsGroup'],
bubblePadding: true,
zoneAxis: 'z',
directTouch: true,
pointAttribs: function(point, state) {
var markerOptions = this.options.marker,
fillOpacity = pick(markerOptions.fillOpacity, 0.5),
attr = Series.prototype.pointAttribs.call(this, point, state);
if (fillOpacity !== 1) {
attr.fill = color(attr.fill).setOpacity(fillOpacity).get('rgba');
}
return attr;
},
/**
* Get the radius for each point based on the minSize, maxSize and each point's Z value. This
* must be done prior to Series.translate because the axis needs to add padding in
* accordance with the point sizes.
*/
getRadii: function(zMin, zMax, minSize, maxSize) {
var len,
i,
pos,
zData = this.zData,
radii = [],
options = this.options,
sizeByArea = options.sizeBy !== 'width',
zThreshold = options.zThreshold,
zRange = zMax - zMin,
value,
radius;
// Set the shape type and arguments to be picked up in drawPoints
for (i = 0, len = zData.length; i < len; i++) {
value = zData[i];
// When sizing by threshold, the absolute value of z determines the size
// of the bubble.
if (options.sizeByAbsoluteValue && value !== null) {
value = Math.abs(value - zThreshold);
zMax = Math.max(zMax - zThreshold, Math.abs(zMin - zThreshold));
zMin = 0;
}
if (value === null) {
radius = null;
// Issue #4419 - if value is less than zMin, push a radius that's always smaller than the minimum size
} else if (value < zMin) {
radius = minSize / 2 - 1;
} else {
// Relative size, a number between 0 and 1
pos = zRange > 0 ? (value - zMin) / zRange : 0.5;
if (sizeByArea && pos >= 0) {
pos = Math.sqrt(pos);
}
radius = Math.ceil(minSize + pos * (maxSize - minSize)) / 2;
}
radii.push(radius);
}
this.radii = radii;
},
/**
* Perform animation on the bubbles
*/
animate: function(init) {
var animation = this.options.animation;
if (!init) { // run the animation
each(this.points, function(point) {
var graphic = point.graphic,
animationTarget;
if (graphic && graphic.width) { // URL symbols don't have width
animationTarget = {
x: graphic.x,
y: graphic.y,
width: graphic.width,
height: graphic.height
};
// Start values
graphic.attr({
x: point.plotX,
y: point.plotY,
width: 1,
height: 1
});
// Run animation
graphic.animate(animationTarget, animation);
}
});
// delete this function to allow it only once
this.animate = null;
}
},
/**
* Extend the base translate method to handle bubble size
*/
translate: function() {
var i,
data = this.data,
point,
radius,
radii = this.radii;
// Run the parent method
seriesTypes.scatter.prototype.translate.call(this);
// Set the shape type and arguments to be picked up in drawPoints
i = data.length;
while (i--) {
point = data[i];
radius = radii ? radii[i] : 0; // #1737
if (isNumber(radius) && radius >= this.minPxSize / 2) {
// Shape arguments
point.marker = H.extend(point.marker, {
radius: radius,
width: 2 * radius,
height: 2 * radius
});
// Alignment box for the data label
point.dlBox = {
x: point.plotX - radius,
y: point.plotY - radius,
width: 2 * radius,
height: 2 * radius
};
} else { // below zThreshold
point.shapeArgs = point.plotY = point.dlBox = undefined; // #1691
}
}
},
alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
buildKDTree: noop,
applyZones: noop
// Point class
}, {
haloPath: function(size) {
return Point.prototype.haloPath.call(
this,
size === 0 ? 0 : (this.marker ? this.marker.radius || 0 : 0) + size // #6067
);
},
ttBelow: false
});
/**
* Add logic to pad each axis with the amount of pixels
* necessary to avoid the bubbles to overflow.
*/
Axis.prototype.beforePadding = function() {
var axis = this,
axisLength = this.len,
chart = this.chart,
pxMin = 0,
pxMax = axisLength,
isXAxis = this.isXAxis,
dataKey = isXAxis ? 'xData' : 'yData',
min = this.min,
extremes = {},
smallestSize = Math.min(chart.plotWidth, chart.plotHeight),
zMin = Number.MAX_VALUE,
zMax = -Number.MAX_VALUE,
range = this.max - min,
transA = axisLength / range,
activeSeries = [];
// Handle padding on the second pass, or on redraw
each(this.series, function(series) {
var seriesOptions = series.options,
zData;
if (series.bubblePadding && (series.visible || !chart.options.chart.ignoreHiddenSeries)) {
// Correction for #1673
axis.allowZoomOutside = true;
// Cache it
activeSeries.push(series);
if (isXAxis) { // because X axis is evaluated first
// For each series, translate the size extremes to pixel values
each(['minSize', 'maxSize'], function(prop) {
var length = seriesOptions[prop],
isPercent = /%$/.test(length);
length = pInt(length);
extremes[prop] = isPercent ?
smallestSize * length / 100 :
length;
});
series.minPxSize = extremes.minSize;
// Prioritize min size if conflict to make sure bubbles are
// always visible. #5873
series.maxPxSize = Math.max(extremes.maxSize, extremes.minSize);
// Find the min and max Z
zData = series.zData;
if (zData.length) { // #1735
zMin = pick(seriesOptions.zMin, Math.min(
zMin,
Math.max(
arrayMin(zData),
seriesOptions.displayNegative === false ? seriesOptions.zThreshold : -Number.MAX_VALUE
)
));
zMax = pick(seriesOptions.zMax, Math.max(zMax, arrayMax(zData)));
}
}
}
});
each(activeSeries, function(series) {
var data = series[dataKey],
i = data.length,
radius;
if (isXAxis) {
series.getRadii(zMin, zMax, series.minPxSize, series.maxPxSize);
}
if (range > 0) {
while (i--) {
if (isNumber(data[i]) && axis.dataMin <= data[i] && data[i] <= axis.dataMax) {
radius = series.radii[i];
pxMin = Math.min(((data[i] - min) * transA) - radius, pxMin);
pxMax = Math.max(((data[i] - min) * transA) + radius, pxMax);
}
}
}
});
if (activeSeries.length && range > 0 && !this.isLog) {
pxMax -= axisLength;
transA *= (axisLength + pxMin - pxMax) / axisLength;
each([
['min', 'userMin', pxMin],
['max', 'userMax', pxMax]
], function(keys) {
if (pick(axis.options[keys[0]], axis[keys[1]]) === undefined) {
axis[keys[0]] += keys[2] / transA;
}
});
}
};
/* ****************************************************************************
* End Bubble series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var merge = H.merge,
Point = H.Point,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
// The mapbubble series type
if (seriesTypes.bubble) {
seriesType('mapbubble', 'bubble', {
animationLimit: 500,
tooltip: {
pointFormat: '{point.name}: {point.z}'
}
// Prototype members
}, {
xyFromShape: true,
type: 'mapbubble',
pointArrayMap: ['z'], // If one single value is passed, it is interpreted as z
/**
* Return the map area identified by the dataJoinBy option
*/
getMapData: seriesTypes.map.prototype.getMapData,
getBox: seriesTypes.map.prototype.getBox,
setData: seriesTypes.map.prototype.setData
// Point class
}, {
applyOptions: function(options, x) {
var point;
if (options && options.lat !== undefined && options.lon !== undefined) {
point = Point.prototype.applyOptions.call(
this,
merge(options, this.series.chart.fromLatLonToPoint(options)),
x
);
} else {
point = seriesTypes.map.prototype.pointClass.prototype.applyOptions.call(this, options, x);
}
return point;
},
ttBelow: false
});
}
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var colorPointMixin = H.colorPointMixin,
colorSeriesMixin = H.colorSeriesMixin,
each = H.each,
LegendSymbolMixin = H.LegendSymbolMixin,
merge = H.merge,
noop = H.noop,
pick = H.pick,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
// The Heatmap series type
seriesType('heatmap', 'scatter', {
animation: false,
borderWidth: 0,
nullColor: '#f7f7f7',
dataLabels: {
formatter: function() { // #2945
return this.point.value;
},
inside: true,
verticalAlign: 'middle',
crop: false,
overflow: false,
padding: 0 // #3837
},
marker: null,
pointRange: null, // dynamically set to colsize by default
tooltip: {
pointFormat: '{point.x}, {point.y}: {point.value}<br/>'
},
states: {
normal: {
animation: true
},
hover: {
halo: false, // #3406, halo is not required on heatmaps
brightness: 0.2
}
}
}, merge(colorSeriesMixin, {
pointArrayMap: ['y', 'value'],
hasPointSpecificOptions: true,
supportsDrilldown: true,
getExtremesFromAll: true,
directTouch: true,
/**
* Override the init method to add point ranges on both axes.
*/
init: function() {
var options;
seriesTypes.scatter.prototype.init.apply(this, arguments);
options = this.options;
options.pointRange = pick(options.pointRange, options.colsize || 1); // #3758, prevent resetting in setData
this.yAxis.axisPointRange = options.rowsize || 1; // general point range
},
translate: function() {
var series = this,
options = series.options,
xAxis = series.xAxis,
yAxis = series.yAxis,
between = function(x, a, b) {
return Math.min(Math.max(a, x), b);
};
series.generatePoints();
each(series.points, function(point) {
var xPad = (options.colsize || 1) / 2,
yPad = (options.rowsize || 1) / 2,
x1 = between(Math.round(xAxis.len - xAxis.translate(point.x - xPad, 0, 1, 0, 1)), -xAxis.len, 2 * xAxis.len),
x2 = between(Math.round(xAxis.len - xAxis.translate(point.x + xPad, 0, 1, 0, 1)), -xAxis.len, 2 * xAxis.len),
y1 = between(Math.round(yAxis.translate(point.y - yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len),
y2 = between(Math.round(yAxis.translate(point.y + yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len);
// Set plotX and plotY for use in K-D-Tree and more
point.plotX = point.clientX = (x1 + x2) / 2;
point.plotY = (y1 + y2) / 2;
point.shapeType = 'rect';
point.shapeArgs = {
x: Math.min(x1, x2),
y: Math.min(y1, y2),
width: Math.abs(x2 - x1),
height: Math.abs(y2 - y1)
};
});
series.translateColors();
},
drawPoints: function() {
seriesTypes.column.prototype.drawPoints.call(this);
each(this.points, function(point) {
point.graphic.attr(this.colorAttribs(point));
}, this);
},
animate: noop,
getBox: noop,
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
getExtremes: function() {
// Get the extremes from the value data
Series.prototype.getExtremes.call(this, this.valueData);
this.valueMin = this.dataMin;
this.valueMax = this.dataMax;
// Get the extremes from the y data
Series.prototype.getExtremes.call(this);
}
}), colorPointMixin);
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Chart = H.Chart,
each = H.each,
extend = H.extend,
format = H.format,
merge = H.merge,
win = H.win,
wrap = H.wrap;
/**
* Test for point in polygon. Polygon defined as array of [x,y] points.
*/
function pointInPolygon(point, polygon) {
var i,
j,
rel1,
rel2,
c = false,
x = point.x,
y = point.y;
for (i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
rel1 = polygon[i][1] > y;
rel2 = polygon[j][1] > y;
if (rel1 !== rel2 && (x < (polygon[j][0] - polygon[i][0]) * (y - polygon[i][1]) / (polygon[j][1] - polygon[i][1]) + polygon[i][0])) {
c = !c;
}
}
return c;
}
/**
* Get point from latLon using specified transform definition
*/
Chart.prototype.transformFromLatLon = function(latLon, transform) {
if (win.proj4 === undefined) {
H.error(21);
return {
x: 0,
y: null
};
}
var projected = win.proj4(transform.crs, [latLon.lon, latLon.lat]),
cosAngle = transform.cosAngle || (transform.rotation && Math.cos(transform.rotation)),
sinAngle = transform.sinAngle || (transform.rotation && Math.sin(transform.rotation)),
rotated = transform.rotation ? [projected[0] * cosAngle + projected[1] * sinAngle, -projected[0] * sinAngle + projected[1] * cosAngle] : projected;
return {
x: ((rotated[0] - (transform.xoffset || 0)) * (transform.scale || 1) + (transform.xpan || 0)) * (transform.jsonres || 1) + (transform.jsonmarginX || 0),
y: (((transform.yoffset || 0) - rotated[1]) * (transform.scale || 1) + (transform.ypan || 0)) * (transform.jsonres || 1) - (transform.jsonmarginY || 0)
};
};
/**
* Get latLon from point using specified transform definition
*/
Chart.prototype.transformToLatLon = function(point, transform) {
if (win.proj4 === undefined) {
H.error(21);
return;
}
var normalized = {
x: ((point.x - (transform.jsonmarginX || 0)) / (transform.jsonres || 1) - (transform.xpan || 0)) / (transform.scale || 1) + (transform.xoffset || 0),
y: ((-point.y - (transform.jsonmarginY || 0)) / (transform.jsonres || 1) + (transform.ypan || 0)) / (transform.scale || 1) + (transform.yoffset || 0)
},
cosAngle = transform.cosAngle || (transform.rotation && Math.cos(transform.rotation)),
sinAngle = transform.sinAngle || (transform.rotation && Math.sin(transform.rotation)),
// Note: Inverted sinAngle to reverse rotation direction
projected = win.proj4(transform.crs, 'WGS84', transform.rotation ? {
x: normalized.x * cosAngle + normalized.y * -sinAngle,
y: normalized.x * sinAngle + normalized.y * cosAngle
} : normalized);
return {
lat: projected.y,
lon: projected.x
};
};
Chart.prototype.fromPointToLatLon = function(point) {
var transforms = this.mapTransforms,
transform;
if (!transforms) {
H.error(22);
return;
}
for (transform in transforms) {
if (transforms.hasOwnProperty(transform) && transforms[transform].hitZone &&
pointInPolygon({
x: point.x,
y: -point.y
}, transforms[transform].hitZone.coordinates[0])) {
return this.transformToLatLon(point, transforms[transform]);
}
}
return this.transformToLatLon(point, transforms['default']); // eslint-disable-line dot-notation
};
Chart.prototype.fromLatLonToPoint = function(latLon) {
var transforms = this.mapTransforms,
transform,
coords;
if (!transforms) {
H.error(22);
return {
x: 0,
y: null
};
}
for (transform in transforms) {
if (transforms.hasOwnProperty(transform) && transforms[transform].hitZone) {
coords = this.transformFromLatLon(latLon, transforms[transform]);
if (pointInPolygon({
x: coords.x,
y: -coords.y
}, transforms[transform].hitZone.coordinates[0])) {
return coords;
}
}
}
return this.transformFromLatLon(latLon, transforms['default']); // eslint-disable-line dot-notation
};
/**
* Convert a geojson object to map data of a given Highcharts type (map, mappoint or mapline).
*/
H.geojson = function(geojson, hType, series) {
var mapData = [],
path = [],
polygonToPath = function(polygon) {
var i,
len = polygon.length;
path.push('M');
for (i = 0; i < len; i++) {
if (i === 1) {
path.push('L');
}
path.push(polygon[i][0], -polygon[i][1]);
}
};
hType = hType || 'map';
each(geojson.features, function(feature) {
var geometry = feature.geometry,
type = geometry.type,
coordinates = geometry.coordinates,
properties = feature.properties,
point;
path = [];
if (hType === 'map' || hType === 'mapbubble') {
if (type === 'Polygon') {
each(coordinates, polygonToPath);
path.push('Z');
} else if (type === 'MultiPolygon') {
each(coordinates, function(items) {
each(items, polygonToPath);
});
path.push('Z');
}
if (path.length) {
point = {
path: path
};
}
} else if (hType === 'mapline') {
if (type === 'LineString') {
polygonToPath(coordinates);
} else if (type === 'MultiLineString') {
each(coordinates, polygonToPath);
}
if (path.length) {
point = {
path: path
};
}
} else if (hType === 'mappoint') {
if (type === 'Point') {
point = {
x: coordinates[0],
y: -coordinates[1]
};
}
}
if (point) {
mapData.push(extend(point, {
name: properties.name || properties.NAME,
properties: properties
}));
}
});
// Create a credits text that includes map source, to be picked up in Chart.addCredits
if (series && geojson.copyrightShort) {
series.chart.mapCredits = format(series.chart.options.credits.mapText, {
geojson: geojson
});
series.chart.mapCreditsFull = format(series.chart.options.credits.mapTextFull, {
geojson: geojson
});
}
return mapData;
};
/**
* Override addCredits to include map source by default
*/
wrap(Chart.prototype, 'addCredits', function(proceed, credits) {
credits = merge(true, this.options.credits, credits);
// Disable credits link if map credits enabled. This to allow for in-text anchors.
if (this.mapCredits) {
credits.href = null;
}
proceed.call(this, credits);
// Add full map credits to hover
if (this.credits && this.mapCreditsFull) {
this.credits.attr({
title: this.mapCreditsFull
});
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Chart = H.Chart,
defaultOptions = H.defaultOptions,
each = H.each,
extend = H.extend,
merge = H.merge,
pick = H.pick,
Renderer = H.Renderer,
SVGRenderer = H.SVGRenderer,
VMLRenderer = H.VMLRenderer;
// Add language
extend(defaultOptions.lang, {
zoomIn: 'Zoom in',
zoomOut: 'Zoom out'
});
// Set the default map navigation options
defaultOptions.mapNavigation = {
buttonOptions: {
alignTo: 'plotBox',
align: 'left',
verticalAlign: 'top',
x: 0,
width: 18,
height: 18,
padding: 5,
style: {
fontSize: '15px',
fontWeight: 'bold'
},
theme: {
'stroke-width': 1,
'text-align': 'center'
}
},
buttons: {
zoomIn: {
onclick: function() {
this.mapZoom(0.5);
},
text: '+',
y: 0
},
zoomOut: {
onclick: function() {
this.mapZoom(2);
},
text: '-',
y: 28
}
},
mouseWheelSensitivity: 1.1
// enabled: false,
// enableButtons: null, // inherit from enabled
// enableTouchZoom: null, // inherit from enabled
// enableDoubleClickZoom: null, // inherit from enabled
// enableDoubleClickZoomTo: false
// enableMouseWheelZoom: null, // inherit from enabled
};
/**
* Utility for reading SVG paths directly.
*/
H.splitPath = function(path) {
var i;
// Move letters apart
path = path.replace(/([A-Za-z])/g, ' $1 ');
// Trim
path = path.replace(/^\s*/, '').replace(/\s*$/, '');
// Split on spaces and commas
path = path.split(/[ ,]+/); // Extra comma to escape gulp.scripts task
// Parse numbers
for (i = 0; i < path.length; i++) {
if (!/[a-zA-Z]/.test(path[i])) {
path[i] = parseFloat(path[i]);
}
}
return path;
};
// A placeholder for map definitions
H.maps = {};
// Create symbols for the zoom buttons
function selectiveRoundedRect(x, y, w, h, rTopLeft, rTopRight, rBottomRight, rBottomLeft) {
return [
'M', x + rTopLeft, y,
// top side
'L', x + w - rTopRight, y,
// top right corner
'C', x + w - rTopRight / 2,
y, x + w,
y + rTopRight / 2, x + w, y + rTopRight,
// right side
'L', x + w, y + h - rBottomRight,
// bottom right corner
'C', x + w, y + h - rBottomRight / 2,
x + w - rBottomRight / 2, y + h,
x + w - rBottomRight, y + h,
// bottom side
'L', x + rBottomLeft, y + h,
// bottom left corner
'C', x + rBottomLeft / 2, y + h,
x, y + h - rBottomLeft / 2,
x, y + h - rBottomLeft,
// left side
'L', x, y + rTopLeft,
// top left corner
'C', x, y + rTopLeft / 2,
x + rTopLeft / 2, y,
x + rTopLeft, y,
'Z'
];
}
SVGRenderer.prototype.symbols.topbutton = function(x, y, w, h, attr) {
return selectiveRoundedRect(x - 1, y - 1, w, h, attr.r, attr.r, 0, 0);
};
SVGRenderer.prototype.symbols.bottombutton = function(x, y, w, h, attr) {
return selectiveRoundedRect(x - 1, y - 1, w, h, 0, 0, attr.r, attr.r);
};
// The symbol callbacks are generated on the SVGRenderer object in all browsers. Even
// VML browsers need this in order to generate shapes in export. Now share
// them with the VMLRenderer.
if (Renderer === VMLRenderer) {
each(['topbutton', 'bottombutton'], function(shape) {
VMLRenderer.prototype.symbols[shape] = SVGRenderer.prototype.symbols[shape];
});
}
/**
* A wrapper for Chart with all the default values for a Map
*/
H.Map = H.mapChart = function(a, b, c) {
var hasRenderToArg = typeof a === 'string' || a.nodeName,
options = arguments[hasRenderToArg ? 1 : 0],
hiddenAxis = {
endOnTick: false,
visible: false,
minPadding: 0,
maxPadding: 0,
startOnTick: false
},
seriesOptions,
defaultCreditsOptions = H.getOptions().credits;
/* For visual testing
hiddenAxis.gridLineWidth = 1;
hiddenAxis.gridZIndex = 10;
hiddenAxis.tickPositions = undefined;
// */
// Don't merge the data
seriesOptions = options.series;
options.series = null;
options = merge({
chart: {
panning: 'xy',
type: 'map'
},
credits: {
mapText: pick(defaultCreditsOptions.mapText, ' \u00a9 <a href="{geojson.copyrightUrl}">{geojson.copyrightShort}</a>'),
mapTextFull: pick(defaultCreditsOptions.mapTextFull, '{geojson.copyright}')
},
tooltip: {
followTouchMove: false
},
xAxis: hiddenAxis,
yAxis: merge(hiddenAxis, {
reversed: true
})
},
options, // user's options
{ // forced options
chart: {
inverted: false,
alignTicks: false
}
}
);
options.series = seriesOptions;
return hasRenderToArg ?
new Chart(a, options, c) :
new Chart(options, b);
};
}(Highcharts));
(function() {
}());
return Highcharts
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /*
Highstock JS v5.0.10 (2017-03-31)
(c) 2009-2016 Torstein Honsi
License: www.highcharts.com/license
*/
(function(K,a){"object"===typeof module&&module.exports?module.exports=K.document?a(K):a:K.Highcharts=a(K)})("undefined"!==typeof window?window:this,function(K){K=function(){var a=window,D=a.document,C=a.navigator&&a.navigator.userAgent||"",G=D&&D.createElementNS&&!!D.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,H=/(edge|msie|trident)/i.test(C)&&!window.opera,v=!G,l=/Firefox/.test(C),r=l&&4>parseInt(C.split("Firefox/")[1],10);return a.Highcharts?a.Highcharts.error(16,!0):{product:"Highstock",
version:"5.0.10",deg2rad:2*Math.PI/360,doc:D,hasBidiBug:r,hasTouch:D&&void 0!==D.documentElement.ontouchstart,isMS:H,isWebKit:/AppleWebKit/.test(C),isFirefox:l,isTouchDevice:/(Mobile|Android|Windows Phone)/.test(C),SVG_NS:"http://www.w3.org/2000/svg",chartCount:0,seriesTypes:{},symbolSizes:{},svg:G,vml:v,win:a,charts:[],marginNames:["plotTop","marginRight","marginBottom","plotLeft"],noop:function(){}}}();(function(a){var D=[],C=a.charts,G=a.doc,H=a.win;a.error=function(v,l){v=a.isNumber(v)?"Highcharts error #"+
v+": www.highcharts.com/errors/"+v:v;if(l)throw Error(v);H.console&&console.log(v)};a.Fx=function(a,l,r){this.options=l;this.elem=a;this.prop=r};a.Fx.prototype={dSetter:function(){var a=this.paths[0],l=this.paths[1],r=[],w=this.now,q=a.length,n;if(1===w)r=this.toD;else if(q===l.length&&1>w)for(;q--;)n=parseFloat(a[q]),r[q]=isNaN(n)?a[q]:w*parseFloat(l[q]-n)+n;else r=l;this.elem.attr("d",r,null,!0)},update:function(){var a=this.elem,l=this.prop,r=this.now,w=this.options.step;if(this[l+"Setter"])this[l+
"Setter"]();else a.attr?a.element&&a.attr(l,r,null,!0):a.style[l]=r+this.unit;w&&w.call(a,r,this)},run:function(a,l,r){var v=this,q=function(a){return q.stopped?!1:v.step(a)},n;this.startTime=+new Date;this.start=a;this.end=l;this.unit=r;this.now=this.start;this.pos=0;q.elem=this.elem;q.prop=this.prop;q()&&1===D.push(q)&&(q.timerId=setInterval(function(){for(n=0;n<D.length;n++)D[n]()||D.splice(n--,1);D.length||clearInterval(q.timerId)},13))},step:function(a){var l=+new Date,v,w=this.options;v=this.elem;
var q=w.complete,n=w.duration,f=w.curAnim,c;if(v.attr&&!v.element)v=!1;else if(a||l>=n+this.startTime){this.now=this.end;this.pos=1;this.update();a=f[this.prop]=!0;for(c in f)!0!==f[c]&&(a=!1);a&&q&&q.call(v);v=!1}else this.pos=w.easing((l-this.startTime)/n),this.now=this.start+(this.end-this.start)*this.pos,this.update(),v=!0;return v},initPath:function(v,l,r){function w(a){var b,k;for(B=a.length;B--;)b="M"===a[B]||"L"===a[B],k=/[a-zA-Z]/.test(a[B+3]),b&&k&&a.splice(B+1,0,a[B+1],a[B+2],a[B+1],a[B+
2])}function q(a,d){for(;a.length<t;){a[0]=d[t-a.length];var k=a.slice(0,b);[].splice.apply(a,[0,0].concat(k));p&&(k=a.slice(a.length-b),[].splice.apply(a,[a.length,0].concat(k)),B--)}a[0]="M"}function n(a,d){for(var k=(t-a.length)/b;0<k&&k--;)h=a.slice().splice(a.length/x-b,b*x),h[0]=d[t-b-k*b],z&&(h[b-6]=h[b-2],h[b-5]=h[b-1]),[].splice.apply(a,[a.length/x,0].concat(h)),p&&k--}l=l||"";var f,c=v.startX,e=v.endX,z=-1<l.indexOf("C"),b=z?7:3,t,h,B;l=l.split(" ");r=r.slice();var p=v.isArea,x=p?2:1,k;
z&&(w(l),w(r));if(c&&e){for(B=0;B<c.length;B++)if(c[B]===e[0]){f=B;break}else if(c[0]===e[e.length-c.length+B]){f=B;k=!0;break}void 0===f&&(l=[])}l.length&&a.isNumber(f)&&(t=r.length+f*x*b,k?(q(l,r),n(r,l)):(q(r,l),n(l,r)));return[l,r]}};a.extend=function(a,l){var v;a||(a={});for(v in l)a[v]=l[v];return a};a.merge=function(){var v,l=arguments,r,w={},q=function(n,f){var c,e;"object"!==typeof n&&(n={});for(e in f)f.hasOwnProperty(e)&&(c=f[e],a.isObject(c,!0)&&"renderTo"!==e&&"number"!==typeof c.nodeType?
n[e]=q(n[e]||{},c):n[e]=f[e]);return n};!0===l[0]&&(w=l[1],l=Array.prototype.slice.call(l,2));r=l.length;for(v=0;v<r;v++)w=q(w,l[v]);return w};a.pInt=function(a,l){return parseInt(a,l||10)};a.isString=function(a){return"string"===typeof a};a.isArray=function(a){a=Object.prototype.toString.call(a);return"[object Array]"===a||"[object Array Iterator]"===a};a.isObject=function(v,l){return v&&"object"===typeof v&&(!l||!a.isArray(v))};a.isNumber=function(a){return"number"===typeof a&&!isNaN(a)};a.erase=
function(a,l){for(var v=a.length;v--;)if(a[v]===l){a.splice(v,1);break}};a.defined=function(a){return void 0!==a&&null!==a};a.attr=function(v,l,r){var w,q;if(a.isString(l))a.defined(r)?v.setAttribute(l,r):v&&v.getAttribute&&(q=v.getAttribute(l));else if(a.defined(l)&&a.isObject(l))for(w in l)v.setAttribute(w,l[w]);return q};a.splat=function(v){return a.isArray(v)?v:[v]};a.syncTimeout=function(a,l,r){if(l)return setTimeout(a,l,r);a.call(0,r)};a.pick=function(){var a=arguments,l,r,w=a.length;for(l=
0;l<w;l++)if(r=a[l],void 0!==r&&null!==r)return r};a.css=function(v,l){a.isMS&&!a.svg&&l&&void 0!==l.opacity&&(l.filter="alpha(opacity\x3d"+100*l.opacity+")");a.extend(v.style,l)};a.createElement=function(v,l,r,w,q){v=G.createElement(v);var n=a.css;l&&a.extend(v,l);q&&n(v,{padding:0,border:"none",margin:0});r&&n(v,r);w&&w.appendChild(v);return v};a.extendClass=function(v,l){var r=function(){};r.prototype=new v;a.extend(r.prototype,l);return r};a.pad=function(a,l,r){return Array((l||2)+1-String(a).length).join(r||
0)+a};a.relativeLength=function(a,l){return/%$/.test(a)?l*parseFloat(a)/100:parseFloat(a)};a.wrap=function(a,l,r){var w=a[l];a[l]=function(){var a=Array.prototype.slice.call(arguments),n=arguments,f=this;f.proceed=function(){w.apply(f,arguments.length?arguments:n)};a.unshift(w);a=r.apply(this,a);f.proceed=null;return a}};a.getTZOffset=function(v){var l=a.Date;return 6E4*(l.hcGetTimezoneOffset&&l.hcGetTimezoneOffset(v)||l.hcTimezoneOffset||0)};a.dateFormat=function(v,l,r){if(!a.defined(l)||isNaN(l))return a.defaultOptions.lang.invalidDate||
"";v=a.pick(v,"%Y-%m-%d %H:%M:%S");var w=a.Date,q=new w(l-a.getTZOffset(l)),n,f=q[w.hcGetHours](),c=q[w.hcGetDay](),e=q[w.hcGetDate](),z=q[w.hcGetMonth](),b=q[w.hcGetFullYear](),t=a.defaultOptions.lang,h=t.weekdays,B=t.shortWeekdays,p=a.pad,w=a.extend({a:B?B[c]:h[c].substr(0,3),A:h[c],d:p(e),e:p(e,2," "),w:c,b:t.shortMonths[z],B:t.months[z],m:p(z+1),y:b.toString().substr(2,2),Y:b,H:p(f),k:f,I:p(f%12||12),l:f%12||12,M:p(q[w.hcGetMinutes]()),p:12>f?"AM":"PM",P:12>f?"am":"pm",S:p(q.getSeconds()),L:p(Math.round(l%
1E3),3)},a.dateFormats);for(n in w)for(;-1!==v.indexOf("%"+n);)v=v.replace("%"+n,"function"===typeof w[n]?w[n](l):w[n]);return r?v.substr(0,1).toUpperCase()+v.substr(1):v};a.formatSingle=function(v,l){var r=/\.([0-9])/,w=a.defaultOptions.lang;/f$/.test(v)?(r=(r=v.match(r))?r[1]:-1,null!==l&&(l=a.numberFormat(l,r,w.decimalPoint,-1<v.indexOf(",")?w.thousandsSep:""))):l=a.dateFormat(v,l);return l};a.format=function(v,l){for(var r="{",w=!1,q,n,f,c,e=[],z;v;){r=v.indexOf(r);if(-1===r)break;q=v.slice(0,
r);if(w){q=q.split(":");n=q.shift().split(".");c=n.length;z=l;for(f=0;f<c;f++)z=z[n[f]];q.length&&(z=a.formatSingle(q.join(":"),z));e.push(z)}else e.push(q);v=v.slice(r+1);r=(w=!w)?"}":"{"}e.push(v);return e.join("")};a.getMagnitude=function(a){return Math.pow(10,Math.floor(Math.log(a)/Math.LN10))};a.normalizeTickInterval=function(v,l,r,w,q){var n,f=v;r=a.pick(r,1);n=v/r;l||(l=q?[1,1.2,1.5,2,2.5,3,4,5,6,8,10]:[1,2,2.5,5,10],!1===w&&(1===r?l=a.grep(l,function(a){return 0===a%1}):.1>=r&&(l=[1/r])));
for(w=0;w<l.length&&!(f=l[w],q&&f*r>=v||!q&&n<=(l[w]+(l[w+1]||l[w]))/2);w++);return f=a.correctFloat(f*r,-Math.round(Math.log(.001)/Math.LN10))};a.stableSort=function(a,l){var r=a.length,w,q;for(q=0;q<r;q++)a[q].safeI=q;a.sort(function(a,f){w=l(a,f);return 0===w?a.safeI-f.safeI:w});for(q=0;q<r;q++)delete a[q].safeI};a.arrayMin=function(a){for(var l=a.length,r=a[0];l--;)a[l]<r&&(r=a[l]);return r};a.arrayMax=function(a){for(var l=a.length,r=a[0];l--;)a[l]>r&&(r=a[l]);return r};a.destroyObjectProperties=
function(a,l){for(var r in a)a[r]&&a[r]!==l&&a[r].destroy&&a[r].destroy(),delete a[r]};a.discardElement=function(v){var l=a.garbageBin;l||(l=a.createElement("div"));v&&l.appendChild(v);l.innerHTML=""};a.correctFloat=function(a,l){return parseFloat(a.toPrecision(l||14))};a.setAnimation=function(v,l){l.renderer.globalAnimation=a.pick(v,l.options.chart.animation,!0)};a.animObject=function(v){return a.isObject(v)?a.merge(v):{duration:v?500:0}};a.timeUnits={millisecond:1,second:1E3,minute:6E4,hour:36E5,
day:864E5,week:6048E5,month:24192E5,year:314496E5};a.numberFormat=function(v,l,r,w){v=+v||0;l=+l;var q=a.defaultOptions.lang,n=(v.toString().split(".")[1]||"").length,f,c;-1===l?l=Math.min(n,20):a.isNumber(l)||(l=2);c=(Math.abs(v)+Math.pow(10,-Math.max(l,n)-1)).toFixed(l);n=String(a.pInt(c));f=3<n.length?n.length%3:0;r=a.pick(r,q.decimalPoint);w=a.pick(w,q.thousandsSep);v=(0>v?"-":"")+(f?n.substr(0,f)+w:"");v+=n.substr(f).replace(/(\d{3})(?=\d)/g,"$1"+w);l&&(v+=r+c.slice(-l));return v};Math.easeInOutSine=
function(a){return-.5*(Math.cos(Math.PI*a)-1)};a.getStyle=function(v,l){return"width"===l?Math.min(v.offsetWidth,v.scrollWidth)-a.getStyle(v,"padding-left")-a.getStyle(v,"padding-right"):"height"===l?Math.min(v.offsetHeight,v.scrollHeight)-a.getStyle(v,"padding-top")-a.getStyle(v,"padding-bottom"):(v=H.getComputedStyle(v,void 0))&&a.pInt(v.getPropertyValue(l))};a.inArray=function(a,l){return l.indexOf?l.indexOf(a):[].indexOf.call(l,a)};a.grep=function(a,l){return[].filter.call(a,l)};a.find=function(a,
l){return[].find.call(a,l)};a.map=function(a,l){for(var r=[],w=0,q=a.length;w<q;w++)r[w]=l.call(a[w],a[w],w,a);return r};a.offset=function(a){var l=G.documentElement;a=a.getBoundingClientRect();return{top:a.top+(H.pageYOffset||l.scrollTop)-(l.clientTop||0),left:a.left+(H.pageXOffset||l.scrollLeft)-(l.clientLeft||0)}};a.stop=function(a,l){for(var r=D.length;r--;)D[r].elem!==a||l&&l!==D[r].prop||(D[r].stopped=!0)};a.each=function(a,l,r){return Array.prototype.forEach.call(a,l,r)};a.addEvent=function(v,
l,r){function w(a){a.target=a.srcElement||H;r.call(v,a)}var q=v.hcEvents=v.hcEvents||{};v.addEventListener?v.addEventListener(l,r,!1):v.attachEvent&&(v.hcEventsIE||(v.hcEventsIE={}),v.hcEventsIE[r.toString()]=w,v.attachEvent("on"+l,w));q[l]||(q[l]=[]);q[l].push(r);return function(){a.removeEvent(v,l,r)}};a.removeEvent=function(v,l,r){function w(a,c){v.removeEventListener?v.removeEventListener(a,c,!1):v.attachEvent&&(c=v.hcEventsIE[c.toString()],v.detachEvent("on"+a,c))}function q(){var a,c;if(v.nodeName)for(c in l?
(a={},a[l]=!0):a=f,a)if(f[c])for(a=f[c].length;a--;)w(c,f[c][a])}var n,f=v.hcEvents,c;f&&(l?(n=f[l]||[],r?(c=a.inArray(r,n),-1<c&&(n.splice(c,1),f[l]=n),w(l,r)):(q(),f[l]=[])):(q(),v.hcEvents={}))};a.fireEvent=function(v,l,r,w){var q;q=v.hcEvents;var n,f;r=r||{};if(G.createEvent&&(v.dispatchEvent||v.fireEvent))q=G.createEvent("Events"),q.initEvent(l,!0,!0),a.extend(q,r),v.dispatchEvent?v.dispatchEvent(q):v.fireEvent(l,q);else if(q)for(q=q[l]||[],n=q.length,r.target||a.extend(r,{preventDefault:function(){r.defaultPrevented=
!0},target:v,type:l}),l=0;l<n;l++)(f=q[l])&&!1===f.call(v,r)&&r.preventDefault();w&&!r.defaultPrevented&&w(r)};a.animate=function(v,l,r){var w,q="",n,f,c;a.isObject(r)||(w=arguments,r={duration:w[2],easing:w[3],complete:w[4]});a.isNumber(r.duration)||(r.duration=400);r.easing="function"===typeof r.easing?r.easing:Math[r.easing]||Math.easeInOutSine;r.curAnim=a.merge(l);for(c in l)a.stop(v,c),f=new a.Fx(v,r,c),n=null,"d"===c?(f.paths=f.initPath(v,v.d,l.d),f.toD=l.d,w=0,n=1):v.attr?w=v.attr(c):(w=parseFloat(a.getStyle(v,
c))||0,"opacity"!==c&&(q="px")),n||(n=l[c]),n&&n.match&&n.match("px")&&(n=n.replace(/px/g,"")),f.run(w,n,q)};a.seriesType=function(v,l,r,w,q){var n=a.getOptions(),f=a.seriesTypes;n.plotOptions[v]=a.merge(n.plotOptions[l],r);f[v]=a.extendClass(f[l]||function(){},w);f[v].prototype.type=v;q&&(f[v].prototype.pointClass=a.extendClass(a.Point,q));return f[v]};a.uniqueKey=function(){var a=Math.random().toString(36).substring(2,9),l=0;return function(){return"highcharts-"+a+"-"+l++}}();H.jQuery&&(H.jQuery.fn.highcharts=
function(){var v=[].slice.call(arguments);if(this[0])return v[0]?(new (a[a.isString(v[0])?v.shift():"Chart"])(this[0],v[0],v[1]),this):C[a.attr(this[0],"data-highcharts-chart")]});G&&!G.defaultView&&(a.getStyle=function(v,l){var r={width:"clientWidth",height:"clientHeight"}[l];if(v.style[l])return a.pInt(v.style[l]);"opacity"===l&&(l="filter");if(r)return v.style.zoom=1,Math.max(v[r]-2*a.getStyle(v,"padding"),0);v=v.currentStyle[l.replace(/\-(\w)/g,function(a,q){return q.toUpperCase()})];"filter"===
l&&(v=v.replace(/alpha\(opacity=([0-9]+)\)/,function(a,q){return q/100}));return""===v?1:a.pInt(v)});Array.prototype.forEach||(a.each=function(a,l,r){for(var w=0,q=a.length;w<q;w++)if(!1===l.call(r,a[w],w,a))return w});Array.prototype.indexOf||(a.inArray=function(a,l){var r,w=0;if(l)for(r=l.length;w<r;w++)if(l[w]===a)return w;return-1});Array.prototype.filter||(a.grep=function(a,l){for(var r=[],w=0,q=a.length;w<q;w++)l(a[w],w)&&r.push(a[w]);return r});Array.prototype.find||(a.find=function(a,l){var r,
w=a.length;for(r=0;r<w;r++)if(l(a[r],r))return a[r]})})(K);(function(a){var D=a.each,C=a.isNumber,G=a.map,H=a.merge,v=a.pInt;a.Color=function(l){if(!(this instanceof a.Color))return new a.Color(l);this.init(l)};a.Color.prototype={parsers:[{regex:/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,parse:function(a){return[v(a[1]),v(a[2]),v(a[3]),parseFloat(a[4],10)]}},{regex:/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,parse:function(a){return[v(a[1]),
v(a[2]),v(a[3]),1]}}],names:{white:"#ffffff",black:"#000000"},init:function(l){var r,w,q,n;if((this.input=l=this.names[l&&l.toLowerCase?l.toLowerCase():""]||l)&&l.stops)this.stops=G(l.stops,function(f){return new a.Color(f[1])});else if(l&&"#"===l[0]&&(r=l.length,l=parseInt(l.substr(1),16),7===r?w=[(l&16711680)>>16,(l&65280)>>8,l&255,1]:4===r&&(w=[(l&3840)>>4|(l&3840)>>8,(l&240)>>4|l&240,(l&15)<<4|l&15,1])),!w)for(q=this.parsers.length;q--&&!w;)n=this.parsers[q],(r=n.regex.exec(l))&&(w=n.parse(r));
this.rgba=w||[]},get:function(a){var l=this.input,w=this.rgba,q;this.stops?(q=H(l),q.stops=[].concat(q.stops),D(this.stops,function(n,f){q.stops[f]=[q.stops[f][0],n.get(a)]})):q=w&&C(w[0])?"rgb"===a||!a&&1===w[3]?"rgb("+w[0]+","+w[1]+","+w[2]+")":"a"===a?w[3]:"rgba("+w.join(",")+")":l;return q},brighten:function(a){var l,w=this.rgba;if(this.stops)D(this.stops,function(q){q.brighten(a)});else if(C(a)&&0!==a)for(l=0;3>l;l++)w[l]+=v(255*a),0>w[l]&&(w[l]=0),255<w[l]&&(w[l]=255);return this},setOpacity:function(a){this.rgba[3]=
a;return this}};a.color=function(l){return new a.Color(l)}})(K);(function(a){var D,C,G=a.addEvent,H=a.animate,v=a.attr,l=a.charts,r=a.color,w=a.css,q=a.createElement,n=a.defined,f=a.deg2rad,c=a.destroyObjectProperties,e=a.doc,z=a.each,b=a.extend,t=a.erase,h=a.grep,B=a.hasTouch,p=a.inArray,x=a.isArray,k=a.isFirefox,F=a.isMS,d=a.isObject,u=a.isString,m=a.isWebKit,y=a.merge,J=a.noop,E=a.pick,I=a.pInt,g=a.removeEvent,L=a.stop,R=a.svg,O=a.SVG_NS,M=a.symbolSizes,P=a.win;D=a.SVGElement=function(){return this};
D.prototype={opacity:1,SVG_NS:O,textProps:"direction fontSize fontWeight fontFamily fontStyle color lineHeight width textAlign textDecoration textOverflow textOutline".split(" "),init:function(a,g){this.element="span"===g?q(g):e.createElementNS(this.SVG_NS,g);this.renderer=a},animate:function(A,g,b){g=a.animObject(E(g,this.renderer.globalAnimation,!0));0!==g.duration?(b&&(g.complete=b),H(this,A,g)):(this.attr(A,null,b),g.step&&g.step.call(this));return this},colorGradient:function(A,g,b){var k=this.renderer,
d,m,c,h,L,E,F,u,Q,p,t,e=[],I;A.radialGradient?m="radialGradient":A.linearGradient&&(m="linearGradient");if(m){c=A[m];L=k.gradients;F=A.stops;p=b.radialReference;x(c)&&(A[m]=c={x1:c[0],y1:c[1],x2:c[2],y2:c[3],gradientUnits:"userSpaceOnUse"});"radialGradient"===m&&p&&!n(c.gradientUnits)&&(h=c,c=y(c,k.getRadialAttr(p,h),{gradientUnits:"userSpaceOnUse"}));for(t in c)"id"!==t&&e.push(t,c[t]);for(t in F)e.push(F[t]);e=e.join(",");L[e]?p=L[e].attr("id"):(c.id=p=a.uniqueKey(),L[e]=E=k.createElement(m).attr(c).add(k.defs),
E.radAttr=h,E.stops=[],z(F,function(A){0===A[1].indexOf("rgba")?(d=a.color(A[1]),u=d.get("rgb"),Q=d.get("a")):(u=A[1],Q=1);A=k.createElement("stop").attr({offset:A[0],"stop-color":u,"stop-opacity":Q}).add(E);E.stops.push(A)}));I="url("+k.url+"#"+p+")";b.setAttribute(g,I);b.gradient=e;A.toString=function(){return I}}},applyTextOutline:function(A){var g=this.element,b,k,d,m,c;-1!==A.indexOf("contrast")&&(A=A.replace(/contrast/g,this.renderer.getContrast(g.style.fill)));A=A.split(" ");k=A[A.length-1];
if((d=A[0])&&"none"!==d&&a.svg){this.fakeTS=!0;A=[].slice.call(g.getElementsByTagName("tspan"));this.ySetter=this.xSetter;d=d.replace(/(^[\d\.]+)(.*?)$/g,function(a,A,g){return 2*A+g});for(c=A.length;c--;)b=A[c],"highcharts-text-outline"===b.getAttribute("class")&&t(A,g.removeChild(b));m=g.firstChild;z(A,function(a,A){0===A&&(a.setAttribute("x",g.getAttribute("x")),A=g.getAttribute("y"),a.setAttribute("y",A||0),null===A&&g.setAttribute("y",0));a=a.cloneNode(1);v(a,{"class":"highcharts-text-outline",
fill:k,stroke:k,"stroke-width":d,"stroke-linejoin":"round"});g.insertBefore(a,m)})}},attr:function(a,g,b,k){var A,d=this.element,m,c=this,h;"string"===typeof a&&void 0!==g&&(A=a,a={},a[A]=g);if("string"===typeof a)c=(this[a+"Getter"]||this._defaultGetter).call(this,a,d);else{for(A in a)g=a[A],h=!1,k||L(this,A),this.symbolName&&/^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)$/.test(A)&&(m||(this.symbolAttr(a),m=!0),h=!0),!this.rotation||"x"!==A&&"y"!==A||(this.doTransform=!0),h||(h=this[A+
"Setter"]||this._defaultSetter,h.call(this,g,A,d),this.shadows&&/^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(A)&&this.updateShadows(A,g,h));this.doTransform&&(this.updateTransform(),this.doTransform=!1)}b&&b();return c},updateShadows:function(a,g,b){for(var A=this.shadows,k=A.length;k--;)b.call(A[k],"height"===a?Math.max(g-(A[k].cutHeight||0),0):"d"===a?this.d:g,a,A[k])},addClass:function(a,g){var A=this.attr("class")||"";-1===A.indexOf(a)&&(g||(a=(A+(A?" ":"")+a).replace(" "," ")),
this.attr("class",a));return this},hasClass:function(a){return-1!==v(this.element,"class").indexOf(a)},removeClass:function(a){v(this.element,"class",(v(this.element,"class")||"").replace(a,""));return this},symbolAttr:function(a){var A=this;z("x y r start end width height innerR anchorX anchorY".split(" "),function(g){A[g]=E(a[g],A[g])});A.attr({d:A.renderer.symbols[A.symbolName](A.x,A.y,A.width,A.height,A)})},clip:function(a){return this.attr("clip-path",a?"url("+this.renderer.url+"#"+a.id+")":
"none")},crisp:function(a,g){var A,b={},k;g=g||a.strokeWidth||0;k=Math.round(g)%2/2;a.x=Math.floor(a.x||this.x||0)+k;a.y=Math.floor(a.y||this.y||0)+k;a.width=Math.floor((a.width||this.width||0)-2*k);a.height=Math.floor((a.height||this.height||0)-2*k);n(a.strokeWidth)&&(a.strokeWidth=g);for(A in a)this[A]!==a[A]&&(this[A]=b[A]=a[A]);return b},css:function(a){var A=this.styles,g={},k=this.element,d,m="",c=!A,h=["textOutline","textOverflow","width"];a&&a.color&&(a.fill=a.color);if(A)for(d in a)a[d]!==
A[d]&&(g[d]=a[d],c=!0);if(c){A&&(a=b(A,g));A=this.textWidth=a&&a.width&&"auto"!==a.width&&"text"===k.nodeName.toLowerCase()&&I(a.width);this.styles=a;A&&!R&&this.renderer.forExport&&delete a.width;if(F&&!R)w(this.element,a);else{A=function(a,A){return"-"+A.toLowerCase()};for(d in a)-1===p(d,h)&&(m+=d.replace(/([A-Z])/g,A)+":"+a[d]+";");m&&v(k,"style",m)}this.added&&("text"===this.element.nodeName&&this.renderer.buildText(this),a&&a.textOutline&&this.applyTextOutline(a.textOutline))}return this},strokeWidth:function(){return this["stroke-width"]||
0},on:function(a,g){var A=this,b=A.element;B&&"click"===a?(b.ontouchstart=function(a){A.touchEventFired=Date.now();a.preventDefault();g.call(b,a)},b.onclick=function(a){(-1===P.navigator.userAgent.indexOf("Android")||1100<Date.now()-(A.touchEventFired||0))&&g.call(b,a)}):b["on"+a]=g;return this},setRadialReference:function(a){var A=this.renderer.gradients[this.element.gradient];this.element.radialReference=a;A&&A.radAttr&&A.animate(this.renderer.getRadialAttr(a,A.radAttr));return this},translate:function(a,
g){return this.attr({translateX:a,translateY:g})},invert:function(a){this.inverted=a;this.updateTransform();return this},updateTransform:function(){var a=this.translateX||0,g=this.translateY||0,b=this.scaleX,k=this.scaleY,d=this.inverted,m=this.rotation,c=this.element;d&&(a+=this.width,g+=this.height);a=["translate("+a+","+g+")"];d?a.push("rotate(90) scale(-1,1)"):m&&a.push("rotate("+m+" "+(c.getAttribute("x")||0)+" "+(c.getAttribute("y")||0)+")");(n(b)||n(k))&&a.push("scale("+E(b,1)+" "+E(k,1)+")");
a.length&&c.setAttribute("transform",a.join(" "))},toFront:function(){var a=this.element;a.parentNode.appendChild(a);return this},align:function(a,g,b){var A,k,d,m,c={};k=this.renderer;d=k.alignedObjects;var h,y;if(a){if(this.alignOptions=a,this.alignByTranslate=g,!b||u(b))this.alignTo=A=b||"renderer",t(d,this),d.push(this),b=null}else a=this.alignOptions,g=this.alignByTranslate,A=this.alignTo;b=E(b,k[A],k);A=a.align;k=a.verticalAlign;d=(b.x||0)+(a.x||0);m=(b.y||0)+(a.y||0);"right"===A?h=1:"center"===
A&&(h=2);h&&(d+=(b.width-(a.width||0))/h);c[g?"translateX":"x"]=Math.round(d);"bottom"===k?y=1:"middle"===k&&(y=2);y&&(m+=(b.height-(a.height||0))/y);c[g?"translateY":"y"]=Math.round(m);this[this.placed?"animate":"attr"](c);this.placed=!0;this.alignAttr=c;return this},getBBox:function(a,g){var A,k=this.renderer,d,m=this.element,c=this.styles,h,y=this.textStr,L,F=k.cache,u=k.cacheKeys,p;g=E(g,this.rotation);d=g*f;h=c&&c.fontSize;void 0!==y&&(p=y.toString(),-1===p.indexOf("\x3c")&&(p=p.replace(/[0-9]/g,
"0")),p+=["",g||0,h,c&&c.width,c&&c.textOverflow].join());p&&!a&&(A=F[p]);if(!A){if(m.namespaceURI===this.SVG_NS||k.forExport){try{(L=this.fakeTS&&function(a){z(m.querySelectorAll(".highcharts-text-outline"),function(A){A.style.display=a})})&&L("none"),A=m.getBBox?b({},m.getBBox()):{width:m.offsetWidth,height:m.offsetHeight},L&&L("")}catch(U){}if(!A||0>A.width)A={width:0,height:0}}else A=this.htmlGetBBox();k.isSVG&&(a=A.width,k=A.height,c&&"11px"===c.fontSize&&17===Math.round(k)&&(A.height=k=14),
g&&(A.width=Math.abs(k*Math.sin(d))+Math.abs(a*Math.cos(d)),A.height=Math.abs(k*Math.cos(d))+Math.abs(a*Math.sin(d))));if(p&&0<A.height){for(;250<u.length;)delete F[u.shift()];F[p]||u.push(p);F[p]=A}}return A},show:function(a){return this.attr({visibility:a?"inherit":"visible"})},hide:function(){return this.attr({visibility:"hidden"})},fadeOut:function(a){var A=this;A.animate({opacity:0},{duration:a||150,complete:function(){A.attr({y:-9999})}})},add:function(a){var A=this.renderer,g=this.element,
b;a&&(this.parentGroup=a);this.parentInverted=a&&a.inverted;void 0!==this.textStr&&A.buildText(this);this.added=!0;if(!a||a.handleZ||this.zIndex)b=this.zIndexSetter();b||(a?a.element:A.box).appendChild(g);if(this.onAdd)this.onAdd();return this},safeRemoveChild:function(a){var A=a.parentNode;A&&A.removeChild(a)},destroy:function(){var a=this,g=a.element||{},b=a.renderer.isSVG&&"SPAN"===g.nodeName&&a.parentGroup,k,d;g.onclick=g.onmouseout=g.onmouseover=g.onmousemove=g.point=null;L(a);a.clipPath&&(z(a.element.ownerSVGElement.querySelectorAll("[clip-path]"),
function(g){-1<g.getAttribute("clip-path").indexOf(a.clipPath.element.id)&&g.removeAttribute("clip-path")}),a.clipPath=a.clipPath.destroy());if(a.stops){for(d=0;d<a.stops.length;d++)a.stops[d]=a.stops[d].destroy();a.stops=null}a.safeRemoveChild(g);for(a.destroyShadows();b&&b.div&&0===b.div.childNodes.length;)g=b.parentGroup,a.safeRemoveChild(b.div),delete b.div,b=g;a.alignTo&&t(a.renderer.alignedObjects,a);for(k in a)delete a[k];return null},shadow:function(a,g,b){var A=[],k,d,m=this.element,c,h,
y,L;if(!a)this.destroyShadows();else if(!this.shadows){h=E(a.width,3);y=(a.opacity||.15)/h;L=this.parentInverted?"(-1,-1)":"("+E(a.offsetX,1)+", "+E(a.offsetY,1)+")";for(k=1;k<=h;k++)d=m.cloneNode(0),c=2*h+1-2*k,v(d,{isShadow:"true",stroke:a.color||"#000000","stroke-opacity":y*k,"stroke-width":c,transform:"translate"+L,fill:"none"}),b&&(v(d,"height",Math.max(v(d,"height")-c,0)),d.cutHeight=c),g?g.element.appendChild(d):m.parentNode.insertBefore(d,m),A.push(d);this.shadows=A}return this},destroyShadows:function(){z(this.shadows||
[],function(a){this.safeRemoveChild(a)},this);this.shadows=void 0},xGetter:function(a){"circle"===this.element.nodeName&&("x"===a?a="cx":"y"===a&&(a="cy"));return this._defaultGetter(a)},_defaultGetter:function(a){a=E(this[a],this.element?this.element.getAttribute(a):null,0);/^[\-0-9\.]+$/.test(a)&&(a=parseFloat(a));return a},dSetter:function(a,g,b){a&&a.join&&(a=a.join(" "));/(NaN| {2}|^$)/.test(a)&&(a="M 0 0");b.setAttribute(g,a);this[g]=a},dashstyleSetter:function(a){var g,A=this["stroke-width"];
"inherit"===A&&(A=1);if(a=a&&a.toLowerCase()){a=a.replace("shortdashdotdot","3,1,1,1,1,1,").replace("shortdashdot","3,1,1,1").replace("shortdot","1,1,").replace("shortdash","3,1,").replace("longdash","8,3,").replace(/dot/g,"1,3,").replace("dash","4,3,").replace(/,$/,"").split(",");for(g=a.length;g--;)a[g]=I(a[g])*A;a=a.join(",").replace(/NaN/g,"none");this.element.setAttribute("stroke-dasharray",a)}},alignSetter:function(a){this.element.setAttribute("text-anchor",{left:"start",center:"middle",right:"end"}[a])},
opacitySetter:function(a,g,b){this[g]=a;b.setAttribute(g,a)},titleSetter:function(a){var g=this.element.getElementsByTagName("title")[0];g||(g=e.createElementNS(this.SVG_NS,"title"),this.element.appendChild(g));g.firstChild&&g.removeChild(g.firstChild);g.appendChild(e.createTextNode(String(E(a),"").replace(/<[^>]*>/g,"")))},textSetter:function(a){a!==this.textStr&&(delete this.bBox,this.textStr=a,this.added&&this.renderer.buildText(this))},fillSetter:function(a,g,b){"string"===typeof a?b.setAttribute(g,
a):a&&this.colorGradient(a,g,b)},visibilitySetter:function(a,g,b){"inherit"===a?b.removeAttribute(g):b.setAttribute(g,a)},zIndexSetter:function(a,g){var A=this.renderer,b=this.parentGroup,k=(b||A).element||A.box,d,m=this.element,c;d=this.added;var h;n(a)&&(m.zIndex=a,a=+a,this[g]===a&&(d=!1),this[g]=a);if(d){(a=this.zIndex)&&b&&(b.handleZ=!0);g=k.childNodes;for(h=0;h<g.length&&!c;h++)b=g[h],d=b.zIndex,b!==m&&(I(d)>a||!n(a)&&n(d)||0>a&&!n(d)&&k!==A.box)&&(k.insertBefore(m,b),c=!0);c||k.appendChild(m)}return c},
_defaultSetter:function(a,g,b){b.setAttribute(g,a)}};D.prototype.yGetter=D.prototype.xGetter;D.prototype.translateXSetter=D.prototype.translateYSetter=D.prototype.rotationSetter=D.prototype.verticalAlignSetter=D.prototype.scaleXSetter=D.prototype.scaleYSetter=function(a,g){this[g]=a;this.doTransform=!0};D.prototype["stroke-widthSetter"]=D.prototype.strokeSetter=function(a,g,b){this[g]=a;this.stroke&&this["stroke-width"]?(D.prototype.fillSetter.call(this,this.stroke,"stroke",b),b.setAttribute("stroke-width",
this["stroke-width"]),this.hasStroke=!0):"stroke-width"===g&&0===a&&this.hasStroke&&(b.removeAttribute("stroke"),this.hasStroke=!1)};C=a.SVGRenderer=function(){this.init.apply(this,arguments)};C.prototype={Element:D,SVG_NS:O,init:function(a,g,b,d,c,h){var A;d=this.createElement("svg").attr({version:"1.1","class":"highcharts-root"}).css(this.getStyle(d));A=d.element;a.appendChild(A);-1===a.innerHTML.indexOf("xmlns")&&v(A,"xmlns",this.SVG_NS);this.isSVG=!0;this.box=A;this.boxWrapper=d;this.alignedObjects=
[];this.url=(k||m)&&e.getElementsByTagName("base").length?P.location.href.replace(/#.*?$/,"").replace(/<[^>]*>/g,"").replace(/([\('\)])/g,"\\$1").replace(/ /g,"%20"):"";this.createElement("desc").add().element.appendChild(e.createTextNode("Created with Highstock 5.0.10"));this.defs=this.createElement("defs").add();this.allowHTML=h;this.forExport=c;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(g,b,!1);var y;k&&a.getBoundingClientRect&&(g=function(){w(a,{left:0,top:0});
y=a.getBoundingClientRect();w(a,{left:Math.ceil(y.left)-y.left+"px",top:Math.ceil(y.top)-y.top+"px"})},g(),this.unSubPixelFix=G(P,"resize",g))},getStyle:function(a){return this.style=b({fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif',fontSize:"12px"},a)},setStyle:function(a){this.boxWrapper.css(this.getStyle(a))},isHidden:function(){return!this.boxWrapper.getBBox().width},destroy:function(){var a=this.defs;this.box=null;this.boxWrapper=this.boxWrapper.destroy();c(this.gradients||
{});this.gradients=null;a&&(this.defs=a.destroy());this.unSubPixelFix&&this.unSubPixelFix();return this.alignedObjects=null},createElement:function(a){var g=new this.Element;g.init(this,a);return g},draw:J,getRadialAttr:function(a,g){return{cx:a[0]-a[2]/2+g.cx*a[2],cy:a[1]-a[2]/2+g.cy*a[2],r:g.r*a[2]}},getSpanWidth:function(a,g){var b=a.getBBox(!0).width;!R&&this.forExport&&(b=this.measureSpanWidth(g.firstChild.data,a.styles));return b},applyEllipsis:function(a,g,b,d){var k=this.getSpanWidth(a,g),
A=k>d,k=b,m,c=0,h=b.length,y=function(a){g.removeChild(g.firstChild);a&&g.appendChild(e.createTextNode(a))};if(A){for(;c<=h;)m=Math.ceil((c+h)/2),k=b.substring(0,m)+"\u2026",y(k),k=this.getSpanWidth(a,g),c===h?c=h+1:k>d?h=m-1:c=m;0===h&&y("")}return A},buildText:function(a){var g=a.element,b=this,k=b.forExport,d=E(a.textStr,"").toString(),m=-1!==d.indexOf("\x3c"),A=g.childNodes,c,y,L,F,p=v(g,"x"),u=a.styles,x=a.textWidth,t=u&&u.lineHeight,B=u&&u.textOutline,f=u&&"ellipsis"===u.textOverflow,J=u&&"nowrap"===
u.whiteSpace,q=u&&u.fontSize,n,l,r=A.length,u=x&&!a.added&&this.box,M=function(a){var d;d=/(px|em)$/.test(a&&a.style.fontSize)?a.style.fontSize:q||b.style.fontSize||12;return t?I(t):b.fontMetrics(d,a.getAttribute("style")?a:g).h};n=[d,f,J,t,B,q,x].join();if(n!==a.textCache){for(a.textCache=n;r--;)g.removeChild(A[r]);m||B||f||x||-1!==d.indexOf(" ")?(c=/<.*class="([^"]+)".*>/,y=/<.*style="([^"]+)".*>/,L=/<.*href="(http[^"]+)".*>/,u&&u.appendChild(g),d=m?d.replace(/<(b|strong)>/g,'\x3cspan style\x3d"font-weight:bold"\x3e').replace(/<(i|em)>/g,
'\x3cspan style\x3d"font-style:italic"\x3e').replace(/<a/g,"\x3cspan").replace(/<\/(b|strong|i|em|a)>/g,"\x3c/span\x3e").split(/<br.*?>/g):[d],d=h(d,function(a){return""!==a}),z(d,function(d,m){var A,h=0;d=d.replace(/^\s+|\s+$/g,"").replace(/<span/g,"|||\x3cspan").replace(/<\/span>/g,"\x3c/span\x3e|||");A=d.split("|||");z(A,function(d){if(""!==d||1===A.length){var E={},u=e.createElementNS(b.SVG_NS,"tspan"),t,I;c.test(d)&&(t=d.match(c)[1],v(u,"class",t));y.test(d)&&(I=d.match(y)[1].replace(/(;| |^)color([ :])/,
"$1fill$2"),v(u,"style",I));L.test(d)&&!k&&(v(u,"onclick",'location.href\x3d"'+d.match(L)[1]+'"'),w(u,{cursor:"pointer"}));d=(d.replace(/<(.|\n)*?>/g,"")||" ").replace(/</g,"\x3c").replace(/>/g,"\x3e");if(" "!==d){u.appendChild(e.createTextNode(d));h?E.dx=0:m&&null!==p&&(E.x=p);v(u,E);g.appendChild(u);!h&&l&&(!R&&k&&w(u,{display:"block"}),v(u,"dy",M(u)));if(x){E=d.replace(/([^\^])-/g,"$1- ").split(" ");t=1<A.length||m||1<E.length&&!J;var z=[],B,q=M(u),n=a.rotation;for(f&&(F=b.applyEllipsis(a,
u,d,x));!f&&t&&(E.length||z.length);)a.rotation=0,B=b.getSpanWidth(a,u),d=B>x,void 0===F&&(F=d),d&&1!==E.length?(u.removeChild(u.firstChild),z.unshift(E.pop())):(E=z,z=[],E.length&&!J&&(u=e.createElementNS(O,"tspan"),v(u,{dy:q,x:p}),I&&v(u,"style",I),g.appendChild(u)),B>x&&(x=B)),E.length&&u.appendChild(e.createTextNode(E.join(" ").replace(/- /g,"-")));a.rotation=n}h++}}});l=l||g.childNodes.length}),F&&a.attr("title",a.textStr),u&&u.removeChild(g),B&&a.applyTextOutline&&a.applyTextOutline(B)):g.appendChild(e.createTextNode(d.replace(/</g,
"\x3c").replace(/>/g,"\x3e")))}},getContrast:function(a){a=r(a).rgba;return 510<a[0]+a[1]+a[2]?"#000000":"#FFFFFF"},button:function(a,g,d,k,m,c,h,L,E){var A=this.label(a,g,d,E,null,null,null,null,"button"),u=0;A.attr(y({padding:8,r:2},m));var p,x,t,e;m=y({fill:"#f7f7f7",stroke:"#cccccc","stroke-width":1,style:{color:"#333333",cursor:"pointer",fontWeight:"normal"}},m);p=m.style;delete m.style;c=y(m,{fill:"#e6e6e6"},c);x=c.style;delete c.style;h=y(m,{fill:"#e6ebf5",style:{color:"#000000",fontWeight:"bold"}},
h);t=h.style;delete h.style;L=y(m,{style:{color:"#cccccc"}},L);e=L.style;delete L.style;G(A.element,F?"mouseover":"mouseenter",function(){3!==u&&A.setState(1)});G(A.element,F?"mouseout":"mouseleave",function(){3!==u&&A.setState(u)});A.setState=function(a){1!==a&&(A.state=u=a);A.removeClass(/highcharts-button-(normal|hover|pressed|disabled)/).addClass("highcharts-button-"+["normal","hover","pressed","disabled"][a||0]);A.attr([m,c,h,L][a||0]).css([p,x,t,e][a||0])};A.attr(m).css(b({cursor:"default"},
p));return A.on("click",function(a){3!==u&&k.call(A,a)})},crispLine:function(a,g){a[1]===a[4]&&(a[1]=a[4]=Math.round(a[1])-g%2/2);a[2]===a[5]&&(a[2]=a[5]=Math.round(a[2])+g%2/2);return a},path:function(a){var g={fill:"none"};x(a)?g.d=a:d(a)&&b(g,a);return this.createElement("path").attr(g)},circle:function(a,g,b){a=d(a)?a:{x:a,y:g,r:b};g=this.createElement("circle");g.xSetter=g.ySetter=function(a,g,d){d.setAttribute("c"+g,a)};return g.attr(a)},arc:function(a,g,b,k,m,c){d(a)?(k=a,g=k.y,b=k.r,a=k.x):
k={innerR:k,start:m,end:c};a=this.symbol("arc",a,g,b,b,k);a.r=b;return a},rect:function(a,g,b,k,m,c){m=d(a)?a.r:m;var h=this.createElement("rect");a=d(a)?a:void 0===a?{}:{x:a,y:g,width:Math.max(b,0),height:Math.max(k,0)};void 0!==c&&(a.strokeWidth=c,a=h.crisp(a));a.fill="none";m&&(a.r=m);h.rSetter=function(a,g,b){v(b,{rx:a,ry:a})};return h.attr(a)},setSize:function(a,g,b){var d=this.alignedObjects,k=d.length;this.width=a;this.height=g;for(this.boxWrapper.animate({width:a,height:g},{step:function(){this.attr({viewBox:"0 0 "+
this.attr("width")+" "+this.attr("height")})},duration:E(b,!0)?void 0:0});k--;)d[k].align()},g:function(a){var g=this.createElement("g");return a?g.attr({"class":"highcharts-"+a}):g},image:function(a,g,d,k,m){var c={preserveAspectRatio:"none"};1<arguments.length&&b(c,{x:g,y:d,width:k,height:m});c=this.createElement("image").attr(c);c.element.setAttributeNS?c.element.setAttributeNS("http://www.w3.org/1999/xlink","href",a):c.element.setAttribute("hc-svg-href",a);return c},symbol:function(a,g,d,k,m,
c){var h=this,A,y=this.symbols[a],L=n(g)&&y&&this.symbols[a](Math.round(g),Math.round(d),k,m,c),u=/^url\((.*?)\)$/,F,p;y?(A=this.path(L),A.attr("fill","none"),b(A,{symbolName:a,x:g,y:d,width:k,height:m}),c&&b(A,c)):u.test(a)&&(F=a.match(u)[1],A=this.image(F),A.imgwidth=E(M[F]&&M[F].width,c&&c.width),A.imgheight=E(M[F]&&M[F].height,c&&c.height),p=function(){A.attr({width:A.width,height:A.height})},z(["width","height"],function(a){A[a+"Setter"]=function(a,g){var d={},b=this["img"+g],k="width"===g?"translateX":
"translateY";this[g]=a;n(b)&&(this.element&&this.element.setAttribute(g,b),this.alignByTranslate||(d[k]=((this[g]||0)-b)/2,this.attr(d)))}}),n(g)&&A.attr({x:g,y:d}),A.isImg=!0,n(A.imgwidth)&&n(A.imgheight)?p():(A.attr({width:0,height:0}),q("img",{onload:function(){var a=l[h.chartIndex];0===this.width&&(w(this,{position:"absolute",top:"-999em"}),e.body.appendChild(this));M[F]={width:this.width,height:this.height};A.imgwidth=this.width;A.imgheight=this.height;A.element&&p();this.parentNode&&this.parentNode.removeChild(this);
h.imgCount--;if(!h.imgCount&&a&&a.onload)a.onload()},src:F}),this.imgCount++));return A},symbols:{circle:function(a,g,b,d){return this.arc(a+b/2,g+d/2,b/2,d/2,{start:0,end:2*Math.PI,open:!1})},square:function(a,g,b,d){return["M",a,g,"L",a+b,g,a+b,g+d,a,g+d,"Z"]},triangle:function(a,g,b,d){return["M",a+b/2,g,"L",a+b,g+d,a,g+d,"Z"]},"triangle-down":function(a,g,b,d){return["M",a,g,"L",a+b,g,a+b/2,g+d,"Z"]},diamond:function(a,g,b,d){return["M",a+b/2,g,"L",a+b,g+d/2,a+b/2,g+d,a,g+d/2,"Z"]},arc:function(a,
g,b,d,k){var m=k.start,c=k.r||b,h=k.r||d||b,y=k.end-.001;b=k.innerR;d=k.open;var A=Math.cos(m),L=Math.sin(m),E=Math.cos(y),y=Math.sin(y);k=k.end-m<Math.PI?0:1;c=["M",a+c*A,g+h*L,"A",c,h,0,k,1,a+c*E,g+h*y];n(b)&&c.push(d?"M":"L",a+b*E,g+b*y,"A",b,b,0,k,0,a+b*A,g+b*L);c.push(d?"":"Z");return c},callout:function(a,g,b,d,k){var m=Math.min(k&&k.r||0,b,d),c=m+6,h=k&&k.anchorX;k=k&&k.anchorY;var y;y=["M",a+m,g,"L",a+b-m,g,"C",a+b,g,a+b,g,a+b,g+m,"L",a+b,g+d-m,"C",a+b,g+d,a+b,g+d,a+b-m,g+d,"L",a+m,g+d,"C",
a,g+d,a,g+d,a,g+d-m,"L",a,g+m,"C",a,g,a,g,a+m,g];h&&h>b?k>g+c&&k<g+d-c?y.splice(13,3,"L",a+b,k-6,a+b+6,k,a+b,k+6,a+b,g+d-m):y.splice(13,3,"L",a+b,d/2,h,k,a+b,d/2,a+b,g+d-m):h&&0>h?k>g+c&&k<g+d-c?y.splice(33,3,"L",a,k+6,a-6,k,a,k-6,a,g+m):y.splice(33,3,"L",a,d/2,h,k,a,d/2,a,g+m):k&&k>d&&h>a+c&&h<a+b-c?y.splice(23,3,"L",h+6,g+d,h,g+d+6,h-6,g+d,a+m,g+d):k&&0>k&&h>a+c&&h<a+b-c&&y.splice(3,3,"L",h-6,g,h,g-6,h+6,g,b-m,g);return y}},clipRect:function(g,b,d,k){var m=a.uniqueKey(),c=this.createElement("clipPath").attr({id:m}).add(this.defs);
g=this.rect(g,b,d,k,0).add(c);g.id=m;g.clipPath=c;g.count=0;return g},text:function(a,g,b,d){var k=!R&&this.forExport,m={};if(d&&(this.allowHTML||!this.forExport))return this.html(a,g,b);m.x=Math.round(g||0);b&&(m.y=Math.round(b));if(a||0===a)m.text=a;a=this.createElement("text").attr(m);k&&a.css({position:"absolute"});d||(a.xSetter=function(a,g,b){var d=b.getElementsByTagName("tspan"),k,m=b.getAttribute(g),c;for(c=0;c<d.length;c++)k=d[c],k.getAttribute(g)===m&&k.setAttribute(g,a);b.setAttribute(g,
a)});return a},fontMetrics:function(a,g){a=a||g&&g.style&&g.style.fontSize||this.style&&this.style.fontSize;a=/px/.test(a)?I(a):/em/.test(a)?parseFloat(a)*(g?this.fontMetrics(null,g.parentNode).f:16):12;g=24>a?a+3:Math.round(1.2*a);return{h:g,b:Math.round(.8*g),f:a}},rotCorr:function(a,g,b){var d=a;g&&b&&(d=Math.max(d*Math.cos(g*f),4));return{x:-a/3*Math.sin(g*f),y:d}},label:function(d,k,m,c,h,L,E,u,F){var A=this,p=A.g("button"!==F&&"label"),x=p.text=A.text("",0,0,E).attr({zIndex:1}),t,e,I=0,B=3,
f=0,J,R,O,q,l,w={},r,M,Q=/^url\((.*?)\)$/.test(c),v=Q,P,S,N,T;F&&p.addClass("highcharts-"+F);v=Q;P=function(){return(r||0)%2/2};S=function(){var a=x.element.style,g={};e=(void 0===J||void 0===R||l)&&n(x.textStr)&&x.getBBox();p.width=(J||e.width||0)+2*B+f;p.height=(R||e.height||0)+2*B;M=B+A.fontMetrics(a&&a.fontSize,x).b;v&&(t||(p.box=t=A.symbols[c]||Q?A.symbol(c):A.rect(),t.addClass(("button"===F?"":"highcharts-label-box")+(F?" highcharts-"+F+"-box":"")),t.add(p),a=P(),g.x=a,g.y=(u?-M:0)+a),g.width=
Math.round(p.width),g.height=Math.round(p.height),t.attr(b(g,w)),w={})};N=function(){var a=f+B,g;g=u?0:M;n(J)&&e&&("center"===l||"right"===l)&&(a+={center:.5,right:1}[l]*(J-e.width));if(a!==x.x||g!==x.y)x.attr("x",a),void 0!==g&&x.attr("y",g);x.x=a;x.y=g};T=function(a,g){t?t.attr(a,g):w[a]=g};p.onAdd=function(){x.add(p);p.attr({text:d||0===d?d:"",x:k,y:m});t&&n(h)&&p.attr({anchorX:h,anchorY:L})};p.widthSetter=function(g){J=a.isNumber(g)?g:null};p.heightSetter=function(a){R=a};p["text-alignSetter"]=
function(a){l=a};p.paddingSetter=function(a){n(a)&&a!==B&&(B=p.padding=a,N())};p.paddingLeftSetter=function(a){n(a)&&a!==f&&(f=a,N())};p.alignSetter=function(a){a={left:0,center:.5,right:1}[a];a!==I&&(I=a,e&&p.attr({x:O}))};p.textSetter=function(a){void 0!==a&&x.textSetter(a);S();N()};p["stroke-widthSetter"]=function(a,g){a&&(v=!0);r=this["stroke-width"]=a;T(g,a)};p.strokeSetter=p.fillSetter=p.rSetter=function(a,g){"fill"===g&&a&&(v=!0);T(g,a)};p.anchorXSetter=function(a,g){h=a;T(g,Math.round(a)-
P()-O)};p.anchorYSetter=function(a,g){L=a;T(g,a-q)};p.xSetter=function(a){p.x=a;I&&(a-=I*((J||e.width)+2*B));O=Math.round(a);p.attr("translateX",O)};p.ySetter=function(a){q=p.y=Math.round(a);p.attr("translateY",q)};var C=p.css;return b(p,{css:function(a){if(a){var g={};a=y(a);z(p.textProps,function(b){void 0!==a[b]&&(g[b]=a[b],delete a[b])});x.css(g)}return C.call(p,a)},getBBox:function(){return{width:e.width+2*B,height:e.height+2*B,x:e.x-B,y:e.y-B}},shadow:function(a){a&&(S(),t&&t.shadow(a));return p},
destroy:function(){g(p.element,"mouseenter");g(p.element,"mouseleave");x&&(x=x.destroy());t&&(t=t.destroy());D.prototype.destroy.call(p);p=A=S=N=T=null}})}};a.Renderer=C})(K);(function(a){var D=a.attr,C=a.createElement,G=a.css,H=a.defined,v=a.each,l=a.extend,r=a.isFirefox,w=a.isMS,q=a.isWebKit,n=a.pInt,f=a.SVGRenderer,c=a.win,e=a.wrap;l(a.SVGElement.prototype,{htmlCss:function(a){var b=this.element;if(b=a&&"SPAN"===b.tagName&&a.width)delete a.width,this.textWidth=b,this.updateTransform();a&&"ellipsis"===
a.textOverflow&&(a.whiteSpace="nowrap",a.overflow="hidden");this.styles=l(this.styles,a);G(this.element,a);return this},htmlGetBBox:function(){var a=this.element;"text"===a.nodeName&&(a.style.position="absolute");return{x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight}},htmlUpdateTransform:function(){if(this.added){var a=this.renderer,b=this.element,c=this.translateX||0,h=this.translateY||0,e=this.x||0,p=this.y||0,x=this.textAlign||"left",k={left:0,center:.5,right:1}[x],F=this.styles;
G(b,{marginLeft:c,marginTop:h});this.shadows&&v(this.shadows,function(a){G(a,{marginLeft:c+1,marginTop:h+1})});this.inverted&&v(b.childNodes,function(d){a.invertChild(d,b)});if("SPAN"===b.tagName){var d=this.rotation,u=n(this.textWidth),m=F&&F.whiteSpace,y=[d,x,b.innerHTML,this.textWidth,this.textAlign].join();y!==this.cTT&&(F=a.fontMetrics(b.style.fontSize).b,H(d)&&this.setSpanRotation(d,k,F),G(b,{width:"",whiteSpace:m||"nowrap"}),b.offsetWidth>u&&/[ \-]/.test(b.textContent||b.innerText)&&G(b,{width:u+
"px",display:"block",whiteSpace:m||"normal"}),this.getSpanCorrection(b.offsetWidth,F,k,d,x));G(b,{left:e+(this.xCorr||0)+"px",top:p+(this.yCorr||0)+"px"});q&&(F=b.offsetHeight);this.cTT=y}}else this.alignOnAdd=!0},setSpanRotation:function(a,b,t){var h={},e=w?"-ms-transform":q?"-webkit-transform":r?"MozTransform":c.opera?"-o-transform":"";h[e]=h.transform="rotate("+a+"deg)";h[e+(r?"Origin":"-origin")]=h.transformOrigin=100*b+"% "+t+"px";G(this.element,h)},getSpanCorrection:function(a,b,c){this.xCorr=
-a*c;this.yCorr=-b}});l(f.prototype,{html:function(a,b,c){var h=this.createElement("span"),t=h.element,p=h.renderer,x=p.isSVG,k=function(a,b){v(["opacity","visibility"],function(d){e(a,d+"Setter",function(a,d,k,c){a.call(this,d,k,c);b[k]=d})})};h.textSetter=function(a){a!==t.innerHTML&&delete this.bBox;t.innerHTML=this.textStr=a;h.htmlUpdateTransform()};x&&k(h,h.element.style);h.xSetter=h.ySetter=h.alignSetter=h.rotationSetter=function(a,b){"align"===b&&(b="textAlign");h[b]=a;h.htmlUpdateTransform()};
h.attr({text:a,x:Math.round(b),y:Math.round(c)}).css({fontFamily:this.style.fontFamily,fontSize:this.style.fontSize,position:"absolute"});t.style.whiteSpace="nowrap";h.css=h.htmlCss;x&&(h.add=function(a){var b,c=p.box.parentNode,m=[];if(this.parentGroup=a){if(b=a.div,!b){for(;a;)m.push(a),a=a.parentGroup;v(m.reverse(),function(a){var d,y=D(a.element,"class");y&&(y={className:y});b=a.div=a.div||C("div",y,{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px",display:a.display,
opacity:a.opacity,pointerEvents:a.styles&&a.styles.pointerEvents},b||c);d=b.style;l(a,{on:function(){h.on.apply({element:m[0].div},arguments);return a},translateXSetter:function(b,g){d.left=b+"px";a[g]=b;a.doTransform=!0},translateYSetter:function(b,g){d.top=b+"px";a[g]=b;a.doTransform=!0}});k(a,d)})}}else b=c;b.appendChild(t);h.added=!0;h.alignOnAdd&&h.htmlUpdateTransform();return h});return h}})})(K);(function(a){var D,C,G=a.createElement,H=a.css,v=a.defined,l=a.deg2rad,r=a.discardElement,w=a.doc,
q=a.each,n=a.erase,f=a.extend;D=a.extendClass;var c=a.isArray,e=a.isNumber,z=a.isObject,b=a.merge;C=a.noop;var t=a.pick,h=a.pInt,B=a.SVGElement,p=a.SVGRenderer,x=a.win;a.svg||(C={docMode8:w&&8===w.documentMode,init:function(a,b){var d=["\x3c",b,' filled\x3d"f" stroked\x3d"f"'],k=["position: ","absolute",";"],m="div"===b;("shape"===b||m)&&k.push("left:0;top:0;width:1px;height:1px;");k.push("visibility: ",m?"hidden":"visible");d.push(' style\x3d"',k.join(""),'"/\x3e');b&&(d=m||"span"===b||"img"===b?
d.join(""):a.prepVML(d),this.element=G(d));this.renderer=a},add:function(a){var b=this.renderer,d=this.element,k=b.box,m=a&&a.inverted,k=a?a.element||a:k;a&&(this.parentGroup=a);m&&b.invertChild(d,k);k.appendChild(d);this.added=!0;this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform();if(this.onAdd)this.onAdd();this.className&&this.attr("class",this.className);return this},updateTransform:B.prototype.htmlUpdateTransform,setSpanRotation:function(){var a=this.rotation,b=Math.cos(a*l),d=
Math.sin(a*l);H(this.element,{filter:a?["progid:DXImageTransform.Microsoft.Matrix(M11\x3d",b,", M12\x3d",-d,", M21\x3d",d,", M22\x3d",b,", sizingMethod\x3d'auto expand')"].join(""):"none"})},getSpanCorrection:function(a,b,d,c,m){var k=c?Math.cos(c*l):1,h=c?Math.sin(c*l):0,p=t(this.elemHeight,this.element.offsetHeight),u;this.xCorr=0>k&&-a;this.yCorr=0>h&&-p;u=0>k*h;this.xCorr+=h*b*(u?1-d:d);this.yCorr-=k*b*(c?u?d:1-d:1);m&&"left"!==m&&(this.xCorr-=a*d*(0>k?-1:1),c&&(this.yCorr-=p*d*(0>h?-1:1)),H(this.element,
{textAlign:m}))},pathToVML:function(a){for(var b=a.length,d=[];b--;)e(a[b])?d[b]=Math.round(10*a[b])-5:"Z"===a[b]?d[b]="x":(d[b]=a[b],!a.isArc||"wa"!==a[b]&&"at"!==a[b]||(d[b+5]===d[b+7]&&(d[b+7]+=a[b+7]>a[b+5]?1:-1),d[b+6]===d[b+8]&&(d[b+8]+=a[b+8]>a[b+6]?1:-1)));return d.join(" ")||"x"},clip:function(a){var b=this,d;a?(d=a.members,n(d,b),d.push(b),b.destroyClip=function(){n(d,b)},a=a.getCSS(b)):(b.destroyClip&&b.destroyClip(),a={clip:b.docMode8?"inherit":"rect(auto)"});return b.css(a)},css:B.prototype.htmlCss,
safeRemoveChild:function(a){a.parentNode&&r(a)},destroy:function(){this.destroyClip&&this.destroyClip();return B.prototype.destroy.apply(this)},on:function(a,b){this.element["on"+a]=function(){var a=x.event;a.target=a.srcElement;b(a)};return this},cutOffPath:function(a,b){var d;a=a.split(/[ ,]/);d=a.length;if(9===d||11===d)a[d-4]=a[d-2]=h(a[d-2])-10*b;return a.join(" ")},shadow:function(a,b,d){var c=[],k,y=this.element,p=this.renderer,E,x=y.style,g,L=y.path,e,F,B,f;L&&"string"!==typeof L.value&&(L=
"x");F=L;if(a){B=t(a.width,3);f=(a.opacity||.15)/B;for(k=1;3>=k;k++)e=2*B+1-2*k,d&&(F=this.cutOffPath(L.value,e+.5)),g=['\x3cshape isShadow\x3d"true" strokeweight\x3d"',e,'" filled\x3d"false" path\x3d"',F,'" coordsize\x3d"10 10" style\x3d"',y.style.cssText,'" /\x3e'],E=G(p.prepVML(g),null,{left:h(x.left)+t(a.offsetX,1),top:h(x.top)+t(a.offsetY,1)}),d&&(E.cutOff=e+1),g=['\x3cstroke color\x3d"',a.color||"#000000",'" opacity\x3d"',f*k,'"/\x3e'],G(p.prepVML(g),null,null,E),b?b.element.appendChild(E):
y.parentNode.insertBefore(E,y),c.push(E);this.shadows=c}return this},updateShadows:C,setAttr:function(a,b){this.docMode8?this.element[a]=b:this.element.setAttribute(a,b)},classSetter:function(a){(this.added?this.element:this).className=a},dashstyleSetter:function(a,b,d){(d.getElementsByTagName("stroke")[0]||G(this.renderer.prepVML(["\x3cstroke/\x3e"]),null,null,d))[b]=a||"solid";this[b]=a},dSetter:function(a,b,d){var c=this.shadows;a=a||[];this.d=a.join&&a.join(" ");d.path=a=this.pathToVML(a);if(c)for(d=
c.length;d--;)c[d].path=c[d].cutOff?this.cutOffPath(a,c[d].cutOff):a;this.setAttr(b,a)},fillSetter:function(a,b,d){var c=d.nodeName;"SPAN"===c?d.style.color=a:"IMG"!==c&&(d.filled="none"!==a,this.setAttr("fillcolor",this.renderer.color(a,d,b,this)))},"fill-opacitySetter":function(a,b,d){G(this.renderer.prepVML(["\x3c",b.split("-")[0],' opacity\x3d"',a,'"/\x3e']),null,null,d)},opacitySetter:C,rotationSetter:function(a,b,d){d=d.style;this[b]=d[b]=a;d.left=-Math.round(Math.sin(a*l)+1)+"px";d.top=Math.round(Math.cos(a*
l))+"px"},strokeSetter:function(a,b,d){this.setAttr("strokecolor",this.renderer.color(a,d,b,this))},"stroke-widthSetter":function(a,b,d){d.stroked=!!a;this[b]=a;e(a)&&(a+="px");this.setAttr("strokeweight",a)},titleSetter:function(a,b){this.setAttr(b,a)},visibilitySetter:function(a,b,d){"inherit"===a&&(a="visible");this.shadows&&q(this.shadows,function(d){d.style[b]=a});"DIV"===d.nodeName&&(a="hidden"===a?"-999em":0,this.docMode8||(d.style[b]=a?"visible":"hidden"),b="top");d.style[b]=a},xSetter:function(a,
b,d){this[b]=a;"x"===b?b="left":"y"===b&&(b="top");this.updateClipping?(this[b]=a,this.updateClipping()):d.style[b]=a},zIndexSetter:function(a,b,d){d.style[b]=a}},C["stroke-opacitySetter"]=C["fill-opacitySetter"],a.VMLElement=C=D(B,C),C.prototype.ySetter=C.prototype.widthSetter=C.prototype.heightSetter=C.prototype.xSetter,C={Element:C,isIE8:-1<x.navigator.userAgent.indexOf("MSIE 8.0"),init:function(a,b,d){var c,m;this.alignedObjects=[];c=this.createElement("div").css({position:"relative"});m=c.element;
a.appendChild(c.element);this.isVML=!0;this.box=m;this.boxWrapper=c;this.gradients={};this.cache={};this.cacheKeys=[];this.imgCount=0;this.setSize(b,d,!1);if(!w.namespaces.hcv){w.namespaces.add("hcv","urn:schemas-microsoft-com:vml");try{w.createStyleSheet().cssText="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}catch(y){w.styleSheets[0].cssText+="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}}},
isHidden:function(){return!this.box.offsetWidth},clipRect:function(a,b,d,c){var m=this.createElement(),k=z(a);return f(m,{members:[],count:0,left:(k?a.x:a)+1,top:(k?a.y:b)+1,width:(k?a.width:d)-1,height:(k?a.height:c)-1,getCSS:function(a){var b=a.element,d=b.nodeName,g=a.inverted,c=this.top-("shape"===d?b.offsetTop:0),m=this.left,b=m+this.width,k=c+this.height,c={clip:"rect("+Math.round(g?m:c)+"px,"+Math.round(g?k:b)+"px,"+Math.round(g?b:k)+"px,"+Math.round(g?c:m)+"px)"};!g&&a.docMode8&&"DIV"===d&&
f(c,{width:b+"px",height:k+"px"});return c},updateClipping:function(){q(m.members,function(a){a.element&&a.css(m.getCSS(a))})}})},color:function(b,c,d,h){var m=this,k,p=/^rgba/,E,x,g="none";b&&b.linearGradient?x="gradient":b&&b.radialGradient&&(x="pattern");if(x){var L,u,t=b.linearGradient||b.radialGradient,e,B,A,F,f,z="";b=b.stops;var n,l=[],w=function(){E=['\x3cfill colors\x3d"'+l.join(",")+'" opacity\x3d"',A,'" o:opacity2\x3d"',B,'" type\x3d"',x,'" ',z,'focus\x3d"100%" method\x3d"any" /\x3e'];
G(m.prepVML(E),null,null,c)};e=b[0];n=b[b.length-1];0<e[0]&&b.unshift([0,e[1]]);1>n[0]&&b.push([1,n[1]]);q(b,function(g,b){p.test(g[1])?(k=a.color(g[1]),L=k.get("rgb"),u=k.get("a")):(L=g[1],u=1);l.push(100*g[0]+"% "+L);b?(A=u,F=L):(B=u,f=L)});if("fill"===d)if("gradient"===x)d=t.x1||t[0]||0,b=t.y1||t[1]||0,e=t.x2||t[2]||0,t=t.y2||t[3]||0,z='angle\x3d"'+(90-180*Math.atan((t-b)/(e-d))/Math.PI)+'"',w();else{var g=t.r,r=2*g,v=2*g,C=t.cx,D=t.cy,H=c.radialReference,K,g=function(){H&&(K=h.getBBox(),C+=(H[0]-
K.x)/K.width-.5,D+=(H[1]-K.y)/K.height-.5,r*=H[2]/K.width,v*=H[2]/K.height);z='src\x3d"'+a.getOptions().global.VMLRadialGradientURL+'" size\x3d"'+r+","+v+'" origin\x3d"0.5,0.5" position\x3d"'+C+","+D+'" color2\x3d"'+f+'" ';w()};h.added?g():h.onAdd=g;g=F}else g=L}else p.test(b)&&"IMG"!==c.tagName?(k=a.color(b),h[d+"-opacitySetter"](k.get("a"),d,c),g=k.get("rgb")):(g=c.getElementsByTagName(d),g.length&&(g[0].opacity=1,g[0].type="solid"),g=b);return g},prepVML:function(a){var b=this.isIE8;a=a.join("");
b?(a=a.replace("/\x3e",' xmlns\x3d"urn:schemas-microsoft-com:vml" /\x3e'),a=-1===a.indexOf('style\x3d"')?a.replace("/\x3e",' style\x3d"display:inline-block;behavior:url(#default#VML);" /\x3e'):a.replace('style\x3d"','style\x3d"display:inline-block;behavior:url(#default#VML);')):a=a.replace("\x3c","\x3chcv:");return a},text:p.prototype.html,path:function(a){var b={coordsize:"10 10"};c(a)?b.d=a:z(a)&&f(b,a);return this.createElement("shape").attr(b)},circle:function(a,b,d){var c=this.symbol("circle");
z(a)&&(d=a.r,b=a.y,a=a.x);c.isCircle=!0;c.r=d;return c.attr({x:a,y:b})},g:function(a){var b;a&&(b={className:"highcharts-"+a,"class":"highcharts-"+a});return this.createElement("div").attr(b)},image:function(a,b,d,c,m){var h=this.createElement("img").attr({src:a});1<arguments.length&&h.attr({x:b,y:d,width:c,height:m});return h},createElement:function(a){return"rect"===a?this.symbol(a):p.prototype.createElement.call(this,a)},invertChild:function(a,b){var d=this;b=b.style;var c="IMG"===a.tagName&&a.style;
H(a,{flip:"x",left:h(b.width)-(c?h(c.top):1),top:h(b.height)-(c?h(c.left):1),rotation:-90});q(a.childNodes,function(b){d.invertChild(b,a)})},symbols:{arc:function(a,b,d,c,m){var h=m.start,k=m.end,p=m.r||d||c;d=m.innerR;c=Math.cos(h);var x=Math.sin(h),g=Math.cos(k),L=Math.sin(k);if(0===k-h)return["x"];h=["wa",a-p,b-p,a+p,b+p,a+p*c,b+p*x,a+p*g,b+p*L];m.open&&!d&&h.push("e","M",a,b);h.push("at",a-d,b-d,a+d,b+d,a+d*g,b+d*L,a+d*c,b+d*x,"x","e");h.isArc=!0;return h},circle:function(a,b,d,c,m){m&&v(m.r)&&
(d=c=2*m.r);m&&m.isCircle&&(a-=d/2,b-=c/2);return["wa",a,b,a+d,b+c,a+d,b+c/2,a+d,b+c/2,"e"]},rect:function(a,b,d,c,m){return p.prototype.symbols[v(m)&&m.r?"callout":"square"].call(0,a,b,d,c,m)}}},a.VMLRenderer=D=function(){this.init.apply(this,arguments)},D.prototype=b(p.prototype,C),a.Renderer=D);p.prototype.measureSpanWidth=function(a,b){var d=w.createElement("span");a=w.createTextNode(a);d.appendChild(a);H(d,b);this.box.appendChild(d);b=d.offsetWidth;r(d);return b}})(K);(function(a){function D(){var q=
a.defaultOptions.global,n=w.moment;if(q.timezone){if(n)return function(a){return-n.tz(a,q.timezone).utcOffset()};a.error(25)}return q.useUTC&&q.getTimezoneOffset}function C(){var q=a.defaultOptions.global,n,f=q.useUTC,c=f?"getUTC":"get",e=f?"setUTC":"set";a.Date=n=q.Date||w.Date;n.hcTimezoneOffset=f&&q.timezoneOffset;n.hcGetTimezoneOffset=D();n.hcMakeTime=function(a,b,c,h,e,p){var x;f?(x=n.UTC.apply(0,arguments),x+=v(x)):x=(new n(a,b,r(c,1),r(h,0),r(e,0),r(p,0))).getTime();return x};H("Minutes Hours Day Date Month FullYear".split(" "),
function(a){n["hcGet"+a]=c+a});H("Milliseconds Seconds Minutes Hours Date Month FullYear".split(" "),function(a){n["hcSet"+a]=e+a})}var G=a.color,H=a.each,v=a.getTZOffset,l=a.merge,r=a.pick,w=a.win;a.defaultOptions={colors:"#7cb5ec #434348 #90ed7d #f7a35c #8085e9 #f15c80 #e4d354 #2b908f #f45b5b #91e8e1".split(" "),symbols:["circle","diamond","square","triangle","triangle-down"],lang:{loading:"Loading...",months:"January February March April May June July August September October November December".split(" "),
shortMonths:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),weekdays:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),decimalPoint:".",numericSymbols:"kMGTPE".split(""),resetZoom:"Reset zoom",resetZoomTitle:"Reset zoom level 1:1",thousandsSep:" "},global:{useUTC:!0,VMLRadialGradientURL:"http://code.highcharts.com/5.0.10/gfx/vml-radial-gradient.png"},chart:{borderRadius:0,defaultSeriesType:"line",ignoreHiddenSeries:!0,spacing:[10,10,15,10],resetZoomButton:{theme:{zIndex:20},
position:{align:"right",x:-10,y:10}},width:null,height:null,borderColor:"#335cad",backgroundColor:"#ffffff",plotBorderColor:"#cccccc"},title:{text:"Chart title",align:"center",margin:15,widthAdjust:-44},subtitle:{text:"",align:"center",widthAdjust:-44},plotOptions:{},labels:{style:{position:"absolute",color:"#333333"}},legend:{enabled:!0,align:"center",layout:"horizontal",labelFormatter:function(){return this.name},borderColor:"#999999",borderRadius:0,navigation:{activeColor:"#003399",inactiveColor:"#cccccc"},
itemStyle:{color:"#333333",fontSize:"12px",fontWeight:"bold"},itemHoverStyle:{color:"#000000"},itemHiddenStyle:{color:"#cccccc"},shadow:!1,itemCheckboxStyle:{position:"absolute",width:"13px",height:"13px"},squareSymbol:!0,symbolPadding:5,verticalAlign:"bottom",x:0,y:0,title:{style:{fontWeight:"bold"}}},loading:{labelStyle:{fontWeight:"bold",position:"relative",top:"45%"},style:{position:"absolute",backgroundColor:"#ffffff",opacity:.5,textAlign:"center"}},tooltip:{enabled:!0,animation:a.svg,borderRadius:3,
dateTimeLabelFormats:{millisecond:"%A, %b %e, %H:%M:%S.%L",second:"%A, %b %e, %H:%M:%S",minute:"%A, %b %e, %H:%M",hour:"%A, %b %e, %H:%M",day:"%A, %b %e, %Y",week:"Week from %A, %b %e, %Y",month:"%B %Y",year:"%Y"},footerFormat:"",padding:8,snap:a.isTouchDevice?25:10,backgroundColor:G("#f7f7f7").setOpacity(.85).get(),borderWidth:1,headerFormat:'\x3cspan style\x3d"font-size: 10px"\x3e{point.key}\x3c/span\x3e\x3cbr/\x3e',pointFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e {series.name}: \x3cb\x3e{point.y}\x3c/b\x3e\x3cbr/\x3e',
shadow:!0,style:{color:"#333333",cursor:"default",fontSize:"12px",pointerEvents:"none",whiteSpace:"nowrap"}},credits:{enabled:!0,href:"http://www.highcharts.com",position:{align:"right",x:-10,verticalAlign:"bottom",y:-5},style:{cursor:"pointer",color:"#999999",fontSize:"9px"},text:"Highcharts.com"}};a.setOptions=function(q){a.defaultOptions=l(!0,a.defaultOptions,q);C();return a.defaultOptions};a.getOptions=function(){return a.defaultOptions};a.defaultPlotOptions=a.defaultOptions.plotOptions;C()})(K);
(function(a){var D=a.arrayMax,C=a.arrayMin,G=a.defined,H=a.destroyObjectProperties,v=a.each,l=a.erase,r=a.merge,w=a.pick;a.PlotLineOrBand=function(a,n){this.axis=a;n&&(this.options=n,this.id=n.id)};a.PlotLineOrBand.prototype={render:function(){var a=this,n=a.axis,f=n.horiz,c=a.options,e=c.label,z=a.label,b=c.to,t=c.from,h=c.value,B=G(t)&&G(b),p=G(h),x=a.svgElem,k=!x,F=[],d,u=c.color,m=w(c.zIndex,0),y=c.events,F={"class":"highcharts-plot-"+(B?"band ":"line ")+(c.className||"")},J={},E=n.chart.renderer,
I=B?"bands":"lines",g=n.log2lin;n.isLog&&(t=g(t),b=g(b),h=g(h));p?(F={stroke:u,"stroke-width":c.width},c.dashStyle&&(F.dashstyle=c.dashStyle)):B&&(u&&(F.fill=u),c.borderWidth&&(F.stroke=c.borderColor,F["stroke-width"]=c.borderWidth));J.zIndex=m;I+="-"+m;(u=n.plotLinesAndBandsGroups[I])||(n.plotLinesAndBandsGroups[I]=u=E.g("plot-"+I).attr(J).add());k&&(a.svgElem=x=E.path().attr(F).add(u));if(p)F=n.getPlotLinePath(h,x.strokeWidth());else if(B)F=n.getPlotBandPath(t,b,c);else return;if(k&&F&&F.length){if(x.attr({d:F}),
y)for(d in c=function(g){x.on(g,function(b){y[g].apply(a,[b])})},y)c(d)}else x&&(F?(x.show(),x.animate({d:F})):(x.hide(),z&&(a.label=z=z.destroy())));e&&G(e.text)&&F&&F.length&&0<n.width&&0<n.height&&!F.flat?(e=r({align:f&&B&&"center",x:f?!B&&4:10,verticalAlign:!f&&B&&"middle",y:f?B?16:10:B?6:-4,rotation:f&&!B&&90},e),this.renderLabel(e,F,B,m)):z&&z.hide();return a},renderLabel:function(a,n,f,c){var e=this.label,z=this.axis.chart.renderer;e||(e={align:a.textAlign||a.align,rotation:a.rotation,"class":"highcharts-plot-"+
(f?"band":"line")+"-label "+(a.className||"")},e.zIndex=c,this.label=e=z.text(a.text,0,0,a.useHTML).attr(e).add(),e.css(a.style));c=[n[1],n[4],f?n[6]:n[1]];n=[n[2],n[5],f?n[7]:n[2]];f=C(c);z=C(n);e.align(a,!1,{x:f,y:z,width:D(c)-f,height:D(n)-z});e.show()},destroy:function(){l(this.axis.plotLinesAndBands,this);delete this.axis;H(this)}};a.AxisPlotLineOrBandExtension={getPlotBandPath:function(a,n){var f=this.getPlotLinePath(n,null,null,!0),c=this.getPlotLinePath(a,null,null,!0),e=this.horiz,z=1;a=
a<this.min&&n<this.min||a>this.max&&n>this.max;c&&f?(a&&(c.flat=c.toString()===f.toString(),z=0),c.push(e&&f[4]===c[4]?f[4]+z:f[4],e||f[5]!==c[5]?f[5]:f[5]+z,e&&f[1]===c[1]?f[1]+z:f[1],e||f[2]!==c[2]?f[2]:f[2]+z)):c=null;return c},addPlotBand:function(a){return this.addPlotBandOrLine(a,"plotBands")},addPlotLine:function(a){return this.addPlotBandOrLine(a,"plotLines")},addPlotBandOrLine:function(l,n){var f=(new a.PlotLineOrBand(this,l)).render(),c=this.userOptions;f&&(n&&(c[n]=c[n]||[],c[n].push(l)),
this.plotLinesAndBands.push(f));return f},removePlotBandOrLine:function(a){for(var n=this.plotLinesAndBands,f=this.options,c=this.userOptions,e=n.length;e--;)n[e].id===a&&n[e].destroy();v([f.plotLines||[],c.plotLines||[],f.plotBands||[],c.plotBands||[]],function(c){for(e=c.length;e--;)c[e].id===a&&l(c,c[e])})}}})(K);(function(a){var D=a.correctFloat,C=a.defined,G=a.destroyObjectProperties,H=a.isNumber,v=a.merge,l=a.pick,r=a.deg2rad;a.Tick=function(a,l,n,f){this.axis=a;this.pos=l;this.type=n||"";this.isNew=
!0;n||f||this.addLabel()};a.Tick.prototype={addLabel:function(){var a=this.axis,q=a.options,n=a.chart,f=a.categories,c=a.names,e=this.pos,z=q.labels,b=a.tickPositions,t=e===b[0],h=e===b[b.length-1],c=f?l(f[e],c[e],e):e,f=this.label,b=b.info,B;a.isDatetimeAxis&&b&&(B=q.dateTimeLabelFormats[b.higherRanks[e]||b.unitName]);this.isFirst=t;this.isLast=h;q=a.labelFormatter.call({axis:a,chart:n,isFirst:t,isLast:h,dateTimeLabelFormat:B,value:a.isLog?D(a.lin2log(c)):c});C(f)?f&&f.attr({text:q}):(this.labelLength=
(this.label=f=C(q)&&z.enabled?n.renderer.text(q,0,0,z.useHTML).css(v(z.style)).add(a.labelGroup):null)&&f.getBBox().width,this.rotation=0)},getLabelSize:function(){return this.label?this.label.getBBox()[this.axis.horiz?"height":"width"]:0},handleOverflow:function(a){var q=this.axis,n=a.x,f=q.chart.chartWidth,c=q.chart.spacing,e=l(q.labelLeft,Math.min(q.pos,c[3])),c=l(q.labelRight,Math.max(q.pos+q.len,f-c[1])),z=this.label,b=this.rotation,t={left:0,center:.5,right:1}[q.labelAlign],h=z.getBBox().width,
B=q.getSlotWidth(),p=B,x=1,k,F={};if(b)0>b&&n-t*h<e?k=Math.round(n/Math.cos(b*r)-e):0<b&&n+t*h>c&&(k=Math.round((f-n)/Math.cos(b*r)));else if(f=n+(1-t)*h,n-t*h<e?p=a.x+p*(1-t)-e:f>c&&(p=c-a.x+p*t,x=-1),p=Math.min(B,p),p<B&&"center"===q.labelAlign&&(a.x+=x*(B-p-t*(B-Math.min(h,p)))),h>p||q.autoRotation&&(z.styles||{}).width)k=p;k&&(F.width=k,(q.options.labels.style||{}).textOverflow||(F.textOverflow="ellipsis"),z.css(F))},getPosition:function(a,l,n,f){var c=this.axis,e=c.chart,z=f&&e.oldChartHeight||
e.chartHeight;return{x:a?c.translate(l+n,null,null,f)+c.transB:c.left+c.offset+(c.opposite?(f&&e.oldChartWidth||e.chartWidth)-c.right-c.left:0),y:a?z-c.bottom+c.offset-(c.opposite?c.height:0):z-c.translate(l+n,null,null,f)-c.transB}},getLabelPosition:function(a,l,n,f,c,e,z,b){var t=this.axis,h=t.transA,B=t.reversed,p=t.staggerLines,x=t.tickRotCorr||{x:0,y:0},k=c.y;C(k)||(k=0===t.side?n.rotation?-8:-n.getBBox().height:2===t.side?x.y+8:Math.cos(n.rotation*r)*(x.y-n.getBBox(!1,0).height/2));a=a+c.x+
x.x-(e&&f?e*h*(B?-1:1):0);l=l+k-(e&&!f?e*h*(B?1:-1):0);p&&(n=z/(b||1)%p,t.opposite&&(n=p-n-1),l+=t.labelOffset/p*n);return{x:a,y:Math.round(l)}},getMarkPath:function(a,l,n,f,c,e){return e.crispLine(["M",a,l,"L",a+(c?0:-n),l+(c?n:0)],f)},renderGridLine:function(a,l,n){var f=this.axis,c=f.options,e=this.gridLine,z={},b=this.pos,t=this.type,h=f.tickmarkOffset,B=f.chart.renderer,p=t?t+"Grid":"grid",x=c[p+"LineWidth"],k=c[p+"LineColor"],c=c[p+"LineDashStyle"];e||(z.stroke=k,z["stroke-width"]=x,c&&(z.dashstyle=
c),t||(z.zIndex=1),a&&(z.opacity=0),this.gridLine=e=B.path().attr(z).addClass("highcharts-"+(t?t+"-":"")+"grid-line").add(f.gridGroup));if(!a&&e&&(a=f.getPlotLinePath(b+h,e.strokeWidth()*n,a,!0)))e[this.isNew?"attr":"animate"]({d:a,opacity:l})},renderMark:function(a,q,n){var f=this.axis,c=f.options,e=f.chart.renderer,z=this.type,b=z?z+"Tick":"tick",t=f.tickSize(b),h=this.mark,B=!h,p=a.x;a=a.y;var x=l(c[b+"Width"],!z&&f.isXAxis?1:0),c=c[b+"Color"];t&&(f.opposite&&(t[0]=-t[0]),B&&(this.mark=h=e.path().addClass("highcharts-"+
(z?z+"-":"")+"tick").add(f.axisGroup),h.attr({stroke:c,"stroke-width":x})),h[B?"attr":"animate"]({d:this.getMarkPath(p,a,t[0],h.strokeWidth()*n,f.horiz,e),opacity:q}))},renderLabel:function(a,q,n,f){var c=this.axis,e=c.horiz,z=c.options,b=this.label,t=z.labels,h=t.step,B=c.tickmarkOffset,p=!0,x=a.x;a=a.y;b&&H(x)&&(b.xy=a=this.getLabelPosition(x,a,b,e,t,B,f,h),this.isFirst&&!this.isLast&&!l(z.showFirstLabel,1)||this.isLast&&!this.isFirst&&!l(z.showLastLabel,1)?p=!1:!e||c.isRadial||t.step||t.rotation||
q||0===n||this.handleOverflow(a),h&&f%h&&(p=!1),p&&H(a.y)?(a.opacity=n,b[this.isNew?"attr":"animate"](a)):b.attr("y",-9999),this.isNew=!1)},render:function(a,q,n){var f=this.axis,c=f.horiz,e=this.getPosition(c,this.pos,f.tickmarkOffset,q),z=e.x,b=e.y,f=c&&z===f.pos+f.len||!c&&b===f.pos?-1:1;n=l(n,1);this.isActive=!0;this.renderGridLine(q,n,f);this.renderMark(e,n,f);this.renderLabel(e,q,n,a)},destroy:function(){G(this,this.axis)}}})(K);(function(a){var D=a.addEvent,C=a.animObject,G=a.arrayMax,H=a.arrayMin,
v=a.AxisPlotLineOrBandExtension,l=a.color,r=a.correctFloat,w=a.defaultOptions,q=a.defined,n=a.deg2rad,f=a.destroyObjectProperties,c=a.each,e=a.extend,z=a.fireEvent,b=a.format,t=a.getMagnitude,h=a.grep,B=a.inArray,p=a.isArray,x=a.isNumber,k=a.isString,F=a.merge,d=a.normalizeTickInterval,u=a.pick,m=a.PlotLineOrBand,y=a.removeEvent,J=a.splat,E=a.syncTimeout,I=a.Tick;a.Axis=function(){this.init.apply(this,arguments)};a.Axis.prototype={defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",
minute:"%H:%M",hour:"%H:%M",day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,labels:{enabled:!0,style:{color:"#666666",cursor:"default",fontSize:"11px"},x:0},minPadding:.01,maxPadding:.01,minorTickLength:2,minorTickPosition:"outside",startOfWeek:1,startOnTick:!1,tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",title:{align:"middle",style:{color:"#666666"}},type:"linear",minorGridLineColor:"#f2f2f2",minorGridLineWidth:1,minorTickColor:"#999999",
lineColor:"#ccd6eb",lineWidth:1,gridLineColor:"#e6e6e6",tickColor:"#ccd6eb"},defaultYAxisOptions:{endOnTick:!0,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8},maxPadding:.05,minPadding:.05,startOnTick:!0,title:{rotation:270,text:"Values"},stackLabels:{enabled:!1,formatter:function(){return a.numberFormat(this.total,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"#000000",textOutline:"1px contrast"}},gridLineWidth:1,lineWidth:0},defaultLeftAxisOptions:{labels:{x:-15},title:{rotation:270}},
defaultRightAxisOptions:{labels:{x:15},title:{rotation:90}},defaultBottomAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},defaultTopAxisOptions:{labels:{autoRotation:[-45],x:0},title:{rotation:0}},init:function(a,b){var g=b.isX;this.chart=a;this.horiz=a.inverted?!g:g;this.isXAxis=g;this.coll=this.coll||(g?"xAxis":"yAxis");this.opposite=b.opposite;this.side=b.side||(this.horiz?this.opposite?0:2:this.opposite?1:3);this.setOptions(b);var d=this.options,c=d.type;this.labelFormatter=d.labels.formatter||
this.defaultLabelFormatter;this.userOptions=b;this.minPixelPadding=0;this.reversed=d.reversed;this.visible=!1!==d.visible;this.zoomEnabled=!1!==d.zoomEnabled;this.hasNames="category"===c||!0===d.categories;this.categories=d.categories||this.hasNames;this.names=this.names||[];this.plotLinesAndBandsGroups={};this.isLog="logarithmic"===c;this.isDatetimeAxis="datetime"===c;this.positiveValuesOnly=this.isLog&&!this.allowNegativeLog;this.isLinked=q(d.linkedTo);this.ticks={};this.labelEdge=[];this.minorTicks=
{};this.plotLinesAndBands=[];this.alternateBands={};this.len=0;this.minRange=this.userMinRange=d.minRange||d.maxZoom;this.range=d.range;this.offset=d.offset||0;this.stacks={};this.oldStacks={};this.stacksTouched=0;this.min=this.max=null;this.crosshair=u(d.crosshair,J(a.options.tooltip.crosshairs)[g?0:1],!1);var m;b=this.options.events;-1===B(this,a.axes)&&(g?a.axes.splice(a.xAxis.length,0,this):a.axes.push(this),a[this.coll].push(this));this.series=this.series||[];a.inverted&&g&&void 0===this.reversed&&
(this.reversed=!0);this.removePlotLine=this.removePlotBand=this.removePlotBandOrLine;for(m in b)D(this,m,b[m]);this.lin2log=d.linearToLogConverter||this.lin2log;this.isLog&&(this.val2lin=this.log2lin,this.lin2val=this.lin2log)},setOptions:function(a){this.options=F(this.defaultOptions,"yAxis"===this.coll&&this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions,this.defaultLeftAxisOptions][this.side],F(w[this.coll],a))},defaultLabelFormatter:function(){var g=
this.axis,d=this.value,c=g.categories,m=this.dateTimeLabelFormat,h=w.lang,k=h.numericSymbols,h=h.numericSymbolMagnitude||1E3,p=k&&k.length,y,E=g.options.labels.format,g=g.isLog?Math.abs(d):g.tickInterval;if(E)y=b(E,this);else if(c)y=d;else if(m)y=a.dateFormat(m,d);else if(p&&1E3<=g)for(;p--&&void 0===y;)c=Math.pow(h,p+1),g>=c&&0===10*d%c&&null!==k[p]&&0!==d&&(y=a.numberFormat(d/c,-1)+k[p]);void 0===y&&(y=1E4<=Math.abs(d)?a.numberFormat(d,-1):a.numberFormat(d,-1,void 0,""));return y},getSeriesExtremes:function(){var a=
this,b=a.chart;a.hasVisibleSeries=!1;a.dataMin=a.dataMax=a.threshold=null;a.softThreshold=!a.isXAxis;a.buildStacks&&a.buildStacks();c(a.series,function(g){if(g.visible||!b.options.chart.ignoreHiddenSeries){var d=g.options,c=d.threshold,m;a.hasVisibleSeries=!0;a.positiveValuesOnly&&0>=c&&(c=null);if(a.isXAxis)d=g.xData,d.length&&(g=H(d),x(g)||g instanceof Date||(d=h(d,function(a){return x(a)}),g=H(d)),a.dataMin=Math.min(u(a.dataMin,d[0]),g),a.dataMax=Math.max(u(a.dataMax,d[0]),G(d)));else if(g.getExtremes(),
m=g.dataMax,g=g.dataMin,q(g)&&q(m)&&(a.dataMin=Math.min(u(a.dataMin,g),g),a.dataMax=Math.max(u(a.dataMax,m),m)),q(c)&&(a.threshold=c),!d.softThreshold||a.positiveValuesOnly)a.softThreshold=!1}})},translate:function(a,b,d,c,m,h){var g=this.linkedParent||this,k=1,p=0,y=c?g.oldTransA:g.transA;c=c?g.oldMin:g.min;var L=g.minPixelPadding;m=(g.isOrdinal||g.isBroken||g.isLog&&m)&&g.lin2val;y||(y=g.transA);d&&(k*=-1,p=g.len);g.reversed&&(k*=-1,p-=k*(g.sector||g.len));b?(a=(a*k+p-L)/y+c,m&&(a=g.lin2val(a))):
(m&&(a=g.val2lin(a)),a=k*(a-c)*y+p+k*L+(x(h)?y*h:0));return a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a-(b?0:this.pos),!0,!this.horiz,null,!0)},getPlotLinePath:function(a,b,d,c,m){var g=this.chart,h=this.left,k=this.top,y,p,L=d&&g.oldChartHeight||g.chartHeight,E=d&&g.oldChartWidth||g.chartWidth,t;y=this.transB;var e=function(a,b,g){if(a<b||a>g)c?a=Math.min(Math.max(b,a),g):t=!0;return a};m=u(m,this.translate(a,
null,null,d));a=d=Math.round(m+y);y=p=Math.round(L-m-y);x(m)?this.horiz?(y=k,p=L-this.bottom,a=d=e(a,h,h+this.width)):(a=h,d=E-this.right,y=p=e(y,k,k+this.height)):t=!0;return t&&!c?null:g.renderer.crispLine(["M",a,y,"L",d,p],b||1)},getLinearTickPositions:function(a,b,d){var g,c=r(Math.floor(b/a)*a);d=r(Math.ceil(d/a)*a);var m=[];if(this.single)return[b];for(b=c;b<=d;){m.push(b);b=r(b+a);if(b===g)break;g=b}return m},getMinorTickPositions:function(){var a=this,b=a.options,d=a.tickPositions,m=a.minorTickInterval,
h=[],k=a.pointRangePadding||0,y=a.min-k,k=a.max+k,p=k-y;if(p&&p/m<a.len/3)if(a.isLog)c(this.paddedTicks,function(b,g,d){g&&h.push.apply(h,a.getLogTickPositions(m,d[g-1],d[g],!0))});else if(a.isDatetimeAxis&&"auto"===b.minorTickInterval)h=h.concat(a.getTimeTicks(a.normalizeTimeTickInterval(m),y,k,b.startOfWeek));else for(b=y+(d[0]-y)%m;b<=k&&b!==h[0];b+=m)h.push(b);0!==h.length&&a.trimTicks(h);return h},adjustForMinRange:function(){var a=this.options,b=this.min,d=this.max,m,h=this.dataMax-this.dataMin>=
this.minRange,k,y,p,E,x,t;this.isXAxis&&void 0===this.minRange&&!this.isLog&&(q(a.min)||q(a.max)?this.minRange=null:(c(this.series,function(a){E=a.xData;for(y=x=a.xIncrement?1:E.length-1;0<y;y--)if(p=E[y]-E[y-1],void 0===k||p<k)k=p}),this.minRange=Math.min(5*k,this.dataMax-this.dataMin)));d-b<this.minRange&&(t=this.minRange,m=(t-d+b)/2,m=[b-m,u(a.min,b-m)],h&&(m[2]=this.isLog?this.log2lin(this.dataMin):this.dataMin),b=G(m),d=[b+t,u(a.max,b+t)],h&&(d[2]=this.isLog?this.log2lin(this.dataMax):this.dataMax),
d=H(d),d-b<t&&(m[0]=d-t,m[1]=u(a.min,d-t),b=G(m)));this.min=b;this.max=d},getClosest:function(){var a;this.categories?a=1:c(this.series,function(b){var g=b.closestPointRange,d=b.visible||!b.chart.options.chart.ignoreHiddenSeries;!b.noSharedTooltip&&q(g)&&d&&(a=q(a)?Math.min(a,g):g)});return a},nameToX:function(a){var b=p(this.categories),g=b?this.categories:this.names,d=a.options.x,c;a.series.requireSorting=!1;q(d)||(d=!1===this.options.uniqueNames?a.series.autoIncrement():B(a.name,g));-1===d?b||
(c=g.length):c=d;void 0!==c&&(this.names[c]=a.name);return c},updateNames:function(){var a=this;0<this.names.length&&(this.names.length=0,this.minRange=void 0,c(this.series||[],function(b){b.xIncrement=null;if(!b.points||b.isDirtyData)b.processData(),b.generatePoints();c(b.points,function(g,d){var c;g.options&&(c=a.nameToX(g),void 0!==c&&c!==g.x&&(g.x=c,b.xData[d]=c))})}))},setAxisTranslation:function(a){var b=this,g=b.max-b.min,d=b.axisPointRange||0,m,h=0,y=0,p=b.linkedParent,E=!!b.categories,x=
b.transA,t=b.isXAxis;if(t||E||d)m=b.getClosest(),p?(h=p.minPointOffset,y=p.pointRangePadding):c(b.series,function(a){var g=E?1:t?u(a.options.pointRange,m,0):b.axisPointRange||0;a=a.options.pointPlacement;d=Math.max(d,g);b.single||(h=Math.max(h,k(a)?0:g/2),y=Math.max(y,"on"===a?0:g))}),p=b.ordinalSlope&&m?b.ordinalSlope/m:1,b.minPointOffset=h*=p,b.pointRangePadding=y*=p,b.pointRange=Math.min(d,g),t&&(b.closestPointRange=m);a&&(b.oldTransA=x);b.translationSlope=b.transA=x=b.options.staticScale||b.len/
(g+y||1);b.transB=b.horiz?b.left:b.bottom;b.minPixelPadding=x*h},minFromRange:function(){return this.max-this.range},setTickInterval:function(b){var g=this,m=g.chart,h=g.options,k=g.isLog,y=g.log2lin,p=g.isDatetimeAxis,E=g.isXAxis,e=g.isLinked,I=h.maxPadding,B=h.minPadding,f=h.tickInterval,F=h.tickPixelInterval,J=g.categories,l=g.threshold,n=g.softThreshold,w,v,C,D;p||J||e||this.getTickAmount();C=u(g.userMin,h.min);D=u(g.userMax,h.max);e?(g.linkedParent=m[g.coll][h.linkedTo],m=g.linkedParent.getExtremes(),
g.min=u(m.min,m.dataMin),g.max=u(m.max,m.dataMax),h.type!==g.linkedParent.options.type&&a.error(11,1)):(!n&&q(l)&&(g.dataMin>=l?(w=l,B=0):g.dataMax<=l&&(v=l,I=0)),g.min=u(C,w,g.dataMin),g.max=u(D,v,g.dataMax));k&&(g.positiveValuesOnly&&!b&&0>=Math.min(g.min,u(g.dataMin,g.min))&&a.error(10,1),g.min=r(y(g.min),15),g.max=r(y(g.max),15));g.range&&q(g.max)&&(g.userMin=g.min=C=Math.max(g.min,g.minFromRange()),g.userMax=D=g.max,g.range=null);z(g,"foundExtremes");g.beforePadding&&g.beforePadding();g.adjustForMinRange();
!(J||g.axisPointRange||g.usePercentage||e)&&q(g.min)&&q(g.max)&&(y=g.max-g.min)&&(!q(C)&&B&&(g.min-=y*B),!q(D)&&I&&(g.max+=y*I));x(h.softMin)&&(g.min=Math.min(g.min,h.softMin));x(h.softMax)&&(g.max=Math.max(g.max,h.softMax));x(h.floor)&&(g.min=Math.max(g.min,h.floor));x(h.ceiling)&&(g.max=Math.min(g.max,h.ceiling));n&&q(g.dataMin)&&(l=l||0,!q(C)&&g.min<l&&g.dataMin>=l?g.min=l:!q(D)&&g.max>l&&g.dataMax<=l&&(g.max=l));g.tickInterval=g.min===g.max||void 0===g.min||void 0===g.max?1:e&&!f&&F===g.linkedParent.options.tickPixelInterval?
f=g.linkedParent.tickInterval:u(f,this.tickAmount?(g.max-g.min)/Math.max(this.tickAmount-1,1):void 0,J?1:(g.max-g.min)*F/Math.max(g.len,F));E&&!b&&c(g.series,function(a){a.processData(g.min!==g.oldMin||g.max!==g.oldMax)});g.setAxisTranslation(!0);g.beforeSetTickPositions&&g.beforeSetTickPositions();g.postProcessTickInterval&&(g.tickInterval=g.postProcessTickInterval(g.tickInterval));g.pointRange&&!f&&(g.tickInterval=Math.max(g.pointRange,g.tickInterval));b=u(h.minTickInterval,g.isDatetimeAxis&&g.closestPointRange);
!f&&g.tickInterval<b&&(g.tickInterval=b);p||k||f||(g.tickInterval=d(g.tickInterval,null,t(g.tickInterval),u(h.allowDecimals,!(.5<g.tickInterval&&5>g.tickInterval&&1E3<g.max&&9999>g.max)),!!this.tickAmount));this.tickAmount||(g.tickInterval=g.unsquish());this.setTickPositions()},setTickPositions:function(){var a=this.options,b,d=a.tickPositions,c=a.tickPositioner,m=a.startOnTick,h=a.endOnTick;this.tickmarkOffset=this.categories&&"between"===a.tickmarkPlacement&&1===this.tickInterval?.5:0;this.minorTickInterval=
"auto"===a.minorTickInterval&&this.tickInterval?this.tickInterval/5:a.minorTickInterval;this.single=this.min===this.max&&q(this.min)&&!this.tickAmount&&!1!==a.allowDecimals;this.tickPositions=b=d&&d.slice();!b&&(b=this.isDatetimeAxis?this.getTimeTicks(this.normalizeTimeTickInterval(this.tickInterval,a.units),this.min,this.max,a.startOfWeek,this.ordinalPositions,this.closestPointRange,!0):this.isLog?this.getLogTickPositions(this.tickInterval,this.min,this.max):this.getLinearTickPositions(this.tickInterval,
this.min,this.max),b.length>this.len&&(b=[b[0],b.pop()]),this.tickPositions=b,c&&(c=c.apply(this,[this.min,this.max])))&&(this.tickPositions=b=c);this.paddedTicks=b.slice(0);this.trimTicks(b,m,h);this.isLinked||(this.single&&(this.min-=.5,this.max+=.5),d||c||this.adjustTickAmount())},trimTicks:function(a,b,d){var g=a[0],c=a[a.length-1],m=this.minPointOffset||0;if(!this.isLinked){if(b&&-Infinity!==g)this.min=g;else for(;this.min-m>a[0];)a.shift();if(d)this.max=c;else for(;this.max+m<a[a.length-1];)a.pop();
0===a.length&&q(g)&&a.push((c+g)/2)}},alignToOthers:function(){var a={},b,d=this.options;!1===this.chart.options.chart.alignTicks||!1===d.alignTicks||this.isLog||c(this.chart[this.coll],function(g){var d=g.options,d=[g.horiz?d.left:d.top,d.width,d.height,d.pane].join();g.series.length&&(a[d]?b=!0:a[d]=1)});return b},getTickAmount:function(){var a=this.options,b=a.tickAmount,d=a.tickPixelInterval;!q(a.tickInterval)&&this.len<d&&!this.isRadial&&!this.isLog&&a.startOnTick&&a.endOnTick&&(b=2);!b&&this.alignToOthers()&&
(b=Math.ceil(this.len/d)+1);4>b&&(this.finalTickAmt=b,b=5);this.tickAmount=b},adjustTickAmount:function(){var a=this.tickInterval,b=this.tickPositions,d=this.tickAmount,c=this.finalTickAmt,m=b&&b.length;if(m<d){for(;b.length<d;)b.push(r(b[b.length-1]+a));this.transA*=(m-1)/(d-1);this.max=b[b.length-1]}else m>d&&(this.tickInterval*=2,this.setTickPositions());if(q(c)){for(a=d=b.length;a--;)(3===c&&1===a%2||2>=c&&0<a&&a<d-1)&&b.splice(a,1);this.finalTickAmt=void 0}},setScale:function(){var a,b;this.oldMin=
this.min;this.oldMax=this.max;this.oldAxisLength=this.len;this.setAxisSize();b=this.len!==this.oldAxisLength;c(this.series,function(b){if(b.isDirtyData||b.isDirty||b.xAxis.isDirty)a=!0});b||a||this.isLinked||this.forceRedraw||this.userMin!==this.oldUserMin||this.userMax!==this.oldUserMax||this.alignToOthers()?(this.resetStacks&&this.resetStacks(),this.forceRedraw=!1,this.getSeriesExtremes(),this.setTickInterval(),this.oldUserMin=this.userMin,this.oldUserMax=this.userMax,this.isDirty||(this.isDirty=
b||this.min!==this.oldMin||this.max!==this.oldMax)):this.cleanStacks&&this.cleanStacks()},setExtremes:function(a,b,d,m,h){var g=this,k=g.chart;d=u(d,!0);c(g.series,function(a){delete a.kdTree});h=e(h,{min:a,max:b});z(g,"setExtremes",h,function(){g.userMin=a;g.userMax=b;g.eventArgs=h;d&&k.redraw(m)})},zoom:function(a,b){var g=this.dataMin,d=this.dataMax,c=this.options,m=Math.min(g,u(c.min,g)),c=Math.max(d,u(c.max,d));if(a!==this.min||b!==this.max)this.allowZoomOutside||(q(g)&&(a<m&&(a=m),a>c&&(a=c)),
q(d)&&(b<m&&(b=m),b>c&&(b=c))),this.displayBtn=void 0!==a||void 0!==b,this.setExtremes(a,b,!1,void 0,{trigger:"zoom"});return!0},setAxisSize:function(){var a=this.chart,b=this.options,d=b.offsets||[0,0,0,0],c=this.horiz,m=u(b.width,a.plotWidth-d[3]+d[1]),h=u(b.height,a.plotHeight-d[0]+d[2]),k=u(b.top,a.plotTop+d[0]),b=u(b.left,a.plotLeft+d[3]),d=/%$/;d.test(h)&&(h=Math.round(parseFloat(h)/100*a.plotHeight));d.test(k)&&(k=Math.round(parseFloat(k)/100*a.plotHeight+a.plotTop));this.left=b;this.top=k;
this.width=m;this.height=h;this.bottom=a.chartHeight-h-k;this.right=a.chartWidth-m-b;this.len=Math.max(c?m:h,0);this.pos=c?b:k},getExtremes:function(){var a=this.isLog,b=this.lin2log;return{min:a?r(b(this.min)):this.min,max:a?r(b(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}},getThreshold:function(a){var b=this.isLog,g=this.lin2log,d=b?g(this.min):this.min,b=b?g(this.max):this.max;null===a?a=d:d>a?a=d:b<a&&(a=b);return this.translate(a,0,
1,0,1)},autoLabelAlign:function(a){a=(u(a,0)-90*this.side+720)%360;return 15<a&&165>a?"right":195<a&&345>a?"left":"center"},tickSize:function(a){var b=this.options,g=b[a+"Length"],d=u(b[a+"Width"],"tick"===a&&this.isXAxis?1:0);if(d&&g)return"inside"===b[a+"Position"]&&(g=-g),[g,d]},labelMetrics:function(){return this.chart.renderer.fontMetrics(this.options.labels.style&&this.options.labels.style.fontSize,this.ticks[0]&&this.ticks[0].label)},unsquish:function(){var a=this.options.labels,b=this.horiz,
d=this.tickInterval,m=d,h=this.len/(((this.categories?1:0)+this.max-this.min)/d),k,y=a.rotation,p=this.labelMetrics(),E,x=Number.MAX_VALUE,t,e=function(a){a/=h||1;a=1<a?Math.ceil(a):1;return a*d};b?(t=!a.staggerLines&&!a.step&&(q(y)?[y]:h<u(a.autoRotationLimit,80)&&a.autoRotation))&&c(t,function(a){var b;if(a===y||a&&-90<=a&&90>=a)E=e(Math.abs(p.h/Math.sin(n*a))),b=E+Math.abs(a/360),b<x&&(x=b,k=a,m=E)}):a.step||(m=e(p.h));this.autoRotation=t;this.labelRotation=u(k,y);return m},getSlotWidth:function(){var a=
this.chart,b=this.horiz,d=this.options.labels,c=Math.max(this.tickPositions.length-(this.categories?0:1),1),m=a.margin[3];return b&&2>(d.step||0)&&!d.rotation&&(this.staggerLines||1)*this.len/c||!b&&(m&&m-a.spacing[3]||.33*a.chartWidth)},renderUnsquish:function(){var a=this.chart,b=a.renderer,d=this.tickPositions,m=this.ticks,h=this.options.labels,y=this.horiz,p=this.getSlotWidth(),E=Math.max(1,Math.round(p-2*(h.padding||5))),t={},x=this.labelMetrics(),e=h.style&&h.style.textOverflow,u,I=0,B,f;k(h.rotation)||
(t.rotation=h.rotation||0);c(d,function(a){(a=m[a])&&a.labelLength>I&&(I=a.labelLength)});this.maxLabelLength=I;if(this.autoRotation)I>E&&I>x.h?t.rotation=this.labelRotation:this.labelRotation=0;else if(p&&(u={width:E+"px"},!e))for(u.textOverflow="clip",B=d.length;!y&&B--;)if(f=d[B],E=m[f].label)E.styles&&"ellipsis"===E.styles.textOverflow?E.css({textOverflow:"clip"}):m[f].labelLength>p&&E.css({width:p+"px"}),E.getBBox().height>this.len/d.length-(x.h-x.f)&&(E.specCss={textOverflow:"ellipsis"});t.rotation&&
(u={width:(I>.5*a.chartHeight?.33*a.chartHeight:a.chartHeight)+"px"},e||(u.textOverflow="ellipsis"));if(this.labelAlign=h.align||this.autoLabelAlign(this.labelRotation))t.align=this.labelAlign;c(d,function(a){var b=(a=m[a])&&a.label;b&&(b.attr(t),u&&b.css(F(u,b.specCss)),delete b.specCss,a.rotation=t.rotation)});this.tickRotCorr=b.rotCorr(x.b,this.labelRotation||0,0!==this.side)},hasData:function(){return this.hasVisibleSeries||q(this.min)&&q(this.max)&&!!this.tickPositions},addTitle:function(a){var b=
this.chart.renderer,g=this.horiz,d=this.opposite,c=this.options.title,m;this.axisTitle||((m=c.textAlign)||(m=(g?{low:"left",middle:"center",high:"right"}:{low:d?"right":"left",middle:"center",high:d?"left":"right"})[c.align]),this.axisTitle=b.text(c.text,0,0,c.useHTML).attr({zIndex:7,rotation:c.rotation||0,align:m}).addClass("highcharts-axis-title").css(c.style).add(this.axisGroup),this.axisTitle.isNew=!0);this.axisTitle[a?"show":"hide"](!0)},generateTick:function(a){var b=this.ticks;b[a]?b[a].addLabel():
b[a]=new I(this,a)},getOffset:function(){var a=this,b=a.chart,d=b.renderer,m=a.options,h=a.tickPositions,k=a.ticks,y=a.horiz,p=a.side,E=b.inverted?[1,0,3,2][p]:p,t,x,e=0,I,B=0,f=m.title,z=m.labels,F=0,J=b.axisOffset,b=b.clipOffset,l=[-1,1,1,-1][p],n,r=m.className,w=a.axisParent,v=this.tickSize("tick");t=a.hasData();a.showAxis=x=t||u(m.showEmpty,!0);a.staggerLines=a.horiz&&z.staggerLines;a.axisGroup||(a.gridGroup=d.g("grid").attr({zIndex:m.gridZIndex||1}).addClass("highcharts-"+this.coll.toLowerCase()+
"-grid "+(r||"")).add(w),a.axisGroup=d.g("axis").attr({zIndex:m.zIndex||2}).addClass("highcharts-"+this.coll.toLowerCase()+" "+(r||"")).add(w),a.labelGroup=d.g("axis-labels").attr({zIndex:z.zIndex||7}).addClass("highcharts-"+a.coll.toLowerCase()+"-labels "+(r||"")).add(w));if(t||a.isLinked)c(h,function(b,g){a.generateTick(b,g)}),a.renderUnsquish(),!1===z.reserveSpace||0!==p&&2!==p&&{1:"left",3:"right"}[p]!==a.labelAlign&&"center"!==a.labelAlign||c(h,function(a){F=Math.max(k[a].getLabelSize(),F)}),
a.staggerLines&&(F*=a.staggerLines,a.labelOffset=F*(a.opposite?-1:1));else for(n in k)k[n].destroy(),delete k[n];f&&f.text&&!1!==f.enabled&&(a.addTitle(x),x&&(e=a.axisTitle.getBBox()[y?"height":"width"],I=f.offset,B=q(I)?0:u(f.margin,y?5:10)));a.renderLine();a.offset=l*u(m.offset,J[p]);a.tickRotCorr=a.tickRotCorr||{x:0,y:0};d=0===p?-a.labelMetrics().h:2===p?a.tickRotCorr.y:0;B=Math.abs(F)+B;F&&(B=B-d+l*(y?u(z.y,a.tickRotCorr.y+8*l):z.x));a.axisTitleMargin=u(I,B);J[p]=Math.max(J[p],a.axisTitleMargin+
e+l*a.offset,B,t&&h.length&&v?v[0]+l*a.offset:0);m=m.offset?0:2*Math.floor(a.axisLine.strokeWidth()/2);b[E]=Math.max(b[E],m)},getLinePath:function(a){var b=this.chart,g=this.opposite,d=this.offset,c=this.horiz,m=this.left+(g?this.width:0)+d,d=b.chartHeight-this.bottom-(g?this.height:0)+d;g&&(a*=-1);return b.renderer.crispLine(["M",c?this.left:m,c?d:this.top,"L",c?b.chartWidth-this.right:m,c?d:b.chartHeight-this.bottom],a)},renderLine:function(){this.axisLine||(this.axisLine=this.chart.renderer.path().addClass("highcharts-axis-line").add(this.axisGroup),
this.axisLine.attr({stroke:this.options.lineColor,"stroke-width":this.options.lineWidth,zIndex:7}))},getTitlePosition:function(){var a=this.horiz,b=this.left,d=this.top,c=this.len,m=this.options.title,h=a?b:d,k=this.opposite,y=this.offset,p=m.x||0,E=m.y||0,t=this.chart.renderer.fontMetrics(m.style&&m.style.fontSize,this.axisTitle).f,c={low:h+(a?0:c),middle:h+c/2,high:h+(a?c:0)}[m.align],b=(a?d+this.height:b)+(a?1:-1)*(k?-1:1)*this.axisTitleMargin+(2===this.side?t:0);return{x:a?c+p:b+(k?this.width:
0)+y+p,y:a?b+E-(k?this.height:0)+y:c+E}},renderMinorTick:function(a){var b=this.chart.hasRendered&&x(this.oldMin),g=this.minorTicks;g[a]||(g[a]=new I(this,a,"minor"));b&&g[a].isNew&&g[a].render(null,!0);g[a].render(null,!1,1)},renderTick:function(a,b){var g=this.isLinked,d=this.ticks,c=this.chart.hasRendered&&x(this.oldMin);if(!g||a>=this.min&&a<=this.max)d[a]||(d[a]=new I(this,a)),c&&d[a].isNew&&d[a].render(b,!0,.1),d[a].render(b)},render:function(){var a=this,b=a.chart,d=a.options,h=a.isLog,k=a.lin2log,
y=a.isLinked,p=a.tickPositions,t=a.axisTitle,x=a.ticks,e=a.minorTicks,u=a.alternateBands,B=d.stackLabels,f=d.alternateGridColor,z=a.tickmarkOffset,F=a.axisLine,J=a.showAxis,l=C(b.renderer.globalAnimation),n,q;a.labelEdge.length=0;a.overlap=!1;c([x,e,u],function(a){for(var b in a)a[b].isActive=!1});if(a.hasData()||y)a.minorTickInterval&&!a.categories&&c(a.getMinorTickPositions(),function(b){a.renderMinorTick(b)}),p.length&&(c(p,function(b,d){a.renderTick(b,d)}),z&&(0===a.min||a.single)&&(x[-1]||(x[-1]=
new I(a,-1,null,!0)),x[-1].render(-1))),f&&c(p,function(d,g){q=void 0!==p[g+1]?p[g+1]+z:a.max-z;0===g%2&&d<a.max&&q<=a.max+(b.polar?-z:z)&&(u[d]||(u[d]=new m(a)),n=d+z,u[d].options={from:h?k(n):n,to:h?k(q):q,color:f},u[d].render(),u[d].isActive=!0)}),a._addedPlotLB||(c((d.plotLines||[]).concat(d.plotBands||[]),function(b){a.addPlotBandOrLine(b)}),a._addedPlotLB=!0);c([x,e,u],function(a){var d,g,c=[],m=l.duration;for(d in a)a[d].isActive||(a[d].render(d,!1,0),a[d].isActive=!1,c.push(d));E(function(){for(g=
c.length;g--;)a[c[g]]&&!a[c[g]].isActive&&(a[c[g]].destroy(),delete a[c[g]])},a!==u&&b.hasRendered&&m?m:0)});F&&(F[F.isPlaced?"animate":"attr"]({d:this.getLinePath(F.strokeWidth())}),F.isPlaced=!0,F[J?"show":"hide"](!0));t&&J&&(t[t.isNew?"attr":"animate"](a.getTitlePosition()),t.isNew=!1);B&&B.enabled&&a.renderStackTotals();a.isDirty=!1},redraw:function(){this.visible&&(this.render(),c(this.plotLinesAndBands,function(a){a.render()}));c(this.series,function(a){a.isDirty=!0})},keepProps:"extKey hcEvents names series userMax userMin".split(" "),
destroy:function(a){var b=this,d=b.stacks,g,m=b.plotLinesAndBands,h,k;a||y(b);for(g in d)f(d[g]),d[g]=null;c([b.ticks,b.minorTicks,b.alternateBands],function(a){f(a)});if(m)for(a=m.length;a--;)m[a].destroy();c("stackTotalGroup axisLine axisTitle axisGroup gridGroup labelGroup cross".split(" "),function(a){b[a]&&(b[a]=b[a].destroy())});for(h in b.plotLinesAndBandsGroups)b.plotLinesAndBandsGroups[h]=b.plotLinesAndBandsGroups[h].destroy();for(k in b)b.hasOwnProperty(k)&&-1===B(k,b.keepProps)&&delete b[k]},
drawCrosshair:function(a,b){var d,g=this.crosshair,c=u(g.snap,!0),m,h=this.cross;a||(a=this.cross&&this.cross.e);this.crosshair&&!1!==(q(b)||!c)?(c?q(b)&&(m=this.isXAxis?b.plotX:this.len-b.plotY):m=a&&(this.horiz?a.chartX-this.pos:this.len-a.chartY+this.pos),q(m)&&(d=this.getPlotLinePath(b&&(this.isXAxis?b.x:u(b.stackY,b.y)),null,null,null,m)||null),q(d)?(b=this.categories&&!this.isRadial,h||(this.cross=h=this.chart.renderer.path().addClass("highcharts-crosshair highcharts-crosshair-"+(b?"category ":
"thin ")+g.className).attr({zIndex:u(g.zIndex,2)}).add(),h.attr({stroke:g.color||(b?l("#ccd6eb").setOpacity(.25).get():"#cccccc"),"stroke-width":u(g.width,1)}),g.dashStyle&&h.attr({dashstyle:g.dashStyle})),h.show().attr({d:d}),b&&!g.width&&h.attr({"stroke-width":this.transA}),this.cross.e=a):this.hideCrosshair()):this.hideCrosshair()},hideCrosshair:function(){this.cross&&this.cross.hide()}};e(a.Axis.prototype,v)})(K);(function(a){var D=a.Axis,C=a.Date,G=a.dateFormat,H=a.defaultOptions,v=a.defined,
l=a.each,r=a.extend,w=a.getMagnitude,q=a.getTZOffset,n=a.normalizeTickInterval,f=a.pick,c=a.timeUnits;D.prototype.getTimeTicks=function(a,z,b,t){var h=[],e={},p=H.global.useUTC,x,k=new C(z-Math.abs(q(z))),F=C.hcMakeTime,d=a.unitRange,u=a.count,m;if(v(z)){k[C.hcSetMilliseconds](d>=c.second?0:u*Math.floor(k.getMilliseconds()/u));if(d>=c.second)k[C.hcSetSeconds](d>=c.minute?0:u*Math.floor(k.getSeconds()/u));if(d>=c.minute)k[C.hcSetMinutes](d>=c.hour?0:u*Math.floor(k[C.hcGetMinutes]()/u));if(d>=c.hour)k[C.hcSetHours](d>=
c.day?0:u*Math.floor(k[C.hcGetHours]()/u));if(d>=c.day)k[C.hcSetDate](d>=c.month?1:u*Math.floor(k[C.hcGetDate]()/u));d>=c.month&&(k[C.hcSetMonth](d>=c.year?0:u*Math.floor(k[C.hcGetMonth]()/u)),x=k[C.hcGetFullYear]());if(d>=c.year)k[C.hcSetFullYear](x-x%u);if(d===c.week)k[C.hcSetDate](k[C.hcGetDate]()-k[C.hcGetDay]()+f(t,1));x=k[C.hcGetFullYear]();t=k[C.hcGetMonth]();var y=k[C.hcGetDate](),J=k[C.hcGetHours]();if(C.hcTimezoneOffset||C.hcGetTimezoneOffset)m=(!p||!!C.hcGetTimezoneOffset)&&(b-z>4*c.month||
q(z)!==q(b)),k=k.getTime(),k=new C(k+q(k));p=k.getTime();for(z=1;p<b;)h.push(p),p=d===c.year?F(x+z*u,0):d===c.month?F(x,t+z*u):!m||d!==c.day&&d!==c.week?m&&d===c.hour?F(x,t,y,J+z*u):p+d*u:F(x,t,y+z*u*(d===c.day?1:7)),z++;h.push(p);d<=c.hour&&1E4>h.length&&l(h,function(a){0===a%18E5&&"000000000"===G("%H%M%S%L",a)&&(e[a]="day")})}h.info=r(a,{higherRanks:e,totalRange:d*u});return h};D.prototype.normalizeTimeTickInterval=function(a,f){var b=f||[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",
[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]];f=b[b.length-1];var t=c[f[0]],h=f[1],e;for(e=0;e<b.length&&!(f=b[e],t=c[f[0]],h=f[1],b[e+1]&&a<=(t*h[h.length-1]+c[b[e+1][0]])/2);e++);t===c.year&&a<5*t&&(h=[1,2,5]);a=n(a/t,h,"year"===f[0]?Math.max(w(a/t),1):1);return{unitRange:t,count:a,unitName:f[0]}}})(K);(function(a){var D=a.Axis,C=a.getMagnitude,G=a.map,H=a.normalizeTickInterval,v=a.pick;D.prototype.getLogTickPositions=
function(a,r,w,q){var n=this.options,f=this.len,c=this.lin2log,e=this.log2lin,z=[];q||(this._minorAutoInterval=null);if(.5<=a)a=Math.round(a),z=this.getLinearTickPositions(a,r,w);else if(.08<=a)for(var f=Math.floor(r),b,t,h,B,p,n=.3<a?[1,2,4]:.15<a?[1,2,4,6,8]:[1,2,3,4,5,6,7,8,9];f<w+1&&!p;f++)for(t=n.length,b=0;b<t&&!p;b++)h=e(c(f)*n[b]),h>r&&(!q||B<=w)&&void 0!==B&&z.push(B),B>w&&(p=!0),B=h;else r=c(r),w=c(w),a=n[q?"minorTickInterval":"tickInterval"],a=v("auto"===a?null:a,this._minorAutoInterval,
n.tickPixelInterval/(q?5:1)*(w-r)/((q?f/this.tickPositions.length:f)||1)),a=H(a,null,C(a)),z=G(this.getLinearTickPositions(a,r,w),e),q||(this._minorAutoInterval=a/5);q||(this.tickInterval=a);return z};D.prototype.log2lin=function(a){return Math.log(a)/Math.LN10};D.prototype.lin2log=function(a){return Math.pow(10,a)}})(K);(function(a){var D=a.dateFormat,C=a.each,G=a.extend,H=a.format,v=a.isNumber,l=a.map,r=a.merge,w=a.pick,q=a.splat,n=a.syncTimeout,f=a.timeUnits;a.Tooltip=function(){this.init.apply(this,
arguments)};a.Tooltip.prototype={init:function(a,e){this.chart=a;this.options=e;this.crosshairs=[];this.now={x:0,y:0};this.isHidden=!0;this.split=e.split&&!a.inverted;this.shared=e.shared||this.split},cleanSplit:function(a){C(this.chart.series,function(c){var e=c&&c.tt;e&&(!e.isActive||a?c.tt=e.destroy():e.isActive=!1)})},getLabel:function(){var a=this.chart.renderer,e=this.options;this.label||(this.split?this.label=a.g("tooltip"):(this.label=a.label("",0,0,e.shape||"callout",null,null,e.useHTML,
null,"tooltip").attr({padding:e.padding,r:e.borderRadius}),this.label.attr({fill:e.backgroundColor,"stroke-width":e.borderWidth}).css(e.style).shadow(e.shadow)),this.label.attr({zIndex:8}).add());return this.label},update:function(a){this.destroy();this.init(this.chart,r(!0,this.options,a))},destroy:function(){this.label&&(this.label=this.label.destroy());this.split&&this.tt&&(this.cleanSplit(this.chart,!0),this.tt=this.tt.destroy());clearTimeout(this.hideTimer);clearTimeout(this.tooltipTimeout)},
move:function(a,e,f,b){var c=this,h=c.now,B=!1!==c.options.animation&&!c.isHidden&&(1<Math.abs(a-h.x)||1<Math.abs(e-h.y)),p=c.followPointer||1<c.len;G(h,{x:B?(2*h.x+a)/3:a,y:B?(h.y+e)/2:e,anchorX:p?void 0:B?(2*h.anchorX+f)/3:f,anchorY:p?void 0:B?(h.anchorY+b)/2:b});c.getLabel().attr(h);B&&(clearTimeout(this.tooltipTimeout),this.tooltipTimeout=setTimeout(function(){c&&c.move(a,e,f,b)},32))},hide:function(a){var c=this;clearTimeout(this.hideTimer);a=w(a,this.options.hideDelay,500);this.isHidden||(this.hideTimer=
n(function(){c.getLabel()[a?"fadeOut":"hide"]();c.isHidden=!0},a))},getAnchor:function(a,e){var c,b=this.chart,t=b.inverted,h=b.plotTop,f=b.plotLeft,p=0,x=0,k,F;a=q(a);c=a[0].tooltipPos;this.followPointer&&e&&(void 0===e.chartX&&(e=b.pointer.normalize(e)),c=[e.chartX-b.plotLeft,e.chartY-h]);c||(C(a,function(a){k=a.series.yAxis;F=a.series.xAxis;p+=a.plotX+(!t&&F?F.left-f:0);x+=(a.plotLow?(a.plotLow+a.plotHigh)/2:a.plotY)+(!t&&k?k.top-h:0)}),p/=a.length,x/=a.length,c=[t?b.plotWidth-x:p,this.shared&&
!t&&1<a.length&&e?e.chartY-h:t?b.plotHeight-p:x]);return l(c,Math.round)},getPosition:function(a,e,f){var b=this.chart,c=this.distance,h={},B=f.h||0,p,x=["y",b.chartHeight,e,f.plotY+b.plotTop,b.plotTop,b.plotTop+b.plotHeight],k=["x",b.chartWidth,a,f.plotX+b.plotLeft,b.plotLeft,b.plotLeft+b.plotWidth],F=!this.followPointer&&w(f.ttBelow,!b.inverted===!!f.negative),d=function(a,b,d,g,m,k){var p=d<g-c,y=g+c+d<b,E=g-c-d;g+=c;if(F&&y)h[a]=g;else if(!F&&p)h[a]=E;else if(p)h[a]=Math.min(k-d,0>E-B?E:E-B);
else if(y)h[a]=Math.max(m,g+B+d>b?g:g+B);else return!1},u=function(a,b,d,g){var m;g<c||g>b-c?m=!1:h[a]=g<d/2?1:g>b-d/2?b-d-2:g-d/2;return m},m=function(a){var b=x;x=k;k=b;p=a},y=function(){!1!==d.apply(0,x)?!1!==u.apply(0,k)||p||(m(!0),y()):p?h.x=h.y=0:(m(!0),y())};(b.inverted||1<this.len)&&m();y();return h},defaultFormatter:function(a){var c=this.points||q(this),f;f=[a.tooltipFooterHeaderFormatter(c[0])];f=f.concat(a.bodyFormatter(c));f.push(a.tooltipFooterHeaderFormatter(c[0],!0));return f},refresh:function(a,
e){var c,b=this.options,t,h=a,f,p={},x=[];c=b.formatter||this.defaultFormatter;var p=this.shared,k;clearTimeout(this.hideTimer);this.followPointer=q(h)[0].series.tooltipOptions.followPointer;f=this.getAnchor(h,e);e=f[0];t=f[1];!p||h.series&&h.series.noSharedTooltip?p=h.getLabelConfig():(C(h,function(a){a.setState("hover");x.push(a.getLabelConfig())}),p={x:h[0].category,y:h[0].y},p.points=x,h=h[0]);this.len=x.length;p=c.call(p,this);k=h.series;this.distance=w(k.tooltipOptions.distance,16);!1===p?this.hide():
(c=this.getLabel(),this.isHidden&&c.attr({opacity:1}).show(),this.split?this.renderSplit(p,a):(c.attr({text:p&&p.join?p.join(""):p}),c.removeClass(/highcharts-color-[\d]+/g).addClass("highcharts-color-"+w(h.colorIndex,k.colorIndex)),c.attr({stroke:b.borderColor||h.color||k.color||"#666666"}),this.updatePosition({plotX:e,plotY:t,negative:h.negative,ttBelow:h.ttBelow,h:f[2]||0})),this.isHidden=!1)},renderSplit:function(c,e){var f=this,b=[],t=this.chart,h=t.renderer,B=!0,p=this.options,x,k=this.getLabel();
C(c.slice(0,e.length+1),function(a,d){d=e[d-1]||{isHeader:!0,plotX:e[0].plotX};var c=d.series||f,m=c.tt,y=d.series||{},F="highcharts-color-"+w(d.colorIndex,y.colorIndex,"none");m||(c.tt=m=h.label(null,null,null,"callout").addClass("highcharts-tooltip-box "+F).attr({padding:p.padding,r:p.borderRadius,fill:p.backgroundColor,stroke:d.color||y.color||"#333333","stroke-width":p.borderWidth}).add(k));m.isActive=!0;m.attr({text:a});m.css(p.style);a=m.getBBox();y=a.width+m.strokeWidth();d.isHeader?(x=a.height,
y=Math.max(0,Math.min(d.plotX+t.plotLeft-y/2,t.chartWidth-y))):y=d.plotX+t.plotLeft-w(p.distance,16)-y;0>y&&(B=!1);a=(d.series&&d.series.yAxis&&d.series.yAxis.pos)+(d.plotY||0);a-=t.plotTop;b.push({target:d.isHeader?t.plotHeight+x:a,rank:d.isHeader?1:0,size:c.tt.getBBox().height+1,point:d,x:y,tt:m})});this.cleanSplit();a.distribute(b,t.plotHeight+x);C(b,function(a){var b=a.point,c=b.series;a.tt.attr({visibility:void 0===a.pos?"hidden":"inherit",x:B||b.isHeader?a.x:b.plotX+t.plotLeft+w(p.distance,
16),y:a.pos+t.plotTop,anchorX:b.isHeader?b.plotX+t.plotLeft:b.plotX+c.xAxis.pos,anchorY:b.isHeader?a.pos+t.plotTop-15:b.plotY+c.yAxis.pos})})},updatePosition:function(a){var c=this.chart,f=this.getLabel(),f=(this.options.positioner||this.getPosition).call(this,f.width,f.height,a);this.move(Math.round(f.x),Math.round(f.y||0),a.plotX+c.plotLeft,a.plotY+c.plotTop)},getDateFormat:function(a,e,z,b){var c=D("%m-%d %H:%M:%S.%L",e),h,B,p={millisecond:15,second:12,minute:9,hour:6,day:3},x="millisecond";for(B in f){if(a===
f.week&&+D("%w",e)===z&&"00:00:00.000"===c.substr(6)){B="week";break}if(f[B]>a){B=x;break}if(p[B]&&c.substr(p[B])!=="01-01 00:00:00.000".substr(p[B]))break;"week"!==B&&(x=B)}B&&(h=b[B]);return h},getXDateFormat:function(a,e,f){e=e.dateTimeLabelFormats;var b=f&&f.closestPointRange;return(b?this.getDateFormat(b,a.x,f.options.startOfWeek,e):e.day)||e.year},tooltipFooterHeaderFormatter:function(a,e){var c=e?"footer":"header";e=a.series;var b=e.tooltipOptions,t=b.xDateFormat,h=e.xAxis,f=h&&"datetime"===
h.options.type&&v(a.key),c=b[c+"Format"];f&&!t&&(t=this.getXDateFormat(a,b,h));f&&t&&(c=c.replace("{point.key}","{point.key:"+t+"}"));return H(c,{point:a,series:e})},bodyFormatter:function(a){return l(a,function(a){var c=a.series.tooltipOptions;return(c.pointFormatter||a.point.tooltipFormatter).call(a.point,c.pointFormat)})}}})(K);(function(a){var D=a.addEvent,C=a.attr,G=a.charts,H=a.color,v=a.css,l=a.defined,r=a.doc,w=a.each,q=a.extend,n=a.fireEvent,f=a.offset,c=a.pick,e=a.removeEvent,z=a.splat,
b=a.Tooltip,t=a.win;a.Pointer=function(a,b){this.init(a,b)};a.Pointer.prototype={init:function(a,t){this.options=t;this.chart=a;this.runChartClick=t.chart.events&&!!t.chart.events.click;this.pinchDown=[];this.lastValidTouch={};b&&t.tooltip.enabled&&(a.tooltip=new b(a,t.tooltip),this.followTouchMove=c(t.tooltip.followTouchMove,!0));this.setDOMEvents()},zoomOption:function(a){var b=this.chart,h=b.options.chart,x=h.zoomType||"",b=b.inverted;/touch/.test(a.type)&&(x=c(h.pinchType,x));this.zoomX=a=/x/.test(x);
this.zoomY=x=/y/.test(x);this.zoomHor=a&&!b||x&&b;this.zoomVert=x&&!b||a&&b;this.hasZoom=a||x},normalize:function(a,b){var c,h;a=a||t.event;a.target||(a.target=a.srcElement);h=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a;b||(this.chartPosition=b=f(this.chart.container));void 0===h.pageX?(c=Math.max(a.x,a.clientX-b.left),b=a.y):(c=h.pageX-b.left,b=h.pageY-b.top);return q(a,{chartX:Math.round(c),chartY:Math.round(b)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};w(this.chart.axes,
function(c){b[c.isXAxis?"xAxis":"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})});return b},getKDPoints:function(a,b,p){var h=[],k,t,d;w(a,function(a){k=a.noSharedTooltip&&b;t=!b&&a.directTouch;a.visible&&!t&&c(a.options.enableMouseTracking,!0)&&(d=a.searchPoint(p,!k&&0>a.options.findNearestPointBy.indexOf("y")))&&d.series&&h.push(d)});h.sort(function(a,d){var c=a.distX-d.distX,m=a.dist-d.dist,h=(d.series.group&&d.series.group.zIndex)-(a.series.group&&a.series.group.zIndex);
return 0!==c&&b?c:0!==m?m:0!==h?h:a.series.index>d.series.index?-1:1});if(b&&h[0]&&!h[0].series.noSharedTooltip)for(a=h.length;a--;)(h[a].x!==h[0].x||h[a].series.noSharedTooltip)&&h.splice(a,1);return h},getPointFromEvent:function(a){a=a.target;for(var b;a&&!b;)b=a.point,a=a.parentNode;return b},getHoverData:function(b,t,p,x,k,e){var d=b,h=t,m;x?k?(m=[],w(p,function(a){var b=a.noSharedTooltip&&k,h=!k&&a.directTouch;a.visible&&!b&&!h&&c(a.options.enableMouseTracking,!0)&&(a=a.searchKDTree({clientX:d.clientX,
plotY:d.plotY},!b&&1===a.kdDimensions))&&a.series&&m.push(a)}),0===m.length&&(m=[d])):m=[d]:h&&!h.stickyTracking?(k||(p=[h]),m=this.getKDPoints(p,k,e),d=a.find(m,function(a){return a.series===h})):(b=a.grep(p,function(a){return a.stickyTracking}),m=this.getKDPoints(b,k,e),h=(d=m[0])&&d.series,k&&(m=this.getKDPoints(p,k,e)));m.sort(function(a,b){return a.series.index-b.series.index});return{hoverPoint:d,hoverSeries:h,hoverPoints:m}},runPointActions:function(b,t){var h=this.chart,x=h.tooltip,k=x?x.shared:
!1,e=t||h.hoverPoint,d=e&&e.series||h.hoverSeries;t=this.getHoverData(e,d,h.series,!!t||!k&&d&&d.directTouch,k,b);var f,m,e=t.hoverPoint;f=(d=t.hoverSeries)&&d.tooltipOptions.followPointer;m=(k=k&&e&&!e.series.noSharedTooltip)?t.hoverPoints:e?[e]:[];if(e&&(e!==h.hoverPoint||x&&x.isHidden)){w(h.hoverPoints||[],function(b){-1===a.inArray(b,m)&&b.setState()});w(m||[],function(a){a.setState("hover")});if(h.hoverSeries!==d)d.onMouseOver();d&&!d.directTouch&&(h.hoverPoint&&h.hoverPoint.firePointEvent("mouseOut"),
e.firePointEvent("mouseOver"));h.hoverPoints=m;h.hoverPoint=e;x&&x.refresh(k?m:e,b)}else f&&x&&!x.isHidden&&(e=x.getAnchor([{}],b),x.updatePosition({plotX:e[0],plotY:e[1]}));this.unDocMouseMove||(this.unDocMouseMove=D(r,"mousemove",function(b){var d=G[a.hoverChartIndex];if(d)d.pointer.onDocumentMouseMove(b)}));w(h.axes,function(a){c(a.crosshair.snap,!0)?w(m,function(d){d.series[a.coll]===a&&a.drawCrosshair(b,d)}):a.drawCrosshair(b)})},reset:function(a,b){var c=this.chart,h=c.hoverSeries,k=c.hoverPoint,
t=c.hoverPoints,d=c.tooltip,e=d&&d.shared?t:k;a&&e&&w(z(e),function(b){b.series.isCartesian&&void 0===b.plotX&&(a=!1)});if(a)d&&e&&(d.refresh(e),k&&(k.setState(k.state,!0),w(c.axes,function(a){a.crosshair&&a.drawCrosshair(null,k)})));else{if(k)k.onMouseOut();t&&w(t,function(a){a.setState()});if(h)h.onMouseOut();d&&d.hide(b);this.unDocMouseMove&&(this.unDocMouseMove=this.unDocMouseMove());w(c.axes,function(a){a.hideCrosshair()});this.hoverX=c.hoverPoints=c.hoverPoint=null}},scaleGroups:function(a,
b){var c=this.chart,h;w(c.series,function(k){h=a||k.getPlotBox();k.xAxis&&k.xAxis.zoomEnabled&&k.group&&(k.group.attr(h),k.markerGroup&&(k.markerGroup.attr(h),k.markerGroup.clip(b?c.clipRect:null)),k.dataLabelsGroup&&k.dataLabelsGroup.attr(h))});c.clipRect.attr(b||c.clipBox)},dragStart:function(a){var b=this.chart;b.mouseIsDown=a.type;b.cancelClick=!1;b.mouseDownX=this.mouseDownX=a.chartX;b.mouseDownY=this.mouseDownY=a.chartY},drag:function(a){var b=this.chart,c=b.options.chart,h=a.chartX,k=a.chartY,
t=this.zoomHor,d=this.zoomVert,e=b.plotLeft,m=b.plotTop,y=b.plotWidth,f=b.plotHeight,E,I=this.selectionMarker,g=this.mouseDownX,n=this.mouseDownY,z=c.panKey&&a[c.panKey+"Key"];I&&I.touch||(h<e?h=e:h>e+y&&(h=e+y),k<m?k=m:k>m+f&&(k=m+f),this.hasDragged=Math.sqrt(Math.pow(g-h,2)+Math.pow(n-k,2)),10<this.hasDragged&&(E=b.isInsidePlot(g-e,n-m),b.hasCartesianSeries&&(this.zoomX||this.zoomY)&&E&&!z&&!I&&(this.selectionMarker=I=b.renderer.rect(e,m,t?1:y,d?1:f,0).attr({fill:c.selectionMarkerFill||H("#335cad").setOpacity(.25).get(),
"class":"highcharts-selection-marker",zIndex:7}).add()),I&&t&&(h-=g,I.attr({width:Math.abs(h),x:(0<h?0:h)+g})),I&&d&&(h=k-n,I.attr({height:Math.abs(h),y:(0<h?0:h)+n})),E&&!I&&c.panning&&b.pan(a,c.panning)))},drop:function(a){var b=this,c=this.chart,h=this.hasPinched;if(this.selectionMarker){var k={originalEvent:a,xAxis:[],yAxis:[]},t=this.selectionMarker,d=t.attr?t.attr("x"):t.x,e=t.attr?t.attr("y"):t.y,m=t.attr?t.attr("width"):t.width,y=t.attr?t.attr("height"):t.height,f;if(this.hasDragged||h)w(c.axes,
function(c){if(c.zoomEnabled&&l(c.min)&&(h||b[{xAxis:"zoomX",yAxis:"zoomY"}[c.coll]])){var p=c.horiz,g="touchend"===a.type?c.minPixelPadding:0,t=c.toValue((p?d:e)+g),p=c.toValue((p?d+m:e+y)-g);k[c.coll].push({axis:c,min:Math.min(t,p),max:Math.max(t,p)});f=!0}}),f&&n(c,"selection",k,function(a){c.zoom(q(a,h?{animation:!1}:null))});this.selectionMarker=this.selectionMarker.destroy();h&&this.scaleGroups()}c&&(v(c.container,{cursor:c._cursor}),c.cancelClick=10<this.hasDragged,c.mouseIsDown=this.hasDragged=
this.hasPinched=!1,this.pinchDown=[])},onContainerMouseDown:function(a){a=this.normalize(a);this.zoomOption(a);a.preventDefault&&a.preventDefault();this.dragStart(a)},onDocumentMouseUp:function(b){G[a.hoverChartIndex]&&G[a.hoverChartIndex].pointer.drop(b)},onDocumentMouseMove:function(a){var b=this.chart,c=this.chartPosition;a=this.normalize(a,c);!c||this.inClass(a.target,"highcharts-tracker")||b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)||this.reset()},onContainerMouseLeave:function(b){var c=
G[a.hoverChartIndex];c&&(b.relatedTarget||b.toElement)&&(c.pointer.reset(),c.pointer.chartPosition=null)},onContainerMouseMove:function(b){var c=this.chart;l(a.hoverChartIndex)&&G[a.hoverChartIndex]&&G[a.hoverChartIndex].mouseIsDown||(a.hoverChartIndex=c.index);b=this.normalize(b);b.returnValue=!1;"mousedown"===c.mouseIsDown&&this.drag(b);!this.inClass(b.target,"highcharts-tracker")&&!c.isInsidePlot(b.chartX-c.plotLeft,b.chartY-c.plotTop)||c.openMenu||this.runPointActions(b)},inClass:function(a,b){for(var c;a;){if(c=
C(a,"class")){if(-1!==c.indexOf(b))return!0;if(-1!==c.indexOf("highcharts-container"))return!1}a=a.parentNode}},onTrackerMouseOut:function(a){var b=this.chart.hoverSeries;a=a.relatedTarget||a.toElement;if(!(!b||!a||b.stickyTracking||this.inClass(a,"highcharts-tooltip")||this.inClass(a,"highcharts-series-"+b.index)&&this.inClass(a,"highcharts-tracker")))b.onMouseOut()},onContainerClick:function(a){var b=this.chart,c=b.hoverPoint,h=b.plotLeft,k=b.plotTop;a=this.normalize(a);b.cancelClick||(c&&this.inClass(a.target,
"highcharts-tracker")?(n(c.series,"click",q(a,{point:c})),b.hoverPoint&&c.firePointEvent("click",a)):(q(a,this.getCoordinates(a)),b.isInsidePlot(a.chartX-h,a.chartY-k)&&n(b,"click",a)))},setDOMEvents:function(){var b=this,c=b.chart.container;c.onmousedown=function(a){b.onContainerMouseDown(a)};c.onmousemove=function(a){b.onContainerMouseMove(a)};c.onclick=function(a){b.onContainerClick(a)};D(c,"mouseleave",b.onContainerMouseLeave);1===a.chartCount&&D(r,"mouseup",b.onDocumentMouseUp);a.hasTouch&&(c.ontouchstart=
function(a){b.onContainerTouchStart(a)},c.ontouchmove=function(a){b.onContainerTouchMove(a)},1===a.chartCount&&D(r,"touchend",b.onDocumentTouchEnd))},destroy:function(){var b;this.unDocMouseMove&&this.unDocMouseMove();e(this.chart.container,"mouseleave",this.onContainerMouseLeave);a.chartCount||(e(r,"mouseup",this.onDocumentMouseUp),e(r,"touchend",this.onDocumentTouchEnd));clearInterval(this.tooltipTimeout);for(b in this)this[b]=null}}})(K);(function(a){var D=a.charts,C=a.each,G=a.extend,H=a.map,
v=a.noop,l=a.pick;G(a.Pointer.prototype,{pinchTranslate:function(a,l,q,n,f,c){this.zoomHor&&this.pinchTranslateDirection(!0,a,l,q,n,f,c);this.zoomVert&&this.pinchTranslateDirection(!1,a,l,q,n,f,c)},pinchTranslateDirection:function(a,l,q,n,f,c,e,z){var b=this.chart,t=a?"x":"y",h=a?"X":"Y",B="chart"+h,p=a?"width":"height",x=b["plot"+(a?"Left":"Top")],k,F,d=z||1,u=b.inverted,m=b.bounds[a?"h":"v"],y=1===l.length,J=l[0][B],E=q[0][B],I=!y&&l[1][B],g=!y&&q[1][B],r;q=function(){!y&&20<Math.abs(J-I)&&(d=z||
Math.abs(E-g)/Math.abs(J-I));F=(x-E)/d+J;k=b["plot"+(a?"Width":"Height")]/d};q();l=F;l<m.min?(l=m.min,r=!0):l+k>m.max&&(l=m.max-k,r=!0);r?(E-=.8*(E-e[t][0]),y||(g-=.8*(g-e[t][1])),q()):e[t]=[E,g];u||(c[t]=F-x,c[p]=k);c=u?1/d:d;f[p]=k;f[t]=l;n[u?a?"scaleY":"scaleX":"scale"+h]=d;n["translate"+h]=c*x+(E-c*J)},pinch:function(a){var r=this,q=r.chart,n=r.pinchDown,f=a.touches,c=f.length,e=r.lastValidTouch,z=r.hasZoom,b=r.selectionMarker,t={},h=1===c&&(r.inClass(a.target,"highcharts-tracker")&&q.runTrackerClick||
r.runChartClick),B={};1<c&&(r.initiated=!0);z&&r.initiated&&!h&&a.preventDefault();H(f,function(a){return r.normalize(a)});"touchstart"===a.type?(C(f,function(a,b){n[b]={chartX:a.chartX,chartY:a.chartY}}),e.x=[n[0].chartX,n[1]&&n[1].chartX],e.y=[n[0].chartY,n[1]&&n[1].chartY],C(q.axes,function(a){if(a.zoomEnabled){var b=q.bounds[a.horiz?"h":"v"],c=a.minPixelPadding,h=a.toPixels(l(a.options.min,a.dataMin)),d=a.toPixels(l(a.options.max,a.dataMax)),t=Math.max(h,d);b.min=Math.min(a.pos,Math.min(h,d)-
c);b.max=Math.max(a.pos+a.len,t+c)}}),r.res=!0):r.followTouchMove&&1===c?this.runPointActions(r.normalize(a)):n.length&&(b||(r.selectionMarker=b=G({destroy:v,touch:!0},q.plotBox)),r.pinchTranslate(n,f,t,b,B,e),r.hasPinched=z,r.scaleGroups(t,B),r.res&&(r.res=!1,this.reset(!1,0)))},touch:function(r,v){var q=this.chart,n,f;if(q.index!==a.hoverChartIndex)this.onContainerMouseLeave({relatedTarget:!0});a.hoverChartIndex=q.index;1===r.touches.length?(r=this.normalize(r),(f=q.isInsidePlot(r.chartX-q.plotLeft,
r.chartY-q.plotTop))&&!q.openMenu?(v&&this.runPointActions(r),"touchmove"===r.type&&(v=this.pinchDown,n=v[0]?4<=Math.sqrt(Math.pow(v[0].chartX-r.chartX,2)+Math.pow(v[0].chartY-r.chartY,2)):!1),l(n,!0)&&this.pinch(r)):v&&this.reset()):2===r.touches.length&&this.pinch(r)},onContainerTouchStart:function(a){this.zoomOption(a);this.touch(a,!0)},onContainerTouchMove:function(a){this.touch(a)},onDocumentTouchEnd:function(l){D[a.hoverChartIndex]&&D[a.hoverChartIndex].pointer.drop(l)}})})(K);(function(a){var D=
a.addEvent,C=a.charts,G=a.css,H=a.doc,v=a.extend,l=a.noop,r=a.Pointer,w=a.removeEvent,q=a.win,n=a.wrap;if(q.PointerEvent||q.MSPointerEvent){var f={},c=!!q.PointerEvent,e=function(){var a,c=[];c.item=function(a){return this[a]};for(a in f)f.hasOwnProperty(a)&&c.push({pageX:f[a].pageX,pageY:f[a].pageY,target:f[a].target});return c},z=function(b,c,h,f){"touch"!==b.pointerType&&b.pointerType!==b.MSPOINTER_TYPE_TOUCH||!C[a.hoverChartIndex]||(f(b),f=C[a.hoverChartIndex].pointer,f[c]({type:h,target:b.currentTarget,
preventDefault:l,touches:e()}))};v(r.prototype,{onContainerPointerDown:function(a){z(a,"onContainerTouchStart","touchstart",function(a){f[a.pointerId]={pageX:a.pageX,pageY:a.pageY,target:a.currentTarget}})},onContainerPointerMove:function(a){z(a,"onContainerTouchMove","touchmove",function(a){f[a.pointerId]={pageX:a.pageX,pageY:a.pageY};f[a.pointerId].target||(f[a.pointerId].target=a.currentTarget)})},onDocumentPointerUp:function(a){z(a,"onDocumentTouchEnd","touchend",function(a){delete f[a.pointerId]})},
batchMSEvents:function(a){a(this.chart.container,c?"pointerdown":"MSPointerDown",this.onContainerPointerDown);a(this.chart.container,c?"pointermove":"MSPointerMove",this.onContainerPointerMove);a(H,c?"pointerup":"MSPointerUp",this.onDocumentPointerUp)}});n(r.prototype,"init",function(a,c,h){a.call(this,c,h);this.hasZoom&&G(c.container,{"-ms-touch-action":"none","touch-action":"none"})});n(r.prototype,"setDOMEvents",function(a){a.apply(this);(this.hasZoom||this.followTouchMove)&&this.batchMSEvents(D)});
n(r.prototype,"destroy",function(a){this.batchMSEvents(w);a.call(this)})}})(K);(function(a){var D,C=a.addEvent,G=a.css,H=a.discardElement,v=a.defined,l=a.each,r=a.isFirefox,w=a.marginNames,q=a.merge,n=a.pick,f=a.setAnimation,c=a.stableSort,e=a.win,z=a.wrap;D=a.Legend=function(a,c){this.init(a,c)};D.prototype={init:function(a,c){this.chart=a;this.setOptions(c);c.enabled&&(this.render(),C(this.chart,"endResize",function(){this.legend.positionCheckboxes()}))},setOptions:function(a){var b=n(a.padding,
8);this.options=a;this.itemStyle=a.itemStyle;this.itemHiddenStyle=q(this.itemStyle,a.itemHiddenStyle);this.itemMarginTop=a.itemMarginTop||0;this.padding=b;this.initialItemY=b-5;this.itemHeight=this.maxItemWidth=0;this.symbolWidth=n(a.symbolWidth,16);this.pages=[]},update:function(a,c){var b=this.chart;this.setOptions(q(!0,this.options,a));this.destroy();b.isDirtyLegend=b.isDirtyBox=!0;n(c,!0)&&b.redraw()},colorizeItem:function(a,c){a.legendGroup[c?"removeClass":"addClass"]("highcharts-legend-item-hidden");
var b=this.options,e=a.legendItem,p=a.legendLine,t=a.legendSymbol,k=this.itemHiddenStyle.color,b=c?b.itemStyle.color:k,f=c?a.color||k:k,d=a.options&&a.options.marker,u={fill:f},m;e&&e.css({fill:b,color:b});p&&p.attr({stroke:f});if(t){if(d&&t.isMarker&&(u=a.pointAttribs(),!c))for(m in u)u[m]=k;t.attr(u)}},positionItem:function(a){var b=this.options,c=b.symbolPadding,b=!b.rtl,e=a._legendItemPos,p=e[0],e=e[1],f=a.checkbox;(a=a.legendGroup)&&a.element&&a.translate(b?p:this.legendWidth-p-2*c-4,e);f&&(f.x=
p,f.y=e)},destroyItem:function(a){var b=a.checkbox;l(["legendItem","legendLine","legendSymbol","legendGroup"],function(b){a[b]&&(a[b]=a[b].destroy())});b&&H(a.checkbox)},destroy:function(){function a(a){this[a]&&(this[a]=this[a].destroy())}l(this.getAllItems(),function(b){l(["legendItem","legendGroup"],a,b)});l("clipRect up down pager nav box title group".split(" "),a,this);this.display=null},positionCheckboxes:function(a){var b=this.group&&this.group.alignAttr,c,e=this.clipHeight||this.legendHeight,
p=this.titleHeight;b&&(c=b.translateY,l(this.allItems,function(h){var k=h.checkbox,t;k&&(t=c+p+k.y+(a||0)+3,G(k,{left:b.translateX+h.checkboxOffset+k.x-20+"px",top:t+"px",display:t>c-6&&t<c+e-6?"":"none"}))}))},renderTitle:function(){var a=this.padding,c=this.options.title,h=0;c.text&&(this.title||(this.title=this.chart.renderer.label(c.text,a-3,a-4,null,null,null,null,null,"legend-title").attr({zIndex:1}).css(c.style).add(this.group)),a=this.title.getBBox(),h=a.height,this.offsetWidth=a.width,this.contentGroup.attr({translateY:h}));
this.titleHeight=h},setText:function(b){var c=this.options;b.legendItem.attr({text:c.labelFormat?a.format(c.labelFormat,b):c.labelFormatter.call(b)})},renderItem:function(a){var b=this.chart,c=b.renderer,e=this.options,p="horizontal"===e.layout,f=this.symbolWidth,k=e.symbolPadding,l=this.itemStyle,d=this.itemHiddenStyle,u=this.padding,m=p?n(e.itemDistance,20):0,y=!e.rtl,J=e.width,E=e.itemMarginBottom||0,I=this.itemMarginTop,g=a.legendItem,z=!a.series,r=!z&&a.series.drawLegendSymbol?a.series:a,v=r.options,
v=this.createCheckboxForItem&&v&&v.showCheckbox,w=e.useHTML,P=a.options.className;g||(a.legendGroup=c.g("legend-item").addClass("highcharts-"+r.type+"-series highcharts-color-"+a.colorIndex+(P?" "+P:"")+(z?" highcharts-series-"+a.index:"")).attr({zIndex:1}).add(this.scrollGroup),a.legendItem=g=c.text("",y?f+k:-k,this.baseline||0,w).css(q(a.visible?l:d)).attr({align:y?"left":"right",zIndex:2}).add(a.legendGroup),this.baseline||(l=l.fontSize,this.fontMetrics=c.fontMetrics(l,g),this.baseline=this.fontMetrics.f+
3+I,g.attr("y",this.baseline)),this.symbolHeight=e.symbolHeight||this.fontMetrics.f,r.drawLegendSymbol(this,a),this.setItemEvents&&this.setItemEvents(a,g,w),v&&this.createCheckboxForItem(a));this.colorizeItem(a,a.visible);this.setText(a);c=g.getBBox();f=a.checkboxOffset=e.itemWidth||a.legendItemWidth||f+k+c.width+m+(v?20:0);this.itemHeight=k=Math.round(a.legendItemHeight||c.height||this.symbolHeight);p&&this.itemX-u+f>(J||b.spacingBox.width-2*u-e.x)&&(this.itemX=u,this.itemY+=I+this.lastLineHeight+
E,this.lastLineHeight=0);this.maxItemWidth=Math.max(this.maxItemWidth,f);this.lastItemY=I+this.itemY+E;this.lastLineHeight=Math.max(k,this.lastLineHeight);a._legendItemPos=[this.itemX,this.itemY];p?this.itemX+=f:(this.itemY+=I+k+E,this.lastLineHeight=k);this.offsetWidth=J||Math.max((p?this.itemX-u-m:f)+u,this.offsetWidth)},getAllItems:function(){var a=[];l(this.chart.series,function(b){var c=b&&b.options;b&&n(c.showInLegend,v(c.linkedTo)?!1:void 0,!0)&&(a=a.concat(b.legendItems||("point"===c.legendType?
b.data:b)))});return a},adjustMargins:function(a,c){var b=this.chart,e=this.options,p=e.align.charAt(0)+e.verticalAlign.charAt(0)+e.layout.charAt(0);e.floating||l([/(lth|ct|rth)/,/(rtv|rm|rbv)/,/(rbh|cb|lbh)/,/(lbv|lm|ltv)/],function(h,k){h.test(p)&&!v(a[k])&&(b[w[k]]=Math.max(b[w[k]],b.legend[(k+1)%2?"legendHeight":"legendWidth"]+[1,-1,-1,1][k]*e[k%2?"x":"y"]+n(e.margin,12)+c[k]))})},render:function(){var a=this,e=a.chart,h=e.renderer,f=a.group,p,x,k,n,d=a.box,u=a.options,m=a.padding;a.itemX=m;a.itemY=
a.initialItemY;a.offsetWidth=0;a.lastItemY=0;f||(a.group=f=h.g("legend").attr({zIndex:7}).add(),a.contentGroup=h.g().attr({zIndex:1}).add(f),a.scrollGroup=h.g().add(a.contentGroup));a.renderTitle();p=a.getAllItems();c(p,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)});u.reversed&&p.reverse();a.allItems=p;a.display=x=!!p.length;a.lastLineHeight=0;l(p,function(b){a.renderItem(b)});k=(u.width||a.offsetWidth)+m;n=a.lastItemY+a.lastLineHeight+a.titleHeight;
n=a.handleOverflow(n);n+=m;d||(a.box=d=h.rect().addClass("highcharts-legend-box").attr({r:u.borderRadius}).add(f),d.isNew=!0);d.attr({stroke:u.borderColor,"stroke-width":u.borderWidth||0,fill:u.backgroundColor||"none"}).shadow(u.shadow);0<k&&0<n&&(d[d.isNew?"attr":"animate"](d.crisp({x:0,y:0,width:k,height:n},d.strokeWidth())),d.isNew=!1);d[x?"show":"hide"]();a.legendWidth=k;a.legendHeight=n;l(p,function(b){a.positionItem(b)});x&&f.align(q(u,{width:k,height:n}),!0,"spacingBox");e.isResizing||this.positionCheckboxes()},
handleOverflow:function(a){var b=this,c=this.chart,e=c.renderer,p=this.options,f=p.y,k=this.padding,c=c.spacingBox.height+("top"===p.verticalAlign?-f:f)-k,f=p.maxHeight,z,d=this.clipRect,u=p.navigation,m=n(u.animation,!0),y=u.arrowSize||12,J=this.nav,E=this.pages,I,g=this.allItems,q=function(a){a?d.attr({height:a}):d&&(b.clipRect=d.destroy(),b.contentGroup.clip());b.contentGroup.div&&(b.contentGroup.div.style.clip=a?"rect("+k+"px,9999px,"+(k+a)+"px,0)":"auto")};"horizontal"!==p.layout||"middle"===
p.verticalAlign||p.floating||(c/=2);f&&(c=Math.min(c,f));E.length=0;a>c&&!1!==u.enabled?(this.clipHeight=z=Math.max(c-20-this.titleHeight-k,0),this.currentPage=n(this.currentPage,1),this.fullHeight=a,l(g,function(a,b){var c=a._legendItemPos[1];a=Math.round(a.legendItem.getBBox().height);var d=E.length;if(!d||c-E[d-1]>z&&(I||c)!==E[d-1])E.push(I||c),d++;b===g.length-1&&c+a-E[d-1]>z&&E.push(c);c!==I&&(I=c)}),d||(d=b.clipRect=e.clipRect(0,k,9999,0),b.contentGroup.clip(d)),q(z),J||(this.nav=J=e.g().attr({zIndex:1}).add(this.group),
this.up=e.symbol("triangle",0,0,y,y).on("click",function(){b.scroll(-1,m)}).add(J),this.pager=e.text("",15,10).addClass("highcharts-legend-navigation").css(u.style).add(J),this.down=e.symbol("triangle-down",0,0,y,y).on("click",function(){b.scroll(1,m)}).add(J)),b.scroll(0),a=c):J&&(q(),this.nav=J.destroy(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0);return a},scroll:function(a,c){var b=this.pages,e=b.length;a=this.currentPage+a;var p=this.clipHeight,t=this.options.navigation,k=this.pager,
n=this.padding;a>e&&(a=e);0<a&&(void 0!==c&&f(c,this.chart),this.nav.attr({translateX:n,translateY:p+this.padding+7+this.titleHeight,visibility:"visible"}),this.up.attr({"class":1===a?"highcharts-legend-nav-inactive":"highcharts-legend-nav-active"}),k.attr({text:a+"/"+e}),this.down.attr({x:18+this.pager.getBBox().width,"class":a===e?"highcharts-legend-nav-inactive":"highcharts-legend-nav-active"}),this.up.attr({fill:1===a?t.inactiveColor:t.activeColor}).css({cursor:1===a?"default":"pointer"}),this.down.attr({fill:a===
e?t.inactiveColor:t.activeColor}).css({cursor:a===e?"default":"pointer"}),c=-b[a-1]+this.initialItemY,this.scrollGroup.animate({translateY:c}),this.currentPage=a,this.positionCheckboxes(c))}};a.LegendSymbolMixin={drawRectangle:function(a,c){var b=a.symbolHeight,e=a.options.squareSymbol;c.legendSymbol=this.chart.renderer.rect(e?(a.symbolWidth-b)/2:0,a.baseline-b+1,e?b:a.symbolWidth,b,n(a.options.symbolRadius,b/2)).addClass("highcharts-point").attr({zIndex:3}).add(c.legendGroup)},drawLineMarker:function(a){var b=
this.options,c=b.marker,e=a.symbolWidth,p=a.symbolHeight,f=p/2,k=this.chart.renderer,l=this.legendGroup;a=a.baseline-Math.round(.3*a.fontMetrics.b);var d;d={"stroke-width":b.lineWidth||0};b.dashStyle&&(d.dashstyle=b.dashStyle);this.legendLine=k.path(["M",0,a,"L",e,a]).addClass("highcharts-graph").attr(d).add(l);c&&!1!==c.enabled&&(b=Math.min(n(c.radius,f),f),0===this.symbol.indexOf("url")&&(c=q(c,{width:p,height:p}),b=0),this.legendSymbol=c=k.symbol(this.symbol,e/2-b,a-b,2*b,2*b,c).addClass("highcharts-point").add(l),
c.isMarker=!0)}};(/Trident\/7\.0/.test(e.navigator.userAgent)||r)&&z(D.prototype,"positionItem",function(a,c){var b=this,e=function(){c._legendItemPos&&a.call(b,c)};e();setTimeout(e)})})(K);(function(a){var D=a.addEvent,C=a.animate,G=a.animObject,H=a.attr,v=a.doc,l=a.Axis,r=a.createElement,w=a.defaultOptions,q=a.discardElement,n=a.charts,f=a.css,c=a.defined,e=a.each,z=a.extend,b=a.find,t=a.fireEvent,h=a.getStyle,B=a.grep,p=a.isNumber,x=a.isObject,k=a.isString,F=a.Legend,d=a.marginNames,u=a.merge,
m=a.Pointer,y=a.pick,J=a.pInt,E=a.removeEvent,I=a.seriesTypes,g=a.splat,L=a.svg,R=a.syncTimeout,O=a.win,M=a.Renderer,P=a.Chart=function(){this.getArgs.apply(this,arguments)};a.chart=function(a,b,c){return new P(a,b,c)};P.prototype={callbacks:[],getArgs:function(){var a=[].slice.call(arguments);if(k(a[0])||a[0].nodeName)this.renderTo=a.shift();this.init(a[0],a[1])},init:function(b,c){var d,g=b.series;b.series=null;d=u(w,b);d.series=b.series=g;this.userOptions=b;b=d.chart;g=b.events;this.margin=[];
this.spacing=[];this.bounds={h:{},v:{}};this.callback=c;this.isResizing=0;this.options=d;this.axes=[];this.series=[];this.hasCartesianSeries=b.showAxes;var m;this.index=n.length;n.push(this);a.chartCount++;if(g)for(m in g)D(this,m,g[m]);this.xAxis=[];this.yAxis=[];this.pointCount=this.colorCounter=this.symbolCounter=0;this.firstRender()},initSeries:function(b){var c=this.options.chart;(c=I[b.type||c.type||c.defaultSeriesType])||a.error(17,!0);c=new c;c.init(this,b);return c},orderSeries:function(a){var b=
this.series;for(a=a||0;a<b.length;a++)b[a]&&(b[a].index=a,b[a].name=b[a].name||"Series "+(b[a].index+1))},isInsidePlot:function(a,b,c){var d=c?b:a;a=c?a:b;return 0<=d&&d<=this.plotWidth&&0<=a&&a<=this.plotHeight},redraw:function(b){var c=this.axes,d=this.series,g=this.pointer,m=this.legend,k=this.isDirtyLegend,h,y,p=this.hasCartesianSeries,f=this.isDirtyBox,E,x=this.renderer,u=x.isHidden(),I=[];this.setResponsive&&this.setResponsive(!1);a.setAnimation(b,this);u&&this.cloneRenderTo();this.layOutTitles();
for(b=d.length;b--;)if(E=d[b],E.options.stacking&&(h=!0,E.isDirty)){y=!0;break}if(y)for(b=d.length;b--;)E=d[b],E.options.stacking&&(E.isDirty=!0);e(d,function(a){a.isDirty&&"point"===a.options.legendType&&(a.updateTotals&&a.updateTotals(),k=!0);a.isDirtyData&&t(a,"updatedData")});k&&m.options.enabled&&(m.render(),this.isDirtyLegend=!1);h&&this.getStacks();p&&e(c,function(a){a.updateNames();a.setScale()});this.getMargins();p&&(e(c,function(a){a.isDirty&&(f=!0)}),e(c,function(a){var b=a.min+","+a.max;
a.extKey!==b&&(a.extKey=b,I.push(function(){t(a,"afterSetExtremes",z(a.eventArgs,a.getExtremes()));delete a.eventArgs}));(f||h)&&a.redraw()}));f&&this.drawChartBox();t(this,"predraw");e(d,function(a){(f||a.isDirty)&&a.visible&&a.redraw();a.isDirtyData=!1});g&&g.reset(!0);x.draw();t(this,"redraw");t(this,"render");u&&this.cloneRenderTo(!0);e(I,function(a){a.call()})},get:function(a){function c(b){return b.id===a||b.options&&b.options.id===a}var d,g=this.series,m;d=b(this.axes,c)||b(this.series,c);
for(m=0;!d&&m<g.length;m++)d=b(g[m].points||[],c);return d},getAxes:function(){var a=this,b=this.options,c=b.xAxis=g(b.xAxis||{}),b=b.yAxis=g(b.yAxis||{});e(c,function(a,b){a.index=b;a.isX=!0});e(b,function(a,b){a.index=b});c=c.concat(b);e(c,function(b){new l(a,b)})},getSelectedPoints:function(){var a=[];e(this.series,function(b){a=a.concat(B(b.points||[],function(a){return a.selected}))});return a},getSelectedSeries:function(){return B(this.series,function(a){return a.selected})},setTitle:function(a,
b,c){var d=this,g=d.options,m;m=g.title=u({style:{color:"#333333",fontSize:g.isStock?"16px":"18px"}},g.title,a);g=g.subtitle=u({style:{color:"#666666"}},g.subtitle,b);e([["title",a,m],["subtitle",b,g]],function(a,b){var c=a[0],g=d[c],m=a[1];a=a[2];g&&m&&(d[c]=g=g.destroy());a&&a.text&&!g&&(d[c]=d.renderer.text(a.text,0,0,a.useHTML).attr({align:a.align,"class":"highcharts-"+c,zIndex:a.zIndex||4}).add(),d[c].update=function(a){d.setTitle(!b&&a,b&&a)},d[c].css(a.style))});d.layOutTitles(c)},layOutTitles:function(a){var b=
0,c,d=this.renderer,g=this.spacingBox;e(["title","subtitle"],function(a){var c=this[a],m=this.options[a],k;c&&(k=m.style.fontSize,k=d.fontMetrics(k,c).b,c.css({width:(m.width||g.width+m.widthAdjust)+"px"}).align(z({y:b+k+("title"===a?-3:2)},m),!1,"spacingBox"),m.floating||m.verticalAlign||(b=Math.ceil(b+c.getBBox(m.useHTML).height)))},this);c=this.titleOffset!==b;this.titleOffset=b;!this.isDirtyBox&&c&&(this.isDirtyBox=c,this.hasRendered&&y(a,!0)&&this.isDirtyBox&&this.redraw())},getChartSize:function(){var b=
this.options.chart,d=b.width,b=b.height,g=this.renderToClone||this.renderTo;c(d)||(this.containerWidth=h(g,"width"));c(b)||(this.containerHeight=h(g,"height"));this.chartWidth=Math.max(0,d||this.containerWidth||600);this.chartHeight=Math.max(0,a.relativeLength(b,this.chartWidth)||this.containerHeight||400)},cloneRenderTo:function(a){var b=this.renderToClone,c=this.container;if(a){if(b){for(;b.childNodes.length;)this.renderTo.appendChild(b.firstChild);q(b);delete this.renderToClone}}else c&&c.parentNode===
this.renderTo&&this.renderTo.removeChild(c),this.renderToClone=b=this.renderTo.cloneNode(0),f(b,{position:"absolute",top:"-9999px",display:"block"}),b.style.setProperty&&b.style.setProperty("display","block","important"),v.body.appendChild(b),c&&b.appendChild(c)},setClassName:function(a){this.container.className="highcharts-container "+(a||"")},getContainer:function(){var b,c=this.options,d=c.chart,g,m;b=this.renderTo;var h=a.uniqueKey(),y;b||(this.renderTo=b=d.renderTo);k(b)&&(this.renderTo=b=v.getElementById(b));
b||a.error(13,!0);g=J(H(b,"data-highcharts-chart"));p(g)&&n[g]&&n[g].hasRendered&&n[g].destroy();H(b,"data-highcharts-chart",this.index);b.innerHTML="";d.skipClone||b.offsetWidth||this.cloneRenderTo();this.getChartSize();g=this.chartWidth;m=this.chartHeight;y=z({position:"relative",overflow:"hidden",width:g+"px",height:m+"px",textAlign:"left",lineHeight:"normal",zIndex:0,"-webkit-tap-highlight-color":"rgba(0,0,0,0)"},d.style);this.container=b=r("div",{id:h},y,this.renderToClone||b);this._cursor=b.style.cursor;
this.renderer=new (a[d.renderer]||M)(b,g,m,null,d.forExport,c.exporting&&c.exporting.allowHTML);this.setClassName(d.className);this.renderer.setStyle(d.style);this.renderer.chartIndex=this.index},getMargins:function(a){var b=this.spacing,d=this.margin,g=this.titleOffset;this.resetMargins();g&&!c(d[0])&&(this.plotTop=Math.max(this.plotTop,g+this.options.title.margin+b[0]));this.legend.display&&this.legend.adjustMargins(d,b);this.extraMargin&&(this[this.extraMargin.type]=(this[this.extraMargin.type]||
0)+this.extraMargin.value);this.extraTopMargin&&(this.plotTop+=this.extraTopMargin);a||this.getAxisMargins()},getAxisMargins:function(){var a=this,b=a.axisOffset=[0,0,0,0],g=a.margin;a.hasCartesianSeries&&e(a.axes,function(a){a.visible&&a.getOffset()});e(d,function(d,m){c(g[m])||(a[d]+=b[m])});a.setChartSize()},reflow:function(a){var b=this,d=b.options.chart,g=b.renderTo,m=c(d.width),k=d.width||h(g,"width"),d=d.height||h(g,"height"),g=a?a.target:O;if(!m&&!b.isPrinting&&k&&d&&(g===O||g===v)){if(k!==
b.containerWidth||d!==b.containerHeight)clearTimeout(b.reflowTimeout),b.reflowTimeout=R(function(){b.container&&b.setSize(void 0,void 0,!1)},a?100:0);b.containerWidth=k;b.containerHeight=d}},initReflow:function(){var a=this,b;b=D(O,"resize",function(b){a.reflow(b)});D(a,"destroy",b)},setSize:function(b,c,d){var g=this,m=g.renderer;g.isResizing+=1;a.setAnimation(d,g);g.oldChartHeight=g.chartHeight;g.oldChartWidth=g.chartWidth;void 0!==b&&(g.options.chart.width=b);void 0!==c&&(g.options.chart.height=
c);g.getChartSize();b=m.globalAnimation;(b?C:f)(g.container,{width:g.chartWidth+"px",height:g.chartHeight+"px"},b);g.setChartSize(!0);m.setSize(g.chartWidth,g.chartHeight,d);e(g.axes,function(a){a.isDirty=!0;a.setScale()});g.isDirtyLegend=!0;g.isDirtyBox=!0;g.layOutTitles();g.getMargins();g.redraw(d);g.oldChartHeight=null;t(g,"resize");R(function(){g&&t(g,"endResize",null,function(){--g.isResizing})},G(b).duration)},setChartSize:function(a){var b=this.inverted,c=this.renderer,d=this.chartWidth,g=
this.chartHeight,m=this.options.chart,k=this.spacing,h=this.clipOffset,y,p,f,E;this.plotLeft=y=Math.round(this.plotLeft);this.plotTop=p=Math.round(this.plotTop);this.plotWidth=f=Math.max(0,Math.round(d-y-this.marginRight));this.plotHeight=E=Math.max(0,Math.round(g-p-this.marginBottom));this.plotSizeX=b?E:f;this.plotSizeY=b?f:E;this.plotBorderWidth=m.plotBorderWidth||0;this.spacingBox=c.spacingBox={x:k[3],y:k[0],width:d-k[3]-k[1],height:g-k[0]-k[2]};this.plotBox=c.plotBox={x:y,y:p,width:f,height:E};
d=2*Math.floor(this.plotBorderWidth/2);b=Math.ceil(Math.max(d,h[3])/2);c=Math.ceil(Math.max(d,h[0])/2);this.clipBox={x:b,y:c,width:Math.floor(this.plotSizeX-Math.max(d,h[1])/2-b),height:Math.max(0,Math.floor(this.plotSizeY-Math.max(d,h[2])/2-c))};a||e(this.axes,function(a){a.setAxisSize();a.setAxisTranslation()})},resetMargins:function(){var a=this,b=a.options.chart;e(["margin","spacing"],function(c){var d=b[c],g=x(d)?d:[d,d,d,d];e(["Top","Right","Bottom","Left"],function(d,m){a[c][m]=y(b[c+d],g[m])})});
e(d,function(b,c){a[b]=y(a.margin[c],a.spacing[c])});a.axisOffset=[0,0,0,0];a.clipOffset=[0,0,0,0]},drawChartBox:function(){var a=this.options.chart,b=this.renderer,c=this.chartWidth,d=this.chartHeight,g=this.chartBackground,m=this.plotBackground,k=this.plotBorder,h,y=this.plotBGImage,e=a.backgroundColor,p=a.plotBackgroundColor,f=a.plotBackgroundImage,E,t=this.plotLeft,x=this.plotTop,u=this.plotWidth,I=this.plotHeight,n=this.plotBox,l=this.clipRect,z=this.clipBox,J="animate";g||(this.chartBackground=
g=b.rect().addClass("highcharts-background").add(),J="attr");h=a.borderWidth||0;E=h+(a.shadow?8:0);e={fill:e||"none"};if(h||g["stroke-width"])e.stroke=a.borderColor,e["stroke-width"]=h;g.attr(e).shadow(a.shadow);g[J]({x:E/2,y:E/2,width:c-E-h%2,height:d-E-h%2,r:a.borderRadius});J="animate";m||(J="attr",this.plotBackground=m=b.rect().addClass("highcharts-plot-background").add());m[J](n);m.attr({fill:p||"none"}).shadow(a.plotShadow);f&&(y?y.animate(n):this.plotBGImage=b.image(f,t,x,u,I).add());l?l.animate({width:z.width,
height:z.height}):this.clipRect=b.clipRect(z);J="animate";k||(J="attr",this.plotBorder=k=b.rect().addClass("highcharts-plot-border").attr({zIndex:1}).add());k.attr({stroke:a.plotBorderColor,"stroke-width":a.plotBorderWidth||0,fill:"none"});k[J](k.crisp({x:t,y:x,width:u,height:I},-k.strokeWidth()));this.isDirtyBox=!1},propFromSeries:function(){var a=this,b=a.options.chart,c,d=a.options.series,g,m;e(["inverted","angular","polar"],function(k){c=I[b.type||b.defaultSeriesType];m=b[k]||c&&c.prototype[k];
for(g=d&&d.length;!m&&g--;)(c=I[d[g].type])&&c.prototype[k]&&(m=!0);a[k]=m})},linkSeries:function(){var a=this,b=a.series;e(b,function(a){a.linkedSeries.length=0});e(b,function(b){var c=b.options.linkedTo;k(c)&&(c=":previous"===c?a.series[b.index-1]:a.get(c))&&c.linkedParent!==b&&(c.linkedSeries.push(b),b.linkedParent=c,b.visible=y(b.options.visible,c.options.visible,b.visible))})},renderSeries:function(){e(this.series,function(a){a.translate();a.render()})},renderLabels:function(){var a=this,b=a.options.labels;
b.items&&e(b.items,function(c){var d=z(b.style,c.style),g=J(d.left)+a.plotLeft,m=J(d.top)+a.plotTop+12;delete d.left;delete d.top;a.renderer.text(c.html,g,m).attr({zIndex:2}).css(d).add()})},render:function(){var a=this.axes,b=this.renderer,c=this.options,d,g,m;this.setTitle();this.legend=new F(this,c.legend);this.getStacks&&this.getStacks();this.getMargins(!0);this.setChartSize();c=this.plotWidth;d=this.plotHeight-=21;e(a,function(a){a.setScale()});this.getAxisMargins();g=1.1<c/this.plotWidth;m=
1.05<d/this.plotHeight;if(g||m)e(a,function(a){(a.horiz&&g||!a.horiz&&m)&&a.setTickInterval(!0)}),this.getMargins();this.drawChartBox();this.hasCartesianSeries&&e(a,function(a){a.visible&&a.render()});this.seriesGroup||(this.seriesGroup=b.g("series-group").attr({zIndex:3}).add());this.renderSeries();this.renderLabels();this.addCredits();this.setResponsive&&this.setResponsive();this.hasRendered=!0},addCredits:function(a){var b=this;a=u(!0,this.options.credits,a);a.enabled&&!this.credits&&(this.credits=
this.renderer.text(a.text+(this.mapCredits||""),0,0).addClass("highcharts-credits").on("click",function(){a.href&&(O.location.href=a.href)}).attr({align:a.position.align,zIndex:8}).css(a.style).add().align(a.position),this.credits.update=function(a){b.credits=b.credits.destroy();b.addCredits(a)})},destroy:function(){var b=this,c=b.axes,d=b.series,g=b.container,m,k=g&&g.parentNode;t(b,"destroy");n[b.index]=void 0;a.chartCount--;b.renderTo.removeAttribute("data-highcharts-chart");E(b);for(m=c.length;m--;)c[m]=
c[m].destroy();this.scroller&&this.scroller.destroy&&this.scroller.destroy();for(m=d.length;m--;)d[m]=d[m].destroy();e("title subtitle chartBackground plotBackground plotBGImage plotBorder seriesGroup clipRect credits pointer rangeSelector legend resetZoomButton tooltip renderer".split(" "),function(a){var c=b[a];c&&c.destroy&&(b[a]=c.destroy())});g&&(g.innerHTML="",E(g),k&&q(g));for(m in b)delete b[m]},isReadyToRender:function(){var a=this;return L||O!=O.top||"complete"===v.readyState?!0:(v.attachEvent("onreadystatechange",
function(){v.detachEvent("onreadystatechange",a.firstRender);"complete"===v.readyState&&a.firstRender()}),!1)},firstRender:function(){var a=this,b=a.options;if(a.isReadyToRender()){a.getContainer();t(a,"init");a.resetMargins();a.setChartSize();a.propFromSeries();a.getAxes();e(b.series||[],function(b){a.initSeries(b)});a.linkSeries();t(a,"beforeRender");m&&(a.pointer=new m(a,b));a.render();if(!a.renderer.imgCount&&a.onload)a.onload();a.cloneRenderTo(!0)}},onload:function(){e([this.callback].concat(this.callbacks),
function(a){a&&void 0!==this.index&&a.apply(this,[this])},this);t(this,"load");t(this,"render");c(this.index)&&!1!==this.options.chart.reflow&&this.initReflow();this.onload=null}}})(K);(function(a){var D,C=a.each,G=a.extend,H=a.erase,v=a.fireEvent,l=a.format,r=a.isArray,w=a.isNumber,q=a.pick,n=a.removeEvent;D=a.Point=function(){};D.prototype={init:function(a,c,e){this.series=a;this.color=a.color;this.applyOptions(c,e);a.options.colorByPoint?(c=a.options.colors||a.chart.options.colors,this.color=this.color||
c[a.colorCounter],c=c.length,e=a.colorCounter,a.colorCounter++,a.colorCounter===c&&(a.colorCounter=0)):e=a.colorIndex;this.colorIndex=q(this.colorIndex,e);a.chart.pointCount++;return this},applyOptions:function(a,c){var e=this.series,f=e.options.pointValKey||e.pointValKey;a=D.prototype.optionsToObject.call(this,a);G(this,a);this.options=this.options?G(this.options,a):a;a.group&&delete this.group;f&&(this.y=this[f]);this.isNull=q(this.isValid&&!this.isValid(),null===this.x||!w(this.y,!0));this.selected&&
(this.state="select");"name"in this&&void 0===c&&e.xAxis&&e.xAxis.hasNames&&(this.x=e.xAxis.nameToX(this));void 0===this.x&&e&&(this.x=void 0===c?e.autoIncrement(this):c);return this},optionsToObject:function(a){var c={},e=this.series,f=e.options.keys,b=f||e.pointArrayMap||["y"],t=b.length,h=0,n=0;if(w(a)||null===a)c[b[0]]=a;else if(r(a))for(!f&&a.length>t&&(e=typeof a[0],"string"===e?c.name=a[0]:"number"===e&&(c.x=a[0]),h++);n<t;)f&&void 0===a[h]||(c[b[n]]=a[h]),h++,n++;else"object"===typeof a&&
(c=a,a.dataLabels&&(e._hasPointLabels=!0),a.marker&&(e._hasPointMarkers=!0));return c},getClassName:function(){return"highcharts-point"+(this.selected?" highcharts-point-select":"")+(this.negative?" highcharts-negative":"")+(this.isNull?" highcharts-null-point":"")+(void 0!==this.colorIndex?" highcharts-color-"+this.colorIndex:"")+(this.options.className?" "+this.options.className:"")+(this.zone&&this.zone.className?" "+this.zone.className.replace("highcharts-negative",""):"")},getZone:function(){var a=
this.series,c=a.zones,a=a.zoneAxis||"y",e=0,n;for(n=c[e];this[a]>=n.value;)n=c[++e];n&&n.color&&!this.options.color&&(this.color=n.color);return n},destroy:function(){var a=this.series.chart,c=a.hoverPoints,e;a.pointCount--;c&&(this.setState(),H(c,this),c.length||(a.hoverPoints=null));if(this===a.hoverPoint)this.onMouseOut();if(this.graphic||this.dataLabel)n(this),this.destroyElements();this.legendItem&&a.legend.destroyItem(this);for(e in this)this[e]=null},destroyElements:function(){for(var a=["graphic",
"dataLabel","dataLabelUpper","connector","shadowGroup"],c,e=6;e--;)c=a[e],this[c]&&(this[c]=this[c].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,color:this.color,colorIndex:this.colorIndex,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},tooltipFormatter:function(a){var c=this.series,e=c.tooltipOptions,f=q(e.valueDecimals,""),b=e.valuePrefix||"",t=e.valueSuffix||"";C(c.pointArrayMap||["y"],function(c){c=
"{point."+c;if(b||t)a=a.replace(c+"}",b+c+"}"+t);a=a.replace(c+"}",c+":,."+f+"f}")});return l(a,{point:this,series:this.series})},firePointEvent:function(a,c,e){var f=this,b=this.series.options;(b.point.events[a]||f.options&&f.options.events&&f.options.events[a])&&this.importEvents();"click"===a&&b.allowPointSelect&&(e=function(a){f.select&&f.select(null,a.ctrlKey||a.metaKey||a.shiftKey)});v(this,a,c,e)},visible:!0}})(K);(function(a){var D=a.addEvent,C=a.animObject,G=a.arrayMax,H=a.arrayMin,v=a.correctFloat,
l=a.Date,r=a.defaultOptions,w=a.defaultPlotOptions,q=a.defined,n=a.each,f=a.erase,c=a.extend,e=a.fireEvent,z=a.grep,b=a.isArray,t=a.isNumber,h=a.isString,B=a.merge,p=a.pick,x=a.removeEvent,k=a.splat,F=a.SVGElement,d=a.syncTimeout,u=a.win;a.Series=a.seriesType("line",null,{lineWidth:2,allowPointSelect:!1,showCheckbox:!1,animation:{duration:1E3},events:{},marker:{lineWidth:0,lineColor:"#ffffff",radius:4,states:{hover:{animation:{duration:50},enabled:!0,radiusPlus:2,lineWidthPlus:1},select:{fillColor:"#cccccc",
lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:{align:"center",formatter:function(){return null===this.y?"":a.numberFormat(this.y,-1)},style:{fontSize:"11px",fontWeight:"bold",color:"contrast",textOutline:"1px contrast"},verticalAlign:"bottom",x:0,y:0,padding:5},cropThreshold:300,pointRange:0,softThreshold:!0,states:{hover:{animation:{duration:50},lineWidthPlus:1,marker:{},halo:{size:10,opacity:.25}},select:{marker:{}}},stickyTracking:!0,turboThreshold:1E3,findNearestPointBy:"x"},
{isCartesian:!0,pointClass:a.Point,sorted:!0,requireSorting:!0,directTouch:!1,axisTypes:["xAxis","yAxis"],colorCounter:0,parallelArrays:["x","y"],coll:"series",init:function(a,b){var d=this,m,k,g=a.series,h;d.chart=a;d.options=b=d.setOptions(b);d.linkedSeries=[];d.bindAxes();c(d,{name:b.name,state:"",visible:!1!==b.visible,selected:!0===b.selected});k=b.events;for(m in k)D(d,m,k[m]);if(k&&k.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)a.runTrackerClick=!0;d.getColor();
d.getSymbol();n(d.parallelArrays,function(a){d[a+"Data"]=[]});d.setData(b.data,!1);d.isCartesian&&(a.hasCartesianSeries=!0);g.length&&(h=g[g.length-1]);d._i=p(h&&h._i,-1)+1;a.orderSeries(this.insert(g))},insert:function(a){var b=this.options.index,c;if(t(b)){for(c=a.length;c--;)if(b>=p(a[c].options.index,a[c]._i)){a.splice(c+1,0,this);break}-1===c&&a.unshift(this);c+=1}else a.push(this);return p(c,a.length-1)},bindAxes:function(){var b=this,c=b.options,d=b.chart,k;n(b.axisTypes||[],function(m){n(d[m],
function(a){k=a.options;if(c[m]===k.index||void 0!==c[m]&&c[m]===k.id||void 0===c[m]&&0===k.index)b.insert(a.series),b[m]=a,a.isDirty=!0});b[m]||b.optionalAxis===m||a.error(18,!0)})},updateParallelArrays:function(a,b){var c=a.series,d=arguments,m=t(b)?function(d){var g="y"===d&&c.toYData?c.toYData(a):a[d];c[d+"Data"][b]=g}:function(a){Array.prototype[b].apply(c[a+"Data"],Array.prototype.slice.call(d,2))};n(c.parallelArrays,m)},autoIncrement:function(){var a=this.options,b=this.xIncrement,c,d=a.pointIntervalUnit,
b=p(b,a.pointStart,0);this.pointInterval=c=p(this.pointInterval,a.pointInterval,1);d&&(a=new l(b),"day"===d?a=+a[l.hcSetDate](a[l.hcGetDate]()+c):"month"===d?a=+a[l.hcSetMonth](a[l.hcGetMonth]()+c):"year"===d&&(a=+a[l.hcSetFullYear](a[l.hcGetFullYear]()+c)),c=a-b);this.xIncrement=b+c;return b},setOptions:function(a){var b=this.chart,c=b.options.plotOptions,b=b.userOptions||{},d=b.plotOptions||{},m=c[this.type];this.userOptions=a;c=B(m,c.series,a);this.tooltipOptions=B(r.tooltip,r.plotOptions[this.type].tooltip,
b.tooltip,d.series&&d.series.tooltip,d[this.type]&&d[this.type].tooltip,a.tooltip);this.stickyTracking=p(a.stickyTracking,d[this.type]&&d[this.type].stickyTracking,d.series&&d.series.stickyTracking,this.tooltipOptions.shared&&!this.noSharedTooltip?!0:c.stickyTracking);null===m.marker&&delete c.marker;this.zoneAxis=c.zoneAxis;a=this.zones=(c.zones||[]).slice();!c.negativeColor&&!c.negativeFillColor||c.zones||a.push({value:c[this.zoneAxis+"Threshold"]||c.threshold||0,className:"highcharts-negative",
color:c.negativeColor,fillColor:c.negativeFillColor});a.length&&q(a[a.length-1].value)&&a.push({color:this.color,fillColor:this.fillColor});return c},getCyclic:function(a,b,c){var d,m=this.chart,g=this.userOptions,k=a+"Index",h=a+"Counter",e=c?c.length:p(m.options.chart[a+"Count"],m[a+"Count"]);b||(d=p(g[k],g["_"+k]),q(d)||(m.series.length||(m[h]=0),g["_"+k]=d=m[h]%e,m[h]+=1),c&&(b=c[d]));void 0!==d&&(this[k]=d);this[a]=b},getColor:function(){this.options.colorByPoint?this.options.color=null:this.getCyclic("color",
this.options.color||w[this.type].color,this.chart.options.colors)},getSymbol:function(){this.getCyclic("symbol",this.options.marker.symbol,this.chart.options.symbols)},drawLegendSymbol:a.LegendSymbolMixin.drawLineMarker,setData:function(c,d,k,e){var m=this,g=m.points,y=g&&g.length||0,E,f=m.options,x=m.chart,u=null,l=m.xAxis,z=f.turboThreshold,F=this.xData,q=this.yData,r=(E=m.pointArrayMap)&&E.length;c=c||[];E=c.length;d=p(d,!0);if(!1!==e&&E&&y===E&&!m.cropped&&!m.hasGroupedData&&m.visible)n(c,function(a,
b){g[b].update&&a!==f.data[b]&&g[b].update(a,!1,null,!1)});else{m.xIncrement=null;m.colorCounter=0;n(this.parallelArrays,function(a){m[a+"Data"].length=0});if(z&&E>z){for(k=0;null===u&&k<E;)u=c[k],k++;if(t(u))for(k=0;k<E;k++)F[k]=this.autoIncrement(),q[k]=c[k];else if(b(u))if(r)for(k=0;k<E;k++)u=c[k],F[k]=u[0],q[k]=u.slice(1,r+1);else for(k=0;k<E;k++)u=c[k],F[k]=u[0],q[k]=u[1];else a.error(12)}else for(k=0;k<E;k++)void 0!==c[k]&&(u={series:m},m.pointClass.prototype.applyOptions.apply(u,[c[k]]),m.updateParallelArrays(u,
k));h(q[0])&&a.error(14,!0);m.data=[];m.options.data=m.userOptions.data=c;for(k=y;k--;)g[k]&&g[k].destroy&&g[k].destroy();l&&(l.minRange=l.userMinRange);m.isDirty=x.isDirtyBox=!0;m.isDirtyData=!!g;k=!1}"point"===f.legendType&&(this.processData(),this.generatePoints());d&&x.redraw(k)},processData:function(b){var c=this.xData,d=this.yData,m=c.length,k;k=0;var g,h,e=this.xAxis,p,f=this.options;p=f.cropThreshold;var t=this.getExtremesFromAll||f.getExtremesFromAll,u=this.isCartesian,f=e&&e.val2lin,x=e&&
e.isLog,n,l;if(u&&!this.isDirty&&!e.isDirty&&!this.yAxis.isDirty&&!b)return!1;e&&(b=e.getExtremes(),n=b.min,l=b.max);if(u&&this.sorted&&!t&&(!p||m>p||this.forceCrop))if(c[m-1]<n||c[0]>l)c=[],d=[];else if(c[0]<n||c[m-1]>l)k=this.cropData(this.xData,this.yData,n,l),c=k.xData,d=k.yData,k=k.start,g=!0;for(p=c.length||1;--p;)m=x?f(c[p])-f(c[p-1]):c[p]-c[p-1],0<m&&(void 0===h||m<h)?h=m:0>m&&this.requireSorting&&a.error(15);this.cropped=g;this.cropStart=k;this.processedXData=c;this.processedYData=d;this.closestPointRange=
h},cropData:function(a,b,c,d){var m=a.length,g=0,k=m,h=p(this.cropShoulder,1),e;for(e=0;e<m;e++)if(a[e]>=c){g=Math.max(0,e-h);break}for(c=e;c<m;c++)if(a[c]>d){k=c+h;break}return{xData:a.slice(g,k),yData:b.slice(g,k),start:g,end:k}},generatePoints:function(){var a=this.options.data,b=this.data,c,d=this.processedXData,h=this.processedYData,g=this.pointClass,e=d.length,p=this.cropStart||0,f,t=this.hasGroupedData,u,x=[],n;b||t||(b=[],b.length=a.length,b=this.data=b);for(n=0;n<e;n++)f=p+n,t?(u=(new g).init(this,
[d[n]].concat(k(h[n]))),u.dataGroup=this.groupMap[n]):(u=b[f])||void 0===a[f]||(b[f]=u=(new g).init(this,a[f],d[n])),u&&(u.index=f,x[n]=u);if(b&&(e!==(c=b.length)||t))for(n=0;n<c;n++)n!==p||t||(n+=e),b[n]&&(b[n].destroyElements(),b[n].plotX=void 0);this.data=b;this.points=x},getExtremes:function(a){var c=this.yAxis,d=this.processedXData,m,k=[],g=0;m=this.xAxis.getExtremes();var h=m.min,e=m.max,p,f,u,x;a=a||this.stackedYData||this.processedYData||[];m=a.length;for(x=0;x<m;x++)if(f=d[x],u=a[x],p=(t(u,
!0)||b(u))&&(!c.positiveValuesOnly||u.length||0<u),f=this.getExtremesFromAll||this.options.getExtremesFromAll||this.cropped||(d[x]||f)>=h&&(d[x]||f)<=e,p&&f)if(p=u.length)for(;p--;)null!==u[p]&&(k[g++]=u[p]);else k[g++]=u;this.dataMin=H(k);this.dataMax=G(k)},translate:function(){this.processedXData||this.processData();this.generatePoints();var a=this.options,b=a.stacking,c=this.xAxis,d=c.categories,k=this.yAxis,g=this.points,h=g.length,e=!!this.modifyValue,f=a.pointPlacement,u="between"===f||t(f),
x=a.threshold,n=a.startFromThreshold?x:0,l,z,F,r,B=Number.MAX_VALUE;"between"===f&&(f=.5);t(f)&&(f*=p(a.pointRange||c.pointRange));for(a=0;a<h;a++){var w=g[a],C=w.x,D=w.y;z=w.low;var G=b&&k.stacks[(this.negStacks&&D<(n?0:x)?"-":"")+this.stackKey],H;k.positiveValuesOnly&&null!==D&&0>=D&&(w.isNull=!0);w.plotX=l=v(Math.min(Math.max(-1E5,c.translate(C,0,0,0,1,f,"flags"===this.type)),1E5));b&&this.visible&&!w.isNull&&G&&G[C]&&(r=this.getStackIndicator(r,C,this.index),H=G[C],D=H.points[r.key],z=D[0],D=
D[1],z===n&&r.key===G[C].base&&(z=p(x,k.min)),k.positiveValuesOnly&&0>=z&&(z=null),w.total=w.stackTotal=H.total,w.percentage=H.total&&w.y/H.total*100,w.stackY=D,H.setOffset(this.pointXOffset||0,this.barW||0));w.yBottom=q(z)?k.translate(z,0,1,0,1):null;e&&(D=this.modifyValue(D,w));w.plotY=z="number"===typeof D&&Infinity!==D?Math.min(Math.max(-1E5,k.translate(D,0,1,0,1)),1E5):void 0;w.isInside=void 0!==z&&0<=z&&z<=k.len&&0<=l&&l<=c.len;w.clientX=u?v(c.translate(C,0,0,0,1,f)):l;w.negative=w.y<(x||0);
w.category=d&&void 0!==d[w.x]?d[w.x]:w.x;w.isNull||(void 0!==F&&(B=Math.min(B,Math.abs(l-F))),F=l);w.zone=this.zones.length&&w.getZone()}this.closestPointRangePx=B},getValidPoints:function(a,b){var c=this.chart;return z(a||this.points||[],function(a){return b&&!c.isInsidePlot(a.plotX,a.plotY,c.inverted)?!1:!a.isNull})},setClip:function(a){var b=this.chart,c=this.options,d=b.renderer,m=b.inverted,g=this.clipBox,k=g||b.clipBox,h=this.sharedClipKey||["_sharedClip",a&&a.duration,a&&a.easing,k.height,
c.xAxis,c.yAxis].join(),e=b[h],p=b[h+"m"];e||(a&&(k.width=0,b[h+"m"]=p=d.clipRect(-99,m?-b.plotLeft:-b.plotTop,99,m?b.chartWidth:b.chartHeight)),b[h]=e=d.clipRect(k),e.count={length:0});a&&!e.count[this.index]&&(e.count[this.index]=!0,e.count.length+=1);!1!==c.clip&&(this.group.clip(a||g?e:b.clipRect),this.markerGroup.clip(p),this.sharedClipKey=h);a||(e.count[this.index]&&(delete e.count[this.index],--e.count.length),0===e.count.length&&h&&b[h]&&(g||(b[h]=b[h].destroy()),b[h+"m"]&&(b[h+"m"]=b[h+"m"].destroy())))},
animate:function(a){var b=this.chart,c=C(this.options.animation),d;a?this.setClip(c):(d=this.sharedClipKey,(a=b[d])&&a.animate({width:b.plotSizeX},c),b[d+"m"]&&b[d+"m"].animate({width:b.plotSizeX+99},c),this.animate=null)},afterAnimate:function(){this.setClip();e(this,"afterAnimate")},drawPoints:function(){var a=this.points,b=this.chart,c,d,k,g,h=this.options.marker,e,f,u,x,n=this.markerGroup,l=p(h.enabled,this.xAxis.isRadial?!0:null,this.closestPointRangePx>=2*h.radius);if(!1!==h.enabled||this._hasPointMarkers)for(d=
0;d<a.length;d++)k=a[d],c=k.plotY,g=k.graphic,e=k.marker||{},f=!!k.marker,u=l&&void 0===e.enabled||e.enabled,x=k.isInside,u&&t(c)&&null!==k.y?(c=p(e.symbol,this.symbol),k.hasImage=0===c.indexOf("url"),u=this.markerAttribs(k,k.selected&&"select"),g?g[x?"show":"hide"](!0).animate(u):x&&(0<u.width||k.hasImage)&&(k.graphic=g=b.renderer.symbol(c,u.x,u.y,u.width,u.height,f?e:h).add(n)),g&&g.attr(this.pointAttribs(k,k.selected&&"select")),g&&g.addClass(k.getClassName(),!0)):g&&(k.graphic=g.destroy())},markerAttribs:function(a,
b){var c=this.options.marker,d=a.marker||{},m=p(d.radius,c.radius);b&&(c=c.states[b],b=d.states&&d.states[b],m=p(b&&b.radius,c&&c.radius,m+(c&&c.radiusPlus||0)));a.hasImage&&(m=0);a={x:Math.floor(a.plotX)-m,y:a.plotY-m};m&&(a.width=a.height=2*m);return a},pointAttribs:function(a,b){var c=this.options.marker,d=a&&a.options,m=d&&d.marker||{},g=this.color,k=d&&d.color,h=a&&a.color,d=p(m.lineWidth,c.lineWidth);a=a&&a.zone&&a.zone.color;g=k||a||h||g;a=m.fillColor||c.fillColor||g;g=m.lineColor||c.lineColor||
g;b&&(c=c.states[b],b=m.states&&m.states[b]||{},d=p(b.lineWidth,c.lineWidth,d+p(b.lineWidthPlus,c.lineWidthPlus,0)),a=b.fillColor||c.fillColor||a,g=b.lineColor||c.lineColor||g);return{stroke:g,"stroke-width":d,fill:a}},destroy:function(){var a=this,b=a.chart,c=/AppleWebKit\/533/.test(u.navigator.userAgent),d,k=a.data||[],g,h,p;e(a,"destroy");x(a);n(a.axisTypes||[],function(b){(p=a[b])&&p.series&&(f(p.series,a),p.isDirty=p.forceRedraw=!0)});a.legendItem&&a.chart.legend.destroyItem(a);for(d=k.length;d--;)(g=
k[d])&&g.destroy&&g.destroy();a.points=null;clearTimeout(a.animationTimeout);for(h in a)a[h]instanceof F&&!a[h].survive&&(d=c&&"group"===h?"hide":"destroy",a[h][d]());b.hoverSeries===a&&(b.hoverSeries=null);f(b.series,a);b.orderSeries();for(h in a)delete a[h]},getGraphPath:function(a,b,c){var d=this,m=d.options,g=m.step,k,h=[],e=[],p;a=a||d.points;(k=a.reversed)&&a.reverse();(g={right:1,center:2}[g]||g&&3)&&k&&(g=4-g);!m.connectNulls||b||c||(a=this.getValidPoints(a));n(a,function(k,f){var u=k.plotX,
x=k.plotY,t=a[f-1];(k.leftCliff||t&&t.rightCliff)&&!c&&(p=!0);k.isNull&&!q(b)&&0<f?p=!m.connectNulls:k.isNull&&!b?p=!0:(0===f||p?f=["M",k.plotX,k.plotY]:d.getPointSpline?f=d.getPointSpline(a,k,f):g?(f=1===g?["L",t.plotX,x]:2===g?["L",(t.plotX+u)/2,t.plotY,"L",(t.plotX+u)/2,x]:["L",u,t.plotY],f.push("L",u,x)):f=["L",u,x],e.push(k.x),g&&e.push(k.x),h.push.apply(h,f),p=!1)});h.xMap=e;return d.graphPath=h},drawGraph:function(){var a=this,b=this.options,c=(this.gappedPath||this.getGraphPath).call(this),
d=[["graph","highcharts-graph",b.lineColor||this.color,b.dashStyle]];n(this.zones,function(c,g){d.push(["zone-graph-"+g,"highcharts-graph highcharts-zone-graph-"+g+" "+(c.className||""),c.color||a.color,c.dashStyle||b.dashStyle])});n(d,function(d,g){var k=d[0],m=a[k];m?(m.endX=c.xMap,m.animate({d:c})):c.length&&(a[k]=a.chart.renderer.path(c).addClass(d[1]).attr({zIndex:1}).add(a.group),m={stroke:d[2],"stroke-width":b.lineWidth,fill:a.fillGraph&&a.color||"none"},d[3]?m.dashstyle=d[3]:"square"!==b.linecap&&
(m["stroke-linecap"]=m["stroke-linejoin"]="round"),m=a[k].attr(m).shadow(2>g&&b.shadow));m&&(m.startX=c.xMap,m.isArea=c.isArea)})},applyZones:function(){var a=this,b=this.chart,c=b.renderer,d=this.zones,k,g,h=this.clips||[],e,f=this.graph,u=this.area,x=Math.max(b.chartWidth,b.chartHeight),t=this[(this.zoneAxis||"y")+"Axis"],l,z,F=b.inverted,q,r,B,w,v=!1;d.length&&(f||u)&&t&&void 0!==t.min&&(z=t.reversed,q=t.horiz,f&&f.hide(),u&&u.hide(),l=t.getExtremes(),n(d,function(d,m){k=z?q?b.plotWidth:0:q?0:
t.toPixels(l.min);k=Math.min(Math.max(p(g,k),0),x);g=Math.min(Math.max(Math.round(t.toPixels(p(d.value,l.max),!0)),0),x);v&&(k=g=t.toPixels(l.max));r=Math.abs(k-g);B=Math.min(k,g);w=Math.max(k,g);t.isXAxis?(e={x:F?w:B,y:0,width:r,height:x},q||(e.x=b.plotHeight-e.x)):(e={x:0,y:F?w:B,width:x,height:r},q&&(e.y=b.plotWidth-e.y));F&&c.isVML&&(e=t.isXAxis?{x:0,y:z?B:w,height:e.width,width:b.chartWidth}:{x:e.y-b.plotLeft-b.spacingBox.x,y:0,width:e.height,height:b.chartHeight});h[m]?h[m].animate(e):(h[m]=
c.clipRect(e),f&&a["zone-graph-"+m].clip(h[m]),u&&a["zone-area-"+m].clip(h[m]));v=d.value>l.max}),this.clips=h)},invertGroups:function(a){function b(){n(["group","markerGroup"],function(b){c[b]&&(d.renderer.isVML&&c[b].attr({width:c.yAxis.len,height:c.xAxis.len}),c[b].width=c.yAxis.len,c[b].height=c.xAxis.len,c[b].invert(a))})}var c=this,d=c.chart,k;c.xAxis&&(k=D(d,"resize",b),D(c,"destroy",k),b(a),c.invertGroups=b)},plotGroup:function(a,b,c,d,k){var g=this[a],m=!g;m&&(this[a]=g=this.chart.renderer.g(b).attr({zIndex:d||
.1}).add(k),g.addClass("highcharts-series-"+this.index+" highcharts-"+this.type+"-series highcharts-color-"+this.colorIndex+" "+(this.options.className||"")));g.attr({visibility:c})[m?"attr":"animate"](this.getPlotBox());return g},getPlotBox:function(){var a=this.chart,b=this.xAxis,c=this.yAxis;a.inverted&&(b=c,c=this.xAxis);return{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var a=this,b=a.chart,c,k=a.options,h=!!a.animate&&b.renderer.isSVG&&C(k.animation).duration,
g=a.visible?"inherit":"hidden",e=k.zIndex,p=a.hasRendered,f=b.seriesGroup,u=b.inverted;c=a.plotGroup("group","series",g,e,f);a.markerGroup=a.plotGroup("markerGroup","markers",g,e,f);h&&a.animate(!0);c.inverted=a.isCartesian?u:!1;a.drawGraph&&(a.drawGraph(),a.applyZones());a.drawDataLabels&&a.drawDataLabels();a.visible&&a.drawPoints();a.drawTracker&&!1!==a.options.enableMouseTracking&&a.drawTracker();a.invertGroups(u);!1===k.clip||a.sharedClipKey||p||c.clip(b.clipRect);h&&a.animate();p||(a.animationTimeout=
d(function(){a.afterAnimate()},h));a.isDirty=!1;a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirty||this.isDirtyData,c=this.group,d=this.xAxis,k=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:p(d&&d.left,a.plotLeft),translateY:p(k&&k.top,a.plotTop)}));this.translate();this.render();b&&delete this.kdTree},kdAxisArray:["clientX","plotY"],searchPoint:function(a,b){var c=this.xAxis,d=this.yAxis,k=this.chart.inverted;return this.searchKDTree({clientX:k?
c.len-a.chartY+c.pos:a.chartX-c.pos,plotY:k?d.len-a.chartX+d.pos:a.chartY-d.pos},b)},buildKDTree:function(){function a(c,d,g){var k,m;if(m=c&&c.length)return k=b.kdAxisArray[d%g],c.sort(function(a,b){return a[k]-b[k]}),m=Math.floor(m/2),{point:c[m],left:a(c.slice(0,m),d+1,g),right:a(c.slice(m+1),d+1,g)}}this.buildingKdTree=!0;var b=this,c=-1<b.options.findNearestPointBy.indexOf("y")?2:1;delete b.kdTree;d(function(){b.kdTree=a(b.getValidPoints(null,!b.directTouch),c,c);b.buildingKdTree=!1},b.options.kdNow?
0:1)},searchKDTree:function(a,b){function c(a,b,h,e){var p=b.point,f=d.kdAxisArray[h%e],u,t,x=p;t=q(a[k])&&q(p[k])?Math.pow(a[k]-p[k],2):null;u=q(a[g])&&q(p[g])?Math.pow(a[g]-p[g],2):null;u=(t||0)+(u||0);p.dist=q(u)?Math.sqrt(u):Number.MAX_VALUE;p.distX=q(t)?Math.sqrt(t):Number.MAX_VALUE;f=a[f]-p[f];u=0>f?"left":"right";t=0>f?"right":"left";b[u]&&(u=c(a,b[u],h+1,e),x=u[m]<x[m]?u:p);b[t]&&Math.sqrt(f*f)<x[m]&&(a=c(a,b[t],h+1,e),x=a[m]<x[m]?a:x);return x}var d=this,k=this.kdAxisArray[0],g=this.kdAxisArray[1],
m=b?"distX":"dist";b=-1<d.options.findNearestPointBy.indexOf("y")?2:1;this.kdTree||this.buildingKdTree||this.buildKDTree();if(this.kdTree)return c(a,this.kdTree,b,b)}})})(K);(function(a){function D(a,f,c,e,l){var b=a.chart.inverted;this.axis=a;this.isNegative=c;this.options=f;this.x=e;this.total=null;this.points={};this.stack=l;this.rightCliff=this.leftCliff=0;this.alignOptions={align:f.align||(b?c?"left":"right":"center"),verticalAlign:f.verticalAlign||(b?"middle":c?"bottom":"top"),y:q(f.y,b?4:c?
14:-6),x:q(f.x,b?c?-6:6:0)};this.textAlign=f.textAlign||(b?c?"right":"left":"center")}var C=a.Axis,G=a.Chart,H=a.correctFloat,v=a.defined,l=a.destroyObjectProperties,r=a.each,w=a.format,q=a.pick;a=a.Series;D.prototype={destroy:function(){l(this,this.axis)},render:function(a){var f=this.options,c=f.format,c=c?w(c,this):f.formatter.call(this);this.label?this.label.attr({text:c,visibility:"hidden"}):this.label=this.axis.chart.renderer.text(c,null,null,f.useHTML).css(f.style).attr({align:this.textAlign,
rotation:f.rotation,visibility:"hidden"}).add(a)},setOffset:function(a,f){var c=this.axis,e=c.chart,n=e.inverted,b=c.reversed,b=this.isNegative&&!b||!this.isNegative&&b,t=c.translate(c.usePercentage?100:this.total,0,0,0,1),c=c.translate(0),c=Math.abs(t-c);a=e.xAxis[0].translate(this.x)+a;var h=e.plotHeight,n={x:n?b?t:t-c:a,y:n?h-a-f:b?h-t-c:h-t,width:n?c:f,height:n?f:c};if(f=this.label)f.align(this.alignOptions,null,n),n=f.alignAttr,f[!1===this.options.crop||e.isInsidePlot(n.x,n.y)?"show":"hide"](!0)}};
G.prototype.getStacks=function(){var a=this;r(a.yAxis,function(a){a.stacks&&a.hasVisibleSeries&&(a.oldStacks=a.stacks)});r(a.series,function(f){!f.options.stacking||!0!==f.visible&&!1!==a.options.chart.ignoreHiddenSeries||(f.stackKey=f.type+q(f.options.stack,""))})};C.prototype.buildStacks=function(){var a=this.series,f,c=q(this.options.reversedStacks,!0),e=a.length,l;if(!this.isXAxis){this.usePercentage=!1;for(l=e;l--;)a[c?l:e-l-1].setStackedPoints();for(l=e;l--;)f=a[c?l:e-l-1],f.setStackCliffs&&
f.setStackCliffs();if(this.usePercentage)for(l=0;l<e;l++)a[l].setPercentStacks()}};C.prototype.renderStackTotals=function(){var a=this.chart,f=a.renderer,c=this.stacks,e,l,b=this.stackTotalGroup;b||(this.stackTotalGroup=b=f.g("stack-labels").attr({visibility:"visible",zIndex:6}).add());b.translate(a.plotLeft,a.plotTop);for(e in c)for(l in a=c[e],a)a[l].render(b)};C.prototype.resetStacks=function(){var a=this.stacks,f,c;if(!this.isXAxis)for(f in a)for(c in a[f])a[f][c].touched<this.stacksTouched?(a[f][c].destroy(),
delete a[f][c]):(a[f][c].total=null,a[f][c].cum=null)};C.prototype.cleanStacks=function(){var a,f,c;if(!this.isXAxis)for(f in this.oldStacks&&(a=this.stacks=this.oldStacks),a)for(c in a[f])a[f][c].cum=a[f][c].total};a.prototype.setStackedPoints=function(){if(this.options.stacking&&(!0===this.visible||!1===this.chart.options.chart.ignoreHiddenSeries)){var a=this.processedXData,f=this.processedYData,c=[],e=f.length,l=this.options,b=l.threshold,t=l.startFromThreshold?b:0,h=l.stack,l=l.stacking,r=this.stackKey,
p="-"+r,x=this.negStacks,k=this.yAxis,F=k.stacks,d=k.oldStacks,u,m,y,w,E,I,g;k.stacksTouched+=1;for(E=0;E<e;E++)I=a[E],g=f[E],u=this.getStackIndicator(u,I,this.index),w=u.key,y=(m=x&&g<(t?0:b))?p:r,F[y]||(F[y]={}),F[y][I]||(d[y]&&d[y][I]?(F[y][I]=d[y][I],F[y][I].total=null):F[y][I]=new D(k,k.options.stackLabels,m,I,h)),y=F[y][I],null!==g&&(y.points[w]=y.points[this.index]=[q(y.cum,t)],v(y.cum)||(y.base=w),y.touched=k.stacksTouched,0<u.index&&!1===this.singleStacks&&(y.points[w][0]=y.points[this.index+
","+I+",0"][0])),"percent"===l?(m=m?r:p,x&&F[m]&&F[m][I]?(m=F[m][I],y.total=m.total=Math.max(m.total,y.total)+Math.abs(g)||0):y.total=H(y.total+(Math.abs(g)||0))):y.total=H(y.total+(g||0)),y.cum=q(y.cum,t)+(g||0),null!==g&&(y.points[w].push(y.cum),c[E]=y.cum);"percent"===l&&(k.usePercentage=!0);this.stackedYData=c;k.oldStacks={}}};a.prototype.setPercentStacks=function(){var a=this,f=a.stackKey,c=a.yAxis.stacks,e=a.processedXData,l;r([f,"-"+f],function(b){for(var f=e.length,h,n;f--;)if(h=e[f],l=a.getStackIndicator(l,
h,a.index,b),h=(n=c[b]&&c[b][h])&&n.points[l.key])n=n.total?100/n.total:0,h[0]=H(h[0]*n),h[1]=H(h[1]*n),a.stackedYData[f]=h[1]})};a.prototype.getStackIndicator=function(a,f,c,e){!v(a)||a.x!==f||e&&a.key!==e?a={x:f,index:0,key:e}:a.index++;a.key=[c,f,a.index].join();return a}})(K);(function(a){var D=a.addEvent,C=a.animate,G=a.Axis,H=a.createElement,v=a.css,l=a.defined,r=a.each,w=a.erase,q=a.extend,n=a.fireEvent,f=a.inArray,c=a.isNumber,e=a.isObject,z=a.merge,b=a.pick,t=a.Point,h=a.Series,B=a.seriesTypes,
p=a.setAnimation,x=a.splat;q(a.Chart.prototype,{addSeries:function(a,c,d){var k,m=this;a&&(c=b(c,!0),n(m,"addSeries",{options:a},function(){k=m.initSeries(a);m.isDirtyLegend=!0;m.linkSeries();c&&m.redraw(d)}));return k},addAxis:function(a,c,d,h){var k=c?"xAxis":"yAxis",e=this.options;a=z(a,{index:this[k].length,isX:c});new G(this,a);e[k]=x(e[k]||{});e[k].push(a);b(d,!0)&&this.redraw(h)},showLoading:function(a){var b=this,c=b.options,k=b.loadingDiv,m=c.loading,h=function(){k&&v(k,{left:b.plotLeft+
"px",top:b.plotTop+"px",width:b.plotWidth+"px",height:b.plotHeight+"px"})};k||(b.loadingDiv=k=H("div",{className:"highcharts-loading highcharts-loading-hidden"},null,b.container),b.loadingSpan=H("span",{className:"highcharts-loading-inner"},null,k),D(b,"redraw",h));k.className="highcharts-loading";b.loadingSpan.innerHTML=a||c.lang.loading;v(k,q(m.style,{zIndex:10}));v(b.loadingSpan,m.labelStyle);b.loadingShown||(v(k,{opacity:0,display:""}),C(k,{opacity:m.style.opacity||.5},{duration:m.showDuration||
0}));b.loadingShown=!0;h()},hideLoading:function(){var a=this.options,b=this.loadingDiv;b&&(b.className="highcharts-loading highcharts-loading-hidden",C(b,{opacity:0},{duration:a.loading.hideDuration||100,complete:function(){v(b,{display:"none"})}}));this.loadingShown=!1},propsRequireDirtyBox:"backgroundColor borderColor borderWidth margin marginTop marginRight marginBottom marginLeft spacing spacingTop spacingRight spacingBottom spacingLeft borderRadius plotBackgroundColor plotBackgroundImage plotBorderColor plotBorderWidth plotShadow shadow".split(" "),
propsRequireUpdateSeries:"chart.inverted chart.polar chart.ignoreHiddenSeries chart.type colors plotOptions".split(" "),update:function(a,h){var d,k={credits:"addCredits",title:"setTitle",subtitle:"setSubtitle"},m=a.chart,e,p;if(m){z(!0,this.options.chart,m);"className"in m&&this.setClassName(m.className);if("inverted"in m||"polar"in m)this.propFromSeries(),e=!0;"alignTicks"in m&&(e=!0);for(d in m)m.hasOwnProperty(d)&&(-1!==f("chart."+d,this.propsRequireUpdateSeries)&&(p=!0),-1!==f(d,this.propsRequireDirtyBox)&&
(this.isDirtyBox=!0));"style"in m&&this.renderer.setStyle(m.style)}for(d in a){if(this[d]&&"function"===typeof this[d].update)this[d].update(a[d],!1);else if("function"===typeof this[k[d]])this[k[d]](a[d]);"chart"!==d&&-1!==f(d,this.propsRequireUpdateSeries)&&(p=!0)}a.colors&&(this.options.colors=a.colors);a.plotOptions&&z(!0,this.options.plotOptions,a.plotOptions);r(["xAxis","yAxis","series","colorAxis","pane"],function(b){a[b]&&r(x(a[b]),function(a,c){(c=l(a.id)&&this.get(a.id)||this[b][c])&&c.coll===
b&&c.update(a,!1)},this)},this);e&&r(this.axes,function(a){a.update({},!1)});p&&r(this.series,function(a){a.update({},!1)});a.loading&&z(!0,this.options.loading,a.loading);d=m&&m.width;m=m&&m.height;c(d)&&d!==this.chartWidth||c(m)&&m!==this.chartHeight?this.setSize(d,m):b(h,!0)&&this.redraw()},setSubtitle:function(a){this.setTitle(void 0,a)}});q(t.prototype,{update:function(a,c,d,h){function k(){p.applyOptions(a);null===p.y&&u&&(p.graphic=u.destroy());e(a,!0)&&(u&&u.element&&a&&a.marker&&a.marker.symbol&&
(p.graphic=u.destroy()),a&&a.dataLabels&&p.dataLabel&&(p.dataLabel=p.dataLabel.destroy()));x=p.index;f.updateParallelArrays(p,x);t.data[x]=e(t.data[x],!0)||e(a,!0)?p.options:a;f.isDirty=f.isDirtyData=!0;!f.fixedBox&&f.hasCartesianSeries&&(g.isDirtyBox=!0);"point"===t.legendType&&(g.isDirtyLegend=!0);c&&g.redraw(d)}var p=this,f=p.series,u=p.graphic,x,g=f.chart,t=f.options;c=b(c,!0);!1===h?k():p.firePointEvent("update",{options:a},k)},remove:function(a,b){this.series.removePoint(f(this,this.series.data),
a,b)}});q(h.prototype,{addPoint:function(a,c,d,h){var k=this.options,e=this.data,p=this.chart,f=this.xAxis,f=f&&f.hasNames&&f.names,u=k.data,g,x,t=this.xData,l,n;c=b(c,!0);g={series:this};this.pointClass.prototype.applyOptions.apply(g,[a]);n=g.x;l=t.length;if(this.requireSorting&&n<t[l-1])for(x=!0;l&&t[l-1]>n;)l--;this.updateParallelArrays(g,"splice",l,0,0);this.updateParallelArrays(g,l);f&&g.name&&(f[n]=g.name);u.splice(l,0,a);x&&(this.data.splice(l,0,null),this.processData());"point"===k.legendType&&
this.generatePoints();d&&(e[0]&&e[0].remove?e[0].remove(!1):(e.shift(),this.updateParallelArrays(g,"shift"),u.shift()));this.isDirtyData=this.isDirty=!0;c&&p.redraw(h)},removePoint:function(a,c,d){var k=this,m=k.data,h=m[a],e=k.points,f=k.chart,x=function(){e&&e.length===m.length&&e.splice(a,1);m.splice(a,1);k.options.data.splice(a,1);k.updateParallelArrays(h||{series:k},"splice",a,1);h&&h.destroy();k.isDirty=!0;k.isDirtyData=!0;c&&f.redraw()};p(d,f);c=b(c,!0);h?h.firePointEvent("remove",null,x):
x()},remove:function(a,c,d){function k(){m.destroy();h.isDirtyLegend=h.isDirtyBox=!0;h.linkSeries();b(a,!0)&&h.redraw(c)}var m=this,h=m.chart;!1!==d?n(m,"remove",null,k):k()},update:function(a,c){var d=this,k=this.chart,m=this.userOptions,h=this.oldType||this.type,e=a.type||m.type||k.options.chart.type,p=B[h].prototype,f=["group","markerGroup","dataLabelsGroup"],g;if(e&&e!==h||void 0!==a.zIndex)f.length=0;r(f,function(a){f[a]=d[a];delete d[a]});a=z(m,{animation:!1,index:this.index,pointStart:this.xData[0]},
{data:this.options.data},a);this.remove(!1,null,!1);for(g in p)this[g]=void 0;q(this,B[e||h].prototype);r(f,function(a){d[a]=f[a]});this.init(k,a);this.oldType=h;k.linkSeries();b(c,!0)&&k.redraw(!1)}});q(G.prototype,{update:function(a,c){var d=this.chart;a=d.options[this.coll][this.options.index]=z(this.userOptions,a);this.destroy(!0);this.init(d,q(a,{events:void 0}));d.isDirtyBox=!0;b(c,!0)&&d.redraw()},remove:function(a){for(var c=this.chart,d=this.coll,k=this.series,m=k.length;m--;)k[m]&&k[m].remove(!1);
w(c.axes,this);w(c[d],this);c.options[d].splice(this.options.index,1);r(c[d],function(a,b){a.options.index=b});this.destroy();c.isDirtyBox=!0;b(a,!0)&&c.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}})})(K);(function(a){var D=a.color,C=a.each,G=a.map,H=a.pick,v=a.Series,l=a.seriesType;l("area","line",{softThreshold:!1,threshold:0},{singleStacks:!1,getStackPoints:function(){var a=[],l=[],q=this.xAxis,n=this.yAxis,f=n.stacks[this.stackKey],
c={},e=this.points,z=this.index,b=n.series,t=b.length,h,B=H(n.options.reversedStacks,!0)?1:-1,p,x;if(this.options.stacking){for(p=0;p<e.length;p++)c[e[p].x]=e[p];for(x in f)null!==f[x].total&&l.push(x);l.sort(function(a,b){return a-b});h=G(b,function(){return this.visible});C(l,function(b,e){var d=0,k,m;if(c[b]&&!c[b].isNull)a.push(c[b]),C([-1,1],function(a){var d=1===a?"rightNull":"leftNull",x=0,u=f[l[e+a]];if(u)for(p=z;0<=p&&p<t;)k=u.points[p],k||(p===z?c[b][d]=!0:h[p]&&(m=f[b].points[p])&&(x-=
m[1]-m[0])),p+=B;c[b][1===a?"rightCliff":"leftCliff"]=x});else{for(p=z;0<=p&&p<t;){if(k=f[b].points[p]){d=k[1];break}p+=B}d=n.translate(d,0,1,0,1);a.push({isNull:!0,plotX:q.translate(b,0,0,0,1),x:b,plotY:d,yBottom:d})}})}return a},getGraphPath:function(a){var l=v.prototype.getGraphPath,q=this.options,n=q.stacking,f=this.yAxis,c,e,z=[],b=[],t=this.index,h,r=f.stacks[this.stackKey],p=q.threshold,x=f.getThreshold(q.threshold),k,q=q.connectNulls||"percent"===n,F=function(c,k,m){var d=a[c];c=n&&r[d.x].points[t];
var e=d[m+"Null"]||0;m=d[m+"Cliff"]||0;var u,l,d=!0;m||e?(u=(e?c[0]:c[1])+m,l=c[0]+m,d=!!e):!n&&a[k]&&a[k].isNull&&(u=l=p);void 0!==u&&(b.push({plotX:h,plotY:null===u?x:f.getThreshold(u),isNull:d,isCliff:!0}),z.push({plotX:h,plotY:null===l?x:f.getThreshold(l),doCurve:!1}))};a=a||this.points;n&&(a=this.getStackPoints());for(c=0;c<a.length;c++)if(e=a[c].isNull,h=H(a[c].rectPlotX,a[c].plotX),k=H(a[c].yBottom,x),!e||q)q||F(c,c-1,"left"),e&&!n&&q||(b.push(a[c]),z.push({x:c,plotX:h,plotY:k})),q||F(c,c+
1,"right");c=l.call(this,b,!0,!0);z.reversed=!0;e=l.call(this,z,!0,!0);e.length&&(e[0]="L");e=c.concat(e);l=l.call(this,b,!1,q);e.xMap=c.xMap;this.areaPath=e;return l},drawGraph:function(){this.areaPath=[];v.prototype.drawGraph.apply(this);var a=this,l=this.areaPath,q=this.options,n=[["area","highcharts-area",this.color,q.fillColor]];C(this.zones,function(f,c){n.push(["zone-area-"+c,"highcharts-area highcharts-zone-area-"+c+" "+f.className,f.color||a.color,f.fillColor||q.fillColor])});C(n,function(f){var c=
f[0],e=a[c];e?(e.endX=l.xMap,e.animate({d:l})):(e=a[c]=a.chart.renderer.path(l).addClass(f[1]).attr({fill:H(f[3],D(f[2]).setOpacity(H(q.fillOpacity,.75)).get()),zIndex:0}).add(a.group),e.isArea=!0);e.startX=l.xMap;e.shiftUnit=q.step?2:1})},drawLegendSymbol:a.LegendSymbolMixin.drawRectangle})})(K);(function(a){var D=a.pick;a=a.seriesType;a("spline","line",{},{getPointSpline:function(a,G,H){var v=G.plotX,l=G.plotY,r=a[H-1];H=a[H+1];var w,q,n,f;if(r&&!r.isNull&&!1!==r.doCurve&&!G.isCliff&&H&&!H.isNull&&
!1!==H.doCurve&&!G.isCliff){a=r.plotY;n=H.plotX;H=H.plotY;var c=0;w=(1.5*v+r.plotX)/2.5;q=(1.5*l+a)/2.5;n=(1.5*v+n)/2.5;f=(1.5*l+H)/2.5;n!==w&&(c=(f-q)*(n-v)/(n-w)+l-f);q+=c;f+=c;q>a&&q>l?(q=Math.max(a,l),f=2*l-q):q<a&&q<l&&(q=Math.min(a,l),f=2*l-q);f>H&&f>l?(f=Math.max(H,l),q=2*l-f):f<H&&f<l&&(f=Math.min(H,l),q=2*l-f);G.rightContX=n;G.rightContY=f}G=["C",D(r.rightContX,r.plotX),D(r.rightContY,r.plotY),D(w,v),D(q,l),v,l];r.rightContX=r.rightContY=null;return G}})})(K);(function(a){var D=a.seriesTypes.area.prototype,
C=a.seriesType;C("areaspline","spline",a.defaultPlotOptions.area,{getStackPoints:D.getStackPoints,getGraphPath:D.getGraphPath,setStackCliffs:D.setStackCliffs,drawGraph:D.drawGraph,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle})})(K);(function(a){var D=a.animObject,C=a.color,G=a.each,H=a.extend,v=a.isNumber,l=a.merge,r=a.pick,w=a.Series,q=a.seriesType,n=a.svg;q("column","line",{borderRadius:0,crisp:!0,groupPadding:.2,marker:null,pointPadding:.1,minPointLength:0,cropThreshold:50,pointRange:null,
states:{hover:{halo:!1,brightness:.1,shadow:!1},select:{color:"#cccccc",borderColor:"#000000",shadow:!1}},dataLabels:{align:null,verticalAlign:null,y:null},softThreshold:!1,startFromThreshold:!0,stickyTracking:!1,tooltip:{distance:6},threshold:0,borderColor:"#ffffff"},{cropShoulder:0,directTouch:!0,trackerGroups:["group","dataLabelsGroup"],negStacks:!0,init:function(){w.prototype.init.apply(this,arguments);var a=this,c=a.chart;c.hasRendered&&G(c.series,function(c){c.type===a.type&&(c.isDirty=!0)})},
getColumnMetrics:function(){var a=this,c=a.options,e=a.xAxis,l=a.yAxis,b=e.reversed,t,h={},n=0;!1===c.grouping?n=1:G(a.chart.series,function(b){var c=b.options,k=b.yAxis,m;b.type===a.type&&b.visible&&l.len===k.len&&l.pos===k.pos&&(c.stacking?(t=b.stackKey,void 0===h[t]&&(h[t]=n++),m=h[t]):!1!==c.grouping&&(m=n++),b.columnIndex=m)});var p=Math.min(Math.abs(e.transA)*(e.ordinalSlope||c.pointRange||e.closestPointRange||e.tickInterval||1),e.len),x=p*c.groupPadding,k=(p-2*x)/(n||1),c=Math.min(c.maxPointWidth||
e.len,r(c.pointWidth,k*(1-2*c.pointPadding)));a.columnMetrics={width:c,offset:(k-c)/2+(x+((a.columnIndex||0)+(b?1:0))*k-p/2)*(b?-1:1)};return a.columnMetrics},crispCol:function(a,c,e,l){var b=this.chart,f=this.borderWidth,h=-(f%2?.5:0),f=f%2?.5:1;b.inverted&&b.renderer.isVML&&(f+=1);this.options.crisp&&(e=Math.round(a+e)+h,a=Math.round(a)+h,e-=a);l=Math.round(c+l)+f;h=.5>=Math.abs(c)&&.5<l;c=Math.round(c)+f;l-=c;h&&l&&(--c,l+=1);return{x:a,y:c,width:e,height:l}},translate:function(){var a=this,c=
a.chart,e=a.options,l=a.dense=2>a.closestPointRange*a.xAxis.transA,l=a.borderWidth=r(e.borderWidth,l?0:1),b=a.yAxis,t=a.translatedThreshold=b.getThreshold(e.threshold),h=r(e.minPointLength,5),n=a.getColumnMetrics(),p=n.width,x=a.barW=Math.max(p,1+2*l),k=a.pointXOffset=n.offset;c.inverted&&(t-=.5);e.pointPadding&&(x=Math.ceil(x));w.prototype.translate.apply(a);G(a.points,function(e){var d=r(e.yBottom,t),f=999+Math.abs(d),f=Math.min(Math.max(-f,e.plotY),b.len+f),m=e.plotX+k,l=x,n=Math.min(f,d),E,q=
Math.max(f,d)-n;Math.abs(q)<h&&h&&(q=h,E=!b.reversed&&!e.negative||b.reversed&&e.negative,n=Math.abs(n-t)>h?d-h:t-(E?h:0));e.barX=m;e.pointWidth=p;e.tooltipPos=c.inverted?[b.len+b.pos-c.plotLeft-f,a.xAxis.len-m-l/2,q]:[m+l/2,f+b.pos-c.plotTop,q];e.shapeType="rect";e.shapeArgs=a.crispCol.apply(a,e.isNull?[e.plotX,b.len/2,0,0]:[m,n,l,q])})},getSymbol:a.noop,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,drawGraph:function(){this.group[this.dense?"addClass":"removeClass"]("highcharts-dense-data")},
pointAttribs:function(a,c){var e=this.options,f,b=this.pointAttrToOptions||{};f=b.stroke||"borderColor";var t=b["stroke-width"]||"borderWidth",h=a&&a.color||this.color,n=a[f]||e[f]||this.color||h,p=a[t]||e[t]||this[t]||0,b=e.dashStyle;a&&this.zones.length&&(h=(h=a.getZone())&&h.color||a.options.color||this.color);c&&(a=l(e.states[c],a.options.states&&a.options.states[c]||{}),c=a.brightness,h=a.color||void 0!==c&&C(h).brighten(a.brightness).get()||h,n=a[f]||n,p=a[t]||p,b=a.dashStyle||b);f={fill:h,
stroke:n,"stroke-width":p};e.borderRadius&&(f.r=e.borderRadius);b&&(f.dashstyle=b);return f},drawPoints:function(){var a=this,c=this.chart,e=a.options,n=c.renderer,b=e.animationLimit||250,t;G(a.points,function(h){var f=h.graphic;if(v(h.plotY)&&null!==h.y){t=h.shapeArgs;if(f)f[c.pointCount<b?"animate":"attr"](l(t));else h.graphic=f=n[h.shapeType](t).add(h.group||a.group);f.attr(a.pointAttribs(h,h.selected&&"select")).shadow(e.shadow,null,e.stacking&&!e.borderRadius);f.addClass(h.getClassName(),!0)}else f&&
(h.graphic=f.destroy())})},animate:function(a){var c=this,e=this.yAxis,f=c.options,b=this.chart.inverted,t={};n&&(a?(t.scaleY=.001,a=Math.min(e.pos+e.len,Math.max(e.pos,e.toPixels(f.threshold))),b?t.translateX=a-e.len:t.translateY=a,c.group.attr(t)):(t[b?"translateX":"translateY"]=e.pos,c.group.animate(t,H(D(c.options.animation),{step:function(a,b){c.group.attr({scaleY:Math.max(.001,b.pos)})}})),c.animate=null))},remove:function(){var a=this,c=a.chart;c.hasRendered&&G(c.series,function(c){c.type===
a.type&&(c.isDirty=!0)});w.prototype.remove.apply(a,arguments)}})})(K);(function(a){a=a.seriesType;a("bar","column",null,{inverted:!0})})(K);(function(a){var D=a.Series;a=a.seriesType;a("scatter","line",{lineWidth:0,findNearestPointBy:"xy",marker:{enabled:!0},tooltip:{headerFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e \x3cspan style\x3d"font-size: 0.85em"\x3e {series.name}\x3c/span\x3e\x3cbr/\x3e',pointFormat:"x: \x3cb\x3e{point.x}\x3c/b\x3e\x3cbr/\x3ey: \x3cb\x3e{point.y}\x3c/b\x3e\x3cbr/\x3e"}},
{sorted:!1,requireSorting:!1,noSharedTooltip:!0,trackerGroups:["group","markerGroup","dataLabelsGroup"],takeOrdinalPosition:!1,drawGraph:function(){this.options.lineWidth&&D.prototype.drawGraph.call(this)}})})(K);(function(a){var D=a.pick,C=a.relativeLength;a.CenteredSeriesMixin={getCenter:function(){var a=this.options,H=this.chart,v=2*(a.slicedOffset||0),l=H.plotWidth-2*v,H=H.plotHeight-2*v,r=a.center,r=[D(r[0],"50%"),D(r[1],"50%"),a.size||"100%",a.innerSize||0],w=Math.min(l,H),q,n;for(q=0;4>q;++q)n=
r[q],a=2>q||2===q&&/%$/.test(n),r[q]=C(n,[l,H,w,r[2]][q])+(a?v:0);r[3]>r[2]&&(r[3]=r[2]);return r}}})(K);(function(a){var D=a.addEvent,C=a.defined,G=a.each,H=a.extend,v=a.inArray,l=a.noop,r=a.pick,w=a.Point,q=a.Series,n=a.seriesType,f=a.setAnimation;n("pie","line",{center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30,enabled:!0,formatter:function(){return null===this.y?void 0:this.point.name},x:0},ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,
stickyTracking:!1,tooltip:{followPointer:!0},borderColor:"#ffffff",borderWidth:1,states:{hover:{brightness:.1,shadow:!1}}},{isCartesian:!1,requireSorting:!1,directTouch:!0,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttribs:a.seriesTypes.column.prototype.pointAttribs,animate:function(a){var c=this,f=c.points,b=c.startAngleRad;a||(G(f,function(a){var h=a.graphic,e=a.shapeArgs;h&&(h.attr({r:a.startR||c.center[3]/2,start:b,end:b}),h.animate({r:e.r,start:e.start,end:e.end},
c.options.animation))}),c.animate=null)},updateTotals:function(){var a,e=0,f=this.points,b=f.length,t,h=this.options.ignoreHiddenPoint;for(a=0;a<b;a++)t=f[a],0>t.y&&(t.y=null),e+=h&&!t.visible?0:t.y;this.total=e;for(a=0;a<b;a++)t=f[a],t.percentage=0<e&&(t.visible||!h)?t.y/e*100:0,t.total=e},generatePoints:function(){q.prototype.generatePoints.call(this);this.updateTotals()},translate:function(a){this.generatePoints();var c=0,f=this.options,b=f.slicedOffset,t=b+(f.borderWidth||0),h,l,p,x=f.startAngle||
0,k=this.startAngleRad=Math.PI/180*(x-90),x=(this.endAngleRad=Math.PI/180*(r(f.endAngle,x+360)-90))-k,n=this.points,d=f.dataLabels.distance,f=f.ignoreHiddenPoint,u,m=n.length,y;a||(this.center=a=this.getCenter());this.getX=function(b,c){p=Math.asin(Math.min((b-a[1])/(a[2]/2+d),1));return a[0]+(c?-1:1)*Math.cos(p)*(a[2]/2+d)};for(u=0;u<m;u++){y=n[u];h=k+c*x;if(!f||y.visible)c+=y.percentage/100;l=k+c*x;y.shapeType="arc";y.shapeArgs={x:a[0],y:a[1],r:a[2]/2,innerR:a[3]/2,start:Math.round(1E3*h)/1E3,end:Math.round(1E3*
l)/1E3};p=(l+h)/2;p>1.5*Math.PI?p-=2*Math.PI:p<-Math.PI/2&&(p+=2*Math.PI);y.slicedTranslation={translateX:Math.round(Math.cos(p)*b),translateY:Math.round(Math.sin(p)*b)};h=Math.cos(p)*a[2]/2;l=Math.sin(p)*a[2]/2;y.tooltipPos=[a[0]+.7*h,a[1]+.7*l];y.half=p<-Math.PI/2||p>Math.PI/2?1:0;y.angle=p;t=Math.min(t,d/5);y.labelPos=[a[0]+h+Math.cos(p)*d,a[1]+l+Math.sin(p)*d,a[0]+h+Math.cos(p)*t,a[1]+l+Math.sin(p)*t,a[0]+h,a[1]+l,0>d?"center":y.half?"right":"left",p]}},drawGraph:null,drawPoints:function(){var a=
this,e=a.chart.renderer,f,b,t,h,l=a.options.shadow;l&&!a.shadowGroup&&(a.shadowGroup=e.g("shadow").add(a.group));G(a.points,function(c){if(null!==c.y){b=c.graphic;h=c.shapeArgs;f=c.getTranslate();var p=c.shadowGroup;l&&!p&&(p=c.shadowGroup=e.g("shadow").add(a.shadowGroup));p&&p.attr(f);t=a.pointAttribs(c,c.selected&&"select");b?b.setRadialReference(a.center).attr(t).animate(H(h,f)):(c.graphic=b=e[c.shapeType](h).setRadialReference(a.center).attr(f).add(a.group),c.visible||b.attr({visibility:"hidden"}),
b.attr(t).attr({"stroke-linejoin":"round"}).shadow(l,p));b.addClass(c.getClassName())}})},searchPoint:l,sortByAngle:function(a,e){a.sort(function(a,b){return void 0!==a.angle&&(b.angle-a.angle)*e})},drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,getCenter:a.CenteredSeriesMixin.getCenter,getSymbol:l},{init:function(){w.prototype.init.apply(this,arguments);var a=this,e;a.name=r(a.name,"Slice");e=function(c){a.slice("select"===c.type)};D(a,"select",e);D(a,"unselect",e);return a},setVisible:function(a,
e){var c=this,b=c.series,f=b.chart,h=b.options.ignoreHiddenPoint;e=r(e,h);a!==c.visible&&(c.visible=c.options.visible=a=void 0===a?!c.visible:a,b.options.data[v(c,b.data)]=c.options,G(["graphic","dataLabel","connector","shadowGroup"],function(b){if(c[b])c[b][a?"show":"hide"](!0)}),c.legendItem&&f.legend.colorizeItem(c,a),a||"hover"!==c.state||c.setState(""),h&&(b.isDirty=!0),e&&f.redraw())},slice:function(a,e,l){var b=this.series;f(l,b.chart);r(e,!0);this.sliced=this.options.sliced=C(a)?a:!this.sliced;
b.options.data[v(this,b.data)]=this.options;this.graphic.animate(this.getTranslate());this.shadowGroup&&this.shadowGroup.animate(this.getTranslate())},getTranslate:function(){return this.sliced?this.slicedTranslation:{translateX:0,translateY:0}},haloPath:function(a){var c=this.shapeArgs;return this.sliced||!this.visible?[]:this.series.chart.renderer.symbols.arc(c.x,c.y,c.r+a,c.r+a,{innerR:this.shapeArgs.r,start:c.start,end:c.end})}})})(K);(function(a){var D=a.addEvent,C=a.arrayMax,G=a.defined,H=a.each,
v=a.extend,l=a.format,r=a.map,w=a.merge,q=a.noop,n=a.pick,f=a.relativeLength,c=a.Series,e=a.seriesTypes,z=a.stableSort;a.distribute=function(a,c){function b(a,b){return a.target-b.target}var e,p=!0,f=a,k=[],l;l=0;for(e=a.length;e--;)l+=a[e].size;if(l>c){z(a,function(a,b){return(b.rank||0)-(a.rank||0)});for(l=e=0;l<=c;)l+=a[e].size,e++;k=a.splice(e-1,a.length)}z(a,b);for(a=r(a,function(a){return{size:a.size,targets:[a.target]}});p;){for(e=a.length;e--;)p=a[e],l=(Math.min.apply(0,p.targets)+Math.max.apply(0,
p.targets))/2,p.pos=Math.min(Math.max(0,l-p.size/2),c-p.size);e=a.length;for(p=!1;e--;)0<e&&a[e-1].pos+a[e-1].size>a[e].pos&&(a[e-1].size+=a[e].size,a[e-1].targets=a[e-1].targets.concat(a[e].targets),a[e-1].pos+a[e-1].size>c&&(a[e-1].pos=c-a[e-1].size),a.splice(e,1),p=!0)}e=0;H(a,function(a){var b=0;H(a.targets,function(){f[e].pos=a.pos+b;b+=f[e].size;e++})});f.push.apply(f,k);z(f,b)};c.prototype.drawDataLabels=function(){var a=this,c=a.options,h=c.dataLabels,e=a.points,p,f,k=a.hasRendered||0,q,d,
u=n(h.defer,!0),m=a.chart.renderer;if(h.enabled||a._hasPointLabels)a.dlProcessOptions&&a.dlProcessOptions(h),d=a.plotGroup("dataLabelsGroup","data-labels",u&&!k?"hidden":"visible",h.zIndex||6),u&&(d.attr({opacity:+k}),k||D(a,"afterAnimate",function(){a.visible&&d.show(!0);d[c.animation?"animate":"attr"]({opacity:1},{duration:200})})),f=h,H(e,function(b){var k,e=b.dataLabel,x,g,t,u=b.connector,y=!e,r;p=b.dlOptions||b.options&&b.options.dataLabels;if(k=n(p&&p.enabled,f.enabled)&&null!==b.y)for(g in h=
w(f,p),x=b.getLabelConfig(),q=h.format?l(h.format,x):h.formatter.call(x,h),r=h.style,t=h.rotation,r.color=n(h.color,r.color,a.color,"#000000"),"contrast"===r.color&&(b.contrastColor=m.getContrast(b.color||a.color),r.color=h.inside||0>h.distance||c.stacking?b.contrastColor:"#000000"),c.cursor&&(r.cursor=c.cursor),x={fill:h.backgroundColor,stroke:h.borderColor,"stroke-width":h.borderWidth,r:h.borderRadius||0,rotation:t,padding:h.padding,zIndex:1},x)void 0===x[g]&&delete x[g];!e||k&&G(q)?k&&G(q)&&(e?
x.text=q:(e=b.dataLabel=m[t?"text":"label"](q,0,-9999,h.shape,null,null,h.useHTML,null,"data-label"),e.addClass("highcharts-data-label-color-"+b.colorIndex+" "+(h.className||"")+(h.useHTML?"highcharts-tracker":""))),e.attr(x),e.css(r).shadow(h.shadow),e.added||e.add(d),a.alignDataLabel(b,e,h,null,y)):(b.dataLabel=e.destroy(),u&&(b.connector=u.destroy()))})};c.prototype.alignDataLabel=function(a,c,h,e,p){var b=this.chart,k=b.inverted,f=n(a.plotX,-9999),d=n(a.plotY,-9999),l=c.getBBox(),m,t=h.rotation,
q=h.align,E=this.visible&&(a.series.forceDL||b.isInsidePlot(f,Math.round(d),k)||e&&b.isInsidePlot(f,k?e.x+1:e.y+e.height-1,k)),r="justify"===n(h.overflow,"justify");E&&(m=h.style.fontSize,m=b.renderer.fontMetrics(m,c).b,e=v({x:k?b.plotWidth-d:f,y:Math.round(k?b.plotHeight-f:d),width:0,height:0},e),v(h,{width:l.width,height:l.height}),t?(r=!1,k=b.renderer.rotCorr(m,t),k={x:e.x+h.x+e.width/2+k.x,y:e.y+h.y+{top:0,middle:.5,bottom:1}[h.verticalAlign]*e.height},c[p?"attr":"animate"](k).attr({align:q}),
f=(t+720)%360,f=180<f&&360>f,"left"===q?k.y-=f?l.height:0:"center"===q?(k.x-=l.width/2,k.y-=l.height/2):"right"===q&&(k.x-=l.width,k.y-=f?0:l.height)):(c.align(h,null,e),k=c.alignAttr),r?a.isLabelJustified=this.justifyDataLabel(c,h,k,l,e,p):n(h.crop,!0)&&(E=b.isInsidePlot(k.x,k.y)&&b.isInsidePlot(k.x+l.width,k.y+l.height)),h.shape&&!t&&c.attr({anchorX:a.plotX,anchorY:a.plotY}));E||(c.attr({y:-9999}),c.placed=!1)};c.prototype.justifyDataLabel=function(a,c,e,f,p,l){var b=this.chart,h=c.align,d=c.verticalAlign,
x,m,t=a.box?0:a.padding||0;x=e.x+t;0>x&&("right"===h?c.align="left":c.x=-x,m=!0);x=e.x+f.width-t;x>b.plotWidth&&("left"===h?c.align="right":c.x=b.plotWidth-x,m=!0);x=e.y+t;0>x&&("bottom"===d?c.verticalAlign="top":c.y=-x,m=!0);x=e.y+f.height-t;x>b.plotHeight&&("top"===d?c.verticalAlign="bottom":c.y=b.plotHeight-x,m=!0);m&&(a.placed=!l,a.align(c,null,p));return m};e.pie&&(e.pie.prototype.drawDataLabels=function(){var b=this,e=b.data,h,f=b.chart,p=b.options.dataLabels,x=n(p.connectorPadding,10),k=n(p.connectorWidth,
1),l=f.plotWidth,d=f.plotHeight,u,m=p.distance,y=b.center,q=y[2]/2,E=y[1],z=0<m,g,v,w,D,M=[[],[]],G,A,Q,S,N=[0,0,0,0];b.visible&&(p.enabled||b._hasPointLabels)&&(H(e,function(a){a.dataLabel&&a.visible&&a.dataLabel.shortened&&(a.dataLabel.attr({width:"auto"}).css({width:"auto",textOverflow:"clip"}),a.dataLabel.shortened=!1)}),c.prototype.drawDataLabels.apply(b),H(e,function(a){a.dataLabel&&a.visible&&(M[a.half].push(a),a.dataLabel._pos=null)}),H(M,function(c,k){var e,t,u=c.length,n,z,I;if(u)for(b.sortByAngle(c,
k-.5),0<m&&(e=Math.max(0,E-q-m),t=Math.min(E+q+m,f.plotHeight),n=r(c,function(a){if(a.dataLabel)return I=a.dataLabel.getBBox().height||21,{target:a.labelPos[1]-e+I/2,size:I,rank:a.y}}),a.distribute(n,t+I-e)),S=0;S<u;S++)h=c[S],w=h.labelPos,g=h.dataLabel,Q=!1===h.visible?"hidden":"inherit",z=w[1],n?void 0===n[S].pos?Q="hidden":(D=n[S].size,A=e+n[S].pos):A=z,G=p.justify?y[0]+(k?-1:1)*(q+m):b.getX(A<e+2||A>t-2?z:A,k),g._attr={visibility:Q,align:w[6]},g._pos={x:G+p.x+({left:x,right:-x}[w[6]]||0),y:A+
p.y-10},w.x=G,w.y=A,null===b.options.size&&(v=g.getBBox().width,z=null,G-v<x?(z=Math.round(v-G+x),N[3]=Math.max(z,N[3])):G+v>l-x&&(z=Math.round(G+v-l+x),N[1]=Math.max(z,N[1])),0>A-D/2?N[0]=Math.max(Math.round(-A+D/2),N[0]):A+D/2>d&&(N[2]=Math.max(Math.round(A+D/2-d),N[2])),g.sideOverflow=z)}),0===C(N)||this.verifyDataLabelOverflow(N))&&(this.placeDataLabels(),z&&k&&H(this.points,function(a){var c;u=a.connector;if((g=a.dataLabel)&&g._pos&&a.visible){Q=g._attr.visibility;if(c=!u)a.connector=u=f.renderer.path().addClass("highcharts-data-label-connector highcharts-color-"+
a.colorIndex).add(b.dataLabelsGroup),u.attr({"stroke-width":k,stroke:p.connectorColor||a.color||"#666666"});u[c?"attr":"animate"]({d:b.connectorPath(a.labelPos)});u.attr("visibility",Q)}else u&&(a.connector=u.destroy())}))},e.pie.prototype.connectorPath=function(a){var b=a.x,c=a.y;return n(this.options.dataLabels.softConnector,!0)?["M",b+("left"===a[6]?5:-5),c,"C",b,c,2*a[2]-a[4],2*a[3]-a[5],a[2],a[3],"L",a[4],a[5]]:["M",b+("left"===a[6]?5:-5),c,"L",a[2],a[3],"L",a[4],a[5]]},e.pie.prototype.placeDataLabels=
function(){H(this.points,function(a){var b=a.dataLabel;b&&a.visible&&((a=b._pos)?(b.sideOverflow&&(b._attr.width=b.getBBox().width-b.sideOverflow,b.css({width:b._attr.width+"px",textOverflow:"ellipsis"}),b.shortened=!0),b.attr(b._attr),b[b.moved?"animate":"attr"](a),b.moved=!0):b&&b.attr({y:-9999}))},this)},e.pie.prototype.alignDataLabel=q,e.pie.prototype.verifyDataLabelOverflow=function(a){var b=this.center,c=this.options,e=c.center,p=c.minSize||80,l,k;null!==e[0]?l=Math.max(b[2]-Math.max(a[1],a[3]),
p):(l=Math.max(b[2]-a[1]-a[3],p),b[0]+=(a[3]-a[1])/2);null!==e[1]?l=Math.max(Math.min(l,b[2]-Math.max(a[0],a[2])),p):(l=Math.max(Math.min(l,b[2]-a[0]-a[2]),p),b[1]+=(a[0]-a[2])/2);l<b[2]?(b[2]=l,b[3]=Math.min(f(c.innerSize||0,l),l),this.translate(b),this.drawDataLabels&&this.drawDataLabels()):k=!0;return k});e.column&&(e.column.prototype.alignDataLabel=function(a,e,h,f,p){var b=this.chart.inverted,k=a.series,l=a.dlBox||a.shapeArgs,d=n(a.below,a.plotY>n(this.translatedThreshold,k.yAxis.len)),u=n(h.inside,
!!this.options.stacking);l&&(f=w(l),0>f.y&&(f.height+=f.y,f.y=0),l=f.y+f.height-k.yAxis.len,0<l&&(f.height-=l),b&&(f={x:k.yAxis.len-f.y-f.height,y:k.xAxis.len-f.x-f.width,width:f.height,height:f.width}),u||(b?(f.x+=d?0:f.width,f.width=0):(f.y+=d?f.height:0,f.height=0)));h.align=n(h.align,!b||u?"center":d?"right":"left");h.verticalAlign=n(h.verticalAlign,b||u?"middle":d?"top":"bottom");c.prototype.alignDataLabel.call(this,a,e,h,f,p);a.isLabelJustified&&a.contrastColor&&a.dataLabel.css({color:a.contrastColor})})})(K);
(function(a){var D=a.Chart,C=a.each,G=a.pick,H=a.addEvent;D.prototype.callbacks.push(function(a){function l(){var l=[];C(a.series||[],function(a){var q=a.options.dataLabels,n=a.dataLabelCollections||["dataLabel"];(q.enabled||a._hasPointLabels)&&!q.allowOverlap&&a.visible&&C(n,function(f){C(a.points,function(a){a[f]&&(a[f].labelrank=G(a.labelrank,a.shapeArgs&&a.shapeArgs.height),l.push(a[f]))})})});a.hideOverlappingLabels(l)}l();H(a,"redraw",l)});D.prototype.hideOverlappingLabels=function(a){var l=
a.length,r,w,q,n,f,c,e,z,b,t=function(a,b,c,e,k,f,d,l){return!(k>a+c||k+d<a||f>b+e||f+l<b)};for(w=0;w<l;w++)if(r=a[w])r.oldOpacity=r.opacity,r.newOpacity=1;a.sort(function(a,b){return(b.labelrank||0)-(a.labelrank||0)});for(w=0;w<l;w++)for(q=a[w],r=w+1;r<l;++r)if(n=a[r],q&&n&&q!==n&&q.placed&&n.placed&&0!==q.newOpacity&&0!==n.newOpacity&&(f=q.alignAttr,c=n.alignAttr,e=q.parentGroup,z=n.parentGroup,b=2*(q.box?0:q.padding),f=t(f.x+e.translateX,f.y+e.translateY,q.width-b,q.height-b,c.x+z.translateX,c.y+
z.translateY,n.width-b,n.height-b)))(q.labelrank<n.labelrank?q:n).newOpacity=0;C(a,function(a){var b,c;a&&(c=a.newOpacity,a.oldOpacity!==c&&a.placed&&(c?a.show(!0):b=function(){a.hide()},a.alignAttr.opacity=c,a[a.isOld?"animate":"attr"](a.alignAttr,null,b)),a.isOld=!0)})}})(K);(function(a){var D=a.addEvent,C=a.Chart,G=a.createElement,H=a.css,v=a.defaultOptions,l=a.defaultPlotOptions,r=a.each,w=a.extend,q=a.fireEvent,n=a.hasTouch,f=a.inArray,c=a.isObject,e=a.Legend,z=a.merge,b=a.pick,t=a.Point,h=a.Series,
B=a.seriesTypes,p=a.svg;a=a.TrackerMixin={drawTrackerPoint:function(){var a=this,b=a.chart.pointer,c=function(a){var c=b.getPointFromEvent(a);if(void 0!==c)c.onMouseOver(a)};r(a.points,function(a){a.graphic&&(a.graphic.element.point=a);a.dataLabel&&(a.dataLabel.div?a.dataLabel.div.point=a:a.dataLabel.element.point=a)});a._hasTracking||(r(a.trackerGroups,function(d){if(a[d]){a[d].addClass("highcharts-tracker").on("mouseover",c).on("mouseout",function(a){b.onTrackerMouseOut(a)});if(n)a[d].on("touchstart",
c);a.options.cursor&&a[d].css(H).css({cursor:a.options.cursor})}}),a._hasTracking=!0)},drawTrackerGraph:function(){var a=this,b=a.options,c=b.trackByArea,d=[].concat(c?a.areaPath:a.graphPath),e=d.length,m=a.chart,h=m.pointer,f=m.renderer,l=m.options.tooltip.snap,t=a.tracker,g,q=function(){if(m.hoverSeries!==a)a.onMouseOver()},z="rgba(192,192,192,"+(p?.0001:.002)+")";if(e&&!c)for(g=e+1;g--;)"M"===d[g]&&d.splice(g+1,0,d[g+1]-l,d[g+2],"L"),(g&&"M"===d[g]||g===e)&&d.splice(g,0,"L",d[g-2]+l,d[g-1]);t?
t.attr({d:d}):a.graph&&(a.tracker=f.path(d).attr({"stroke-linejoin":"round",visibility:a.visible?"visible":"hidden",stroke:z,fill:c?z:"none","stroke-width":a.graph.strokeWidth()+(c?0:2*l),zIndex:2}).add(a.group),r([a.tracker,a.markerGroup],function(a){a.addClass("highcharts-tracker").on("mouseover",q).on("mouseout",function(a){h.onTrackerMouseOut(a)});b.cursor&&a.css({cursor:b.cursor});if(n)a.on("touchstart",q)}))}};B.column&&(B.column.prototype.drawTracker=a.drawTrackerPoint);B.pie&&(B.pie.prototype.drawTracker=
a.drawTrackerPoint);B.scatter&&(B.scatter.prototype.drawTracker=a.drawTrackerPoint);w(e.prototype,{setItemEvents:function(a,b,c){var d=this,k=d.chart.renderer.boxWrapper,e="highcharts-legend-"+(a.series?"point":"series")+"-active";(c?b:a.legendGroup).on("mouseover",function(){a.setState("hover");k.addClass(e);b.css(d.options.itemHoverStyle)}).on("mouseout",function(){b.css(a.visible?d.itemStyle:d.itemHiddenStyle);k.removeClass(e);a.setState()}).on("click",function(b){var c=function(){a.setVisible&&
a.setVisible()};b={browserEvent:b};a.firePointEvent?a.firePointEvent("legendItemClick",b,c):q(a,"legendItemClick",b,c)})},createCheckboxForItem:function(a){a.checkbox=G("input",{type:"checkbox",checked:a.selected,defaultChecked:a.selected},this.options.itemCheckboxStyle,this.chart.container);D(a.checkbox,"click",function(b){q(a.series||a,"checkboxClick",{checked:b.target.checked,item:a},function(){a.select()})})}});v.legend.itemStyle.cursor="pointer";w(C.prototype,{showResetZoom:function(){var a=
this,b=v.lang,c=a.options.chart.resetZoomButton,d=c.theme,e=d.states,m="chart"===c.relativeTo?null:"plotBox";this.resetZoomButton=a.renderer.button(b.resetZoom,null,null,function(){a.zoomOut()},d,e&&e.hover).attr({align:c.position.align,title:b.resetZoomTitle}).addClass("highcharts-reset-zoom").add().align(c.position,!1,m)},zoomOut:function(){var a=this;q(a,"selection",{resetSelection:!0},function(){a.zoom()})},zoom:function(a){var k,e=this.pointer,d=!1,h;!a||a.resetSelection?r(this.axes,function(a){k=
a.zoom()}):r(a.xAxis.concat(a.yAxis),function(a){var b=a.axis;e[b.isXAxis?"zoomX":"zoomY"]&&(k=b.zoom(a.min,a.max),b.displayBtn&&(d=!0))});h=this.resetZoomButton;d&&!h?this.showResetZoom():!d&&c(h)&&(this.resetZoomButton=h.destroy());k&&this.redraw(b(this.options.chart.animation,a&&a.animation,100>this.pointCount))},pan:function(a,b){var c=this,d=c.hoverPoints,k;d&&r(d,function(a){a.setState()});r("xy"===b?[1,0]:[1],function(b){b=c[b?"xAxis":"yAxis"][0];var d=b.horiz,e=a[d?"chartX":"chartY"],d=d?
"mouseDownX":"mouseDownY",m=c[d],h=(b.pointRange||0)/2,g=b.getExtremes(),f=b.toValue(m-e,!0)+h,h=b.toValue(m+b.len-e,!0)-h,p=h<f,m=p?h:f,f=p?f:h,p=b.toValue(b.toPixels(g.min)-b.minPixelPadding),h=b.toValue(b.toPixels(g.max)+b.minPixelPadding),p=Math.min(g.dataMin,p)-m,g=f-Math.max(g.dataMax,h);b.series.length&&0>p&&0>g&&(b.setExtremes(m,f,!1,!1,{trigger:"pan"}),k=!0);c[d]=e});k&&c.redraw(!1);H(c.container,{cursor:"move"})}});w(t.prototype,{select:function(a,c){var k=this,d=k.series,e=d.chart;a=b(a,
!k.selected);k.firePointEvent(a?"select":"unselect",{accumulate:c},function(){k.selected=k.options.selected=a;d.options.data[f(k,d.data)]=k.options;k.setState(a&&"select");c||r(e.getSelectedPoints(),function(a){a.selected&&a!==k&&(a.selected=a.options.selected=!1,d.options.data[f(a,d.data)]=a.options,a.setState(""),a.firePointEvent("unselect"))})})},onMouseOver:function(a){var b=this.series.chart.pointer;this.firePointEvent("mouseOver");b.runPointActions(a,this)},onMouseOut:function(){var a=this.series.chart;
this.firePointEvent("mouseOut");r(a.hoverPoints||[],function(a){a.setState()});a.hoverPoints=a.hoverPoint=null},importEvents:function(){if(!this.hasImportedEvents){var a=z(this.series.options.point,this.options).events,b;this.events=a;for(b in a)D(this,b,a[b]);this.hasImportedEvents=!0}},setState:function(a,c){var k=Math.floor(this.plotX),d=this.plotY,e=this.series,h=e.options.states[a]||{},f=l[e.type].marker&&e.options.marker,p=f&&!1===f.enabled,t=f&&f.states&&f.states[a]||{},n=!1===t.enabled,g=
e.stateMarkerGraphic,x=this.marker||{},q=e.chart,r=e.halo,z,v=f&&e.markerAttribs;a=a||"";if(!(a===this.state&&!c||this.selected&&"select"!==a||!1===h.enabled||a&&(n||p&&!1===t.enabled)||a&&x.states&&x.states[a]&&!1===x.states[a].enabled)){v&&(z=e.markerAttribs(this,a));if(this.graphic)this.state&&this.graphic.removeClass("highcharts-point-"+this.state),a&&this.graphic.addClass("highcharts-point-"+a),this.graphic.attr(e.pointAttribs(this,a)),z&&this.graphic.animate(z,b(q.options.chart.animation,t.animation,
f.animation)),g&&g.hide();else{if(a&&t){f=x.symbol||e.symbol;g&&g.currentSymbol!==f&&(g=g.destroy());if(g)g[c?"animate":"attr"]({x:z.x,y:z.y});else f&&(e.stateMarkerGraphic=g=q.renderer.symbol(f,z.x,z.y,z.width,z.height).add(e.markerGroup),g.currentSymbol=f);g&&g.attr(e.pointAttribs(this,a))}g&&(g[a&&q.isInsidePlot(k,d,q.inverted)?"show":"hide"](),g.element.point=this)}(k=h.halo)&&k.size?(r||(e.halo=r=q.renderer.path().add(v?e.markerGroup:e.group)),r[c?"animate":"attr"]({d:this.haloPath(k.size)}),
r.attr({"class":"highcharts-halo highcharts-color-"+b(this.colorIndex,e.colorIndex)}),r.point=this,r.attr(w({fill:this.color||e.color,"fill-opacity":k.opacity,zIndex:-1},k.attributes))):r&&r.point&&r.point.haloPath&&r.animate({d:r.point.haloPath(0)});this.state=a}},haloPath:function(a){return this.series.chart.renderer.symbols.circle(Math.floor(this.plotX)-a,this.plotY-a,2*a,2*a)}});w(h.prototype,{onMouseOver:function(){var a=this.chart,b=a.hoverSeries;if(b&&b!==this)b.onMouseOut();this.options.events.mouseOver&&
q(this,"mouseOver");this.setState("hover");a.hoverSeries=this},onMouseOut:function(){var a=this.options,b=this.chart,c=b.tooltip,d=b.hoverPoint;b.hoverSeries=null;if(d)d.onMouseOut();this&&a.events.mouseOut&&q(this,"mouseOut");!c||this.stickyTracking||c.shared&&!this.noSharedTooltip||c.hide();this.setState()},setState:function(a){var c=this,e=c.options,d=c.graph,h=e.states,m=e.lineWidth,e=0;a=a||"";if(c.state!==a&&(r([c.group,c.markerGroup,c.dataLabelsGroup],function(b){b&&(c.state&&b.removeClass("highcharts-series-"+
c.state),a&&b.addClass("highcharts-series-"+a))}),c.state=a,!h[a]||!1!==h[a].enabled)&&(a&&(m=h[a].lineWidth||m+(h[a].lineWidthPlus||0)),d&&!d.dashstyle))for(m={"stroke-width":m},d.animate(m,b(c.chart.options.chart.animation,h[a]&&h[a].animation));c["zone-graph-"+e];)c["zone-graph-"+e].attr(m),e+=1},setVisible:function(a,b){var c=this,d=c.chart,e=c.legendItem,k,h=d.options.chart.ignoreHiddenSeries,f=c.visible;k=(c.visible=a=c.options.visible=c.userOptions.visible=void 0===a?!f:a)?"show":"hide";r(["group",
"dataLabelsGroup","markerGroup","tracker","tt"],function(a){if(c[a])c[a][k]()});if(d.hoverSeries===c||(d.hoverPoint&&d.hoverPoint.series)===c)c.onMouseOut();e&&d.legend.colorizeItem(c,a);c.isDirty=!0;c.options.stacking&&r(d.series,function(a){a.options.stacking&&a.visible&&(a.isDirty=!0)});r(c.linkedSeries,function(b){b.setVisible(a,!1)});h&&(d.isDirtyBox=!0);!1!==b&&d.redraw();q(c,k)},show:function(){this.setVisible(!0)},hide:function(){this.setVisible(!1)},select:function(a){this.selected=a=void 0===
a?!this.selected:a;this.checkbox&&(this.checkbox.checked=a);q(this,a?"select":"unselect")},drawTracker:a.drawTrackerGraph})})(K);(function(a){var D=a.Chart,C=a.each,G=a.inArray,H=a.isArray,v=a.isObject,l=a.pick,r=a.splat;D.prototype.setResponsive=function(l){var q=this.options.responsive,n=[],f=this.currentResponsive;q&&q.rules&&C(q.rules,function(c){void 0===c._id&&(c._id=a.uniqueKey());this.matchResponsiveRule(c,n,l)},this);var c=a.merge.apply(0,a.map(n,function(c){return a.find(q.rules,function(a){return a._id===
c}).chartOptions})),n=n.toString()||void 0;n!==(f&&f.ruleIds)&&(f&&this.update(f.undoOptions,l),n?(this.currentResponsive={ruleIds:n,mergedOptions:c,undoOptions:this.currentOptions(c)},this.update(c,l)):this.currentResponsive=void 0)};D.prototype.matchResponsiveRule=function(a,q){var n=a.condition;(n.callback||function(){return this.chartWidth<=l(n.maxWidth,Number.MAX_VALUE)&&this.chartHeight<=l(n.maxHeight,Number.MAX_VALUE)&&this.chartWidth>=l(n.minWidth,0)&&this.chartHeight>=l(n.minHeight,0)}).call(this)&&
q.push(a._id)};D.prototype.currentOptions=function(a){function l(a,c,e,n){var b,f;for(b in a)if(!n&&-1<G(b,["series","xAxis","yAxis"]))for(a[b]=r(a[b]),e[b]=[],f=0;f<a[b].length;f++)c[b][f]&&(e[b][f]={},l(a[b][f],c[b][f],e[b][f],n+1));else v(a[b])?(e[b]=H(a[b])?[]:{},l(a[b],c[b]||{},e[b],n+1)):e[b]=c[b]||null}var n={};l(a,this.options,n,0);return n}})(K);(function(a){var D=a.addEvent,C=a.Axis,G=a.Chart,H=a.css,v=a.dateFormat,l=a.defined,r=a.each,w=a.extend,q=a.noop,n=a.Series,f=a.timeUnits;a=a.wrap;
a(n.prototype,"init",function(a){var c;a.apply(this,Array.prototype.slice.call(arguments,1));(c=this.xAxis)&&c.options.ordinal&&D(this,"updatedData",function(){delete c.ordinalIndex})});a(C.prototype,"getTimeTicks",function(a,e,n,b,t,h,q,p){var c=0,k,r,d={},u,m,y,z=[],E=-Number.MAX_VALUE,w=this.options.tickPixelInterval;if(!this.options.ordinal&&!this.options.breaks||!h||3>h.length||void 0===n)return a.call(this,e,n,b,t);m=h.length;for(k=0;k<m;k++){y=k&&h[k-1]>b;h[k]<n&&(c=k);if(k===m-1||h[k+1]-h[k]>
5*q||y){if(h[k]>E){for(r=a.call(this,e,h[c],h[k],t);r.length&&r[0]<=E;)r.shift();r.length&&(E=r[r.length-1]);z=z.concat(r)}c=k+1}if(y)break}a=r.info;if(p&&a.unitRange<=f.hour){k=z.length-1;for(c=1;c<k;c++)v("%d",z[c])!==v("%d",z[c-1])&&(d[z[c]]="day",u=!0);u&&(d[z[0]]="day");a.higherRanks=d}z.info=a;if(p&&l(w)){p=a=z.length;k=[];var g;for(u=[];p--;)c=this.translate(z[p]),g&&(u[p]=g-c),k[p]=g=c;u.sort();u=u[Math.floor(u.length/2)];u<.6*w&&(u=null);p=z[a-1]>b?a-1:a;for(g=void 0;p--;)c=k[p],b=Math.abs(g-
c),g&&b<.8*w&&(null===u||b<.8*u)?(d[z[p]]&&!d[z[p+1]]?(b=p+1,g=c):b=p,z.splice(b,1)):g=c}return z});w(C.prototype,{beforeSetTickPositions:function(){var a,e=[],f=!1,b,l=this.getExtremes(),h=l.min,n=l.max,p,x=this.isXAxis&&!!this.options.breaks,l=this.options.ordinal,k=this.chart.options.chart.ignoreHiddenSeries;if(l||x){r(this.series,function(b,c){if(!(k&&!1===b.visible||!1===b.takeOrdinalPosition&&!x)&&(e=e.concat(b.processedXData),a=e.length,e.sort(function(a,b){return a-b}),a))for(c=a-1;c--;)e[c]===
e[c+1]&&e.splice(c,1)});a=e.length;if(2<a){b=e[1]-e[0];for(p=a-1;p--&&!f;)e[p+1]-e[p]!==b&&(f=!0);!this.options.keepOrdinalPadding&&(e[0]-h>b||n-e[e.length-1]>b)&&(f=!0)}f?(this.ordinalPositions=e,b=this.ordinal2lin(Math.max(h,e[0]),!0),p=Math.max(this.ordinal2lin(Math.min(n,e[e.length-1]),!0),1),this.ordinalSlope=n=(n-h)/(p-b),this.ordinalOffset=h-b*n):this.ordinalPositions=this.ordinalSlope=this.ordinalOffset=void 0}this.isOrdinal=l&&f;this.groupIntervalFactor=null},val2lin:function(a,e){var c=
this.ordinalPositions;if(c){var b=c.length,f,h;for(f=b;f--;)if(c[f]===a){h=f;break}for(f=b-1;f--;)if(a>c[f]||0===f){a=(a-c[f])/(c[f+1]-c[f]);h=f+a;break}e=e?h:this.ordinalSlope*(h||0)+this.ordinalOffset}else e=a;return e},lin2val:function(a,e){var c=this.ordinalPositions;if(c){var b=this.ordinalSlope,f=this.ordinalOffset,h=c.length-1,l;if(e)0>a?a=c[0]:a>h?a=c[h]:(h=Math.floor(a),l=a-h);else for(;h--;)if(e=b*h+f,a>=e){b=b*(h+1)+f;l=(a-e)/(b-e);break}return void 0!==l&&void 0!==c[h]?c[h]+(l?l*(c[h+
1]-c[h]):0):a}return a},getExtendedPositions:function(){var a=this.chart,e=this.series[0].currentDataGrouping,f=this.ordinalIndex,b=e?e.count+e.unitName:"raw",l=this.getExtremes(),h,n;f||(f=this.ordinalIndex={});f[b]||(h={series:[],chart:a,getExtremes:function(){return{min:l.dataMin,max:l.dataMax}},options:{ordinal:!0},val2lin:C.prototype.val2lin,ordinal2lin:C.prototype.ordinal2lin},r(this.series,function(b){n={xAxis:h,xData:b.xData,chart:a,destroyGroupedData:q};n.options={dataGrouping:e?{enabled:!0,
forced:!0,approximation:"open",units:[[e.unitName,[e.count]]]}:{enabled:!1}};b.processData.apply(n);h.series.push(n)}),this.beforeSetTickPositions.apply(h),f[b]=h.ordinalPositions);return f[b]},getGroupIntervalFactor:function(a,e,f){var b;f=f.processedXData;var c=f.length,h=[];b=this.groupIntervalFactor;if(!b){for(b=0;b<c-1;b++)h[b]=f[b+1]-f[b];h.sort(function(a,b){return a-b});h=h[Math.floor(c/2)];a=Math.max(a,f[0]);e=Math.min(e,f[c-1]);this.groupIntervalFactor=b=c*h/(e-a)}return b},postProcessTickInterval:function(a){var c=
this.ordinalSlope;return c?this.options.breaks?this.closestPointRange:a/(c/this.closestPointRange):a}});C.prototype.ordinal2lin=C.prototype.val2lin;a(G.prototype,"pan",function(a,e){var c=this.xAxis[0],b=e.chartX,f=!1;if(c.options.ordinal&&c.series.length){var h=this.mouseDownX,l=c.getExtremes(),p=l.dataMax,n=l.min,k=l.max,q=this.hoverPoints,d=c.closestPointRange,h=(h-b)/(c.translationSlope*(c.ordinalSlope||d)),u={ordinalPositions:c.getExtendedPositions()},d=c.lin2val,m=c.val2lin,y;u.ordinalPositions?
1<Math.abs(h)&&(q&&r(q,function(a){a.setState()}),0>h?(q=u,y=c.ordinalPositions?c:u):(q=c.ordinalPositions?c:u,y=u),u=y.ordinalPositions,p>u[u.length-1]&&u.push(p),this.fixedRange=k-n,h=c.toFixedRange(null,null,d.apply(q,[m.apply(q,[n,!0])+h,!0]),d.apply(y,[m.apply(y,[k,!0])+h,!0])),h.min>=Math.min(l.dataMin,n)&&h.max<=Math.max(p,k)&&c.setExtremes(h.min,h.max,!0,!1,{trigger:"pan"}),this.mouseDownX=b,H(this.container,{cursor:"move"})):f=!0}else f=!0;f&&a.apply(this,Array.prototype.slice.call(arguments,
1))});n.prototype.gappedPath=function(){var a=this.options.gapSize,e=this.points.slice(),f=e.length-1;if(a&&0<f)for(;f--;)e[f+1].x-e[f].x>this.closestPointRange*a&&e.splice(f+1,0,{isNull:!0});return this.getGraphPath(e)}})(K);(function(a){function D(){return Array.prototype.slice.call(arguments,1)}function C(a){a.apply(this);this.drawBreaks(this.xAxis,["x"]);this.drawBreaks(this.yAxis,G(this.pointArrayMap,["y"]))}var G=a.pick,H=a.wrap,v=a.each,l=a.extend,r=a.isArray,w=a.fireEvent,q=a.Axis,n=a.Series;
l(q.prototype,{isInBreak:function(a,c){var e=a.repeat||Infinity,f=a.from,b=a.to-a.from;c=c>=f?(c-f)%e:e-(f-c)%e;return a.inclusive?c<=b:c<b&&0!==c},isInAnyBreak:function(a,c){var e=this.options.breaks,f=e&&e.length,b,l,h;if(f){for(;f--;)this.isInBreak(e[f],a)&&(b=!0,l||(l=G(e[f].showPoints,this.isXAxis?!1:!0)));h=b&&c?b&&!l:b}return h}});H(q.prototype,"setTickPositions",function(a){a.apply(this,Array.prototype.slice.call(arguments,1));if(this.options.breaks){var c=this.tickPositions,e=this.tickPositions.info,
f=[],b;for(b=0;b<c.length;b++)this.isInAnyBreak(c[b])||f.push(c[b]);this.tickPositions=f;this.tickPositions.info=e}});H(q.prototype,"init",function(a,c,e){var f=this;e.breaks&&e.breaks.length&&(e.ordinal=!1);a.call(this,c,e);a=this.options.breaks;f.isBroken=r(a)&&!!a.length;f.isBroken&&(f.val2lin=function(a){var b=a,c,e;for(e=0;e<f.breakArray.length;e++)if(c=f.breakArray[e],c.to<=a)b-=c.len;else if(c.from>=a)break;else if(f.isInBreak(c,a)){b-=a-c.from;break}return b},f.lin2val=function(a){var b,c;
for(c=0;c<f.breakArray.length&&!(b=f.breakArray[c],b.from>=a);c++)b.to<a?a+=b.len:f.isInBreak(b,a)&&(a+=b.len);return a},f.setExtremes=function(a,c,e,f,p){for(;this.isInAnyBreak(a);)a-=this.closestPointRange;for(;this.isInAnyBreak(c);)c-=this.closestPointRange;q.prototype.setExtremes.call(this,a,c,e,f,p)},f.setAxisTranslation=function(a){q.prototype.setAxisTranslation.call(this,a);var b=f.options.breaks;a=[];var c=[],e=0,p,l,k=f.userMin||f.min,n=f.userMax||f.max,d=G(f.pointRangePadding,0),u,m;for(m in b)l=
b[m],p=l.repeat||Infinity,f.isInBreak(l,k)&&(k+=l.to%p-k%p),f.isInBreak(l,n)&&(n-=n%p-l.from%p);for(m in b){l=b[m];u=l.from;for(p=l.repeat||Infinity;u-p>k;)u-=p;for(;u<k;)u+=p;for(;u<n;u+=p)a.push({value:u,move:"in"}),a.push({value:u+(l.to-l.from),move:"out",size:l.breakSize})}a.sort(function(a,b){return a.value===b.value?("in"===a.move?0:1)-("in"===b.move?0:1):a.value-b.value});b=0;u=k;for(m in a)l=a[m],b+="in"===l.move?1:-1,1===b&&"in"===l.move&&(u=l.value),0===b&&(c.push({from:u,to:l.value,len:l.value-
u-(l.size||0)}),e+=l.value-u-(l.size||0));f.breakArray=c;f.unitLength=n-k-e+d;w(f,"afterBreaks");f.transA=f.options.staticScale?f.options.staticScale:(n-f.min+d)/f.unitLength*f.transA;d&&(f.minPixelPadding=f.transA*f.minPointOffset);f.min=k;f.max=n})});H(n.prototype,"generatePoints",function(a){a.apply(this,D(arguments));var c=this.xAxis,e=this.yAxis,f=this.points,b,l=f.length,h=this.options.connectNulls,n;if(c&&e&&(c.options.breaks||e.options.breaks))for(;l--;)b=f[l],n=null===b.y&&!1===h,n||!c.isInAnyBreak(b.x,
!0)&&!e.isInAnyBreak(b.y,!0)||(f.splice(l,1),this.data[l]&&this.data[l].destroyElements())});a.Series.prototype.drawBreaks=function(a,c){var e=this,f=e.points,b,l,h,n;a&&v(c,function(c){b=a.breakArray||[];l=a.isXAxis?a.min:G(e.options.threshold,a.min);v(f,function(e){n=G(e["stack"+c.toUpperCase()],e[c]);v(b,function(b){h=!1;if(l<b.from&&n>b.to||l>b.from&&n<b.from)h="pointBreak";else if(l<b.from&&n>b.from&&n<b.to||l>b.from&&n>b.to&&n<b.from)h="pointInBreak";h&&w(a,h,{point:e,brk:b})})})})};H(a.seriesTypes.column.prototype,
"drawPoints",C);H(a.Series.prototype,"drawPoints",C)})(K);(function(a){var D=a.arrayMax,C=a.arrayMin,G=a.Axis,H=a.defaultPlotOptions,v=a.defined,l=a.each,r=a.extend,w=a.format,q=a.isNumber,n=a.merge,f=a.pick,c=a.Point,e=a.Tooltip,z=a.wrap,b=a.Series.prototype,t=b.processData,h=b.generatePoints,B=b.destroy,p={approximation:"average",groupPixelWidth:2,dateTimeLabelFormats:{millisecond:["%A, %b %e, %H:%M:%S.%L","%A, %b %e, %H:%M:%S.%L","-%H:%M:%S.%L"],second:["%A, %b %e, %H:%M:%S","%A, %b %e, %H:%M:%S",
"-%H:%M:%S"],minute:["%A, %b %e, %H:%M","%A, %b %e, %H:%M","-%H:%M"],hour:["%A, %b %e, %H:%M","%A, %b %e, %H:%M","-%H:%M"],day:["%A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],week:["Week from %A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],month:["%B %Y","%B","-%B %Y"],year:["%Y","%Y","-%Y"]}},x={line:{},spline:{},area:{},areaspline:{},column:{approximation:"sum",groupPixelWidth:10},arearange:{approximation:"range"},areasplinerange:{approximation:"range"},columnrange:{approximation:"range",groupPixelWidth:10},
candlestick:{approximation:"ohlc",groupPixelWidth:10},ohlc:{approximation:"ohlc",groupPixelWidth:5}},k=a.defaultDataGroupingUnits=[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1]],["week",[1]],["month",[1,3,6]],["year",null]],F={sum:function(a){var b=a.length,c;if(!b&&a.hasNulls)c=null;else if(b)for(c=0;b--;)c+=a[b];return c},average:function(a){var b=a.length;a=F.sum(a);q(a)&&b&&(a/=b);return a},open:function(a){return a.length?
a[0]:a.hasNulls?null:void 0},high:function(a){return a.length?D(a):a.hasNulls?null:void 0},low:function(a){return a.length?C(a):a.hasNulls?null:void 0},close:function(a){return a.length?a[a.length-1]:a.hasNulls?null:void 0},ohlc:function(a,b,c,e){a=F.open(a);b=F.high(b);c=F.low(c);e=F.close(e);if(q(a)||q(b)||q(c)||q(e))return[a,b,c,e]},range:function(a,b){a=F.low(a);b=F.high(b);if(q(a)||q(b))return[a,b]}};b.groupData=function(a,b,c,e){var d=this.data,k=this.options.data,f=[],g=[],h=[],m=a.length,
p,l,n=!!b,u=[[],[],[],[]];e="function"===typeof e?e:F[e];var t=this.pointArrayMap,x=t&&t.length,r,y=0;for(r=l=0;r<=m&&!(a[r]>=c[0]);r++);for(r;r<=m;r++){for(;(void 0!==c[y+1]&&a[r]>=c[y+1]||r===m)&&(p=c[y],this.dataGroupInfo={start:l,length:u[0].length},l=e.apply(this,u),void 0!==l&&(f.push(p),g.push(l),h.push(this.dataGroupInfo)),l=r,u[0]=[],u[1]=[],u[2]=[],u[3]=[],y+=1,r!==m););if(r===m)break;if(t){p=this.cropStart+r;p=d&&d[p]||this.pointClass.prototype.applyOptions.apply({series:this},[k[p]]);
var v,w;for(v=0;v<x;v++)w=p[t[v]],q(w)?u[v].push(w):null===w&&(u[v].hasNulls=!0)}else p=n?b[r]:null,q(p)?u[0].push(p):null===p&&(u[0].hasNulls=!0)}return[f,g,h]};b.processData=function(){var a=this.chart,c=this.options.dataGrouping,e=!1!==this.allowDG&&c&&f(c.enabled,a.options.isStock),h=this.visible||!a.options.chart.ignoreHiddenSeries,p;this.forceCrop=e;this.groupPixelWidth=null;this.hasProcessed=!0;if(!1!==t.apply(this,arguments)&&e){this.destroyGroupedData();var l=this.processedXData,n=this.processedYData,
g=a.plotSizeX,a=this.xAxis,q=a.options.ordinal,r=this.groupPixelWidth=a.getGroupPixelWidth&&a.getGroupPixelWidth();if(r){this.isDirty=p=!0;var x=a.getExtremes(),e=x.min,x=x.max,q=q&&a.getGroupIntervalFactor(e,x,this)||1,g=r*(x-e)/g*q,r=a.getTimeTicks(a.normalizeTimeTickInterval(g,c.units||k),Math.min(e,l[0]),Math.max(x,l[l.length-1]),a.options.startOfWeek,l,this.closestPointRange),l=b.groupData.apply(this,[l,n,r,c.approximation]),n=l[0],q=l[1];if(c.smoothed){c=n.length-1;for(n[c]=Math.min(n[c],x);c--&&
0<c;)n[c]+=g/2;n[0]=Math.max(n[0],e)}this.currentDataGrouping=r.info;this.closestPointRange=r.info.totalRange;this.groupMap=l[2];v(n[0])&&n[0]<a.dataMin&&h&&(a.min===a.dataMin&&(a.min=n[0]),a.dataMin=n[0]);this.processedXData=n;this.processedYData=q}else this.currentDataGrouping=this.groupMap=null;this.hasGroupedData=p}};b.destroyGroupedData=function(){var a=this.groupedData;l(a||[],function(b,c){b&&(a[c]=b.destroy?b.destroy():null)});this.groupedData=null};b.generatePoints=function(){h.apply(this);
this.destroyGroupedData();this.groupedData=this.hasGroupedData?this.points:null};z(c.prototype,"update",function(b){this.dataGroup?a.error(24):b.apply(this,[].slice.call(arguments,1))});z(e.prototype,"tooltipFooterHeaderFormatter",function(b,c,e){var d=c.series,k=d.tooltipOptions,f=d.options.dataGrouping,h=k.xDateFormat,g,m=d.xAxis,l=a.dateFormat;return m&&"datetime"===m.options.type&&f&&q(c.key)?(b=d.currentDataGrouping,f=f.dateTimeLabelFormats,b?(m=f[b.unitName],1===b.count?h=m[0]:(h=m[1],g=m[2])):
!h&&f&&(h=this.getXDateFormat(c,k,m)),h=l(h,c.key),g&&(h+=l(g,c.key+b.totalRange-1)),w(k[(e?"footer":"header")+"Format"],{point:r(c.point,{key:h}),series:d})):b.call(this,c,e)});b.destroy=function(){for(var a=this.groupedData||[],b=a.length;b--;)a[b]&&a[b].destroy();B.apply(this)};z(b,"setOptions",function(a,b){a=a.call(this,b);var c=this.type,d=this.chart.options.plotOptions,e=H[c].dataGrouping;x[c]&&(e||(e=n(p,x[c])),a.dataGrouping=n(e,d.series&&d.series.dataGrouping,d[c].dataGrouping,b.dataGrouping));
this.chart.options.isStock&&(this.requireSorting=!0);return a});z(G.prototype,"setScale",function(a){a.call(this);l(this.series,function(a){a.hasProcessed=!1})});G.prototype.getGroupPixelWidth=function(){var a=this.series,b=a.length,c,e=0,k=!1,h;for(c=b;c--;)(h=a[c].options.dataGrouping)&&(e=Math.max(e,h.groupPixelWidth));for(c=b;c--;)(h=a[c].options.dataGrouping)&&a[c].hasProcessed&&(b=(a[c].processedXData||a[c].data).length,a[c].groupPixelWidth||b>this.chart.plotSizeX/e||b&&h.forced)&&(k=!0);return k?
e:0};G.prototype.setDataGrouping=function(a,b){var c;b=f(b,!0);a||(a={forced:!1,units:null});if(this instanceof G)for(c=this.series.length;c--;)this.series[c].update({dataGrouping:a},!1);else l(this.chart.options.series,function(b){b.dataGrouping=a},!1);b&&this.chart.redraw()}})(K);(function(a){var D=a.each,C=a.Point,G=a.seriesType,H=a.seriesTypes;G("ohlc","column",{lineWidth:1,tooltip:{pointFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e \x3cb\x3e {series.name}\x3c/b\x3e\x3cbr/\x3eOpen: {point.open}\x3cbr/\x3eHigh: {point.high}\x3cbr/\x3eLow: {point.low}\x3cbr/\x3eClose: {point.close}\x3cbr/\x3e'},
threshold:null,states:{hover:{lineWidth:3}},stickyTracking:!0},{directTouch:!1,pointArrayMap:["open","high","low","close"],toYData:function(a){return[a.open,a.high,a.low,a.close]},pointValKey:"high",pointAttrToOptions:{stroke:"color","stroke-width":"lineWidth"},pointAttribs:function(a,l){l=H.column.prototype.pointAttribs.call(this,a,l);var r=this.options;delete l.fill;!a.options.color&&r.upColor&&a.open<a.close&&(l.stroke=r.upColor);return l},translate:function(){var a=this,l=a.yAxis,r=!!a.modifyValue,
w=["plotOpen","plotHigh","plotLow","plotClose","yBottom"];H.column.prototype.translate.apply(a);D(a.points,function(q){D([q.open,q.high,q.low,q.close,q.low],function(n,f){null!==n&&(r&&(n=a.modifyValue(n)),q[w[f]]=l.toPixels(n,!0))})})},drawPoints:function(){var a=this,l=a.chart;D(a.points,function(r){var w,q,n,f,c=r.graphic,e,v=!c;void 0!==r.plotY&&(c||(r.graphic=c=l.renderer.path().add(a.group)),c.attr(a.pointAttribs(r,r.selected&&"select")),q=c.strokeWidth()%2/2,e=Math.round(r.plotX)-q,n=Math.round(r.shapeArgs.width/
2),f=["M",e,Math.round(r.yBottom),"L",e,Math.round(r.plotY)],null!==r.open&&(w=Math.round(r.plotOpen)+q,f.push("M",e,w,"L",e-n,w)),null!==r.close&&(w=Math.round(r.plotClose)+q,f.push("M",e,w,"L",e+n,w)),c[v?"attr":"animate"]({d:f}).addClass(r.getClassName(),!0))})},animate:null},{getClassName:function(){return C.prototype.getClassName.call(this)+(this.open<this.close?" highcharts-point-up":" highcharts-point-down")}})})(K);(function(a){var D=a.defaultPlotOptions,C=a.each,G=a.merge,H=a.seriesType,
v=a.seriesTypes;H("candlestick","ohlc",G(D.column,{states:{hover:{lineWidth:2}},tooltip:D.ohlc.tooltip,threshold:null,lineColor:"#000000",lineWidth:1,upColor:"#ffffff",stickyTracking:!0}),{pointAttribs:function(a,r){var l=v.column.prototype.pointAttribs.call(this,a,r),q=this.options,n=a.open<a.close,f=q.lineColor||this.color;l["stroke-width"]=q.lineWidth;l.fill=a.options.color||(n?q.upColor||this.color:this.color);l.stroke=a.lineColor||(n?q.upLineColor||f:f);r&&(a=q.states[r],l.fill=a.color||l.fill,
l.stroke=a.lineColor||l.stroke,l["stroke-width"]=a.lineWidth||l["stroke-width"]);return l},drawPoints:function(){var a=this,r=a.chart;C(a.points,function(l){var q=l.graphic,n,f,c,e,v,b,t,h=!q;void 0!==l.plotY&&(q||(l.graphic=q=r.renderer.path().add(a.group)),q.attr(a.pointAttribs(l,l.selected&&"select")).shadow(a.options.shadow),v=q.strokeWidth()%2/2,b=Math.round(l.plotX)-v,n=l.plotOpen,f=l.plotClose,c=Math.min(n,f),n=Math.max(n,f),t=Math.round(l.shapeArgs.width/2),f=Math.round(c)!==Math.round(l.plotY),
e=n!==l.yBottom,c=Math.round(c)+v,n=Math.round(n)+v,v=[],v.push("M",b-t,n,"L",b-t,c,"L",b+t,c,"L",b+t,n,"Z","M",b,c,"L",b,f?Math.round(l.plotY):c,"M",b,n,"L",b,e?Math.round(l.yBottom):n),q[h?"attr":"animate"]({d:v}).addClass(l.getClassName(),!0))})}})})(K);(function(a){var D=a.addEvent,C=a.each,G=a.merge,H=a.noop,v=a.Renderer,l=a.seriesType,r=a.seriesTypes,w=a.TrackerMixin,q=a.VMLRenderer,n=a.SVGRenderer.prototype.symbols,f=a.stableSort;l("flags","column",{pointRange:0,shape:"flag",stackDistance:12,
textAlign:"center",tooltip:{pointFormat:"{point.text}\x3cbr/\x3e"},threshold:null,y:-30,fillColor:"#ffffff",lineWidth:1,states:{hover:{lineColor:"#000000",fillColor:"#ccd6eb"}},style:{fontSize:"11px",fontWeight:"bold"}},{sorted:!1,noSharedTooltip:!0,allowDG:!1,takeOrdinalPosition:!1,trackerGroups:["markerGroup"],forceCrop:!0,init:a.Series.prototype.init,pointAttribs:function(a,e){var c=this.options,b=a&&a.color||this.color,f=c.lineColor,h=a&&a.lineWidth;a=a&&a.fillColor||c.fillColor;e&&(a=c.states[e].fillColor,
f=c.states[e].lineColor,h=c.states[e].lineWidth);return{fill:a||b,stroke:f||b,"stroke-width":h||c.lineWidth||0}},translate:function(){r.column.prototype.translate.apply(this);var a=this.options,e=this.chart,l=this.points,b=l.length-1,n,h,q=a.onSeries;n=q&&e.get(q);var a=a.onKey||"y",q=n&&n.options.step,p=n&&n.points,x=p&&p.length,k=this.xAxis,v=this.yAxis,d=k.getExtremes(),u=0,m,y,w;if(n&&n.visible&&x)for(u=(n.pointXOffset||0)+(n.barW||0)/2,n=n.currentDataGrouping,y=p[x-1].x+(n?n.totalRange:0),f(l,
function(a,b){return a.x-b.x}),a="plot"+a[0].toUpperCase()+a.substr(1);x--&&l[b]&&!(n=l[b],m=p[x],m.x<=n.x&&void 0!==m[a]&&(n.x<=y&&(n.plotY=m[a],m.x<n.x&&!q&&(w=p[x+1])&&void 0!==w[a]&&(n.plotY+=(n.x-m.x)/(w.x-m.x)*(w[a]-m[a]))),b--,x++,0>b)););C(l,function(a,b){var c;void 0===a.plotY&&(a.x>=d.min&&a.x<=d.max?a.plotY=e.chartHeight-k.bottom-(k.opposite?k.height:0)+k.offset-v.top:a.shapeArgs={});a.plotX+=u;(h=l[b-1])&&h.plotX===a.plotX&&(void 0===h.stackIndex&&(h.stackIndex=0),c=h.stackIndex+1);a.stackIndex=
c})},drawPoints:function(){var c=this.points,e=this.chart,f=e.renderer,b,l,h=this.options,n=h.y,p,q,k,r,d,u,m,y=this.yAxis;for(q=c.length;q--;)k=c[q],m=k.plotX>this.xAxis.len,b=k.plotX,r=k.stackIndex,p=k.options.shape||h.shape,l=k.plotY,void 0!==l&&(l=k.plotY+n-(void 0!==r&&r*h.stackDistance)),d=r?void 0:k.plotX,u=r?void 0:k.plotY,r=k.graphic,void 0!==l&&0<=b&&!m?(r||(r=k.graphic=f.label("",null,null,p,null,null,h.useHTML).attr(this.pointAttribs(k)).css(G(h.style,k.style)).attr({align:"flag"===p?
"left":"center",width:h.width,height:h.height,"text-align":h.textAlign}).addClass("highcharts-point").add(this.markerGroup),k.graphic.div&&(k.graphic.div.point=k),r.shadow(h.shadow)),0<b&&(b-=r.strokeWidth()%2),r.attr({text:k.options.title||h.title||"A",x:b,y:l,anchorX:d,anchorY:u}),k.tooltipPos=e.inverted?[y.len+y.pos-e.plotLeft-l,this.xAxis.len-b]:[b,l+y.pos-e.plotTop]):r&&(k.graphic=r.destroy());h.useHTML&&a.wrap(this.markerGroup,"on",function(b){return a.SVGElement.prototype.on.apply(b.apply(this,
[].slice.call(arguments,1)),[].slice.call(arguments,1))})},drawTracker:function(){var a=this.points;w.drawTrackerPoint.apply(this);C(a,function(c){var e=c.graphic;e&&D(e.element,"mouseover",function(){0<c.stackIndex&&!c.raised&&(c._y=e.y,e.attr({y:c._y-8}),c.raised=!0);C(a,function(a){a!==c&&a.raised&&a.graphic&&(a.graphic.attr({y:a._y}),a.raised=!1)})})})},animate:H,buildKDTree:H,setClip:H});n.flag=function(a,e,f,b,l){return["M",l&&l.anchorX||a,l&&l.anchorY||e,"L",a,e+b,a,e,a+f,e,a+f,e+b,a,e+b,"Z"]};
C(["circle","square"],function(a){n[a+"pin"]=function(c,f,b,l,h){var e=h&&h.anchorX;h=h&&h.anchorY;"circle"===a&&l>b&&(c-=Math.round((l-b)/2),b=l);c=n[a](c,f,b,l);e&&h&&c.push("M",e,f>h?f:f+l,"L",e,h);return c}});v===q&&C(["flag","circlepin","squarepin"],function(a){q.prototype.symbols[a]=n[a]})})(K);(function(a){function D(a,b,c){this.init(a,b,c)}var C=a.addEvent,G=a.Axis,H=a.correctFloat,v=a.defaultOptions,l=a.defined,r=a.destroyObjectProperties,w=a.doc,q=a.each,n=a.fireEvent,f=a.hasTouch,c=a.isTouchDevice,
e=a.merge,z=a.pick,b=a.removeEvent,t=a.wrap,h,B={height:c?20:14,barBorderRadius:0,buttonBorderRadius:0,liveRedraw:a.svg&&!c,margin:10,minWidth:6,step:.2,zIndex:3,barBackgroundColor:"#cccccc",barBorderWidth:1,barBorderColor:"#cccccc",buttonArrowColor:"#333333",buttonBackgroundColor:"#e6e6e6",buttonBorderColor:"#cccccc",buttonBorderWidth:1,rifleColor:"#333333",trackBackgroundColor:"#f2f2f2",trackBorderColor:"#f2f2f2",trackBorderWidth:1};v.scrollbar=e(!0,B,v.scrollbar);a.swapXY=h=function(a,b){var c=
a.length,e;if(b)for(b=0;b<c;b+=3)e=a[b+1],a[b+1]=a[b+2],a[b+2]=e;return a};D.prototype={init:function(a,b,c){this.scrollbarButtons=[];this.renderer=a;this.userOptions=b;this.options=e(B,b);this.chart=c;this.size=z(this.options.size,this.options.height);b.enabled&&(this.render(),this.initEvents(),this.addEvents())},render:function(){var a=this.renderer,b=this.options,c=this.size,e;this.group=e=a.g("scrollbar").attr({zIndex:b.zIndex,translateY:-99999}).add();this.track=a.rect().addClass("highcharts-scrollbar-track").attr({x:0,
r:b.trackBorderRadius||0,height:c,width:c}).add(e);this.track.attr({fill:b.trackBackgroundColor,stroke:b.trackBorderColor,"stroke-width":b.trackBorderWidth});this.trackBorderWidth=this.track.strokeWidth();this.track.attr({y:-this.trackBorderWidth%2/2});this.scrollbarGroup=a.g().add(e);this.scrollbar=a.rect().addClass("highcharts-scrollbar-thumb").attr({height:c,width:c,r:b.barBorderRadius||0}).add(this.scrollbarGroup);this.scrollbarRifles=a.path(h(["M",-3,c/4,"L",-3,2*c/3,"M",0,c/4,"L",0,2*c/3,"M",
3,c/4,"L",3,2*c/3],b.vertical)).addClass("highcharts-scrollbar-rifles").add(this.scrollbarGroup);this.scrollbar.attr({fill:b.barBackgroundColor,stroke:b.barBorderColor,"stroke-width":b.barBorderWidth});this.scrollbarRifles.attr({stroke:b.rifleColor,"stroke-width":1});this.scrollbarStrokeWidth=this.scrollbar.strokeWidth();this.scrollbarGroup.translate(-this.scrollbarStrokeWidth%2/2,-this.scrollbarStrokeWidth%2/2);this.drawScrollbarButton(0);this.drawScrollbarButton(1)},position:function(a,b,c,e){var d=
this.options.vertical,k=0,f=this.rendered?"animate":"attr";this.x=a;this.y=b+this.trackBorderWidth;this.width=c;this.xOffset=this.height=e;this.yOffset=k;d?(this.width=this.yOffset=c=k=this.size,this.xOffset=b=0,this.barWidth=e-2*c,this.x=a+=this.options.margin):(this.height=this.xOffset=e=b=this.size,this.barWidth=c-2*e,this.y+=this.options.margin);this.group[f]({translateX:a,translateY:this.y});this.track[f]({width:c,height:e});this.scrollbarButtons[1][f]({translateX:d?0:c-b,translateY:d?e-k:0})},
drawScrollbarButton:function(a){var b=this.renderer,c=this.scrollbarButtons,e=this.options,d=this.size,f;f=b.g().add(this.group);c.push(f);f=b.rect().addClass("highcharts-scrollbar-button").add(f);f.attr({stroke:e.buttonBorderColor,"stroke-width":e.buttonBorderWidth,fill:e.buttonBackgroundColor});f.attr(f.crisp({x:-.5,y:-.5,width:d+1,height:d+1,r:e.buttonBorderRadius},f.strokeWidth()));f=b.path(h(["M",d/2+(a?-1:1),d/2-3,"L",d/2+(a?-1:1),d/2+3,"L",d/2+(a?2:-2),d/2],e.vertical)).addClass("highcharts-scrollbar-arrow").add(c[a]);
f.attr({fill:e.buttonArrowColor})},setRange:function(a,b){var c=this.options,e=c.vertical,d=c.minWidth,f=this.barWidth,h,p,n=this.rendered&&!this.hasDragged?"animate":"attr";l(f)&&(a=Math.max(a,0),h=Math.ceil(f*a),this.calculatedWidth=p=H(f*Math.min(b,1)-h),p<d&&(h=(f-d+p)*a,p=d),d=Math.floor(h+this.xOffset+this.yOffset),f=p/2-.5,this.from=a,this.to=b,e?(this.scrollbarGroup[n]({translateY:d}),this.scrollbar[n]({height:p}),this.scrollbarRifles[n]({translateY:f}),this.scrollbarTop=d,this.scrollbarLeft=
0):(this.scrollbarGroup[n]({translateX:d}),this.scrollbar[n]({width:p}),this.scrollbarRifles[n]({translateX:f}),this.scrollbarLeft=d,this.scrollbarTop=0),12>=p?this.scrollbarRifles.hide():this.scrollbarRifles.show(!0),!1===c.showFull&&(0>=a&&1<=b?this.group.hide():this.group.show()),this.rendered=!0)},initEvents:function(){var a=this;a.mouseMoveHandler=function(b){var c=a.chart.pointer.normalize(b),e=a.options.vertical?"chartY":"chartX",d=a.initPositions;!a.grabbedCenter||b.touches&&0===b.touches[0][e]||
(c=a.cursorToScrollbarPosition(c)[e],e=a[e],e=c-e,a.hasDragged=!0,a.updatePosition(d[0]+e,d[1]+e),a.hasDragged&&n(a,"changed",{from:a.from,to:a.to,trigger:"scrollbar",DOMType:b.type,DOMEvent:b}))};a.mouseUpHandler=function(b){a.hasDragged&&n(a,"changed",{from:a.from,to:a.to,trigger:"scrollbar",DOMType:b.type,DOMEvent:b});a.grabbedCenter=a.hasDragged=a.chartX=a.chartY=null};a.mouseDownHandler=function(b){b=a.chart.pointer.normalize(b);b=a.cursorToScrollbarPosition(b);a.chartX=b.chartX;a.chartY=b.chartY;
a.initPositions=[a.from,a.to];a.grabbedCenter=!0};a.buttonToMinClick=function(b){var c=H(a.to-a.from)*a.options.step;a.updatePosition(H(a.from-c),H(a.to-c));n(a,"changed",{from:a.from,to:a.to,trigger:"scrollbar",DOMEvent:b})};a.buttonToMaxClick=function(b){var c=(a.to-a.from)*a.options.step;a.updatePosition(a.from+c,a.to+c);n(a,"changed",{from:a.from,to:a.to,trigger:"scrollbar",DOMEvent:b})};a.trackClick=function(b){var c=a.chart.pointer.normalize(b),e=a.to-a.from,d=a.y+a.scrollbarTop,f=a.x+a.scrollbarLeft;
a.options.vertical&&c.chartY>d||!a.options.vertical&&c.chartX>f?a.updatePosition(a.from+e,a.to+e):a.updatePosition(a.from-e,a.to-e);n(a,"changed",{from:a.from,to:a.to,trigger:"scrollbar",DOMEvent:b})}},cursorToScrollbarPosition:function(a){var b=this.options,b=b.minWidth>this.calculatedWidth?b.minWidth:0;return{chartX:(a.chartX-this.x-this.xOffset)/(this.barWidth-b),chartY:(a.chartY-this.y-this.yOffset)/(this.barWidth-b)}},updatePosition:function(a,b){1<b&&(a=H(1-H(b-a)),b=1);0>a&&(b=H(b-a),a=0);
this.from=a;this.to=b},update:function(a){this.destroy();this.init(this.chart.renderer,e(!0,this.options,a),this.chart)},addEvents:function(){var a=this.options.inverted?[1,0]:[0,1],b=this.scrollbarButtons,c=this.scrollbarGroup.element,e=this.mouseDownHandler,d=this.mouseMoveHandler,h=this.mouseUpHandler,a=[[b[a[0]].element,"click",this.buttonToMinClick],[b[a[1]].element,"click",this.buttonToMaxClick],[this.track.element,"click",this.trackClick],[c,"mousedown",e],[w,"mousemove",d],[w,"mouseup",h]];
f&&a.push([c,"touchstart",e],[w,"touchmove",d],[w,"touchend",h]);q(a,function(a){C.apply(null,a)});this._events=a},removeEvents:function(){q(this._events,function(a){b.apply(null,a)});this._events=void 0},destroy:function(){var a=this.chart.scroller;this.removeEvents();q(["track","scrollbarRifles","scrollbar","scrollbarGroup","group"],function(a){this[a]&&this[a].destroy&&(this[a]=this[a].destroy())},this);a&&this===a.scrollbar&&(a.scrollbar=null,r(a.scrollbarButtons))}};t(G.prototype,"init",function(a){var b=
this;a.apply(b,Array.prototype.slice.call(arguments,1));b.options.scrollbar&&b.options.scrollbar.enabled&&(b.options.scrollbar.vertical=!b.horiz,b.options.startOnTick=b.options.endOnTick=!1,b.scrollbar=new D(b.chart.renderer,b.options.scrollbar,b.chart),C(b.scrollbar,"changed",function(a){var c=Math.min(z(b.options.min,b.min),b.min,b.dataMin),d=Math.max(z(b.options.max,b.max),b.max,b.dataMax)-c,e;b.horiz&&!b.reversed||!b.horiz&&b.reversed?(e=c+d*this.to,c+=d*this.from):(e=c+d*(1-this.from),c+=d*(1-
this.to));b.setExtremes(c,e,!0,!1,a)}))});t(G.prototype,"render",function(a){var b=Math.min(z(this.options.min,this.min),this.min,this.dataMin),c=Math.max(z(this.options.max,this.max),this.max,this.dataMax),e=this.scrollbar,d;a.apply(this,Array.prototype.slice.call(arguments,1));if(e){this.horiz?(e.position(this.left,this.top+this.height+2+this.chart.scrollbarsOffsets[1]+(this.opposite?0:this.axisTitleMargin+this.offset),this.width,this.height),d=1):(e.position(this.left+this.width+2+this.chart.scrollbarsOffsets[0]+
(this.opposite?this.axisTitleMargin+this.offset:0),this.top,this.width,this.height),d=0);if(!this.opposite&&!this.horiz||this.opposite&&this.horiz)this.chart.scrollbarsOffsets[d]+=this.scrollbar.size+this.scrollbar.options.margin;isNaN(b)||isNaN(c)||!l(this.min)||!l(this.max)?e.setRange(0,0):(d=(this.min-b)/(c-b),b=(this.max-b)/(c-b),this.horiz&&!this.reversed||!this.horiz&&this.reversed?e.setRange(d,b):e.setRange(1-b,1-d))}});t(G.prototype,"getOffset",function(a){var b=this.horiz?2:1,c=this.scrollbar;
a.apply(this,Array.prototype.slice.call(arguments,1));c&&(this.chart.scrollbarsOffsets=[0,0],this.chart.axisOffset[b]+=c.size+c.options.margin)});t(G.prototype,"destroy",function(a){this.scrollbar&&(this.scrollbar=this.scrollbar.destroy());a.apply(this,Array.prototype.slice.call(arguments,1))});a.Scrollbar=D})(K);(function(a){function D(a){this.init(a)}var C=a.addEvent,G=a.Axis,H=a.Chart,v=a.color,l=a.defaultOptions,r=a.defined,w=a.destroyObjectProperties,q=a.doc,n=a.each,f=a.erase,c=a.error,e=a.extend,
z=a.grep,b=a.hasTouch,t=a.isNumber,h=a.isObject,B=a.merge,p=a.pick,x=a.removeEvent,k=a.Scrollbar,F=a.Series,d=a.seriesTypes,u=a.wrap,m=a.swapXY,y=[].concat(a.defaultDataGroupingUnits),J=function(a){var b=z(arguments,t);if(b.length)return Math[a].apply(0,b)};y[4]=["day",[1,2,3,4]];y[5]=["week",[1,2,3]];d=void 0===d.areaspline?"line":"areaspline";e(l,{navigator:{height:40,margin:25,maskInside:!0,handles:{backgroundColor:"#f2f2f2",borderColor:"#999999"},maskFill:v("#6685c2").setOpacity(.3).get(),outlineColor:"#cccccc",
outlineWidth:1,series:{type:d,color:"#335cad",fillOpacity:.05,lineWidth:1,compare:null,dataGrouping:{approximation:"average",enabled:!0,groupPixelWidth:2,smoothed:!0,units:y},dataLabels:{enabled:!1,zIndex:2},id:"highcharts-navigator-series",className:"highcharts-navigator-series",lineColor:null,marker:{enabled:!1},pointRange:0,shadow:!1,threshold:null},xAxis:{className:"highcharts-navigator-xaxis",tickLength:0,lineWidth:0,gridLineColor:"#e6e6e6",gridLineWidth:1,tickPixelInterval:200,labels:{align:"left",
style:{color:"#999999"},x:3,y:-4},crosshair:!1},yAxis:{className:"highcharts-navigator-yaxis",gridLineWidth:0,startOnTick:!1,endOnTick:!1,minPadding:.1,maxPadding:.1,labels:{enabled:!1},crosshair:!1,title:{text:null},tickLength:0,tickWidth:0}}});D.prototype={drawHandle:function(a,b,c,d){this.handles[b][d](c?{translateX:Math.round(this.left+this.height/2-8),translateY:Math.round(this.top+parseInt(a,10)+.5)}:{translateX:Math.round(this.left+parseInt(a,10)),translateY:Math.round(this.top+this.height/
2-8)})},getHandlePath:function(a){return m(["M",-4.5,.5,"L",3.5,.5,"L",3.5,15.5,"L",-4.5,15.5,"L",-4.5,.5,"M",-1.5,4,"L",-1.5,12,"M",.5,4,"L",.5,12],a)},drawOutline:function(a,b,c,d){var g=this.navigatorOptions.maskInside,e=this.outline.strokeWidth(),f=e/2,e=e%2/2,h=this.outlineHeight,k=this.scrollbarHeight,m=this.size,l=this.left-k,n=this.top;c?(l-=f,c=n+b+e,b=n+a+e,a=["M",l+h,n-k-e,"L",l+h,c,"L",l,c,"L",l,b,"L",l+h,b,"L",l+h,n+m+k].concat(g?["M",l+h,c-f,"L",l+h,b+f]:[])):(a+=l+k-e,b+=l+k-e,n+=f,
a=["M",l,n,"L",a,n,"L",a,n+h,"L",b,n+h,"L",b,n,"L",l+m+2*k,n].concat(g?["M",a-f,n,"L",b+f,n]:[]));this.outline[d]({d:a})},drawMasks:function(a,b,c,d){var g=this.left,e=this.top,f=this.height,h,k,l,m;c?(l=[g,g,g],m=[e,e+a,e+b],k=[f,f,f],h=[a,b-a,this.size-b]):(l=[g,g+a,g+b],m=[e,e,e],k=[a,b-a,this.size-b],h=[f,f,f]);n(this.shades,function(a,b){a[d]({x:l[b],y:m[b],width:k[b],height:h[b]})})},renderElements:function(){var a=this,b=a.navigatorOptions,c=b.maskInside,d=a.chart,e=d.inverted,f=d.renderer,
h;a.navigatorGroup=h=f.g("navigator").attr({zIndex:8,visibility:"hidden"}).add();var k={cursor:e?"ns-resize":"ew-resize"};n([!c,c,!c],function(c,d){a.shades[d]=f.rect().addClass("highcharts-navigator-mask"+(1===d?"-inside":"-outside")).attr({fill:c?b.maskFill:"transparent"}).css(1===d&&k).add(h)});a.outline=f.path().addClass("highcharts-navigator-outline").attr({"stroke-width":b.outlineWidth,stroke:b.outlineColor}).add(h);n([0,1],function(c){a.handles[c]=f.path(a.getHandlePath(e)).attr({zIndex:7-
c}).addClass("highcharts-navigator-handle highcharts-navigator-handle-"+["left","right"][c]).add(h);var d=b.handles;a.handles[c].attr({fill:d.backgroundColor,stroke:d.borderColor,"stroke-width":1}).css(k)})},update:function(a){this.destroy();B(!0,this.chart.options.navigator,this.options,a);this.init(this.chart)},render:function(a,b,c,d){var g=this.chart,e,f,h=this.scrollbarHeight,k,l=this.xAxis;e=this.navigatorEnabled;var m,n=this.rendered;f=g.inverted;var q=g.xAxis[0].minRange;if(!this.hasDragged||
r(c)){if(!t(a)||!t(b))if(n)c=0,d=l.width;else return;this.left=p(l.left,g.plotLeft+h+(f?g.plotWidth:0));this.size=m=k=p(l.len,(f?g.plotHeight:g.plotWidth)-2*h);g=f?h:k+2*h;c=p(c,l.toPixels(a,!0));d=p(d,l.toPixels(b,!0));t(c)&&Infinity!==Math.abs(c)||(c=0,d=g);a=l.toValue(c,!0);b=l.toValue(d,!0);if(Math.abs(b-a)<q)if(this.grabbedLeft)c=l.toPixels(b-q,!0);else if(this.grabbedRight)d=l.toPixels(a+q,!0);else return;this.zoomedMax=Math.min(Math.max(c,d,0),m);this.zoomedMin=Math.min(Math.max(this.fixedWidth?
this.zoomedMax-this.fixedWidth:Math.min(c,d),0),m);this.range=this.zoomedMax-this.zoomedMin;m=Math.round(this.zoomedMax);c=Math.round(this.zoomedMin);e&&(this.navigatorGroup.attr({visibility:"visible"}),n=n&&!this.hasDragged?"animate":"attr",this.drawMasks(c,m,f,n),this.drawOutline(c,m,f,n),this.drawHandle(c,0,f,n),this.drawHandle(m,1,f,n));this.scrollbar&&(f?(f=this.top-h,e=this.left-h+(e?0:this.height),h=k+2*h):(f=this.top+(e?this.height:-h),e=this.left-h),this.scrollbar.position(e,f,g,h),this.scrollbar.setRange(this.zoomedMin/
k,this.zoomedMax/k));this.rendered=!0}},addMouseEvents:function(){var a=this,c=a.chart,d=c.container,e=[],f,h;a.mouseMoveHandler=f=function(b){a.onMouseMove(b)};a.mouseUpHandler=h=function(b){a.onMouseUp(b)};e=a.getPartsEvents("mousedown");e.push(C(d,"mousemove",f),C(q,"mouseup",h));b&&(e.push(C(d,"touchmove",f),C(q,"touchend",h)),e.concat(a.getPartsEvents("touchstart")));a.eventsToUnbind=e;a.series&&a.series[0]&&e.push(C(a.series[0].xAxis,"foundExtremes",function(){c.navigator.modifyNavigatorAxisExtremes()}))},
getPartsEvents:function(a){var b=this,c=[];n(["shades","handles"],function(d){n(b[d],function(g,e){c.push(C(g.element,a,function(a){b[d+"Mousedown"](a,e)}))})});return c},shadesMousedown:function(a,b){a=this.chart.pointer.normalize(a);var c=this.chart,d=this.xAxis,e=this.zoomedMin,f=this.left,h=this.size,k=this.range,l=a.chartX,m;c.inverted&&(l=a.chartY,f=this.top);1===b?(this.grabbedCenter=l,this.fixedWidth=k,this.dragOffset=l-e):(a=l-f-k/2,0===b?a=Math.max(0,a):2===b&&a+k>=h&&(a=h-k,m=this.getUnionExtremes().dataMax),
a!==e&&(this.fixedWidth=k,b=d.toFixedRange(a,a+k,null,m),c.xAxis[0].setExtremes(Math.min(b.min,b.max),Math.max(b.min,b.max),!0,null,{trigger:"navigator"})))},handlesMousedown:function(a,b){this.chart.pointer.normalize(a);a=this.chart;var c=a.xAxis[0],d=a.inverted&&!c.reversed||!a.inverted&&c.reversed;0===b?(this.grabbedLeft=!0,this.otherHandlePos=this.zoomedMax,this.fixedExtreme=d?c.min:c.max):(this.grabbedRight=!0,this.otherHandlePos=this.zoomedMin,this.fixedExtreme=d?c.max:c.min);a.fixedRange=null},
onMouseMove:function(a){var b=this,c=b.chart,d=b.left,e=b.navigatorSize,f=b.range,h=b.dragOffset,k=c.inverted;a.touches&&0===a.touches[0].pageX||(a=c.pointer.normalize(a),c=a.chartX,k&&(d=b.top,c=a.chartY),b.grabbedLeft?(b.hasDragged=!0,b.render(0,0,c-d,b.otherHandlePos)):b.grabbedRight?(b.hasDragged=!0,b.render(0,0,b.otherHandlePos,c-d)):b.grabbedCenter&&(b.hasDragged=!0,c<h?c=h:c>e+h-f&&(c=e+h-f),b.render(0,0,c-h,c-h+f)),b.hasDragged&&b.scrollbar&&b.scrollbar.options.liveRedraw&&(a.DOMType=a.type,
setTimeout(function(){b.onMouseUp(a)},0)))},onMouseUp:function(a){var b=this.chart,c=this.xAxis,d=this.scrollbar,e,f,h=a.DOMEvent||a;(!this.hasDragged||d&&d.hasDragged)&&"scrollbar"!==a.trigger||(this.zoomedMin===this.otherHandlePos?e=this.fixedExtreme:this.zoomedMax===this.otherHandlePos&&(f=this.fixedExtreme),this.zoomedMax===this.size&&(f=this.getUnionExtremes().dataMax),c=c.toFixedRange(this.zoomedMin,this.zoomedMax,e,f),r(c.min)&&b.xAxis[0].setExtremes(Math.min(c.min,c.max),Math.max(c.min,c.max),
!0,this.hasDragged?!1:null,{trigger:"navigator",triggerOp:"navigator-drag",DOMEvent:h}));"mousemove"!==a.DOMType&&(this.grabbedLeft=this.grabbedRight=this.grabbedCenter=this.fixedWidth=this.fixedExtreme=this.otherHandlePos=this.hasDragged=this.dragOffset=null)},removeEvents:function(){this.eventsToUnbind&&(n(this.eventsToUnbind,function(a){a()}),this.eventsToUnbind=void 0);this.removeBaseSeriesEvents()},removeBaseSeriesEvents:function(){var a=this.baseSeries||[];this.navigatorEnabled&&a[0]&&!1!==
this.navigatorOptions.adaptToUpdatedData&&(n(a,function(a){x(a,"updatedData",this.updatedDataHandler)},this),a[0].xAxis&&x(a[0].xAxis,"foundExtremes",this.modifyBaseAxisExtremes))},init:function(a){var b=a.options,c=b.navigator,d=c.enabled,e=b.scrollbar,f=e.enabled,b=d?c.height:0,h=f?e.height:0;this.handles=[];this.shades=[];this.chart=a;this.setBaseSeries();this.height=b;this.scrollbarHeight=h;this.scrollbarEnabled=f;this.navigatorEnabled=d;this.navigatorOptions=c;this.scrollbarOptions=e;this.outlineHeight=
b+h;this.opposite=p(c.opposite,!d&&a.inverted);var l=this,e=l.baseSeries,f=a.xAxis.length,m=a.yAxis.length,n=e&&e[0]&&e[0].xAxis||a.xAxis[0];a.extraMargin={type:l.opposite?"plotTop":"marginBottom",value:(d||!a.inverted?l.outlineHeight:0)+c.margin};a.inverted&&(a.extraMargin.type=l.opposite?"marginRight":"plotLeft");a.isDirtyBox=!0;l.navigatorEnabled?(l.xAxis=new G(a,B({breaks:n.options.breaks,ordinal:n.options.ordinal},c.xAxis,{id:"navigator-x-axis",yAxis:"navigator-y-axis",isX:!0,type:"datetime",
index:f,offset:0,keepOrdinalPadding:!0,startOnTick:!1,endOnTick:!1,minPadding:0,maxPadding:0,zoomEnabled:!1},a.inverted?{offsets:[h,0,-h,0],width:b}:{offsets:[0,-h,0,h],height:b})),l.yAxis=new G(a,B(c.yAxis,{id:"navigator-y-axis",alignTicks:!1,offset:0,index:m,zoomEnabled:!1},a.inverted?{width:b}:{height:b})),e||c.series.data?l.addBaseSeries():0===a.series.length&&u(a,"redraw",function(b,c){0<a.series.length&&!l.series&&(l.setBaseSeries(),a.redraw=b);b.call(a,c)}),l.renderElements(),l.addMouseEvents()):
l.xAxis={translate:function(b,c){var d=a.xAxis[0],g=d.getExtremes(),e=d.len-2*h,f=J("min",d.options.min,g.dataMin),d=J("max",d.options.max,g.dataMax)-f;return c?b*d/e+f:e*(b-f)/d},toPixels:function(a){return this.translate(a)},toValue:function(a){return this.translate(a,!0)},toFixedRange:G.prototype.toFixedRange,fake:!0};a.options.scrollbar.enabled&&(a.scrollbar=l.scrollbar=new k(a.renderer,B(a.options.scrollbar,{margin:l.navigatorEnabled?0:10,vertical:a.inverted}),a),C(l.scrollbar,"changed",function(b){var c=
l.size,d=c*this.to,c=c*this.from;l.hasDragged=l.scrollbar.hasDragged;l.render(0,0,c,d);(a.options.scrollbar.liveRedraw||"mousemove"!==b.DOMType)&&setTimeout(function(){l.onMouseUp(b)})}));l.addBaseSeriesEvents();l.addChartEvents()},getUnionExtremes:function(a){var b=this.chart.xAxis[0],c=this.xAxis,d=c.options,e=b.options,f;a&&null===b.dataMin||(f={dataMin:p(d&&d.min,J("min",e.min,b.dataMin,c.dataMin,c.min)),dataMax:p(d&&d.max,J("max",e.max,b.dataMax,c.dataMax,c.max))});return f},setBaseSeries:function(a){var b=
this.chart,c;a=a||b.options&&b.options.navigator.baseSeries||0;this.series&&(this.removeBaseSeriesEvents(),n(this.series,function(a){a.destroy()}));c=this.baseSeries=[];n(b.series||[],function(b,d){(b.options.showInNavigator||(d===a||b.options.id===a)&&!1!==b.options.showInNavigator)&&c.push(b)});this.xAxis&&!this.xAxis.fake&&this.addBaseSeries()},addBaseSeries:function(){var a=this,b=a.chart,c=a.series=[],d=a.baseSeries,e,f,h=a.navigatorOptions.series,k,l={enableMouseTracking:!1,index:null,group:"nav",
padXAxis:!1,xAxis:"navigator-x-axis",yAxis:"navigator-y-axis",showInLegend:!1,stacking:!1,isInternal:!0,visible:!0};d?n(d,function(d,g){l.name="Navigator "+(g+1);e=d.options||{};k=e.navigatorOptions||{};f=B(e,l,h,k);g=k.data||h.data;a.hasNavigatorData=a.hasNavigatorData||!!g;f.data=g||e.data&&e.data.slice(0);d.navigatorSeries=b.initSeries(f);c.push(d.navigatorSeries)}):(f=B(h,l),f.data=h.data,a.hasNavigatorData=!!f.data,c.push(b.initSeries(f)));this.addBaseSeriesEvents()},addBaseSeriesEvents:function(){var a=
this,b=a.baseSeries||[];b[0]&&b[0].xAxis&&C(b[0].xAxis,"foundExtremes",this.modifyBaseAxisExtremes);!1!==this.navigatorOptions.adaptToUpdatedData&&n(b,function(b){b.xAxis&&C(b,"updatedData",this.updatedDataHandler);C(b,"remove",function(){this.navigatorSeries&&(f(a.series,this.navigatorSeries),this.navigatorSeries.remove(!1),delete this.navigatorSeries)})},this)},modifyNavigatorAxisExtremes:function(){var a=this.xAxis,b;a.getExtremes&&(!(b=this.getUnionExtremes(!0))||b.dataMin===a.min&&b.dataMax===
a.max||(a.min=b.dataMin,a.max=b.dataMax))},modifyBaseAxisExtremes:function(){var a=this.chart.navigator,b=this.getExtremes(),c=b.dataMin,d=b.dataMax,b=b.max-b.min,e=a.stickToMin,f=a.stickToMax,h,k,l=a.series&&a.series[0],m=!!this.setExtremes;this.eventArgs&&"rangeSelectorButton"===this.eventArgs.trigger||(e&&(k=c,h=k+b),f&&(h=d,e||(k=Math.max(h-b,l&&l.xData?l.xData[0]:-Number.MAX_VALUE))),m&&(e||f)&&t(k)&&(this.min=this.userMin=k,this.max=this.userMax=h));a.stickToMin=a.stickToMax=null},updatedDataHandler:function(){var a=
this.chart.navigator,b=this.navigatorSeries;a.stickToMin=t(this.xAxis.min)&&this.xAxis.min<=this.xData[0];a.stickToMax=Math.round(a.zoomedMax)>=Math.round(a.size);b&&!a.hasNavigatorData&&(b.options.pointStart=this.xData[0],b.setData(this.options.data,!1,null,!1))},addChartEvents:function(){C(this.chart,"redraw",function(){var a=this.navigator,b=a&&(a.baseSeries&&a.baseSeries[0]&&a.baseSeries[0].xAxis||a.scrollbar&&this.xAxis[0]);b&&a.render(b.min,b.max)})},destroy:function(){this.removeEvents();this.xAxis&&
(f(this.chart.xAxis,this.xAxis),f(this.chart.axes,this.xAxis));this.yAxis&&(f(this.chart.yAxis,this.yAxis),f(this.chart.axes,this.yAxis));n(this.series||[],function(a){a.destroy&&a.destroy()});n("series xAxis yAxis shades outline scrollbarTrack scrollbarRifles scrollbarGroup scrollbar navigatorGroup rendered".split(" "),function(a){this[a]&&this[a].destroy&&this[a].destroy();this[a]=null},this);n([this.handles],function(a){w(a)},this)}};a.Navigator=D;u(G.prototype,"zoom",function(a,b,c){var d=this.chart,
e=d.options,g=e.chart.zoomType,f=e.navigator,e=e.rangeSelector,h;this.isXAxis&&(f&&f.enabled||e&&e.enabled)&&("x"===g?d.resetZoomButton="blocked":"y"===g?h=!1:"xy"===g&&(d=this.previousZoom,r(b)?this.previousZoom=[this.min,this.max]:d&&(b=d[0],c=d[1],delete this.previousZoom)));return void 0!==h?h:a.call(this,b,c)});u(H.prototype,"init",function(a,b,c){C(this,"beforeRender",function(){var a=this.options;if(a.navigator.enabled||a.scrollbar.enabled)this.scroller=this.navigator=new D(this)});a.call(this,
b,c)});u(H.prototype,"setChartSize",function(a){var b=this.legend,c=this.navigator,d,e,f,h;a.apply(this,[].slice.call(arguments,1));c&&(e=b.options,f=c.xAxis,h=c.yAxis,d=c.scrollbarHeight,this.inverted?(c.left=c.opposite?this.chartWidth-d-c.height:this.spacing[3]+d,c.top=this.plotTop+d):(c.left=this.plotLeft+d,c.top=c.navigatorOptions.top||this.chartHeight-c.height-d-this.spacing[2]-("bottom"===e.verticalAlign&&e.enabled&&!e.floating?b.legendHeight+p(e.margin,10):0)),f&&h&&(this.inverted?f.options.left=
h.options.left=c.left:f.options.top=h.options.top=c.top,f.setAxisSize(),h.setAxisSize()))});u(F.prototype,"addPoint",function(a,b,d,e,f){var g=this.options.turboThreshold;g&&this.xData.length>g&&h(b,!0)&&this.chart.navigator&&c(20,!0);a.call(this,b,d,e,f)});u(H.prototype,"addSeries",function(a,b,c,d){a=a.call(this,b,!1,d);this.navigator&&this.navigator.setBaseSeries();p(c,!0)&&this.redraw();return a});u(F.prototype,"update",function(a,b,c){a.call(this,b,!1);this.chart.navigator&&this.chart.navigator.setBaseSeries();
p(c,!0)&&this.chart.redraw()});H.prototype.callbacks.push(function(a){var b=a.navigator;b&&(a=a.xAxis[0].getExtremes(),b.render(a.min,a.max))})})(K);(function(a){function D(a){this.init(a)}var C=a.addEvent,G=a.Axis,H=a.Chart,v=a.css,l=a.createElement,r=a.dateFormat,w=a.defaultOptions,q=w.global.useUTC,n=a.defined,f=a.destroyObjectProperties,c=a.discardElement,e=a.each,z=a.extend,b=a.fireEvent,t=a.Date,h=a.isNumber,B=a.merge,p=a.pick,x=a.pInt,k=a.splat,F=a.wrap;z(w,{rangeSelector:{buttonTheme:{"stroke-width":0,
width:28,height:18,padding:2,zIndex:7},height:35,inputPosition:{align:"right"},labelStyle:{color:"#666666"}}});w.lang=B(w.lang,{rangeSelectorZoom:"Zoom",rangeSelectorFrom:"From",rangeSelectorTo:"To"});D.prototype={clickButton:function(a,b){var c=this,d=c.chart,f=c.buttonOptions[a],l=d.xAxis[0],n=d.scroller&&d.scroller.getUnionExtremes()||l||{},g=n.dataMin,r=n.dataMax,t,u=l&&Math.round(Math.min(l.max,p(r,l.max))),v=f.type,w,n=f._range,x,z,B,D=f.dataGrouping;if(null!==g&&null!==r){d.fixedRange=n;D&&
(this.forcedDataGrouping=!0,G.prototype.setDataGrouping.call(l||{chart:this.chart},D,!1));if("month"===v||"year"===v)l?(v={range:f,max:u,dataMin:g,dataMax:r},t=l.minFromRange.call(v),h(v.newMax)&&(u=v.newMax)):n=f;else if(n)t=Math.max(u-n,g),u=Math.min(t+n,r);else if("ytd"===v)if(l)void 0===r&&(g=Number.MAX_VALUE,r=Number.MIN_VALUE,e(d.series,function(a){a=a.xData;g=Math.min(a[0],g);r=Math.max(a[a.length-1],r)}),b=!1),u=c.getYTDExtremes(r,g,q),t=x=u.min,u=u.max;else{C(d,"beforeRender",function(){c.clickButton(a)});
return}else"all"===v&&l&&(t=g,u=r);c.setSelected(a);l?l.setExtremes(t,u,p(b,1),null,{trigger:"rangeSelectorButton",rangeSelectorButton:f}):(w=k(d.options.xAxis)[0],B=w.range,w.range=n,z=w.min,w.min=x,C(d,"load",function(){w.range=B;w.min=z}))}},setSelected:function(a){this.selected=this.options.selected=a},defaultButtons:[{type:"month",count:1,text:"1m"},{type:"month",count:3,text:"3m"},{type:"month",count:6,text:"6m"},{type:"ytd",text:"YTD"},{type:"year",count:1,text:"1y"},{type:"all",text:"All"}],
init:function(a){var c=this,d=a.options.rangeSelector,f=d.buttons||[].concat(c.defaultButtons),h=d.selected,k=function(){var a=c.minInput,d=c.maxInput;a&&a.blur&&b(a,"blur");d&&d.blur&&b(d,"blur")};c.chart=a;c.options=d;c.buttons=[];a.extraTopMargin=d.height;c.buttonOptions=f;this.unMouseDown=C(a.container,"mousedown",k);this.unResize=C(a,"resize",k);e(f,c.computeButtonRange);void 0!==h&&f[h]&&this.clickButton(h,!1);C(a,"load",function(){C(a.xAxis[0],"setExtremes",function(b){this.max-this.min!==
a.fixedRange&&"rangeSelectorButton"!==b.trigger&&"updatedData"!==b.trigger&&c.forcedDataGrouping&&this.setDataGrouping(!1,!1)})})},updateButtonStates:function(){var a=this.chart,b=a.xAxis[0],c=Math.round(b.max-b.min),f=!b.hasVisibleSeries,a=a.scroller&&a.scroller.getUnionExtremes()||b,k=a.dataMin,l=a.dataMax,a=this.getYTDExtremes(l,k,q),n=a.min,g=a.max,p=this.selected,r=h(p),t=this.options.allButtonsEnabled,v=this.buttons;e(this.buttonOptions,function(a,d){var e=a._range,h=a.type,m=a.count||1;a=v[d];
var q=0;d=d===p;var u=e>l-k,y=e<b.minRange,w=!1,x=!1,e=e===c;("month"===h||"year"===h)&&c>=864E5*{month:28,year:365}[h]*m&&c<=864E5*{month:31,year:366}[h]*m?e=!0:"ytd"===h?(e=g-n===c,w=!d):"all"===h&&(e=b.max-b.min>=l-k,x=!d&&r&&e);h=!t&&(u||y||x||f);e=d&&e||e&&!r&&!w;h?q=3:e&&(r=!0,q=2);a.state!==q&&a.setState(q)})},computeButtonRange:function(a){var b=a.type,c=a.count||1,d={millisecond:1,second:1E3,minute:6E4,hour:36E5,day:864E5,week:6048E5};if(d[b])a._range=d[b]*c;else if("month"===b||"year"===
b)a._range=864E5*{month:30,year:365}[b]*c},setInputValue:function(a,b){var c=this.chart.options.rangeSelector,d=this[a+"Input"];n(b)&&(d.previousValue=d.HCTime,d.HCTime=b);d.value=r(c.inputEditDateFormat||"%Y-%m-%d",d.HCTime);this[a+"DateBox"].attr({text:r(c.inputDateFormat||"%b %e, %Y",d.HCTime)})},showInput:function(a){var b=this.inputGroup,c=this[a+"DateBox"];v(this[a+"Input"],{left:b.translateX+c.x+"px",top:b.translateY+"px",width:c.width-2+"px",height:c.height-2+"px",border:"2px solid silver"})},
hideInput:function(a){v(this[a+"Input"],{border:0,width:"1px",height:"1px"});this.setInputValue(a)},drawInput:function(a){function b(){var a=p.value,b=(k.inputDateParser||Date.parse)(a),e=d.xAxis[0],g=d.scroller&&d.scroller.xAxis?d.scroller.xAxis:e,f=g.dataMin,g=g.dataMax;b!==p.previousValue&&(p.previousValue=b,h(b)||(b=a.split("-"),b=Date.UTC(x(b[0]),x(b[1])-1,x(b[2]))),h(b)&&(q||(b+=6E4*(new Date).getTimezoneOffset()),n?b>c.maxInput.HCTime?b=void 0:b<f&&(b=f):b<c.minInput.HCTime?b=void 0:b>g&&(b=
g),void 0!==b&&e.setExtremes(n?b:e.min,n?e.max:b,void 0,void 0,{trigger:"rangeSelectorInput"})))}var c=this,d=c.chart,e=d.renderer.style||{},f=d.renderer,k=d.options.rangeSelector,g=c.div,n="min"===a,p,r,t=this.inputGroup;this[a+"Label"]=r=f.label(w.lang[n?"rangeSelectorFrom":"rangeSelectorTo"],this.inputGroup.offset).addClass("highcharts-range-label").attr({padding:2}).add(t);t.offset+=r.width+5;this[a+"DateBox"]=f=f.label("",t.offset).addClass("highcharts-range-input").attr({padding:2,width:k.inputBoxWidth||
90,height:k.inputBoxHeight||17,stroke:k.inputBoxBorderColor||"#cccccc","stroke-width":1,"text-align":"center"}).on("click",function(){c.showInput(a);c[a+"Input"].focus()}).add(t);t.offset+=f.width+(n?10:0);this[a+"Input"]=p=l("input",{name:a,className:"highcharts-range-selector",type:"text"},{top:d.plotTop+"px"},g);r.css(B(e,k.labelStyle));f.css(B({color:"#333333"},e,k.inputStyle));v(p,z({position:"absolute",border:0,width:"1px",height:"1px",padding:0,textAlign:"center",fontSize:e.fontSize,fontFamily:e.fontFamily,
left:"-9em"},k.inputStyle));p.onfocus=function(){c.showInput(a)};p.onblur=function(){c.hideInput(a)};p.onchange=b;p.onkeypress=function(a){13===a.keyCode&&b()}},getPosition:function(){var a=this.chart,b=a.options.rangeSelector,a=p((b.buttonPosition||{}).y,a.plotTop-a.axisOffset[0]-b.height);return{buttonTop:a,inputTop:a-10}},getYTDExtremes:function(a,b,c){var d=new t(a),e=d[t.hcGetFullYear]();c=c?t.UTC(e,0,1):+new t(e,0,1);b=Math.max(b||0,c);d=d.getTime();return{max:Math.min(a||d,d),min:b}},render:function(a,
b){var c=this,d=c.chart,f=d.renderer,h=d.container,k=d.options,g=k.exporting&&!1!==k.exporting.enabled&&k.navigation&&k.navigation.buttonOptions,q=k.rangeSelector,r=c.buttons,k=w.lang,t=c.div,t=c.inputGroup,u=q.buttonTheme,v=q.buttonPosition||{},x=q.inputEnabled,B=u&&u.states,C=d.plotLeft,D,F=this.getPosition(),G=c.group,H=c.rendered;!1!==q.enabled&&(H||(c.group=G=f.g("range-selector-buttons").add(),c.zoomText=f.text(k.rangeSelectorZoom,p(v.x,C),15).css(q.labelStyle).add(G),D=p(v.x,C)+c.zoomText.getBBox().width+
5,e(c.buttonOptions,function(a,b){r[b]=f.button(a.text,D,0,function(){c.clickButton(b);c.isActive=!0},u,B&&B.hover,B&&B.select,B&&B.disabled).attr({"text-align":"center"}).add(G);D+=r[b].width+p(q.buttonSpacing,5)}),!1!==x&&(c.div=t=l("div",null,{position:"relative",height:0,zIndex:1}),h.parentNode.insertBefore(t,h),c.inputGroup=t=f.g("input-group").add(),t.offset=0,c.drawInput("min"),c.drawInput("max"))),c.updateButtonStates(),G[H?"animate":"attr"]({translateY:F.buttonTop}),!1!==x&&(t.align(z({y:F.inputTop,
width:t.offset,x:g&&F.inputTop<(g.y||0)+g.height-d.spacing[0]?-40:0},q.inputPosition),!0,d.spacingBox),n(x)||(d=G.getBBox(),t[t.alignAttr.translateX<d.x+d.width+10?"hide":"show"]()),c.setInputValue("min",a),c.setInputValue("max",b)),c.rendered=!0)},update:function(a){var b=this.chart;B(!0,b.options.rangeSelector,a);this.destroy();this.init(b)},destroy:function(){var a=this.minInput,b=this.maxInput,e;this.unMouseDown();this.unResize();f(this.buttons);a&&(a.onfocus=a.onblur=a.onchange=null);b&&(b.onfocus=
b.onblur=b.onchange=null);for(e in this)this[e]&&"chart"!==e&&(this[e].destroy?this[e].destroy():this[e].nodeType&&c(this[e])),this[e]!==D.prototype[e]&&(this[e]=null)}};G.prototype.toFixedRange=function(a,b,c,e){var d=this.chart&&this.chart.fixedRange;a=p(c,this.translate(a,!0,!this.horiz));b=p(e,this.translate(b,!0,!this.horiz));c=d&&(b-a)/d;.7<c&&1.3>c&&(e?a=b-d:b=a+d);h(a)||(a=b=void 0);return{min:a,max:b}};G.prototype.minFromRange=function(){var a=this.range,b={month:"Month",year:"FullYear"}[a.type],
c,e=this.max,f,k,l=function(a,c){var d=new Date(a);d["set"+b](d["get"+b]()+c);return d.getTime()-a};h(a)?(c=e-a,k=a):(c=e+l(e,-a.count),this.chart&&(this.chart.fixedRange=e-c));f=p(this.dataMin,Number.MIN_VALUE);h(c)||(c=f);c<=f&&(c=f,void 0===k&&(k=l(c,a.count)),this.newMax=Math.min(c+k,this.dataMax));h(e)||(c=void 0);return c};F(H.prototype,"init",function(a,b,c){C(this,"init",function(){this.options.rangeSelector.enabled&&(this.rangeSelector=new D(this))});a.call(this,b,c)});H.prototype.callbacks.push(function(a){function b(){c=
a.xAxis[0].getExtremes();h(c.min)&&d.render(c.min,c.max)}var c,d=a.rangeSelector,e,f;d&&(f=C(a.xAxis[0],"afterSetExtremes",function(a){d.render(a.min,a.max)}),e=C(a,"redraw",b),b());C(a,"destroy",function(){d&&(e(),f())})});a.RangeSelector=D})(K);(function(a){var D=a.arrayMax,C=a.arrayMin,G=a.Axis,H=a.Chart,v=a.defined,l=a.each,r=a.extend,w=a.format,q=a.inArray,n=a.isNumber,f=a.isString,c=a.map,e=a.merge,z=a.pick,b=a.Point,t=a.Renderer,h=a.Series,B=a.splat,p=a.SVGRenderer,x=a.VMLRenderer,k=a.wrap,
F=h.prototype,d=F.init,u=F.processData,m=b.prototype.tooltipFormatter;a.StockChart=a.stockChart=function(b,d,h){var k=f(b)||b.nodeName,g=arguments[k?1:0],l=g.series,m=a.getOptions(),n,p=z(g.navigator&&g.navigator.enabled,m.navigator.enabled,!0),q=p?{startOnTick:!1,endOnTick:!1}:null,r={marker:{enabled:!1,radius:2}},t={shadow:!1,borderWidth:0};g.xAxis=c(B(g.xAxis||{}),function(a){return e({minPadding:0,maxPadding:0,ordinal:!0,title:{text:null},labels:{overflow:"justify"},showLastLabel:!0},m.xAxis,
a,{type:"datetime",categories:null},q)});g.yAxis=c(B(g.yAxis||{}),function(a){n=z(a.opposite,!0);return e({labels:{y:-2},opposite:n,showLastLabel:!1,title:{text:null}},m.yAxis,a)});g.series=null;g=e({chart:{panning:!0,pinchType:"x"},navigator:{enabled:p},scrollbar:{enabled:z(m.scrollbar.enabled,!0)},rangeSelector:{enabled:z(m.rangeSelector.enabled,!0)},title:{text:null},tooltip:{shared:!0,crosshairs:!0},legend:{enabled:!1},plotOptions:{line:r,spline:r,area:r,areaspline:r,arearange:r,areasplinerange:r,
column:t,columnrange:t,candlestick:t,ohlc:t}},g,{isStock:!0});g.series=l;return k?new H(b,g,h):new H(g,d)};k(G.prototype,"autoLabelAlign",function(a){var b=this.chart,c=this.options,b=b._labelPanes=b._labelPanes||{},d=this.options.labels;return this.chart.options.isStock&&"yAxis"===this.coll&&(c=c.top+","+c.height,!b[c]&&d.enabled)?(15===d.x&&(d.x=0),void 0===d.align&&(d.align="right"),b[c]=this,"right"):a.call(this,[].slice.call(arguments,1))});k(G.prototype,"destroy",function(a){var b=this.chart,
c=this.options&&this.options.top+","+this.options.height;c&&b._labelPanes&&b._labelPanes[c]===this&&delete b._labelPanes[c];return a.call(this,Array.prototype.slice.call(arguments,1))});k(G.prototype,"getPlotLinePath",function(a,b,d,e,g,h){var k=this,m=this.isLinked&&!this.series?this.linkedParent.series:this.series,p=k.chart,r=p.renderer,t=k.left,u=k.top,w,x,y,B,E=[],C=[],D,F;if("colorAxis"===k.coll)return a.apply(this,[].slice.call(arguments,1));C=function(a){var b="xAxis"===a?"yAxis":"xAxis";a=
k.options[b];return n(a)?[p[b][a]]:f(a)?[p.get(a)]:c(m,function(a){return a[b]})}(k.coll);l(k.isXAxis?p.yAxis:p.xAxis,function(a){if(v(a.options.id)?-1===a.options.id.indexOf("navigator"):1){var b=a.isXAxis?"yAxis":"xAxis",b=v(a.options[b])?p[b][a.options[b]]:p[b][0];k===b&&C.push(a)}});D=C.length?[]:[k.isXAxis?p.yAxis[0]:p.xAxis[0]];l(C,function(a){-1===q(a,D)&&D.push(a)});F=z(h,k.translate(b,null,null,e));n(F)&&(k.horiz?l(D,function(a){var b;x=a.pos;B=x+a.len;w=y=Math.round(F+k.transB);if(w<t||
w>t+k.width)g?w=y=Math.min(Math.max(t,w),t+k.width):b=!0;b||E.push("M",w,x,"L",y,B)}):l(D,function(a){var b;w=a.pos;y=w+a.len;x=B=Math.round(u+k.height-F);if(x<u||x>u+k.height)g?x=B=Math.min(Math.max(u,x),k.top+k.height):b=!0;b||E.push("M",w,x,"L",y,B)}));return 0<E.length?r.crispPolyLine(E,d||1):null});G.prototype.getPlotBandPath=function(a,b){b=this.getPlotLinePath(b,null,null,!0);a=this.getPlotLinePath(a,null,null,!0);var c=[],d;if(a&&b)if(a.toString()===b.toString())c=a,c.flat=!0;else for(d=0;d<
a.length;d+=6)c.push("M",a[d+1],a[d+2],"L",a[d+4],a[d+5],b[d+4],b[d+5],b[d+1],b[d+2],"z");else c=null;return c};p.prototype.crispPolyLine=function(a,b){var c;for(c=0;c<a.length;c+=6)a[c+1]===a[c+4]&&(a[c+1]=a[c+4]=Math.round(a[c+1])-b%2/2),a[c+2]===a[c+5]&&(a[c+2]=a[c+5]=Math.round(a[c+2])+b%2/2);return a};t===x&&(x.prototype.crispPolyLine=p.prototype.crispPolyLine);k(G.prototype,"hideCrosshair",function(a,b){a.call(this,b);this.crossLabel&&(this.crossLabel=this.crossLabel.hide())});k(G.prototype,
"drawCrosshair",function(a,b,c){var d,e;a.call(this,b,c);if(v(this.crosshair.label)&&this.crosshair.label.enabled&&this.cross){a=this.chart;var f=this.options.crosshair.label,h=this.horiz;d=this.opposite;e=this.left;var k=this.top,l=this.crossLabel,m,n=f.format,p="",q="inside"===this.options.tickPosition,t=!1!==this.crosshair.snap,u=0;b||(b=this.cross&&this.cross.e);m=h?"center":d?"right"===this.labelAlign?"right":"left":"left"===this.labelAlign?"left":"center";l||(l=this.crossLabel=a.renderer.label(null,
null,null,f.shape||"callout").addClass("highcharts-crosshair-label"+(this.series[0]&&" highcharts-color-"+this.series[0].colorIndex)).attr({align:f.align||m,padding:z(f.padding,8),r:z(f.borderRadius,3),zIndex:2}).add(this.labelGroup),l.attr({fill:f.backgroundColor||this.series[0]&&this.series[0].color||"#666666",stroke:f.borderColor||"","stroke-width":f.borderWidth||0}).css(r({color:"#ffffff",fontWeight:"normal",fontSize:"11px",textAlign:"center"},f.style)));h?(m=t?c.plotX+e:b.chartX,k+=d?0:this.height):
(m=d?this.width+e:0,k=t?c.plotY+k:b.chartY);n||f.formatter||(this.isDatetimeAxis&&(p="%b %d, %Y"),n="{value"+(p?":"+p:"")+"}");b=t?c[this.isXAxis?"x":"y"]:this.toValue(h?b.chartX:b.chartY);l.attr({text:n?w(n,{value:b}):f.formatter.call(this,b),x:m,y:k,visibility:"visible"});b=l.getBBox();if(h){if(q&&!d||!q&&d)k=l.y-b.height}else k=l.y-b.height/2;h?(d=e-b.x,e=e+this.width-b.x):(d="left"===this.labelAlign?e:0,e="right"===this.labelAlign?e+this.width:a.chartWidth);l.translateX<d&&(u=d-l.translateX);
l.translateX+b.width>=e&&(u=-(l.translateX+b.width-e));l.attr({x:m+u,y:k,anchorX:h?m:this.opposite?0:a.chartWidth,anchorY:h?this.opposite?a.chartHeight:0:k+b.height/2})}});F.init=function(){d.apply(this,arguments);this.setCompare(this.options.compare)};F.setCompare=function(a){this.modifyValue="value"===a||"percent"===a?function(b,c){var d=this.compareValue;if(void 0!==b&&void 0!==d)return b="value"===a?b-d:b/d*100-(100===this.options.compareBase?0:100),c&&(c.change=b),b}:null;this.userOptions.compare=
a;this.chart.hasRendered&&(this.isDirty=!0)};F.processData=function(){var a,b=-1,c,d,e,f;u.apply(this,arguments);if(this.xAxis&&this.processedYData)for(c=this.processedXData,d=this.processedYData,e=d.length,this.pointArrayMap&&(b=q("close",this.pointArrayMap),-1===b&&(b=q(this.pointValKey||"y",this.pointArrayMap))),a=0;a<e-1;a++)if(f=-1<b?d[a][b]:d[a],n(f)&&c[a+1]>=this.xAxis.min&&0!==f){this.compareValue=f;break}};k(F,"getExtremes",function(a){var b;a.apply(this,[].slice.call(arguments,1));this.modifyValue&&
(b=[this.modifyValue(this.dataMin),this.modifyValue(this.dataMax)],this.dataMin=C(b),this.dataMax=D(b))});G.prototype.setCompare=function(a,b){this.isXAxis||(l(this.series,function(b){b.setCompare(a)}),z(b,!0)&&this.chart.redraw())};b.prototype.tooltipFormatter=function(b){b=b.replace("{point.change}",(0<this.change?"+":"")+a.numberFormat(this.change,z(this.series.tooltipOptions.changeDecimals,2)));return m.apply(this,[b])};k(h.prototype,"render",function(a){this.chart.is3d&&this.chart.is3d()||this.chart.polar||
!this.xAxis||this.xAxis.isRadial||(!this.clipBox&&this.animate?(this.clipBox=e(this.chart.clipBox),this.clipBox.width=this.xAxis.len,this.clipBox.height=this.yAxis.len):this.chart[this.sharedClipKey]?this.chart[this.sharedClipKey].attr({width:this.xAxis.len,height:this.yAxis.len}):this.clipBox&&(this.clipBox.width=this.xAxis.len,this.clipBox.height=this.yAxis.len));a.call(this)})})(K);return K});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 17043 17044 17045 17046 17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 17151 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 17353 17354 17355 17356 17357 17358 17359 17360 17361 17362 17363 17364 17365 17366 17367 17368 17369 17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 17507 17508 17509 17510 17511 17512 17513 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 17531 17532 17533 17534 17535 17536 17537 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 17598 17599 17600 17601 17602 17603 17604 17605 17606 17607 17608 17609 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 17639 17640 17641 17642 17643 17644 17645 17646 17647 17648 17649 17650 17651 17652 17653 17654 17655 17656 17657 17658 17659 17660 17661 17662 17663 17664 17665 17666 17667 17668 17669 17670 17671 17672 17673 17674 17675 17676 17677 17678 17679 17680 17681 17682 17683 17684 17685 17686 17687 17688 17689 17690 17691 17692 17693 17694 17695 17696 17697 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 17748 17749 17750 17751 17752 17753 17754 17755 17756 17757 17758 17759 17760 17761 17762 17763 17764 17765 17766 17767 17768 17769 17770 17771 17772 17773 17774 17775 17776 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 17787 17788 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 17799 17800 17801 17802 17803 17804 17805 17806 17807 17808 17809 17810 17811 17812 17813 17814 17815 17816 17817 17818 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 17843 17844 17845 17846 17847 17848 17849 17850 17851 17852 17853 17854 17855 17856 17857 17858 17859 17860 17861 17862 17863 17864 17865 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 17880 17881 17882 17883 17884 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 17931 17932 17933 17934 17935 17936 17937 17938 17939 17940 17941 17942 17943 17944 17945 17946 17947 17948 17949 17950 17951 17952 17953 17954 17955 17956 17957 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 17988 17989 17990 17991 17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 18002 18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 18038 18039 18040 18041 18042 18043 18044 18045 18046 18047 18048 18049 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 18103 18104 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 18167 18168 18169 18170 18171 18172 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 18185 18186 18187 18188 18189 18190 18191 18192 18193 18194 18195 18196 18197 18198 18199 18200 18201 18202 18203 18204 18205 18206 18207 18208 18209 18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 18242 18243 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 18470 18471 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 18559 18560 18561 18562 18563 18564 18565 18566 18567 18568 18569 18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 18793 18794 18795 18796 18797 18798 18799 18800 18801 18802 18803 18804 18805 18806 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 18880 18881 18882 18883 18884 18885 18886 18887 18888 18889 18890 18891 18892 18893 18894 18895 18896 18897 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 19000 19001 19002 19003 19004 19005 19006 19007 19008 19009 19010 19011 19012 19013 19014 19015 19016 19017 19018 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 19038 19039 19040 19041 19042 19043 19044 19045 19046 19047 19048 19049 19050 19051 19052 19053 19054 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 19088 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 19101 19102 19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352 19353 19354 19355 19356 19357 19358 19359 19360 19361 19362 19363 19364 19365 19366 19367 19368 19369 19370 19371 19372 19373 19374 19375 19376 19377 19378 19379 19380 19381 19382 19383 19384 19385 19386 19387 19388 19389 19390 19391 19392 19393 19394 19395 19396 19397 19398 19399 19400 19401 19402 19403 19404 19405 19406 19407 19408 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 19440 19441 19442 19443 19444 19445 19446 19447 19448 19449 19450 19451 19452 19453 19454 19455 19456 19457 19458 19459 19460 19461 19462 19463 19464 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 19483 19484 19485 19486 19487 19488 19489 19490 19491 19492 19493 19494 19495 19496 19497 19498 19499 19500 19501 19502 19503 19504 19505 19506 19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 19545 19546 19547 19548 19549 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 19565 19566 19567 19568 19569 19570 19571 19572 19573 19574 19575 19576 19577 19578 19579 19580 19581 19582 19583 19584 19585 19586 19587 19588 19589 19590 19591 19592 19593 19594 19595 19596 19597 19598 19599 19600 19601 19602 19603 19604 19605 19606 19607 19608 19609 19610 19611 19612 19613 19614 19615 19616 19617 19618 19619 19620 19621 19622 19623 19624 19625 19626 19627 19628 19629 19630 19631 19632 19633 19634 19635 19636 19637 19638 19639 19640 19641 19642 19643 19644 19645 19646 19647 19648 19649 19650 19651 19652 19653 19654 19655 19656 19657 19658 19659 19660 19661 19662 19663 19664 19665 19666 19667 19668 19669 19670 19671 19672 19673 19674 19675 19676 19677 19678 19679 19680 19681 19682 19683 19684 19685 19686 19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 19711 19712 19713 19714 19715 19716 19717 19718 19719 19720 19721 19722 19723 19724 19725 19726 19727 19728 19729 19730 19731 19732 19733 19734 19735 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 19760 19761 19762 19763 19764 19765 19766 19767 19768 19769 19770 19771 19772 19773 19774 19775 19776 19777 19778 19779 19780 19781 19782 19783 19784 19785 19786 19787 19788 19789 19790 19791 19792 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 19865 19866 19867 19868 19869 19870 19871 19872 19873 19874 19875 19876 19877 19878 19879 19880 19881 19882 19883 19884 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 20131 20132 20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 20148 20149 20150 20151 20152 20153 20154 20155 20156 20157 20158 20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 20326 20327 20328 20329 20330 20331 20332 20333 20334 20335 20336 20337 20338 20339 20340 20341 20342 20343 20344 20345 20346 20347 20348 20349 20350 20351 20352 20353 20354 20355 20356 20357 20358 20359 20360 20361 20362 20363 20364 20365 20366 20367 20368 20369 20370 20371 20372 20373 20374 20375 20376 20377 20378 20379 20380 20381 20382 20383 20384 20385 20386 20387 20388 20389 20390 20391 20392 20393 20394 20395 20396 20397 20398 20399 20400 20401 20402 20403 20404 20405 20406 20407 20408 20409 20410 20411 20412 20413 20414 20415 20416 20417 20418 20419 20420 20421 20422 20423 20424 20425 20426 20427 20428 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 20485 20486 20487 20488 20489 20490 20491 20492 20493 20494 20495 20496 20497 20498 20499 20500 20501 20502 20503 20504 20505 20506 20507 20508 20509 20510 20511 20512 20513 20514 20515 20516 20517 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 20530 20531 20532 20533 20534 20535 20536 20537 20538 20539 20540 20541 20542 20543 20544 20545 20546 20547 20548 20549 20550 20551 20552 20553 20554 20555 20556 20557 20558 20559 20560 20561 20562 20563 20564 20565 20566 20567 20568 20569 20570 20571 20572 20573 20574 20575 20576 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 20607 20608 20609 20610 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 20646 20647 20648 20649 20650 20651 20652 20653 20654 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 20672 20673 20674 20675 20676 20677 20678 20679 20680 20681 20682 20683 20684 20685 20686 20687 20688 20689 20690 20691 20692 20693 20694 20695 20696 20697 20698 20699 20700 20701 20702 20703 20704 20705 20706 20707 20708 20709 20710 20711 20712 20713 20714 20715 20716 20717 20718 20719 20720 20721 20722 20723 20724 20725 20726 20727 20728 20729 20730 20731 20732 20733 20734 20735 20736 20737 20738 20739 20740 20741 20742 20743 20744 20745 20746 20747 20748 20749 20750 20751 20752 20753 20754 20755 20756 20757 20758 20759 20760 20761 20762 20763 20764 20765 20766 20767 20768 20769 20770 20771 20772 20773 20774 20775 20776 20777 20778 20779 20780 20781 20782 20783 20784 20785 20786 20787 20788 20789 20790 20791 20792 20793 20794 20795 20796 20797 20798 20799 20800 20801 20802 20803 20804 20805 20806 20807 20808 20809 20810 20811 20812 20813 20814 20815 20816 20817 20818 20819 20820 20821 20822 20823 20824 20825 20826 20827 20828 20829 20830 20831 20832 20833 20834 20835 20836 20837 20838 20839 20840 20841 20842 20843 20844 20845 20846 20847 20848 20849 20850 20851 20852 20853 20854 20855 20856 20857 20858 20859 20860 20861 20862 20863 20864 20865 20866 20867 20868 20869 20870 20871 20872 20873 20874 20875 20876 20877 20878 20879 20880 20881 20882 20883 20884 20885 20886 20887 20888 20889 20890 20891 20892 20893 20894 20895 20896 20897 20898 20899 20900 20901 20902 20903 20904 20905 20906 20907 20908 20909 20910 20911 20912 20913 20914 20915 20916 20917 20918 20919 20920 20921 20922 20923 20924 20925 20926 20927 20928 20929 20930 20931 20932 20933 20934 20935 20936 20937 20938 20939 20940 20941 20942 20943 20944 20945 20946 20947 20948 20949 20950 20951 20952 20953 20954 20955 20956 20957 20958 20959 20960 20961 20962 20963 20964 20965 20966 20967 20968 20969 20970 20971 20972 20973 20974 20975 20976 20977 20978 20979 20980 20981 20982 20983 20984 20985 20986 20987 20988 20989 20990 20991 20992 20993 20994 20995 20996 20997 20998 20999 21000 21001 21002 21003 21004 21005 21006 21007 21008 21009 21010 21011 21012 21013 21014 21015 21016 21017 21018 21019 21020 21021 21022 21023 21024 21025 21026 21027 21028 21029 21030 21031 21032 21033 21034 21035 21036 21037 21038 21039 21040 21041 21042 21043 21044 21045 21046 21047 21048 21049 21050 21051 21052 21053 21054 21055 21056 21057 21058 21059 21060 21061 21062 21063 21064 21065 21066 21067 21068 21069 21070 21071 21072 21073 21074 21075 21076 21077 21078 21079 21080 21081 21082 21083 21084 21085 21086 21087 21088 21089 21090 21091 21092 21093 21094 21095 21096 21097 21098 21099 21100 21101 21102 21103 21104 21105 21106 21107 21108 21109 21110 21111 21112 21113 21114 21115 21116 21117 21118 21119 21120 21121 21122 21123 21124 21125 21126 21127 21128 21129 21130 21131 21132 21133 21134 21135 21136 21137 21138 21139 21140 21141 21142 21143 21144 21145 21146 21147 21148 21149 21150 21151 21152 21153 21154 21155 21156 21157 21158 21159 21160 21161 21162 21163 21164 21165 21166 21167 21168 21169 21170 21171 21172 21173 21174 21175 21176 21177 21178 21179 21180 21181 21182 21183 21184 21185 21186 21187 21188 21189 21190 21191 21192 21193 21194 21195 21196 21197 21198 21199 21200 21201 21202 21203 21204 21205 21206 21207 21208 21209 21210 21211 21212 21213 21214 21215 21216 21217 21218 21219 21220 21221 21222 21223 21224 21225 21226 21227 21228 21229 21230 21231 21232 21233 21234 21235 21236 21237 21238 21239 21240 21241 21242 21243 21244 21245 21246 21247 21248 21249 21250 21251 21252 21253 21254 21255 21256 21257 21258 21259 21260 21261 21262 21263 21264 21265 21266 21267 21268 21269 21270 21271 21272 21273 21274 21275 21276 21277 21278 21279 21280 21281 21282 21283 21284 21285 21286 21287 21288 21289 21290 21291 21292 21293 21294 21295 21296 21297 21298 21299 21300 21301 21302 21303 21304 21305 21306 21307 21308 21309 21310 21311 21312 21313 21314 21315 21316 21317 21318 21319 21320 21321 21322 21323 21324 21325 21326 21327 21328 21329 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 21345 21346 21347 21348 21349 21350 21351 21352 21353 21354 21355 21356 21357 21358 21359 21360 21361 21362 21363 21364 21365 21366 21367 21368 21369 21370 21371 21372 21373 21374 21375 21376 21377 21378 21379 21380 21381 21382 21383 21384 21385 21386 21387 21388 21389 21390 21391 21392 21393 21394 21395 21396 21397 21398 21399 21400 21401 21402 21403 21404 21405 21406 21407 21408 21409 21410 21411 21412 21413 21414 21415 21416 21417 21418 21419 21420 21421 21422 21423 21424 21425 21426 21427 21428 21429 21430 21431 21432 21433 21434 21435 21436 21437 21438 21439 21440 21441 21442 21443 21444 21445 21446 21447 21448 21449 21450 21451 21452 21453 21454 21455 21456 21457 21458 21459 21460 21461 21462 21463 21464 21465 21466 21467 21468 21469 21470 21471 21472 21473 21474 21475 21476 21477 21478 21479 21480 21481 21482 21483 21484 21485 21486 21487 21488 21489 21490 21491 21492 21493 21494 21495 21496 21497 21498 21499 21500 21501 21502 21503 21504 21505 21506 21507 21508 21509 21510 21511 21512 21513 21514 21515 21516 21517 21518 21519 21520 21521 21522 21523 21524 21525 21526 21527 21528 21529 21530 21531 21532 21533 21534 21535 21536 21537 21538 21539 21540 21541 21542 21543 21544 21545 21546 21547 21548 21549 21550 21551 21552 21553 21554 21555 21556 21557 21558 21559 21560 21561 21562 21563 21564 21565 21566 21567 21568 21569 21570 21571 21572 21573 21574 21575 21576 21577 21578 21579 21580 21581 21582 21583 21584 21585 21586 21587 21588 21589 21590 21591 21592 21593 21594 21595 21596 21597 21598 21599 21600 21601 21602 21603 21604 21605 21606 21607 21608 21609 21610 21611 21612 21613 21614 21615 21616 21617 21618 21619 21620 21621 21622 21623 21624 21625 21626 21627 21628 21629 21630 21631 21632 21633 21634 21635 21636 21637 21638 21639 21640 21641 21642 21643 21644 21645 21646 21647 21648 21649 21650 21651 21652 21653 21654 21655 21656 21657 21658 21659 21660 21661 21662 21663 21664 21665 21666 21667 21668 21669 21670 21671 21672 21673 21674 21675 21676 21677 21678 21679 21680 21681 21682 21683 21684 21685 21686 21687 21688 21689 21690 21691 21692 21693 21694 21695 21696 21697 21698 21699 21700 21701 21702 21703 21704 21705 21706 21707 21708 21709 21710 21711 21712 21713 21714 21715 21716 21717 21718 21719 21720 21721 21722 21723 21724 21725 21726 21727 21728 21729 21730 21731 21732 21733 21734 21735 21736 21737 21738 21739 21740 21741 21742 21743 21744 21745 21746 21747 21748 21749 21750 21751 21752 21753 21754 21755 21756 21757 21758 21759 21760 21761 21762 21763 21764 21765 21766 21767 21768 21769 21770 21771 21772 21773 21774 21775 21776 21777 21778 21779 21780 21781 21782 21783 21784 21785 21786 21787 21788 21789 21790 21791 21792 21793 21794 21795 21796 21797 21798 21799 21800 21801 21802 21803 21804 21805 21806 21807 21808 21809 21810 21811 21812 21813 21814 21815 21816 21817 21818 21819 21820 21821 21822 21823 21824 21825 21826 21827 21828 21829 21830 21831 21832 21833 21834 21835 21836 21837 21838 21839 21840 21841 21842 21843 21844 21845 21846 21847 21848 21849 21850 21851 21852 21853 21854 21855 21856 21857 21858 21859 21860 21861 21862 21863 21864 21865 21866 21867 21868 21869 21870 21871 21872 21873 21874 21875 21876 21877 21878 21879 21880 21881 21882 21883 21884 21885 21886 21887 21888 21889 21890 21891 21892 21893 21894 21895 21896 21897 21898 21899 21900 21901 21902 21903 21904 21905 21906 21907 21908 21909 21910 21911 21912 21913 21914 21915 21916 21917 21918 21919 21920 21921 21922 21923 21924 21925 21926 21927 21928 21929 21930 21931 21932 21933 21934 21935 21936 21937 21938 21939 21940 21941 21942 21943 21944 21945 21946 21947 21948 21949 21950 21951 21952 21953 21954 21955 21956 21957 21958 21959 21960 21961 21962 21963 21964 21965 21966 21967 21968 21969 21970 21971 21972 21973 21974 21975 21976 21977 21978 21979 21980 21981 21982 21983 21984 21985 21986 21987 21988 21989 21990 21991 21992 21993 21994 21995 21996 21997 21998 21999 22000 22001 22002 22003 22004 22005 22006 22007 22008 22009 22010 22011 22012 22013 22014 22015 22016 22017 22018 22019 22020 22021 22022 22023 22024 22025 22026 22027 22028 22029 22030 22031 22032 22033 22034 22035 22036 22037 22038 22039 22040 22041 22042 22043 22044 22045 22046 22047 22048 22049 22050 22051 22052 22053 22054 22055 22056 22057 22058 22059 22060 22061 22062 22063 22064 22065 22066 22067 22068 22069 22070 22071 22072 22073 22074 22075 22076 22077 22078 22079 22080 22081 22082 22083 22084 22085 22086 22087 22088 22089 22090 22091 22092 22093 22094 22095 22096 22097 22098 22099 22100 22101 22102 22103 22104 22105 22106 22107 22108 22109 22110 22111 22112 22113 22114 22115 22116 22117 22118 22119 22120 22121 22122 22123 22124 22125 22126 22127 22128 22129 22130 22131 22132 22133 22134 22135 22136 22137 22138 22139 22140 22141 22142 22143 22144 22145 22146 22147 22148 22149 22150 22151 22152 22153 22154 22155 22156 22157 22158 22159 22160 22161 22162 22163 22164 22165 22166 22167 22168 22169 22170 22171 22172 22173 22174 22175 22176 22177 22178 22179 22180 22181 22182 22183 22184 22185 22186 22187 22188 22189 22190 22191 22192 22193 22194 22195 22196 22197 22198 22199 22200 22201 22202 22203 22204 22205 22206 22207 22208 22209 22210 22211 22212 22213 22214 22215 22216 22217 22218 22219 22220 22221 22222 22223 22224 22225 22226 22227 22228 22229 22230 22231 22232 22233 22234 22235 22236 22237 22238 22239 22240 22241 22242 22243 22244 22245 22246 22247 22248 22249 22250 22251 22252 22253 22254 22255 22256 22257 22258 22259 22260 22261 22262 22263 22264 22265 22266 22267 22268 22269 22270 22271 22272 22273 22274 22275 22276 22277 22278 22279 22280 22281 22282 22283 22284 22285 22286 22287 22288 22289 22290 22291 22292 22293 22294 22295 22296 22297 22298 22299 22300 22301 22302 22303 22304 22305 22306 22307 22308 22309 22310 22311 22312 22313 22314 22315 22316 22317 22318 22319 22320 22321 22322 22323 22324 22325 22326 22327 22328 22329 22330 22331 22332 22333 22334 22335 22336 22337 22338 22339 22340 22341 22342 22343 22344 22345 22346 22347 22348 22349 22350 22351 22352 22353 22354 22355 22356 22357 22358 22359 22360 22361 22362 22363 22364 22365 22366 22367 22368 22369 22370 22371 22372 22373 22374 22375 22376 22377 22378 22379 22380 22381 22382 22383 22384 22385 22386 22387 22388 22389 22390 22391 22392 22393 22394 22395 22396 22397 22398 22399 22400 22401 22402 22403 22404 22405 22406 22407 22408 22409 22410 22411 22412 22413 22414 22415 22416 22417 22418 22419 22420 22421 22422 22423 22424 22425 22426 22427 22428 22429 22430 22431 22432 22433 22434 22435 22436 22437 22438 22439 22440 22441 22442 22443 22444 22445 22446 22447 22448 22449 22450 22451 22452 22453 22454 22455 22456 22457 22458 22459 22460 22461 22462 22463 22464 22465 22466 22467 22468 22469 22470 22471 22472 22473 22474 22475 22476 22477 22478 22479 22480 22481 22482 22483 22484 22485 22486 22487 22488 22489 22490 22491 22492 22493 22494 22495 22496 22497 22498 22499 22500 22501 22502 22503 22504 22505 22506 22507 22508 22509 22510 22511 22512 22513 22514 22515 22516 22517 22518 22519 22520 22521 22522 22523 22524 22525 22526 22527 22528 22529 22530 22531 22532 22533 22534 22535 22536 22537 22538 22539 22540 22541 22542 22543 22544 22545 22546 22547 22548 22549 22550 22551 22552 22553 22554 22555 22556 22557 22558 22559 22560 22561 22562 22563 22564 22565 22566 22567 22568 22569 22570 22571 22572 22573 22574 22575 22576 22577 22578 22579 22580 22581 22582 22583 22584 22585 22586 22587 22588 22589 22590 22591 22592 22593 22594 22595 22596 22597 22598 22599 22600 22601 22602 22603 22604 22605 22606 22607 22608 22609 22610 22611 22612 22613 22614 22615 22616 22617 22618 22619 22620 22621 22622 22623 22624 22625 22626 22627 22628 22629 22630 22631 22632 22633 22634 22635 22636 22637 22638 22639 22640 22641 22642 22643 22644 22645 22646 22647 22648 22649 22650 22651 22652 22653 22654 22655 22656 22657 22658 22659 22660 22661 22662 22663 22664 22665 22666 22667 22668 22669 22670 22671 22672 22673 22674 22675 22676 22677 22678 22679 22680 22681 22682 22683 22684 22685 22686 22687 22688 22689 22690 22691 22692 22693 22694 22695 22696 22697 22698 22699 22700 22701 22702 22703 22704 22705 22706 22707 22708 22709 22710 22711 22712 22713 22714 22715 22716 22717 22718 22719 22720 22721 22722 22723 22724 22725 22726 22727 22728 22729 22730 22731 22732 22733 22734 22735 22736 22737 22738 22739 22740 22741 22742 22743 22744 22745 22746 22747 22748 22749 22750 22751 22752 22753 22754 22755 22756 22757 22758 22759 22760 22761 22762 22763 22764 22765 22766 22767 22768 22769 22770 22771 22772 22773 22774 22775 22776 22777 22778 22779 22780 22781 22782 22783 22784 22785 22786 22787 22788 22789 22790 22791 22792 22793 22794 22795 22796 22797 22798 22799 22800 22801 22802 22803 22804 22805 22806 22807 22808 22809 22810 22811 22812 22813 22814 22815 22816 22817 22818 22819 22820 22821 22822 22823 22824 22825 22826 22827 22828 22829 22830 22831 22832 22833 22834 22835 22836 22837 22838 22839 22840 22841 22842 22843 22844 22845 22846 22847 22848 22849 22850 22851 22852 22853 22854 22855 22856 22857 22858 22859 22860 22861 22862 22863 22864 22865 22866 22867 22868 22869 22870 22871 22872 22873 22874 22875 22876 22877 22878 22879 22880 22881 22882 22883 22884 22885 22886 22887 22888 22889 22890 22891 22892 22893 22894 22895 22896 22897 22898 22899 22900 22901 22902 22903 22904 22905 22906 22907 22908 22909 22910 22911 22912 22913 22914 22915 22916 22917 22918 22919 22920 22921 22922 22923 22924 22925 22926 22927 22928 22929 22930 22931 22932 22933 22934 22935 22936 22937 22938 22939 22940 22941 22942 22943 22944 22945 22946 22947 22948 22949 22950 22951 22952 22953 22954 22955 22956 22957 22958 22959 22960 22961 22962 22963 22964 22965 22966 22967 22968 22969 22970 22971 22972 22973 22974 22975 22976 22977 22978 22979 22980 22981 22982 22983 22984 22985 22986 22987 22988 22989 22990 22991 22992 22993 22994 22995 22996 22997 22998 22999 23000 23001 23002 23003 23004 23005 23006 23007 23008 23009 23010 23011 23012 23013 23014 23015 23016 23017 23018 23019 23020 23021 23022 23023 23024 23025 23026 23027 23028 23029 23030 23031 23032 23033 23034 23035 23036 23037 23038 23039 23040 23041 23042 23043 23044 23045 23046 23047 23048 23049 23050 23051 23052 23053 23054 23055 23056 23057 23058 23059 23060 23061 23062 23063 23064 23065 23066 23067 23068 23069 23070 23071 23072 23073 23074 23075 23076 23077 23078 23079 23080 23081 23082 23083 23084 23085 23086 23087 23088 23089 23090 23091 23092 23093 23094 23095 23096 23097 23098 23099 23100 23101 23102 23103 23104 23105 23106 23107 23108 23109 23110 23111 23112 23113 23114 23115 23116 23117 23118 23119 23120 23121 23122 23123 23124 23125 23126 23127 23128 23129 23130 23131 23132 23133 23134 23135 23136 23137 23138 23139 23140 23141 23142 23143 23144 23145 23146 23147 23148 23149 23150 23151 23152 23153 23154 23155 23156 23157 23158 23159 23160 23161 23162 23163 23164 23165 23166 23167 23168 23169 23170 23171 23172 23173 23174 23175 23176 23177 23178 23179 23180 23181 23182 23183 23184 23185 23186 23187 23188 23189 23190 23191 23192 23193 23194 23195 23196 23197 23198 23199 23200 23201 23202 23203 23204 23205 23206 23207 23208 23209 23210 23211 23212 23213 23214 23215 23216 23217 23218 23219 23220 23221 23222 23223 23224 23225 23226 23227 23228 23229 23230 23231 23232 23233 23234 23235 23236 23237 23238 23239 23240 23241 23242 23243 23244 23245 23246 23247 23248 23249 23250 23251 23252 23253 23254 23255 23256 23257 23258 23259 23260 23261 23262 23263 23264 23265 23266 23267 23268 23269 23270 23271 23272 23273 23274 23275 23276 23277 23278 23279 23280 23281 23282 23283 23284 23285 23286 23287 23288 23289 23290 23291 23292 23293 23294 23295 23296 23297 23298 23299 23300 23301 23302 23303 23304 23305 23306 23307 23308 23309 23310 23311 23312 23313 23314 23315 23316 23317 23318 23319 23320 23321 23322 23323 23324 23325 23326 23327 23328 23329 23330 23331 23332 23333 23334 23335 23336 23337 23338 23339 23340 23341 23342 23343 23344 23345 23346 23347 23348 23349 23350 23351 23352 23353 23354 23355 23356 23357 23358 23359 23360 23361 23362 23363 23364 23365 23366 23367 23368 23369 23370 23371 23372 23373 23374 23375 23376 23377 23378 23379 23380 23381 23382 23383 23384 23385 23386 23387 23388 23389 23390 23391 23392 23393 23394 23395 23396 23397 23398 23399 23400 23401 23402 23403 23404 23405 23406 23407 23408 23409 23410 23411 23412 23413 23414 23415 23416 23417 23418 23419 23420 23421 23422 23423 23424 23425 23426 23427 23428 23429 23430 23431 23432 23433 23434 23435 23436 23437 23438 23439 23440 23441 23442 23443 23444 23445 23446 23447 23448 23449 23450 23451 23452 23453 23454 23455 23456 23457 23458 23459 23460 23461 23462 23463 23464 23465 23466 23467 23468 23469 23470 23471 23472 23473 23474 23475 23476 23477 23478 23479 23480 23481 23482 23483 23484 23485 23486 23487 23488 23489 23490 23491 23492 23493 23494 23495 23496 23497 23498 23499 23500 23501 23502 23503 23504 23505 23506 23507 23508 23509 23510 23511 23512 23513 23514 23515 23516 23517 23518 23519 23520 23521 23522 23523 23524 23525 23526 23527 23528 23529 23530 23531 23532 23533 23534 23535 23536 23537 23538 23539 23540 23541 23542 23543 23544 23545 23546 23547 23548 23549 23550 23551 23552 23553 23554 23555 23556 23557 23558 23559 23560 23561 23562 23563 23564 23565 23566 23567 23568 23569 23570 23571 23572 23573 23574 23575 23576 23577 23578 23579 23580 23581 23582 23583 23584 23585 23586 23587 23588 23589 23590 23591 23592 23593 23594 23595 23596 23597 23598 23599 23600 23601 23602 23603 23604 23605 23606 23607 23608 23609 23610 23611 23612 23613 23614 23615 23616 23617 23618 23619 23620 23621 23622 23623 23624 23625 23626 23627 23628 23629 23630 23631 23632 23633 23634 23635 23636 23637 23638 23639 23640 23641 23642 23643 23644 23645 23646 23647 23648 23649 23650 23651 23652 23653 23654 23655 23656 23657 23658 23659 23660 23661 23662 23663 23664 23665 23666 23667 23668 23669 23670 23671 23672 23673 23674 23675 23676 23677 23678 23679 23680 23681 23682 23683 23684 23685 23686 23687 23688 23689 23690 23691 23692 23693 23694 23695 23696 23697 23698 23699 23700 23701 23702 23703 23704 23705 23706 23707 23708 23709 23710 23711 23712 23713 23714 23715 23716 23717 23718 23719 23720 23721 23722 23723 23724 23725 23726 23727 23728 23729 23730 23731 23732 23733 23734 23735 23736 23737 23738 23739 23740 23741 23742 23743 23744 23745 23746 23747 23748 23749 23750 23751 23752 23753 23754 23755 23756 23757 23758 23759 23760 23761 23762 23763 23764 23765 23766 23767 23768 23769 23770 23771 23772 23773 23774 23775 23776 23777 23778 23779 23780 23781 23782 23783 23784 23785 23786 23787 23788 23789 23790 23791 23792 23793 23794 23795 23796 23797 23798 23799 23800 23801 23802 23803 23804 23805 23806 23807 23808 23809 23810 23811 23812 23813 23814 23815 23816 23817 23818 23819 23820 23821 23822 23823 23824 23825 23826 23827 23828 23829 23830 23831 23832 23833 23834 23835 23836 23837 23838 23839 23840 23841 23842 23843 23844 23845 23846 23847 23848 23849 23850 23851 23852 23853 23854 23855 23856 23857 23858 23859 23860 23861 23862 23863 23864 23865 23866 23867 23868 23869 23870 23871 23872 23873 23874 23875 23876 23877 23878 23879 23880 23881 23882 23883 23884 23885 23886 23887 23888 23889 23890 23891 23892 23893 23894 23895 23896 23897 23898 23899 23900 23901 23902 23903 23904 23905 23906 23907 23908 23909 23910 23911 23912 23913 23914 23915 23916 23917 23918 23919 23920 23921 23922 23923 23924 23925 23926 23927 23928 23929 23930 23931 23932 23933 23934 23935 23936 23937 23938 23939 23940 23941 23942 23943 23944 23945 23946 23947 23948 23949 23950 23951 23952 23953 23954 23955 23956 23957 23958 23959 23960 23961 23962 23963 23964 23965 23966 23967 23968 23969 23970 23971 23972 23973 23974 23975 23976 23977 23978 23979 23980 23981 23982 23983 23984 23985 23986 23987 23988 23989 23990 23991 23992 23993 23994 23995 23996 23997 23998 23999 24000 24001 24002 24003 24004 24005 24006 24007 24008 24009 24010 24011 24012 24013 24014 24015 24016 24017 24018 24019 24020 24021 24022 24023 24024 24025 24026 24027 24028 24029 24030 24031 24032 24033 24034 24035 24036 24037 24038 24039 24040 24041 24042 24043 24044 24045 24046 24047 24048 24049 24050 24051 24052 24053 24054 24055 24056 24057 24058 24059 24060 24061 24062 24063 24064 24065 24066 24067 24068 24069 24070 24071 24072 24073 24074 24075 24076 24077 24078 24079 24080 24081 24082 24083 24084 24085 24086 24087 24088 24089 24090 24091 24092 24093 24094 24095 24096 24097 24098 24099 24100 24101 24102 24103 24104 24105 24106 24107 24108 24109 24110 24111 24112 24113 24114 24115 24116 24117 24118 24119 24120 24121 24122 24123 24124 24125 24126 24127 24128 24129 24130 24131 24132 24133 24134 24135 24136 24137 24138 24139 24140 24141 24142 24143 24144 24145 24146 24147 24148 24149 24150 24151 24152 24153 24154 24155 24156 24157 24158 24159 24160 24161 24162 24163 24164 24165 24166 24167 24168 24169 24170 24171 24172 24173 24174 24175 24176 24177 24178 24179 24180 24181 24182 24183 24184 24185 24186 24187 24188 24189 24190 24191 24192 24193 24194 24195 24196 24197 24198 24199 24200 24201 24202 24203 24204 24205 24206 24207 24208 24209 24210 24211 24212 24213 24214 24215 24216 24217 24218 24219 24220 24221 24222 24223 24224 24225 24226 24227 24228 24229 24230 24231 24232 24233 24234 24235 24236 24237 24238 24239 24240 24241 24242 24243 24244 24245 24246 24247 24248 24249 24250 24251 24252 24253 24254 24255 24256 24257 24258 24259 24260 24261 24262 24263 24264 24265 24266 24267 24268 24269 24270 24271 24272 24273 24274 24275 24276 24277 24278 24279 24280 24281 24282 24283 24284 24285 24286 24287 24288 24289 24290 24291 24292 24293 24294 24295 24296 24297 24298 24299 24300 24301 24302 24303 24304 24305 24306 24307 24308 24309 24310 24311 24312 24313 24314 24315 24316 24317 24318 24319 24320 24321 24322 24323 24324 24325 24326 24327 24328 24329 24330 24331 24332 24333 24334 24335 24336 24337 24338 24339 24340 24341 24342 24343 24344 24345 24346 24347 24348 24349 24350 24351 24352 24353 24354 24355 24356 24357 24358 24359 24360 24361 24362 24363 24364 24365 24366 24367 24368 24369 24370 24371 24372 24373 24374 24375 24376 24377 24378 24379 24380 24381 24382 24383 24384 24385 24386 24387 24388 24389 24390 24391 24392 24393 24394 24395 24396 24397 24398 24399 24400 24401 24402 24403 24404 24405 24406 24407 24408 24409 24410 24411 24412 24413 24414 24415 24416 24417 24418 24419 24420 24421 24422 24423 24424 24425 24426 24427 24428 24429 24430 24431 24432 24433 24434 24435 24436 24437 24438 24439 24440 24441 24442 24443 24444 24445 24446 24447 24448 24449 24450 24451 24452 24453 24454 24455 24456 24457 24458 24459 24460 24461 24462 24463 24464 24465 24466 24467 24468 24469 24470 24471 24472 24473 24474 24475 24476 24477 24478 24479 24480 24481 24482 24483 24484 24485 24486 24487 24488 24489 24490 24491 24492 24493 24494 24495 24496 24497 24498 24499 24500 24501 24502 24503 24504 24505 24506 24507 24508 24509 24510 24511 24512 24513 24514 24515 24516 24517 24518 24519 24520 24521 24522 24523 24524 24525 24526 24527 24528 24529 24530 24531 24532 24533 24534 24535 24536 24537 24538 24539 24540 24541 24542 24543 24544 24545 24546 24547 24548 24549 24550 24551 24552 24553 24554 24555 24556 24557 24558 24559 24560 24561 24562 24563 24564 24565 24566 24567 24568 24569 24570 24571 24572 24573 24574 24575 24576 24577 24578 24579 24580 24581 24582 24583 24584 24585 24586 24587 24588 24589 24590 24591 24592 24593 24594 24595 24596 24597 24598 24599 24600 24601 24602 24603 24604 24605 24606 24607 24608 24609 24610 24611 24612 24613 24614 24615 24616 24617 24618 24619 24620 24621 24622 24623 24624 24625 24626 24627 24628 24629 24630 24631 24632 24633 24634 24635 24636 24637 24638 24639 24640 24641 24642 24643 24644 24645 24646 24647 24648 24649 24650 24651 24652 24653 24654 24655 24656 24657 24658 24659 24660 24661 24662 24663 24664 24665 24666 24667 24668 24669 24670 24671 24672 24673 24674 24675 24676 24677 24678 24679 24680 24681 24682 24683 24684 24685 24686 24687 24688 24689 24690 24691 24692 24693 24694 24695 24696 24697 24698 24699 24700 24701 24702 24703 24704 24705 24706 24707 24708 24709 24710 24711 24712 24713 24714 24715 24716 24717 24718 24719 24720 24721 24722 24723 24724 24725 24726 24727 24728 24729 24730 24731 24732 24733 24734 24735 24736 24737 24738 24739 24740 24741 24742 24743 24744 24745 24746 24747 24748 24749 24750 24751 24752 24753 24754 24755 24756 24757 24758 24759 24760 24761 24762 24763 24764 24765 24766 24767 24768 24769 24770 24771 24772 24773 24774 24775 24776 24777 24778 24779 24780 24781 24782 24783 24784 24785 24786 24787 24788 24789 24790 24791 24792 24793 24794 24795 24796 24797 24798 24799 24800 24801 24802 24803 24804 24805 24806 24807 24808 24809 24810 24811 24812 24813 24814 24815 24816 24817 24818 24819 24820 24821 24822 24823 24824 24825 24826 24827 24828 24829 24830 24831 24832 24833 24834 24835 24836 24837 24838 24839 24840 24841 24842 24843 24844 24845 24846 24847 24848 24849 24850 24851 24852 24853 24854 24855 24856 24857 24858 24859 24860 24861 24862 24863 24864 24865 24866 24867 24868 24869 24870 24871 24872 24873 24874 24875 24876 24877 24878 24879 24880 24881 24882 24883 24884 24885 24886 24887 24888 24889 24890 24891 24892 24893 24894 24895 24896 24897 24898 24899 24900 24901 24902 24903 24904 24905 24906 24907 24908 24909 24910 24911 24912 24913 24914 24915 24916 24917 24918 24919 24920 24921 24922 24923 24924 24925 24926 24927 24928 24929 24930 24931 24932 24933 24934 24935 24936 24937 24938 24939 24940 24941 24942 24943 24944 24945 24946 24947 24948 24949 24950 24951 24952 24953 24954 24955 24956 24957 24958 24959 24960 24961 24962 24963 24964 24965 24966 24967 24968 24969 24970 24971 24972 24973 24974 24975 24976 24977 24978 24979 24980 24981 24982 24983 24984 24985 24986 24987 24988 24989 24990 24991 24992 24993 24994 24995 24996 24997 24998 24999 25000 25001 25002 25003 25004 25005 25006 25007 25008 25009 25010 25011 25012 25013 25014 25015 25016 25017 25018 25019 25020 25021 25022 25023 25024 25025 25026 25027 25028 25029 25030 25031 25032 25033 25034 25035 25036 25037 25038 25039 25040 25041 25042 25043 25044 25045 25046 25047 25048 25049 25050 25051 25052 25053 25054 25055 25056 25057 25058 25059 25060 25061 25062 25063 25064 25065 25066 25067 25068 25069 25070 25071 25072 25073 25074 25075 25076 25077 25078 25079 25080 25081 25082 25083 25084 25085 25086 25087 25088 25089 25090 25091 25092 25093 25094 25095 25096 25097 25098 25099 25100 25101 25102 25103 25104 25105 25106 25107 25108 25109 25110 25111 25112 25113 25114 25115 25116 25117 25118 25119 25120 25121 25122 25123 25124 25125 25126 25127 25128 25129 25130 25131 25132 25133 25134 25135 25136 25137 25138 25139 25140 25141 25142 25143 25144 25145 25146 25147 25148 25149 25150 25151 25152 25153 25154 25155 25156 25157 25158 25159 25160 25161 25162 25163 25164 25165 25166 25167 25168 25169 25170 25171 25172 25173 25174 25175 25176 25177 25178 25179 25180 25181 25182 25183 25184 25185 25186 25187 25188 25189 25190 25191 25192 25193 25194 25195 25196 25197 25198 25199 25200 25201 25202 25203 25204 25205 25206 25207 25208 25209 25210 25211 25212 25213 25214 25215 25216 25217 25218 25219 25220 25221 25222 25223 25224 25225 25226 25227 25228 25229 25230 25231 25232 25233 25234 25235 25236 25237 25238 25239 25240 25241 25242 25243 25244 25245 25246 25247 25248 25249 25250 25251 25252 25253 25254 25255 25256 25257 25258 25259 25260 25261 25262 25263 25264 25265 25266 25267 25268 25269 25270 25271 25272 25273 25274 25275 25276 25277 25278 25279 25280 25281 25282 25283 25284 25285 25286 25287 25288 25289 25290 25291 25292 25293 25294 25295 25296 25297 25298 25299 25300 25301 25302 25303 25304 25305 25306 25307 25308 25309 25310 25311 25312 25313 25314 25315 25316 25317 25318 25319 25320 25321 25322 25323 25324 25325 25326 25327 25328 25329 25330 25331 25332 25333 25334 25335 25336 25337 25338 25339 25340 25341 25342 25343 25344 25345 25346 25347 25348 25349 25350 25351 25352 25353 25354 25355 25356 25357 25358 25359 25360 25361 25362 25363 25364 25365 25366 25367 25368 25369 25370 25371 25372 25373 25374 25375 25376 25377 25378 25379 25380 25381 25382 25383 25384 25385 25386 25387 25388 25389 25390 25391 25392 25393 25394 25395 25396 25397 25398 25399 25400 25401 25402 25403 25404 25405 25406 25407 25408 25409 25410 25411 25412 25413 25414 25415 25416 25417 25418 25419 25420 25421 25422 25423 25424 25425 25426 25427 25428 25429 25430 25431 25432 25433 25434 25435 25436 25437 25438 25439 25440 25441 25442 25443 25444 25445 25446 25447 25448 25449 25450 25451 25452 25453 25454 25455 25456 25457 25458 25459 25460 25461 25462 25463 25464 25465 25466 25467 25468 25469 25470 25471 25472 25473 25474 25475 25476 25477 25478 25479 25480 25481 25482 25483 25484 25485 25486 25487 25488 25489 25490 25491 25492 25493 25494 25495 25496 25497 25498 25499 25500 25501 25502 25503 25504 25505 25506 25507 25508 25509 25510 25511 25512 25513 25514 25515 25516 25517 25518 25519 25520 25521 25522 25523 25524 25525 25526 25527 25528 25529 25530 25531 25532 25533 25534 25535 25536 25537 25538 25539 25540 25541 25542 25543 25544 25545 25546 25547 25548 25549 25550 25551 25552 25553 25554 25555 25556 25557 25558 25559 25560 25561 25562 25563 25564 25565 25566 25567 25568 25569 25570 25571 25572 25573 25574 25575 25576 25577 25578 25579 25580 25581 25582 25583 25584 25585 25586 25587 25588 25589 25590 25591 25592 25593 25594 25595 25596 25597 25598 25599 25600 25601 25602 25603 25604 25605 25606 25607 25608 25609 25610 25611 25612 25613 25614 25615 25616 25617 25618 25619 25620 25621 25622 25623 25624 25625 25626 25627 25628 25629 25630 25631 25632 25633 25634 25635 25636 25637 25638 25639 25640 25641 25642 25643 25644 25645 25646 25647 25648 25649 25650 25651 25652 25653 25654 25655 25656 25657 25658 25659 25660 25661 25662 25663 25664 25665 25666 25667 25668 25669 25670 25671 25672 25673 25674 25675 25676 25677 25678 25679 25680 25681 25682 25683 25684 25685 25686 25687 25688 25689 25690 25691 25692 25693 25694 25695 25696 25697 25698 25699 25700 25701 25702 25703 25704 25705 25706 25707 25708 25709 25710 25711 25712 25713 25714 25715 25716 25717 25718 25719 25720 25721 25722 25723 25724 25725 25726 25727 25728 25729 25730 25731 25732 25733 25734 25735 25736 25737 25738 25739 25740 25741 25742 25743 25744 25745 25746 25747 25748 25749 25750 25751 25752 25753 25754 25755 25756 25757 25758 25759 25760 25761 25762 25763 25764 25765 25766 25767 25768 25769 25770 25771 25772 25773 25774 25775 25776 25777 25778 25779 25780 25781 25782 25783 25784 25785 25786 25787 25788 25789 25790 25791 25792 25793 25794 25795 25796 25797 25798 25799 25800 25801 25802 25803 25804 25805 25806 25807 25808 25809 25810 25811 25812 25813 25814 25815 25816 25817 25818 25819 25820 25821 25822 25823 25824 25825 25826 25827 25828 25829 25830 25831 25832 25833 25834 25835 25836 25837 25838 25839 25840 25841 25842 25843 25844 25845 25846 25847 25848 25849 25850 25851 25852 25853 25854 25855 25856 25857 25858 25859 25860 25861 25862 25863 25864 25865 25866 25867 25868 25869 25870 25871 25872 25873 25874 25875 25876 25877 25878 25879 25880 25881 25882 25883 25884 25885 25886 25887 25888 25889 25890 25891 25892 25893 25894 25895 25896 25897 25898 25899 25900 25901 25902 25903 25904 25905 25906 25907 25908 25909 25910 25911 25912 25913 25914 25915 25916 25917 25918 25919 25920 25921 25922 25923 25924 25925 25926 25927 25928 25929 25930 25931 25932 25933 25934 25935 25936 25937 25938 25939 25940 25941 25942 25943 25944 25945 25946 25947 25948 25949 25950 25951 25952 25953 25954 25955 25956 25957 25958 25959 25960 25961 25962 25963 25964 25965 25966 25967 25968 25969 25970 25971 25972 25973 25974 25975 25976 25977 25978 25979 25980 25981 25982 25983 25984 25985 25986 25987 25988 25989 25990 25991 25992 25993 25994 25995 25996 25997 25998 25999 26000 26001 26002 26003 26004 26005 26006 26007 26008 26009 26010 26011 26012 26013 26014 26015 26016 26017 26018 26019 26020 26021 26022 26023 26024 26025 26026 26027 26028 26029 26030 26031 26032 26033 26034 26035 26036 26037 26038 26039 26040 26041 26042 26043 26044 26045 26046 26047 26048 26049 26050 26051 26052 26053 26054 26055 26056 26057 26058 26059 26060 26061 26062 26063 26064 26065 26066 26067 26068 26069 26070 26071 26072 26073 26074 26075 26076 26077 26078 26079 26080 26081 26082 26083 26084 26085 26086 26087 26088 26089 26090 26091 26092 26093 26094 26095 26096 26097 26098 26099 26100 26101 26102 26103 26104 26105 26106 26107 26108 26109 26110 26111 26112 26113 26114 26115 26116 26117 26118 26119 26120 26121 26122 26123 26124 26125 26126 26127 26128 26129 26130 26131 26132 26133 26134 26135 26136 26137 26138 26139 26140 26141 26142 26143 26144 26145 26146 26147 26148 26149 26150 26151 26152 26153 26154 26155 26156 26157 26158 26159 26160 26161 26162 26163 26164 26165 26166 26167 26168 26169 26170 26171 26172 26173 26174 26175 26176 26177 26178 26179 26180 26181 26182 26183 26184 26185 26186 26187 26188 26189 26190 26191 26192 26193 26194 26195 26196 26197 26198 26199 26200 26201 26202 26203 26204 26205 26206 26207 26208 26209 26210 26211 26212 26213 26214 26215 26216 26217 26218 26219 26220 26221 26222 26223 26224 26225 26226 26227 26228 26229 26230 26231 26232 26233 26234 26235 26236 26237 26238 26239 26240 26241 26242 26243 26244 26245 26246 26247 26248 26249 26250 26251 26252 26253 26254 26255 26256 26257 26258 26259 26260 26261 26262 26263 26264 26265 26266 26267 26268 26269 26270 26271 26272 26273 26274 26275 26276 26277 26278 26279 26280 26281 26282 26283 26284 26285 26286 26287 26288 26289 26290 26291 26292 26293 26294 26295 26296 26297 26298 26299 26300 26301 26302 26303 26304 26305 26306 26307 26308 26309 26310 26311 26312 26313 26314 26315 26316 26317 26318 26319 26320 26321 26322 26323 26324 26325 26326 26327 26328 26329 26330 26331 26332 26333 26334 26335 26336 26337 26338 26339 26340 26341 26342 26343 26344 26345 26346 26347 26348 26349 26350 26351 26352 26353 26354 26355 26356 26357 26358 26359 26360 26361 26362 26363 26364 26365 26366 26367 26368 26369 26370 26371 26372 26373 26374 26375 26376 26377 26378 26379 26380 26381 26382 26383 26384 26385 26386 26387 26388 26389 26390 26391 26392 26393 26394 26395 26396 26397 26398 26399 26400 26401 26402 26403 26404 26405 26406 26407 26408 26409 26410 26411 26412 26413 26414 26415 26416 26417 26418 26419 26420 26421 26422 26423 26424 26425 26426 26427 26428 26429 26430 26431 26432 26433 26434 26435 26436 26437 26438 26439 26440 26441 26442 26443 26444 26445 26446 26447 26448 26449 26450 26451 26452 26453 26454 26455 26456 26457 26458 26459 26460 26461 26462 26463 26464 26465 26466 26467 26468 26469 26470 26471 26472 26473 26474 26475 26476 26477 26478 26479 26480 26481 26482 26483 26484 26485 26486 26487 26488 26489 26490 26491 26492 26493 26494 26495 26496 26497 26498 26499 26500 26501 26502 26503 26504 26505 26506 26507 26508 26509 26510 26511 26512 26513 26514 26515 26516 26517 26518 26519 26520 26521 26522 26523 26524 26525 26526 26527 26528 26529 26530 26531 26532 26533 26534 26535 26536 26537 26538 26539 26540 26541 26542 26543 26544 26545 26546 26547 26548 26549 26550 26551 26552 26553 26554 26555 26556 26557 26558 26559 26560 26561 26562 26563 26564 26565 26566 26567 26568 26569 26570 26571 26572 26573 26574 26575 26576 26577 26578 26579 26580 26581 26582 26583 26584 26585 26586 26587 26588 26589 26590 26591 26592 26593 26594 26595 26596 26597 26598 26599 26600 26601 26602 26603 26604 26605 26606 26607 26608 26609 26610 26611 26612 26613 26614 26615 26616 26617 26618 26619 26620 26621 26622 26623 26624 26625 26626 26627 26628 26629 26630 26631 26632 26633 26634 26635 26636 26637 26638 26639 26640 26641 26642 26643 26644 26645 26646 26647 26648 26649 26650 26651 26652 26653 26654 26655 26656 26657 26658 26659 26660 26661 26662 26663 26664 26665 26666 26667 26668 26669 26670 26671 26672 26673 26674 26675 26676 26677 26678 26679 26680 26681 26682 26683 26684 26685 26686 26687 26688 26689 26690 26691 26692 26693 26694 26695 26696 26697 26698 26699 26700 26701 26702 26703 26704 26705 26706 26707 26708 26709 26710 26711 26712 26713 26714 26715 26716 26717 26718 26719 26720 26721 26722 26723 26724 26725 26726 26727 26728 26729 26730 26731 26732 26733 26734 26735 26736 26737 26738 26739 26740 26741 26742 26743 26744 26745 26746 26747 26748 26749 26750 26751 26752 26753 26754 26755 26756 26757 26758 26759 26760 26761 26762 26763 26764 26765 26766 26767 26768 26769 26770 26771 26772 26773 26774 26775 26776 26777 26778 26779 26780 26781 26782 26783 26784 26785 26786 26787 26788 26789 26790 26791 26792 26793 26794 26795 26796 26797 26798 26799 26800 26801 26802 26803 26804 26805 26806 26807 26808 26809 26810 26811 26812 26813 26814 26815 26816 26817 26818 26819 26820 26821 26822 26823 26824 26825 26826 26827 26828 26829 26830 26831 26832 26833 26834 26835 26836 26837 26838 26839 26840 26841 26842 26843 26844 26845 26846 26847 26848 26849 26850 26851 26852 26853 26854 26855 26856 26857 26858 26859 26860 26861 26862 26863 26864 26865 26866 26867 26868 26869 26870 26871 26872 26873 26874 26875 26876 26877 26878 26879 26880 26881 26882 26883 26884 26885 26886 26887 26888 26889 26890 26891 26892 26893 26894 26895 26896 26897 26898 26899 26900 26901 26902 26903 26904 26905 26906 26907 26908 26909 26910 26911 26912 26913 26914 26915 26916 26917 26918 26919 26920 26921 26922 26923 26924 26925 26926 26927 26928 26929 26930 26931 26932 26933 26934 26935 26936 26937 26938 26939 26940 26941 26942 26943 26944 26945 26946 26947 26948 26949 26950 26951 26952 26953 26954 26955 26956 26957 26958 26959 26960 26961 26962 26963 26964 26965 26966 26967 26968 26969 26970 26971 26972 26973 26974 26975 26976 26977 26978 26979 26980 26981 26982 26983 26984 26985 26986 26987 26988 26989 26990 26991 26992 26993 26994 26995 26996 26997 26998 26999 27000 27001 27002 27003 27004 27005 27006 27007 27008 27009 27010 27011 27012 27013 27014 27015 27016 27017 27018 27019 27020 27021 27022 27023 27024 27025 27026 27027 27028 27029 27030 27031 27032 27033 27034 27035 27036 27037 27038 27039 27040 27041 27042 27043 27044 27045 27046 27047 27048 27049 27050 27051 27052 27053 27054 27055 27056 27057 27058 27059 27060 27061 27062 27063 27064 27065 27066 27067 27068 27069 27070 27071 27072 27073 27074 27075 27076 27077 27078 27079 27080 27081 27082 27083 27084 27085 27086 27087 27088 27089 27090 27091 27092 27093 27094 27095 27096 27097 27098 27099 27100 27101 27102 27103 27104 27105 27106 27107 27108 27109 27110 27111 27112 27113 27114 27115 27116 27117 27118 27119 27120 27121 27122 27123 27124 27125 27126 27127 27128 27129 27130 27131 27132 27133 27134 27135 27136 27137 27138 27139 27140 27141 27142 27143 27144 27145 27146 27147 27148 27149 27150 27151 27152 27153 27154 27155 27156 27157 27158 27159 27160 27161 27162 27163 27164 27165 27166 27167 27168 27169 27170 27171 27172 27173 27174 27175 27176 27177 27178 27179 27180 27181 27182 27183 27184 27185 27186 27187 27188 27189 27190 27191 27192 27193 27194 27195 27196 27197 27198 27199 27200 27201 27202 27203 27204 27205 27206 27207 27208 27209 27210 27211 27212 27213 27214 27215 27216 27217 27218 27219 27220 27221 27222 27223 27224 27225 27226 27227 27228 27229 27230 27231 27232 27233 27234 27235 27236 27237 27238 27239 27240 27241 27242 27243 27244 27245 27246 27247 27248 27249 27250 27251 27252 27253 27254 27255 27256 27257 27258 27259 27260 27261 27262 27263 27264 27265 27266 27267 27268 27269 27270 27271 27272 27273 27274 27275 27276 27277 27278 27279 27280 27281 27282 27283 27284 27285 27286 27287 27288 27289 27290 27291 27292 27293 27294 27295 27296 27297 27298 27299 27300 27301 27302 27303 27304 27305 27306 27307 27308 27309 27310 27311 27312 27313 27314 27315 27316 27317 27318 27319 27320 27321 27322 27323 27324 27325 27326 27327 27328 27329 27330 27331 27332 27333 27334 27335 27336 27337 27338 27339 27340 27341 27342 27343 27344 27345 27346 27347 27348 27349 27350 27351 27352 27353 27354 27355 27356 27357 27358 27359 27360 27361 27362 27363 27364 27365 27366 27367 27368 27369 27370 27371 27372 27373 27374 27375 27376 27377 27378 27379 27380 27381 27382 27383 27384 27385 27386 27387 27388 27389 27390 27391 27392 27393 27394 27395 27396 27397 27398 27399 27400 27401 27402 27403 27404 27405 27406 27407 27408 27409 27410 27411 27412 27413 27414 27415 27416 27417 27418 27419 27420 27421 27422 27423 27424 27425 27426 27427 27428 27429 27430 27431 27432 27433 27434 27435 27436 27437 27438 27439 27440 27441 27442 27443 27444 27445 27446 27447 27448 27449 27450 27451 27452 27453 27454 27455 27456 27457 27458 27459 27460 27461 27462 27463 27464 27465 27466 27467 27468 27469 27470 27471 27472 27473 27474 27475 27476 27477 27478 27479 27480 27481 27482 27483 27484 27485 27486 27487 27488 27489 27490 27491 27492 27493 27494 27495 27496 27497 27498 27499 27500 27501 27502 27503 27504 27505 27506 27507 27508 27509 27510 27511 27512 27513 27514 27515 27516 27517 27518 27519 27520 27521 27522 27523 27524 27525 27526 27527 27528 27529 27530 27531 27532 27533 27534 27535 27536 27537 27538 27539 27540 27541 27542 27543 27544 27545 27546 27547 27548 27549 27550 27551 27552 27553 27554 27555 27556 27557 27558 27559 27560 27561 27562 27563 27564 27565 27566 27567 27568 27569 27570 27571 27572 27573 27574 27575 27576 27577 27578 27579 27580 27581 27582 27583 27584 27585 27586 27587 27588 27589 27590 27591 27592 27593 27594 27595 27596 27597 27598 27599 27600 27601 27602 27603 27604 27605 27606 27607 27608 27609 27610 27611 27612 27613 27614 27615 27616 27617 27618 27619 27620 27621 27622 27623 27624 27625 27626 27627 27628 27629 27630 27631 27632 27633 27634 27635 27636 27637 27638 27639 27640 27641 27642 27643 27644 27645 27646 27647 27648 27649 27650 27651 27652 27653 27654 27655 27656 27657 27658 27659 27660 27661 27662 27663 27664 27665 27666 27667 27668 27669 27670 27671 27672 27673 27674 27675 27676 27677 27678 27679 27680 27681 27682 27683 27684 27685 27686 27687 27688 27689 27690 27691 27692 27693 27694 27695 27696 27697 27698 27699 27700 27701 27702 27703 27704 27705 27706 27707 27708 27709 27710 27711 27712 27713 27714 27715 27716 27717 27718 27719 27720 27721 27722 27723 27724 27725 27726 27727 27728 27729 27730 27731 27732 27733 27734 27735 27736 27737 27738 27739 27740 27741 27742 27743 27744 27745 27746 27747 27748 27749 27750 27751 27752 27753 27754 27755 27756 27757 27758 27759 27760 27761 27762 27763 27764 27765 27766 27767 27768 27769 27770 27771 27772 27773 27774 27775 27776 27777 27778 27779 27780 27781 27782 27783 27784 27785 27786 27787 27788 27789 27790 27791 27792 27793 27794 27795 27796 27797 27798 27799 27800 27801 27802 27803 27804 27805 27806 27807 27808 27809 27810 27811 27812 27813 27814 27815 27816 27817 27818 27819 27820 27821 27822 27823 27824 27825 27826 27827 27828 27829 27830 27831 27832 27833 27834 27835 27836 27837 27838 27839 27840 27841 27842 27843 27844 27845 27846 27847 27848 27849 27850 27851 27852 27853 27854 27855 27856 27857 27858 27859 27860 27861 27862 27863 27864 27865 27866 27867 27868 27869 27870 27871 27872 27873 27874 27875 27876 27877 27878 27879 27880 27881 27882 27883 27884 27885 27886 27887 27888 27889 27890 27891 27892 27893 27894 27895 27896 27897 27898 27899 27900 27901 27902 27903 27904 27905 27906 27907 27908 27909 27910 27911 27912 27913 27914 27915 27916 27917 27918 27919 27920 27921 27922 27923 27924 27925 27926 27927 27928 27929 27930 27931 27932 27933 27934 27935 27936 27937 27938 27939 27940 27941 27942 27943 27944 27945 27946 27947 27948 27949 27950 27951 27952 27953 27954 27955 27956 27957 27958 27959 27960 27961 27962 27963 27964 27965 27966 27967 27968 27969 27970 27971 27972 27973 27974 27975 27976 27977 27978 27979 27980 27981 27982 27983 27984 27985 27986 27987 27988 27989 27990 27991 27992 27993 27994 27995 27996 27997 27998 27999 28000 28001 28002 28003 28004 28005 28006 28007 28008 28009 28010 28011 28012 28013 28014 28015 28016 28017 28018 28019 28020 28021 28022 28023 28024 28025 28026 28027 28028 28029 28030 28031 28032 28033 28034 28035 28036 28037 28038 28039 28040 28041 28042 28043 28044 28045 28046 28047 28048 28049 28050 28051 28052 28053 28054 28055 28056 28057 28058 28059 28060 28061 28062 28063 28064 28065 28066 28067 28068 28069 28070 28071 28072 28073 28074 28075 28076 28077 28078 28079 28080 28081 28082 28083 28084 28085 28086 28087 28088 28089 28090 28091 28092 28093 28094 28095 28096 28097 28098 28099 28100 28101 28102 28103 28104 28105 28106 28107 28108 28109 28110 28111 28112 28113 28114 28115 28116 28117 28118 28119 28120 28121 28122 28123 28124 28125 28126 28127 28128 28129 28130 28131 28132 28133 28134 28135 28136 28137 28138 28139 28140 28141 28142 28143 28144 28145 28146 28147 28148 28149 28150 28151 28152 28153 28154 28155 28156 28157 28158 28159 28160 28161 28162 28163 28164 28165 28166 28167 28168 28169 28170 28171 28172 28173 28174 28175 28176 28177 28178 28179 28180 28181 28182 28183 28184 28185 28186 28187 28188 28189 28190 28191 28192 28193 28194 28195 28196 28197 28198 28199 28200 28201 28202 28203 28204 28205 28206 28207 28208 28209 28210 28211 28212 28213 28214 28215 28216 28217 28218 28219 28220 28221 28222 28223 28224 28225 28226 28227 28228 28229 28230 28231 28232 28233 28234 28235 28236 28237 28238 28239 28240 28241 28242 28243 28244 28245 28246 28247 28248 28249 28250 28251 28252 28253 28254 28255 28256 28257 28258 28259 28260 28261 28262 28263 28264 28265 28266 28267 28268 28269 28270 28271 28272 28273 28274 28275 28276 28277 28278 28279 28280 28281 28282 28283 28284 28285 28286 28287 28288 28289 28290 28291 28292 28293 28294 28295 28296 28297 28298 28299 28300 28301 28302 28303 28304 28305 28306 28307 28308 28309 28310 28311 28312 28313 28314 28315 28316 28317 28318 28319 28320 28321 28322 28323 28324 28325 28326 28327 28328 28329 28330 28331 28332 28333 28334 28335 28336 28337 28338 28339 28340 28341 28342 28343 28344 28345 28346 28347 28348 28349 28350 28351 28352 28353 28354 28355 28356 28357 28358 28359 28360 28361 28362 28363 28364 28365 28366 28367 28368 28369 28370 28371 28372 28373 28374 28375 28376 28377 28378 28379 28380 28381 28382 28383 28384 28385 28386 28387 28388 28389 28390 28391 28392 28393 28394 28395 28396 28397 28398 28399 28400 28401 28402 28403 28404 28405 28406 28407 28408 28409 28410 28411 28412 28413 28414 28415 28416 28417 28418 28419 28420 28421 28422 28423 28424 28425 28426 28427 28428 28429 28430 28431 28432 28433 28434 28435 28436 28437 28438 28439 28440 28441 28442 28443 28444 28445 28446 28447 28448 28449 28450 28451 28452 28453 28454 28455 28456 28457 28458 28459 28460 28461 28462 28463 28464 28465 28466 28467 28468 28469 28470 28471 28472 28473 28474 28475 28476 28477 28478 28479 28480 28481 28482 28483 28484 28485 28486 28487 28488 28489 28490 28491 28492 28493 28494 28495 28496 28497 28498 28499 28500 28501 28502 28503 28504 28505 28506 28507 28508 28509 28510 28511 28512 28513 28514 28515 28516 28517 28518 28519 28520 28521 28522 28523 28524 28525 28526 28527 28528 28529 28530 28531 28532 28533 28534 28535 28536 28537 28538 28539 28540 28541 28542 28543 28544 28545 28546 28547 28548 28549 28550 28551 28552 28553 28554 28555 28556 28557 28558 28559 28560 28561 28562 28563 28564 28565 28566 28567 28568 28569 28570 28571 28572 28573 28574 28575 28576 28577 28578 28579 28580 28581 28582 28583 28584 28585 28586 28587 28588 28589 28590 28591 28592 28593 28594 28595 28596 28597 28598 28599 28600 28601 28602 28603 28604 28605 28606 28607 28608 28609 28610 28611 28612 28613 28614 28615 28616 28617 28618 28619 28620 28621 28622 28623 28624 28625 28626 28627 28628 28629 28630 28631 28632 28633 28634 28635 28636 28637 28638 28639 28640 28641 28642 28643 28644 28645 28646 28647 28648 28649 28650 28651 28652 28653 28654 28655 28656 28657 28658 28659 28660 28661 28662 28663 28664 28665 28666 28667 28668 28669 28670 28671 28672 28673 28674 28675 28676 28677 28678 28679 28680 28681 28682 28683 28684 28685 28686 28687 28688 28689 28690 28691 28692 28693 28694 28695 28696 28697 28698 28699 28700 28701 28702 28703 28704 28705 28706 28707 28708 28709 28710 28711 28712 28713 28714 28715 28716 28717 28718 28719 28720 28721 28722 28723 28724 28725 28726 28727 28728 28729 28730 28731 28732 28733 28734 28735 28736 28737 28738 28739 28740 28741 28742 28743 28744 28745 28746 28747 28748 28749 28750 28751 28752 28753 28754 28755 28756 28757 28758 28759 28760 28761 28762 28763 28764 28765 28766 28767 28768 28769 28770 28771 28772 28773 28774 28775 28776 28777 28778 28779 28780 28781 28782 28783 28784 28785 28786 28787 28788 28789 28790 28791 28792 28793 28794 28795 28796 28797 28798 28799 28800 28801 28802 28803 28804 28805 28806 28807 28808 28809 28810 28811 28812 28813 28814 28815 28816 28817 28818 28819 28820 28821 28822 28823 28824 28825 28826 28827 28828 28829 28830 28831 28832 28833 28834 28835 28836 28837 28838 28839 28840 28841 28842 28843 28844 28845 28846 28847 28848 28849 28850 28851 28852 28853 28854 28855 28856 28857 28858 28859 28860 28861 28862 28863 28864 28865 28866 28867 28868 28869 28870 28871 28872 28873 28874 28875 28876 28877 28878 28879 28880 28881 28882 28883 28884 28885 28886 28887 28888 28889 28890 28891 28892 28893 28894 28895 28896 28897 28898 28899 28900 28901 28902 28903 28904 28905 28906 28907 28908 28909 28910 28911 28912 28913 28914 28915 28916 28917 28918 28919 28920 28921 28922 28923 28924 28925 28926 28927 28928 28929 28930 28931 28932 28933 28934 28935 28936 28937 28938 28939 28940 28941 28942 28943 28944 28945 28946 28947 28948 28949 28950 28951 28952 28953 28954 28955 28956 28957 28958 28959 28960 28961 28962 28963 28964 28965 28966 28967 28968 28969 28970 28971 28972 28973 28974 28975 28976 28977 28978 28979 28980 28981 28982 28983 28984 28985 28986 28987 28988 28989 28990 28991 28992 28993 28994 28995 28996 28997 28998 28999 29000 29001 29002 29003 29004 29005 29006 29007 29008 29009 29010 29011 29012 29013 29014 29015 29016 29017 29018 29019 29020 29021 29022 29023 29024 29025 29026 29027 29028 29029 29030 29031 29032 29033 29034 29035 29036 29037 29038 29039 29040 29041 29042 29043 29044 29045 29046 29047 29048 29049 29050 29051 29052 29053 29054 29055 29056 29057 29058 29059 29060 29061 29062 29063 29064 29065 29066 29067 29068 29069 29070 29071 29072 29073 29074 29075 29076 29077 29078 29079 29080 29081 29082 29083 29084 29085 29086 29087 29088 29089 29090 29091 29092 29093 29094 29095 29096 29097 29098 29099 29100 29101 29102 29103 29104 29105 29106 29107 29108 29109 29110 29111 29112 29113 29114 29115 29116 29117 29118 29119 29120 29121 29122 29123 29124 29125 29126 29127 29128 29129 29130 29131 29132 29133 29134 29135 29136 29137 29138 29139 29140 29141 29142 29143 29144 29145 29146 29147 29148 29149 29150 29151 29152 29153 29154 29155 29156 29157 29158 29159 29160 29161 29162 29163 29164 29165 29166 29167 29168 29169 29170 29171 29172 29173 29174 29175 29176 29177 29178 29179 29180 29181 29182 29183 29184 29185 29186 29187 29188 29189 29190 29191 29192 29193 29194 29195 29196 29197 29198 29199 29200 29201 29202 29203 29204 29205 29206 29207 29208 29209 29210 29211 29212 29213 29214 29215 29216 29217 29218 29219 29220 29221 29222 29223 29224 29225 29226 29227 29228 29229 29230 29231 29232 29233 29234 29235 29236 29237 29238 29239 29240 29241 29242 29243 29244 29245 29246 29247 29248 29249 29250 29251 29252 29253 29254 29255 29256 29257 29258 29259 29260 29261 29262 29263 29264 29265 29266 29267 29268 29269 29270 29271 29272 29273 29274 29275 29276 29277 29278 29279 29280 29281 29282 29283 29284 29285 29286 29287 29288 29289 29290 29291 29292 29293 29294 29295 29296 29297 29298 29299 29300 29301 29302 29303 29304 29305 29306 29307 29308 29309 29310 29311 29312 29313 29314 29315 29316 29317 29318 29319 29320 29321 29322 29323 29324 29325 29326 29327 29328 29329 29330 29331 29332 29333 29334 29335 29336 29337 29338 29339 29340 29341 29342 29343 29344 29345 29346 29347 29348 29349 29350 29351 29352 29353 29354 29355 29356 29357 29358 29359 29360 29361 29362 29363 29364 29365 29366 29367 29368 29369 29370 29371 29372 29373 29374 29375 29376 29377 29378 29379 29380 29381 29382 29383 29384 29385 29386 29387 29388 29389 29390 29391 29392 29393 29394 29395 29396 29397 29398 29399 29400 29401 29402 29403 29404 29405 29406 29407 29408 29409 29410 29411 29412 29413 29414 29415 29416 29417 29418 29419 29420 29421 29422 29423 29424 29425 29426 29427 29428 29429 29430 29431 29432 29433 29434 29435 29436 29437 29438 29439 29440 29441 29442 29443 29444 29445 29446 29447 29448 29449 29450 29451 29452 29453 29454 29455 29456 29457 29458 29459 29460 29461 29462 29463 29464 29465 29466 29467 29468 29469 29470 29471 29472 29473 29474 29475 29476 29477 29478 29479 29480 29481 29482 29483 29484 29485 29486 29487 29488 29489 29490 29491 29492 29493 29494 29495 29496 29497 29498 29499 29500 29501 29502 29503 29504 29505 29506 29507 29508 29509 29510 29511 29512 29513 29514 29515 29516 29517 29518 29519 29520 29521 29522 29523 29524 29525 29526 29527 29528 29529 29530 29531 29532 29533 29534 29535 29536 29537 29538 29539 29540 29541 29542 29543 29544 29545 29546 29547 29548 29549 29550 29551 29552 29553 29554 29555 29556 29557 29558 29559 29560 29561 29562 29563 29564 29565 29566 29567 29568 29569 29570 29571 29572 29573 29574 29575 29576 29577 29578 29579 29580 29581 29582 29583 29584 29585 29586 29587 29588 29589 29590 29591 29592 29593 29594 29595 29596 29597 29598 29599 29600 29601 29602 29603 29604 29605 29606 29607 29608 29609 29610 29611 29612 29613 29614 29615 29616 29617 29618 29619 29620 29621 29622 29623 29624 29625 29626 29627 29628 29629 29630 29631 29632 29633 29634 29635 29636 29637 29638 29639 29640 29641 29642 29643 29644 29645 29646 29647 29648 29649 29650 29651 29652 29653 29654 29655 29656 29657 29658 29659 29660 29661 29662 29663 29664 29665 29666 29667 29668 29669 29670 29671 29672 29673 29674 29675 29676 29677 29678 29679 29680 29681 29682 29683 29684 29685 29686 29687 29688 29689 29690 29691 29692 29693 29694 29695 29696 29697 29698 29699 29700 29701 29702 29703 29704 29705 29706 29707 29708 29709 29710 29711 29712 29713 29714 29715 29716 29717 29718 29719 29720 29721 29722 29723 29724 29725 29726 29727 29728 29729 29730 29731 29732 29733 29734 29735 29736 29737 29738 29739 29740 29741 29742 29743 29744 29745 29746 29747 29748 29749 29750 29751 29752 29753 29754 29755 29756 29757 29758 29759 29760 29761 29762 29763 29764 29765 29766 29767 29768 29769 29770 29771 29772 29773 29774 29775 29776 29777 29778 29779 29780 29781 29782 29783 29784 29785 29786 29787 29788 29789 29790 29791 29792 29793 29794 29795 29796 29797 29798 29799 29800 29801 29802 29803 29804 29805 29806 29807 29808 29809 29810 29811 29812 29813 29814 29815 29816 29817 29818 29819 29820 29821 29822 29823 29824 29825 29826 29827 29828 29829 29830 29831 29832 29833 29834 29835 29836 29837 29838 29839 29840 29841 29842 29843 29844 29845 29846 29847 29848 29849 29850 29851 29852 29853 29854 29855 29856 29857 29858 29859 29860 29861 29862 29863 29864 29865 29866 29867 29868 29869 29870 29871 29872 29873 29874 29875 29876 29877 29878 29879 29880 29881 29882 29883 29884 29885 29886 29887 29888 29889 29890 29891 29892 29893 29894 29895 29896 29897 29898 29899 29900 29901 29902 29903 29904 29905 29906 29907 29908 29909 29910 29911 29912 29913 29914 29915 29916 29917 29918 29919 29920 29921 29922 29923 29924 29925 29926 29927 29928 29929 29930 29931 29932 29933 29934 29935 29936 29937 29938 29939 29940 29941 29942 29943 29944 29945 29946 29947 29948 29949 29950 29951 29952 29953 29954 29955 29956 29957 29958 29959 29960 29961 29962 29963 29964 29965 29966 29967 29968 29969 29970 29971 29972 29973 29974 29975 29976 29977 29978 29979 29980 29981 29982 29983 29984 29985 29986 29987 29988 29989 29990 29991 29992 29993 29994 29995 29996 29997 29998 29999 30000 30001 30002 30003 30004 30005 30006 30007 30008 30009 30010 30011 30012 30013 30014 30015 30016 30017 30018 30019 30020 30021 30022 30023 30024 30025 30026 30027 30028 30029 30030 30031 30032 30033 30034 30035 30036 30037 30038 30039 30040 30041 30042 30043 30044 30045 30046 30047 30048 30049 30050 30051 30052 30053 30054 30055 30056 30057 30058 30059 30060 30061 30062 30063 30064 30065 30066 30067 30068 30069 30070 30071 30072 30073 30074 30075 30076 30077 30078 30079 30080 30081 30082 30083 30084 30085 30086 30087 30088 30089 30090 30091 30092 30093 30094 30095 30096 30097 30098 30099 30100 30101 30102 30103 30104 30105 30106 30107 30108 30109 30110 30111 30112 30113 30114 30115 30116 30117 30118 30119 30120 30121 30122 30123 30124 30125 30126 30127 30128 30129 30130 30131 30132 30133 30134 30135 30136 30137 30138 30139 30140 30141 30142 30143 30144 30145 30146 30147 30148 30149 30150 30151 30152 30153 30154 30155 30156 30157 30158 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /**
* @license Highstock JS v5.0.10 (2017-03-31)
*
* (c) 2009-2016 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(root, factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = root.document ?
factory(root) :
factory;
} else {
root.Highcharts = factory(root);
}
}(typeof window !== 'undefined' ? window : this, function(win) {
var Highcharts = (function() {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/* global window */
var win = window,
doc = win.document;
var SVG_NS = 'http://www.w3.org/2000/svg',
userAgent = (win.navigator && win.navigator.userAgent) || '',
svg = doc && doc.createElementNS && !!doc.createElementNS(SVG_NS, 'svg').createSVGRect,
isMS = /(edge|msie|trident)/i.test(userAgent) && !window.opera,
vml = !svg,
isFirefox = /Firefox/.test(userAgent),
hasBidiBug = isFirefox && parseInt(userAgent.split('Firefox/')[1], 10) < 4; // issue #38
var Highcharts = win.Highcharts ? win.Highcharts.error(16, true) : {
product: 'Highstock',
version: '5.0.10',
deg2rad: Math.PI * 2 / 360,
doc: doc,
hasBidiBug: hasBidiBug,
hasTouch: doc && doc.documentElement.ontouchstart !== undefined,
isMS: isMS,
isWebKit: /AppleWebKit/.test(userAgent),
isFirefox: isFirefox,
isTouchDevice: /(Mobile|Android|Windows Phone)/.test(userAgent),
SVG_NS: SVG_NS,
chartCount: 0,
seriesTypes: {},
symbolSizes: {},
svg: svg,
vml: vml,
win: win,
charts: [],
marginNames: ['plotTop', 'marginRight', 'marginBottom', 'plotLeft'],
noop: function() {
return undefined;
}
};
return Highcharts;
}());
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/* eslint max-len: ["warn", 80, 4] */
/**
* The Highcharts object is the placeholder for all other members, and various
* utility functions.
* @namespace Highcharts
*/
var timers = [];
var charts = H.charts,
doc = H.doc,
win = H.win;
/**
* Provide error messages for debugging, with links to online explanation. This
* function can be overridden to provide custom error handling.
*
* @function #error
* @memberOf Highcharts
* @param {Number|String} code - The error code. See [errors.xml]{@link
* https://github.com/highcharts/highcharts/blob/master/errors/errors.xml}
* for available codes. If it is a string, the error message is printed
* directly in the console.
* @param {Boolean} [stop=false] - Whether to throw an error or just log a
* warning in the console.
*/
H.error = function(code, stop) {
var msg = H.isNumber(code) ?
'Highcharts error #' + code + ': www.highcharts.com/errors/' + code :
code;
if (stop) {
throw new Error(msg);
}
// else ...
if (win.console) {
console.log(msg); // eslint-disable-line no-console
}
};
/**
* An animator object. One instance applies to one property (attribute or style
* prop) on one element.
*
* @constructor Fx
* @memberOf Highcharts
* @param {HTMLDOMElement|SVGElement} elem - The element to animate.
* @param {AnimationOptions} options - Animation options.
* @param {string} prop - The single attribute or CSS property to animate.
*/
H.Fx = function(elem, options, prop) {
this.options = options;
this.elem = elem;
this.prop = prop;
};
H.Fx.prototype = {
/**
* Set the current step of a path definition on SVGElement.
*
* @function #dSetter
* @memberOf Highcharts.Fx
*/
dSetter: function() {
var start = this.paths[0],
end = this.paths[1],
ret = [],
now = this.now,
i = start.length,
startVal;
// Land on the final path without adjustment points appended in the ends
if (now === 1) {
ret = this.toD;
} else if (i === end.length && now < 1) {
while (i--) {
startVal = parseFloat(start[i]);
ret[i] =
isNaN(startVal) ? // a letter instruction like M or L
start[i] :
now * (parseFloat(end[i] - startVal)) + startVal;
}
// If animation is finished or length not matching, land on right value
} else {
ret = end;
}
this.elem.attr('d', ret, null, true);
},
/**
* Update the element with the current animation step.
*
* @function #update
* @memberOf Highcharts.Fx
*/
update: function() {
var elem = this.elem,
prop = this.prop, // if destroyed, it is null
now = this.now,
step = this.options.step;
// Animation setter defined from outside
if (this[prop + 'Setter']) {
this[prop + 'Setter']();
// Other animations on SVGElement
} else if (elem.attr) {
if (elem.element) {
elem.attr(prop, now, null, true);
}
// HTML styles, raw HTML content like container size
} else {
elem.style[prop] = now + this.unit;
}
if (step) {
step.call(elem, now, this);
}
},
/**
* Run an animation.
*
* @function #run
* @memberOf Highcharts.Fx
* @param {Number} from - The current value, value to start from.
* @param {Number} to - The end value, value to land on.
* @param {String} [unit] - The property unit, for example `px`.
* @returns {void}
*/
run: function(from, to, unit) {
var self = this,
timer = function(gotoEnd) {
return timer.stopped ? false : self.step(gotoEnd);
},
i;
this.startTime = +new Date();
this.start = from;
this.end = to;
this.unit = unit;
this.now = this.start;
this.pos = 0;
timer.elem = this.elem;
timer.prop = this.prop;
if (timer() && timers.push(timer) === 1) {
timer.timerId = setInterval(function() {
for (i = 0; i < timers.length; i++) {
if (!timers[i]()) {
timers.splice(i--, 1);
}
}
if (!timers.length) {
clearInterval(timer.timerId);
}
}, 13);
}
},
/**
* Run a single step in the animation.
*
* @function #step
* @memberOf Highcharts.Fx
* @param {Boolean} [gotoEnd] - Whether to go to the endpoint of the
* animation after abort.
* @returns {Boolean} Returns `true` if animation continues.
*/
step: function(gotoEnd) {
var t = +new Date(),
ret,
done,
options = this.options,
elem = this.elem,
complete = options.complete,
duration = options.duration,
curAnim = options.curAnim,
i;
if (elem.attr && !elem.element) { // #2616, element is destroyed
ret = false;
} else if (gotoEnd || t >= duration + this.startTime) {
this.now = this.end;
this.pos = 1;
this.update();
curAnim[this.prop] = true;
done = true;
for (i in curAnim) {
if (curAnim[i] !== true) {
done = false;
}
}
if (done && complete) {
complete.call(elem);
}
ret = false;
} else {
this.pos = options.easing((t - this.startTime) / duration);
this.now = this.start + ((this.end - this.start) * this.pos);
this.update();
ret = true;
}
return ret;
},
/**
* Prepare start and end values so that the path can be animated one to one.
*
* @function #initPath
* @memberOf Highcharts.Fx
* @param {SVGElement} elem - The SVGElement item.
* @param {String} fromD - Starting path definition.
* @param {Array} toD - Ending path definition.
* @returns {Array} An array containing start and end paths in array form
* so that they can be animated in parallel.
*/
initPath: function(elem, fromD, toD) {
fromD = fromD || '';
var shift,
startX = elem.startX,
endX = elem.endX,
bezier = fromD.indexOf('C') > -1,
numParams = bezier ? 7 : 3,
fullLength,
slice,
i,
start = fromD.split(' '),
end = toD.slice(), // copy
isArea = elem.isArea,
positionFactor = isArea ? 2 : 1,
reverse;
/**
* In splines make moveTo and lineTo points have six parameters like
* bezier curves, to allow animation one-to-one.
*/
function sixify(arr) {
var isOperator,
nextIsOperator;
i = arr.length;
while (i--) {
// Fill in dummy coordinates only if the next operator comes
// three places behind (#5788)
isOperator = arr[i] === 'M' || arr[i] === 'L';
nextIsOperator = /[a-zA-Z]/.test(arr[i + 3]);
if (isOperator && nextIsOperator) {
arr.splice(
i + 1, 0,
arr[i + 1], arr[i + 2],
arr[i + 1], arr[i + 2]
);
}
}
}
/**
* Insert an array at the given position of another array
*/
function insertSlice(arr, subArr, index) {
[].splice.apply(
arr, [index, 0].concat(subArr)
);
}
/**
* If shifting points, prepend a dummy point to the end path.
*/
function prepend(arr, other) {
while (arr.length < fullLength) {
// Move to, line to or curve to?
arr[0] = other[fullLength - arr.length];
// Prepend a copy of the first point
insertSlice(arr, arr.slice(0, numParams), 0);
// For areas, the bottom path goes back again to the left, so we
// need to append a copy of the last point.
if (isArea) {
insertSlice(
arr,
arr.slice(arr.length - numParams), arr.length
);
i--;
}
}
arr[0] = 'M';
}
/**
* Copy and append last point until the length matches the end length
*/
function append(arr, other) {
var i = (fullLength - arr.length) / numParams;
while (i > 0 && i--) {
// Pull out the slice that is going to be appended or inserted.
// In a line graph, the positionFactor is 1, and the last point
// is sliced out. In an area graph, the positionFactor is 2,
// causing the middle two points to be sliced out, since an area
// path starts at left, follows the upper path then turns and
// follows the bottom back.
slice = arr.slice().splice(
(arr.length / positionFactor) - numParams,
numParams * positionFactor
);
// Move to, line to or curve to?
slice[0] = other[fullLength - numParams - (i * numParams)];
// Disable first control point
if (bezier) {
slice[numParams - 6] = slice[numParams - 2];
slice[numParams - 5] = slice[numParams - 1];
}
// Now insert the slice, either in the middle (for areas) or at
// the end (for lines)
insertSlice(arr, slice, arr.length / positionFactor);
if (isArea) {
i--;
}
}
}
if (bezier) {
sixify(start);
sixify(end);
}
// For sideways animation, find out how much we need to shift to get the
// start path Xs to match the end path Xs.
if (startX && endX) {
for (i = 0; i < startX.length; i++) {
// Moving left, new points coming in on right
if (startX[i] === endX[0]) {
shift = i;
break;
// Moving right
} else if (startX[0] ===
endX[endX.length - startX.length + i]) {
shift = i;
reverse = true;
break;
}
}
if (shift === undefined) {
start = [];
}
}
if (start.length && H.isNumber(shift)) {
// The common target length for the start and end array, where both
// arrays are padded in opposite ends
fullLength = end.length + shift * positionFactor * numParams;
if (!reverse) {
prepend(end, start);
append(start, end);
} else {
prepend(start, end);
append(end, start);
}
}
return [start, end];
}
}; // End of Fx prototype
/**
* Utility function to extend an object with the members of another.
*
* @function #extend
* @memberOf Highcharts
* @param {Object} a - The object to be extended.
* @param {Object} b - The object to add to the first one.
* @returns {Object} Object a, the original object.
*/
H.extend = function(a, b) {
var n;
if (!a) {
a = {};
}
for (n in b) {
a[n] = b[n];
}
return a;
};
/**
* Utility function to deep merge two or more objects and return a third object.
* If the first argument is true, the contents of the second object is copied
* into the first object. The merge function can also be used with a single
* object argument to create a deep copy of an object.
*
* @function #merge
* @memberOf Highcharts
* @param {Boolean} [extend] - Whether to extend the left-side object (a) or
return a whole new object.
* @param {Object} a - The first object to extend. When only this is given, the
function returns a deep copy.
* @param {...Object} [n] - An object to merge into the previous one.
* @returns {Object} - The merged object. If the first argument is true, the
* return is the same as the second argument.
*/
H.merge = function() {
var i,
args = arguments,
len,
ret = {},
doCopy = function(copy, original) {
var value, key;
// An object is replacing a primitive
if (typeof copy !== 'object') {
copy = {};
}
for (key in original) {
if (original.hasOwnProperty(key)) {
value = original[key];
// Copy the contents of objects, but not arrays or DOM nodes
if (H.isObject(value, true) &&
key !== 'renderTo' &&
typeof value.nodeType !== 'number') {
copy[key] = doCopy(copy[key] || {}, value);
// Primitives and arrays are copied over directly
} else {
copy[key] = original[key];
}
}
}
return copy;
};
// If first argument is true, copy into the existing object. Used in
// setOptions.
if (args[0] === true) {
ret = args[1];
args = Array.prototype.slice.call(args, 2);
}
// For each argument, extend the return
len = args.length;
for (i = 0; i < len; i++) {
ret = doCopy(ret, args[i]);
}
return ret;
};
/**
* Shortcut for parseInt
* @ignore
* @param {Object} s
* @param {Number} mag Magnitude
*/
H.pInt = function(s, mag) {
return parseInt(s, mag || 10);
};
/**
* Utility function to check for string type.
*
* @function #isString
* @memberOf Highcharts
* @param {Object} s - The item to check.
* @returns {Boolean} - True if the argument is a string.
*/
H.isString = function(s) {
return typeof s === 'string';
};
/**
* Utility function to check if an item is an array.
*
* @function #isArray
* @memberOf Highcharts
* @param {Object} obj - The item to check.
* @returns {Boolean} - True if the argument is an array.
*/
H.isArray = function(obj) {
var str = Object.prototype.toString.call(obj);
return str === '[object Array]' || str === '[object Array Iterator]';
};
/**
* Utility function to check if an item is of type object.
*
* @function #isObject
* @memberOf Highcharts
* @param {Object} obj - The item to check.
* @param {Boolean} [strict=false] - Also checks that the object is not an
* array.
* @returns {Boolean} - True if the argument is an object.
*/
H.isObject = function(obj, strict) {
return obj && typeof obj === 'object' && (!strict || !H.isArray(obj));
};
/**
* Utility function to check if an item is of type number.
*
* @function #isNumber
* @memberOf Highcharts
* @param {Object} n - The item to check.
* @returns {Boolean} - True if the item is a number and is not NaN.
*/
H.isNumber = function(n) {
return typeof n === 'number' && !isNaN(n);
};
/**
* Remove the last occurence of an item from an array.
*
* @function #erase
* @memberOf Highcharts
* @param {Array} arr - The array.
* @param {*} item - The item to remove.
*/
H.erase = function(arr, item) {
var i = arr.length;
while (i--) {
if (arr[i] === item) {
arr.splice(i, 1);
break;
}
}
};
/**
* Check if an object is null or undefined.
*
* @function #defined
* @memberOf Highcharts
* @param {Object} obj - The object to check.
* @returns {Boolean} - False if the object is null or undefined, otherwise
* true.
*/
H.defined = function(obj) {
return obj !== undefined && obj !== null;
};
/**
* Set or get an attribute or an object of attributes. To use as a setter, pass
* a key and a value, or let the second argument be a collection of keys and
* values. To use as a getter, pass only a string as the second argument.
*
* @function #attr
* @memberOf Highcharts
* @param {Object} elem - The DOM element to receive the attribute(s).
* @param {String|Object} [prop] - The property or an object of key-value pairs.
* @param {String} [value] - The value if a single property is set.
* @returns {*} When used as a getter, return the value.
*/
H.attr = function(elem, prop, value) {
var key,
ret;
// if the prop is a string
if (H.isString(prop)) {
// set the value
if (H.defined(value)) {
elem.setAttribute(prop, value);
// get the value
} else if (elem && elem.getAttribute) {
ret = elem.getAttribute(prop);
}
// else if prop is defined, it is a hash of key/value pairs
} else if (H.defined(prop) && H.isObject(prop)) {
for (key in prop) {
elem.setAttribute(key, prop[key]);
}
}
return ret;
};
/**
* Check if an element is an array, and if not, make it into an array.
*
* @function #splat
* @memberOf Highcharts
* @param obj {*} - The object to splat.
* @returns {Array} The produced or original array.
*/
H.splat = function(obj) {
return H.isArray(obj) ? obj : [obj];
};
/**
* Set a timeout if the delay is given, otherwise perform the function
* synchronously.
*
* @function #syncTimeout
* @memberOf Highcharts
* @param {Function} fn - The function callback.
* @param {Number} delay - Delay in milliseconds.
* @param {Object} [context] - The context.
* @returns {Number} An identifier for the timeout that can later be cleared
* with clearTimeout.
*/
H.syncTimeout = function(fn, delay, context) {
if (delay) {
return setTimeout(fn, delay, context);
}
fn.call(0, context);
};
/**
* Return the first value that is not null or undefined.
*
* @function #pick
* @memberOf Highcharts
* @param {...*} items - Variable number of arguments to inspect.
* @returns {*} The value of the first argument that is not null or undefined.
*/
H.pick = function() {
var args = arguments,
i,
arg,
length = args.length;
for (i = 0; i < length; i++) {
arg = args[i];
if (arg !== undefined && arg !== null) {
return arg;
}
}
};
/**
* @typedef {Object} CSSObject - A style object with camel case property names.
* The properties can be whatever styles are supported on the given SVG or HTML
* element.
* @example
* {
* fontFamily: 'monospace',
* fontSize: '1.2em'
* }
*/
/**
* Set CSS on a given element.
*
* @function #css
* @memberOf Highcharts
* @param {HTMLDOMElement} el - A HTML DOM element.
* @param {CSSObject} styles - Style object with camel case property names.
* @returns {void}
*/
H.css = function(el, styles) {
if (H.isMS && !H.svg) { // #2686
if (styles && styles.opacity !== undefined) {
styles.filter = 'alpha(opacity=' + (styles.opacity * 100) + ')';
}
}
H.extend(el.style, styles);
};
/**
* A HTML DOM element.
* @typedef {Object} HTMLDOMElement
*/
/**
* Utility function to create an HTML element with attributes and styles.
*
* @function #createElement
* @memberOf Highcharts
* @param {String} tag - The HTML tag.
* @param {Object} [attribs] - Attributes as an object of key-value pairs.
* @param {CSSObject} [styles] - Styles as an object of key-value pairs.
* @param {Object} [parent] - The parent HTML object.
* @param {Boolean} [nopad=false] - If true, remove all padding, border and
* margin.
* @returns {HTMLDOMElement} The created DOM element.
*/
H.createElement = function(tag, attribs, styles, parent, nopad) {
var el = doc.createElement(tag),
css = H.css;
if (attribs) {
H.extend(el, attribs);
}
if (nopad) {
css(el, {
padding: 0,
border: 'none',
margin: 0
});
}
if (styles) {
css(el, styles);
}
if (parent) {
parent.appendChild(el);
}
return el;
};
/**
* Extend a prototyped class by new members.
*
* @function #extendClass
* @memberOf Highcharts
* @param {Object} parent - The parent prototype to inherit.
* @param {Object} members - A collection of prototype members to add or
* override compared to the parent prototype.
* @returns {Object} A new prototype.
*/
H.extendClass = function(parent, members) {
var object = function() {};
object.prototype = new parent(); // eslint-disable-line new-cap
H.extend(object.prototype, members);
return object;
};
/**
* Left-pad a string to a given length by adding a character repetetively.
*
* @function #pad
* @memberOf Highcharts
* @param {Number} number - The input string or number.
* @param {Number} length - The desired string length.
* @param {String} [padder=0] - The character to pad with.
* @returns {String} The padded string.
*/
H.pad = function(number, length, padder) {
return new Array((length || 2) + 1 -
String(number).length).join(padder || 0) + number;
};
/**
* @typedef {Number|String} RelativeSize - If a number is given, it defines the
* pixel length. If a percentage string is given, like for example `'50%'`,
* the setting defines a length relative to a base size, for example the size
* of a container.
*/
/**
* Return a length based on either the integer value, or a percentage of a base.
*
* @function #relativeLength
* @memberOf Highcharts
* @param {RelativeSize} value - A percentage string or a number.
* @param {Number} base - The full length that represents 100%.
* @returns {Number} The computed length.
*/
H.relativeLength = function(value, base) {
return (/%$/).test(value) ?
base * parseFloat(value) / 100 :
parseFloat(value);
};
/**
* Wrap a method with extended functionality, preserving the original function.
*
* @function #wrap
* @memberOf Highcharts
* @param {Object} obj - The context object that the method belongs to. In real
* cases, this is often a prototype.
* @param {String} method - The name of the method to extend.
* @param {Function} func - A wrapper function callback. This function is called
* with the same arguments as the original function, except that the
* original function is unshifted and passed as the first argument.
* @returns {void}
*/
H.wrap = function(obj, method, func) {
var proceed = obj[method];
obj[method] = function() {
var args = Array.prototype.slice.call(arguments),
outerArgs = arguments,
ctx = this,
ret;
ctx.proceed = function() {
proceed.apply(ctx, arguments.length ? arguments : outerArgs);
};
args.unshift(proceed);
ret = func.apply(this, args);
ctx.proceed = null;
return ret;
};
};
/**
* Get the time zone offset based on the current timezone information as set in
* the global options.
*
* @function #getTZOffset
* @memberOf Highcharts
* @param {Number} timestamp - The JavaScript timestamp to inspect.
* @return {Number} - The timezone offset in minutes compared to UTC.
*/
H.getTZOffset = function(timestamp) {
var d = H.Date;
return ((d.hcGetTimezoneOffset && d.hcGetTimezoneOffset(timestamp)) ||
d.hcTimezoneOffset || 0) * 60000;
};
/**
* Format a date, based on the syntax for PHP's [strftime]{@link
* http://www.php.net/manual/en/function.strftime.php} function.
*
* @function #dateFormat
* @memberOf Highcharts
* @param {String} format - The desired format where various time
* representations are prefixed with %.
* @param {Number} timestamp - The JavaScript timestamp.
* @param {Boolean} [capitalize=false] - Upper case first letter in the return.
* @returns {String} The formatted date.
*/
H.dateFormat = function(format, timestamp, capitalize) {
if (!H.defined(timestamp) || isNaN(timestamp)) {
return H.defaultOptions.lang.invalidDate || '';
}
format = H.pick(format, '%Y-%m-%d %H:%M:%S');
var D = H.Date,
date = new D(timestamp - H.getTZOffset(timestamp)),
key, // used in for constuct below
// get the basic time values
hours = date[D.hcGetHours](),
day = date[D.hcGetDay](),
dayOfMonth = date[D.hcGetDate](),
month = date[D.hcGetMonth](),
fullYear = date[D.hcGetFullYear](),
lang = H.defaultOptions.lang,
langWeekdays = lang.weekdays,
shortWeekdays = lang.shortWeekdays,
pad = H.pad,
// List all format keys. Custom formats can be added from the outside.
replacements = H.extend({
//-- Day
// Short weekday, like 'Mon'
'a': shortWeekdays ?
shortWeekdays[day] : langWeekdays[day].substr(0, 3),
// Long weekday, like 'Monday'
'A': langWeekdays[day],
// Two digit day of the month, 01 to 31
'd': pad(dayOfMonth),
// Day of the month, 1 through 31
'e': pad(dayOfMonth, 2, ' '),
'w': day,
// Week (none implemented)
//'W': weekNumber(),
//-- Month
// Short month, like 'Jan'
'b': lang.shortMonths[month],
// Long month, like 'January'
'B': lang.months[month],
// Two digit month number, 01 through 12
'm': pad(month + 1),
//-- Year
// Two digits year, like 09 for 2009
'y': fullYear.toString().substr(2, 2),
// Four digits year, like 2009
'Y': fullYear,
//-- Time
// Two digits hours in 24h format, 00 through 23
'H': pad(hours),
// Hours in 24h format, 0 through 23
'k': hours,
// Two digits hours in 12h format, 00 through 11
'I': pad((hours % 12) || 12),
// Hours in 12h format, 1 through 12
'l': (hours % 12) || 12,
// Two digits minutes, 00 through 59
'M': pad(date[D.hcGetMinutes]()),
// Upper case AM or PM
'p': hours < 12 ? 'AM' : 'PM',
// Lower case AM or PM
'P': hours < 12 ? 'am' : 'pm',
// Two digits seconds, 00 through 59
'S': pad(date.getSeconds()),
// Milliseconds (naming from Ruby)
'L': pad(Math.round(timestamp % 1000), 3)
}, H.dateFormats);
// Do the replaces
for (key in replacements) {
// Regex would do it in one line, but this is faster
while (format.indexOf('%' + key) !== -1) {
format = format.replace(
'%' + key,
typeof replacements[key] === 'function' ?
replacements[key](timestamp) :
replacements[key]
);
}
}
// Optionally capitalize the string and return
return capitalize ?
format.substr(0, 1).toUpperCase() + format.substr(1) :
format;
};
/**
* Format a single variable. Similar to sprintf, without the % prefix.
*
* @example
* formatSingle('.2f', 5); // => '5.00'.
*
* @function #formatSingle
* @memberOf Highcharts
* @param {String} format The format string.
* @param {*} val The value.
* @returns {String} The formatted representation of the value.
*/
H.formatSingle = function(format, val) {
var floatRegex = /f$/,
decRegex = /\.([0-9])/,
lang = H.defaultOptions.lang,
decimals;
if (floatRegex.test(format)) { // float
decimals = format.match(decRegex);
decimals = decimals ? decimals[1] : -1;
if (val !== null) {
val = H.numberFormat(
val,
decimals,
lang.decimalPoint,
format.indexOf(',') > -1 ? lang.thousandsSep : ''
);
}
} else {
val = H.dateFormat(format, val);
}
return val;
};
/**
* Format a string according to a subset of the rules of Python's String.format
* method.
*
* @function #format
* @memberOf Highcharts
* @param {String} str The string to format.
* @param {Object} ctx The context, a collection of key-value pairs where each
* key is replaced by its value.
* @returns {String} The formatted string.
*
* @example
* var s = Highcharts.format(
* 'The {color} fox was {len:.2f} feet long',
* { color: 'red', len: Math.PI }
* );
* // => The red fox was 3.14 feet long
*/
H.format = function(str, ctx) {
var splitter = '{',
isInside = false,
segment,
valueAndFormat,
path,
i,
len,
ret = [],
val,
index;
while (str) {
index = str.indexOf(splitter);
if (index === -1) {
break;
}
segment = str.slice(0, index);
if (isInside) { // we're on the closing bracket looking back
valueAndFormat = segment.split(':');
path = valueAndFormat.shift().split('.'); // get first and leave
len = path.length;
val = ctx;
// Assign deeper paths
for (i = 0; i < len; i++) {
val = val[path[i]];
}
// Format the replacement
if (valueAndFormat.length) {
val = H.formatSingle(valueAndFormat.join(':'), val);
}
// Push the result and advance the cursor
ret.push(val);
} else {
ret.push(segment);
}
str = str.slice(index + 1); // the rest
isInside = !isInside; // toggle
splitter = isInside ? '}' : '{'; // now look for next matching bracket
}
ret.push(str);
return ret.join('');
};
/**
* Get the magnitude of a number.
*
* @function #getMagnitude
* @memberOf Highcharts
* @param {Number} number The number.
* @returns {Number} The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2
* etc.
*/
H.getMagnitude = function(num) {
return Math.pow(10, Math.floor(Math.log(num) / Math.LN10));
};
/**
* Take an interval and normalize it to multiples of round numbers.
*
* @todo Move this function to the Axis prototype. It is here only for
* historical reasons.
* @function #normalizeTickInterval
* @memberOf Highcharts
* @param {Number} interval - The raw, un-rounded interval.
* @param {Array} [multiples] - Allowed multiples.
* @param {Number} [magnitude] - The magnitude of the number.
* @param {Boolean} [allowDecimals] - Whether to allow decimals.
* @param {Boolean} [hasTickAmount] - If it has tickAmount, avoid landing
* on tick intervals lower than original.
* @returns {Number} The normalized interval.
*/
H.normalizeTickInterval = function(interval, multiples, magnitude,
allowDecimals, hasTickAmount) {
var normalized,
i,
retInterval = interval;
// round to a tenfold of 1, 2, 2.5 or 5
magnitude = H.pick(magnitude, 1);
normalized = interval / magnitude;
// multiples for a linear scale
if (!multiples) {
multiples = hasTickAmount ?
// Finer grained ticks when the tick amount is hard set, including
// when alignTicks is true on multiple axes (#4580).
[1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :
// Else, let ticks fall on rounder numbers
[1, 2, 2.5, 5, 10];
// the allowDecimals option
if (allowDecimals === false) {
if (magnitude === 1) {
multiples = H.grep(multiples, function(num) {
return num % 1 === 0;
});
} else if (magnitude <= 0.1) {
multiples = [1 / magnitude];
}
}
}
// normalize the interval to the nearest multiple
for (i = 0; i < multiples.length; i++) {
retInterval = multiples[i];
// only allow tick amounts smaller than natural
if ((hasTickAmount && retInterval * magnitude >= interval) ||
(!hasTickAmount && (normalized <= (multiples[i] +
(multiples[i + 1] || multiples[i])) / 2))) {
break;
}
}
// Multiply back to the correct magnitude. Correct floats to appropriate
// precision (#6085).
retInterval = H.correctFloat(
retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10)
);
return retInterval;
};
/**
* Sort an object array and keep the order of equal items. The ECMAScript
* standard does not specify the behaviour when items are equal.
*
* @function #stableSort
* @memberOf Highcharts
* @param {Array} arr - The array to sort.
* @param {Function} sortFunction - The function to sort it with, like with
* regular Array.prototype.sort.
* @returns {void}
*/
H.stableSort = function(arr, sortFunction) {
var length = arr.length,
sortValue,
i;
// Add index to each item
for (i = 0; i < length; i++) {
arr[i].safeI = i; // stable sort index
}
arr.sort(function(a, b) {
sortValue = sortFunction(a, b);
return sortValue === 0 ? a.safeI - b.safeI : sortValue;
});
// Remove index from items
for (i = 0; i < length; i++) {
delete arr[i].safeI; // stable sort index
}
};
/**
* Non-recursive method to find the lowest member of an array. `Math.min` raises
* a maximum call stack size exceeded error in Chrome when trying to apply more
* than 150.000 points. This method is slightly slower, but safe.
*
* @function #arrayMin
* @memberOf Highcharts
* @param {Array} data An array of numbers.
* @returns {Number} The lowest number.
*/
H.arrayMin = function(data) {
var i = data.length,
min = data[0];
while (i--) {
if (data[i] < min) {
min = data[i];
}
}
return min;
};
/**
* Non-recursive method to find the lowest member of an array. `Math.max` raises
* a maximum call stack size exceeded error in Chrome when trying to apply more
* than 150.000 points. This method is slightly slower, but safe.
*
* @function #arrayMax
* @memberOf Highcharts
* @param {Array} data - An array of numbers.
* @returns {Number} The highest number.
*/
H.arrayMax = function(data) {
var i = data.length,
max = data[0];
while (i--) {
if (data[i] > max) {
max = data[i];
}
}
return max;
};
/**
* Utility method that destroys any SVGElement instances that are properties on
* the given object. It loops all properties and invokes destroy if there is a
* destroy method. The property is then delete.
*
* @function #destroyObjectProperties
* @memberOf Highcharts
* @param {Object} obj - The object to destroy properties on.
* @param {Object} [except] - Exception, do not destroy this property, only
* delete it.
* @returns {void}
*/
H.destroyObjectProperties = function(obj, except) {
var n;
for (n in obj) {
// If the object is non-null and destroy is defined
if (obj[n] && obj[n] !== except && obj[n].destroy) {
// Invoke the destroy
obj[n].destroy();
}
// Delete the property from the object.
delete obj[n];
}
};
/**
* Discard a HTML element by moving it to the bin and delete.
*
* @function #discardElement
* @memberOf Highcharts
* @param {HTMLDOMElement} element - The HTML node to discard.
* @returns {void}
*/
H.discardElement = function(element) {
var garbageBin = H.garbageBin;
// create a garbage bin element, not part of the DOM
if (!garbageBin) {
garbageBin = H.createElement('div');
}
// move the node and empty bin
if (element) {
garbageBin.appendChild(element);
}
garbageBin.innerHTML = '';
};
/**
* Fix JS round off float errors.
*
* @function #correctFloat
* @memberOf Highcharts
* @param {Number} num - A float number to fix.
* @param {Number} [prec=14] - The precision.
* @returns {Number} The corrected float number.
*/
H.correctFloat = function(num, prec) {
return parseFloat(
num.toPrecision(prec || 14)
);
};
/**
* Set the global animation to either a given value, or fall back to the given
* chart's animation option.
*
* @function #setAnimation
* @memberOf Highcharts
* @param {Boolean|Animation} animation - The animation object.
* @param {Object} chart - The chart instance.
* @returns {void}
* @todo This function always relates to a chart, and sets a property on the
* renderer, so it should be moved to the SVGRenderer.
*/
H.setAnimation = function(animation, chart) {
chart.renderer.globalAnimation = H.pick(
animation,
chart.options.chart.animation,
true
);
};
/**
* Get the animation in object form, where a disabled animation is always
* returned as `{ duration: 0 }`.
*
* @function #animObject
* @memberOf Highcharts
* @param {Boolean|AnimationOptions} animation - An animation setting. Can be an
* object with duration, complete and easing properties, or a boolean to
* enable or disable.
* @returns {AnimationOptions} An object with at least a duration property.
*/
H.animObject = function(animation) {
return H.isObject(animation) ?
H.merge(animation) : {
duration: animation ? 500 : 0
};
};
/**
* The time unit lookup
*/
H.timeUnits = {
millisecond: 1,
second: 1000,
minute: 60000,
hour: 3600000,
day: 24 * 3600000,
week: 7 * 24 * 3600000,
month: 28 * 24 * 3600000,
year: 364 * 24 * 3600000
};
/**
* Format a number and return a string based on input settings.
*
* @function #numberFormat
* @memberOf Highcharts
* @param {Number} number - The input number to format.
* @param {Number} decimals - The amount of decimals. A value of -1 preserves
* the amount in the input number.
* @param {String} [decimalPoint] - The decimal point, defaults to the one given
* in the lang options.
* @param {String} [thousandsSep] - The thousands separator, defaults to the one
* given in the lang options.
* @returns {String} The formatted number.
*/
H.numberFormat = function(number, decimals, decimalPoint, thousandsSep) {
number = +number || 0;
decimals = +decimals;
var lang = H.defaultOptions.lang,
origDec = (number.toString().split('.')[1] || '').length,
strinteger,
thousands,
ret,
roundedNumber;
if (decimals === -1) {
// Preserve decimals. Not huge numbers (#3793).
decimals = Math.min(origDec, 20);
} else if (!H.isNumber(decimals)) {
decimals = 2;
}
// Add another decimal to avoid rounding errors of float numbers. (#4573)
// Then use toFixed to handle rounding.
roundedNumber = (
Math.abs(number) + Math.pow(10, -Math.max(decimals, origDec) - 1)
).toFixed(decimals);
// A string containing the positive integer component of the number
strinteger = String(H.pInt(roundedNumber));
// Leftover after grouping into thousands. Can be 0, 1 or 3.
thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;
// Language
decimalPoint = H.pick(decimalPoint, lang.decimalPoint);
thousandsSep = H.pick(thousandsSep, lang.thousandsSep);
// Start building the return
ret = number < 0 ? '-' : '';
// Add the leftover after grouping into thousands. For example, in the
// number 42 000 000, this line adds 42.
ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';
// Add the remaining thousands groups, joined by the thousands separator
ret += strinteger
.substr(thousands)
.replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);
// Add the decimal point and the decimal component
if (decimals) {
// Get the decimal component
ret += decimalPoint + roundedNumber.slice(-decimals);
}
return ret;
};
/**
* Easing definition
* @ignore
* @param {Number} pos Current position, ranging from 0 to 1.
*/
Math.easeInOutSine = function(pos) {
return -0.5 * (Math.cos(Math.PI * pos) - 1);
};
/**
* Get the computed CSS value for given element and property, only for numerical
* properties. For width and height, the dimension of the inner box (excluding
* padding) is returned. Used for fitting the chart within the container.
*
* @function #getStyle
* @memberOf Highcharts
* @param {HTMLDOMElement} el - A HTML element.
* @param {String} prop - The property name.
* @returns {Number} - The numeric value.
*/
H.getStyle = function(el, prop) {
var style;
// For width and height, return the actual inner pixel size (#4913)
if (prop === 'width') {
return Math.min(el.offsetWidth, el.scrollWidth) -
H.getStyle(el, 'padding-left') -
H.getStyle(el, 'padding-right');
} else if (prop === 'height') {
return Math.min(el.offsetHeight, el.scrollHeight) -
H.getStyle(el, 'padding-top') -
H.getStyle(el, 'padding-bottom');
}
// Otherwise, get the computed style
style = win.getComputedStyle(el, undefined);
return style && H.pInt(style.getPropertyValue(prop));
};
/**
* Search for an item in an array.
*
* @function #inArray
* @memberOf Highcharts
* @param {*} item - The item to search for.
* @param {arr} arr - The array or node collection to search in.
* @returns {Number} - The index within the array, or -1 if not found.
*/
H.inArray = function(item, arr) {
return arr.indexOf ? arr.indexOf(item) : [].indexOf.call(arr, item);
};
/**
* Filter an array by a callback.
*
* @function #grep
* @memberOf Highcharts
* @param {Array} arr - The array to filter.
* @param {Function} callback - The callback function. The function receives the
* item as the first argument. Return `true` if the item is to be
* preserved.
* @returns {Array} - A new, filtered array.
*/
H.grep = function(arr, callback) {
return [].filter.call(arr, callback);
};
/**
* Return the value of the first element in the array that satisfies the
* provided testing function.
*
* @function #find
* @memberOf Highcharts
* @param {Array} arr - The array to test.
* @param {Function} callback - The callback function. The function receives the
* item as the first argument. Return `true` if this item satisfies the
* condition.
* @returns {Mixed} - The value of the element.
*/
H.find = function(arr, callback) {
return [].find.call(arr, callback);
};
/**
* Map an array by a callback.
*
* @function #map
* @memberOf Highcharts
* @param {Array} arr - The array to map.
* @param {Function} fn - The callback function. Return the new value for the
* new array.
* @returns {Array} - A new array item with modified items.
*/
H.map = function(arr, fn) {
var results = [],
i = 0,
len = arr.length;
for (; i < len; i++) {
results[i] = fn.call(arr[i], arr[i], i, arr);
}
return results;
};
/**
* Get the element's offset position, corrected for `overflow: auto`.
*
* @function #offset
* @memberOf Highcharts
* @param {HTMLDOMElement} el - The HTML element.
* @returns {Object} An object containing `left` and `top` properties for the
* position in the page.
*/
H.offset = function(el) {
var docElem = doc.documentElement,
box = el.getBoundingClientRect();
return {
top: box.top + (win.pageYOffset || docElem.scrollTop) -
(docElem.clientTop || 0),
left: box.left + (win.pageXOffset || docElem.scrollLeft) -
(docElem.clientLeft || 0)
};
};
/**
* Stop running animation.
*
* @todo A possible extension to this would be to stop a single property, when
* we want to continue animating others. Then assign the prop to the timer
* in the Fx.run method, and check for the prop here. This would be an
* improvement in all cases where we stop the animation from .attr. Instead of
* stopping everything, we can just stop the actual attributes we're setting.
*
* @function #stop
* @memberOf Highcharts
* @param {SVGElement} el - The SVGElement to stop animation on.
* @param {string} [prop] - The property to stop animating. If given, the stop
* method will stop a single property from animating, while others continue.
* @returns {void}
*/
H.stop = function(el, prop) {
var i = timers.length;
// Remove timers related to this element (#4519)
while (i--) {
if (timers[i].elem === el && (!prop || prop === timers[i].prop)) {
timers[i].stopped = true; // #4667
}
}
};
/**
* Iterate over an array.
*
* @function #each
* @memberOf Highcharts
* @param {Array} arr - The array to iterate over.
* @param {Function} fn - The iterator callback. It passes three arguments:
* * item - The array item.
* * index - The item's index in the array.
* * arr - The array that each is being applied to.
* @param {Object} [ctx] The context.
*/
H.each = function(arr, fn, ctx) { // modern browsers
return Array.prototype.forEach.call(arr, fn, ctx);
};
/**
* Add an event listener.
*
* @function #addEvent
* @memberOf Highcharts
* @param {Object} el - The element or object to add a listener to. It can be a
* {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
* @param {String} type - The event type.
* @param {Function} fn - The function callback to execute when the event is
* fired.
* @returns {Function} A callback function to remove the added event.
*/
H.addEvent = function(el, type, fn) {
var events = el.hcEvents = el.hcEvents || {};
function wrappedFn(e) {
e.target = e.srcElement || win; // #2820
fn.call(el, e);
}
// Handle DOM events in modern browsers
if (el.addEventListener) {
el.addEventListener(type, fn, false);
// Handle old IE implementation
} else if (el.attachEvent) {
if (!el.hcEventsIE) {
el.hcEventsIE = {};
}
// Link wrapped fn with original fn, so we can get this in removeEvent
el.hcEventsIE[fn.toString()] = wrappedFn;
el.attachEvent('on' + type, wrappedFn);
}
if (!events[type]) {
events[type] = [];
}
events[type].push(fn);
// Return a function that can be called to remove this event.
return function() {
H.removeEvent(el, type, fn);
};
};
/**
* Remove an event that was added with {@link Highcharts#addEvent}.
*
* @function #removeEvent
* @memberOf Highcharts
* @param {Object} el - The element to remove events on.
* @param {String} [type] - The type of events to remove. If undefined, all
* events are removed from the element.
* @param {Function} [fn] - The specific callback to remove. If undefined, all
* events that match the element and optionally the type are removed.
* @returns {void}
*/
H.removeEvent = function(el, type, fn) {
var events,
hcEvents = el.hcEvents,
index;
function removeOneEvent(type, fn) {
if (el.removeEventListener) {
el.removeEventListener(type, fn, false);
} else if (el.attachEvent) {
fn = el.hcEventsIE[fn.toString()];
el.detachEvent('on' + type, fn);
}
}
function removeAllEvents() {
var types,
len,
n;
if (!el.nodeName) {
return; // break on non-DOM events
}
if (type) {
types = {};
types[type] = true;
} else {
types = hcEvents;
}
for (n in types) {
if (hcEvents[n]) {
len = hcEvents[n].length;
while (len--) {
removeOneEvent(n, hcEvents[n][len]);
}
}
}
}
if (hcEvents) {
if (type) {
events = hcEvents[type] || [];
if (fn) {
index = H.inArray(fn, events);
if (index > -1) {
events.splice(index, 1);
hcEvents[type] = events;
}
removeOneEvent(type, fn);
} else {
removeAllEvents();
hcEvents[type] = [];
}
} else {
removeAllEvents();
el.hcEvents = {};
}
}
};
/**
* Fire an event that was registered with {@link Highcharts#addEvent}.
*
* @function #fireEvent
* @memberOf Highcharts
* @param {Object} el - The object to fire the event on. It can be a
* {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
* @param {String} type - The type of event.
* @param {Object} [eventArguments] - Custom event arguments that are passed on
* as an argument to the event handler.
* @param {Function} [defaultFunction] - The default function to execute if the
* other listeners haven't returned false.
* @returns {void}
*/
H.fireEvent = function(el, type, eventArguments, defaultFunction) {
var e,
hcEvents = el.hcEvents,
events,
len,
i,
fn;
eventArguments = eventArguments || {};
if (doc.createEvent && (el.dispatchEvent || el.fireEvent)) {
e = doc.createEvent('Events');
e.initEvent(type, true, true);
//e.target = el;
H.extend(e, eventArguments);
if (el.dispatchEvent) {
el.dispatchEvent(e);
} else {
el.fireEvent(type, e);
}
} else if (hcEvents) {
events = hcEvents[type] || [];
len = events.length;
if (!eventArguments.target) { // We're running a custom event
H.extend(eventArguments, {
// Attach a simple preventDefault function to skip default
// handler if called. The built-in defaultPrevented property is
// not overwritable (#5112)
preventDefault: function() {
eventArguments.defaultPrevented = true;
},
// Setting target to native events fails with clicking the
// zoom-out button in Chrome.
target: el,
// If the type is not set, we're running a custom event (#2297).
// If it is set, we're running a browser event, and setting it
// will cause en error in IE8 (#2465).
type: type
});
}
for (i = 0; i < len; i++) {
fn = events[i];
// If the event handler return false, prevent the default handler
// from executing
if (fn && fn.call(el, eventArguments) === false) {
eventArguments.preventDefault();
}
}
}
// Run the default if not prevented
if (defaultFunction && !eventArguments.defaultPrevented) {
defaultFunction(eventArguments);
}
};
/**
* An animation configuration. Animation configurations can also be defined as
* booleans, where `false` turns off animation and `true` defaults to a duration
* of 500ms.
* @typedef {Object} AnimationOptions
* @property {Number} duration - The animation duration in milliseconds.
* @property {String} [easing] - The name of an easing function as defined on
* the `Math` object.
* @property {Function} [complete] - A callback function to exectute when the
* animation finishes.
* @property {Function} [step] - A callback function to execute on each step of
* each attribute or CSS property that's being animated. The first argument
* contains information about the animation and progress.
*/
/**
* The global animate method, which uses Fx to create individual animators.
*
* @function #animate
* @memberOf Highcharts
* @param {HTMLDOMElement|SVGElement} el - The element to animate.
* @param {Object} params - An object containing key-value pairs of the
* properties to animate. Supports numeric as pixel-based CSS properties
* for HTML objects and attributes for SVGElements.
* @param {AnimationOptions} [opt] - Animation options.
*/
H.animate = function(el, params, opt) {
var start,
unit = '',
end,
fx,
args,
prop;
if (!H.isObject(opt)) { // Number or undefined/null
args = arguments;
opt = {
duration: args[2],
easing: args[3],
complete: args[4]
};
}
if (!H.isNumber(opt.duration)) {
opt.duration = 400;
}
opt.easing = typeof opt.easing === 'function' ?
opt.easing :
(Math[opt.easing] || Math.easeInOutSine);
opt.curAnim = H.merge(params);
for (prop in params) {
// Stop current running animation of this property
H.stop(el, prop);
fx = new H.Fx(el, opt, prop);
end = null;
if (prop === 'd') {
fx.paths = fx.initPath(
el,
el.d,
params.d
);
fx.toD = params.d;
start = 0;
end = 1;
} else if (el.attr) {
start = el.attr(prop);
} else {
start = parseFloat(H.getStyle(el, prop)) || 0;
if (prop !== 'opacity') {
unit = 'px';
}
}
if (!end) {
end = params[prop];
}
if (end && end.match && end.match('px')) {
end = end.replace(/px/g, ''); // #4351
}
fx.run(start, end, unit);
}
};
/**
* Factory to create new series prototypes.
*
* @function #seriesType
* @memberOf Highcharts
*
* @param {String} type - The series type name.
* @param {String} parent - The parent series type name. Use `line` to inherit
* from the basic {@link Series} object.
* @param {Object} options - The additional default options that is merged with
* the parent's options.
* @param {Object} props - The properties (functions and primitives) to set on
* the new prototype.
* @param {Object} [pointProps] - Members for a series-specific extension of the
* {@link Point} prototype if needed.
* @returns {*} - The newly created prototype as extended from {@link Series}
* or its derivatives.
*/
// docs: add to API + extending Highcharts
H.seriesType = function(type, parent, options, props, pointProps) {
var defaultOptions = H.getOptions(),
seriesTypes = H.seriesTypes;
// Merge the options
defaultOptions.plotOptions[type] = H.merge(
defaultOptions.plotOptions[parent],
options
);
// Create the class
seriesTypes[type] = H.extendClass(seriesTypes[parent] ||
function() {}, props);
seriesTypes[type].prototype.type = type;
// Create the point class if needed
if (pointProps) {
seriesTypes[type].prototype.pointClass =
H.extendClass(H.Point, pointProps);
}
return seriesTypes[type];
};
/**
* Get a unique key for using in internal element id's and pointers. The key
* is composed of a random hash specific to this Highcharts instance, and a
* counter.
* @function #uniqueKey
* @memberOf Highcharts
* @return {string} The key.
* @example
* var id = H.uniqueKey(); // => 'highcharts-x45f6hp-0'
*/
H.uniqueKey = (function() {
var uniqueKeyHash = Math.random().toString(36).substring(2, 9),
idCounter = 0;
return function() {
return 'highcharts-' + uniqueKeyHash + '-' + idCounter++;
};
}());
/**
* Register Highcharts as a plugin in jQuery
*/
if (win.jQuery) {
win.jQuery.fn.highcharts = function() {
var args = [].slice.call(arguments);
if (this[0]) { // this[0] is the renderTo div
// Create the chart
if (args[0]) {
new H[ // eslint-disable-line no-new
// Constructor defaults to Chart
H.isString(args[0]) ? args.shift() : 'Chart'
](this[0], args[0], args[1]);
return this;
}
// When called without parameters or with the return argument,
// return an existing chart
return charts[H.attr(this[0], 'data-highcharts-chart')];
}
};
}
/**
* Compatibility section to add support for legacy IE. This can be removed if
* old IE support is not needed.
*/
if (doc && !doc.defaultView) {
H.getStyle = function(el, prop) {
var val,
alias = {
width: 'clientWidth',
height: 'clientHeight'
}[prop];
if (el.style[prop]) {
return H.pInt(el.style[prop]);
}
if (prop === 'opacity') {
prop = 'filter';
}
// Getting the rendered width and height
if (alias) {
el.style.zoom = 1;
return Math.max(el[alias] - 2 * H.getStyle(el, 'padding'), 0);
}
val = el.currentStyle[prop.replace(/\-(\w)/g, function(a, b) {
return b.toUpperCase();
})];
if (prop === 'filter') {
val = val.replace(
/alpha\(opacity=([0-9]+)\)/,
function(a, b) {
return b / 100;
}
);
}
return val === '' ? 1 : H.pInt(val);
};
}
if (!Array.prototype.forEach) {
H.each = function(arr, fn, ctx) { // legacy
var i = 0,
len = arr.length;
for (; i < len; i++) {
if (fn.call(ctx, arr[i], i, arr) === false) {
return i;
}
}
};
}
if (!Array.prototype.indexOf) {
H.inArray = function(item, arr) {
var len,
i = 0;
if (arr) {
len = arr.length;
for (; i < len; i++) {
if (arr[i] === item) {
return i;
}
}
}
return -1;
};
}
if (!Array.prototype.filter) {
H.grep = function(elements, fn) {
var ret = [],
i = 0,
length = elements.length;
for (; i < length; i++) {
if (fn(elements[i], i)) {
ret.push(elements[i]);
}
}
return ret;
};
}
if (!Array.prototype.find) {
H.find = function(arr, fn) {
var i,
length = arr.length;
for (i = 0; i < length; i++) {
if (fn(arr[i], i)) {
return arr[i];
}
}
};
}
//--- End compatibility section ---
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var each = H.each,
isNumber = H.isNumber,
map = H.map,
merge = H.merge,
pInt = H.pInt;
/**
* @typedef {string} ColorString
* A valid color to be parsed and handled by Highcharts. Highcharts internally
* supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
* rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
* browsers and displayed correctly, but Highcharts is not able to process them
* and apply concepts like opacity and brightening.
*/
/**
* Handle color operations. The object methods are chainable.
* @param {String} input The input color in either rbga or hex format
*/
H.Color = function(input) {
// Backwards compatibility, allow instanciation without new
if (!(this instanceof H.Color)) {
return new H.Color(input);
}
// Initialize
this.init(input);
};
H.Color.prototype = {
// Collection of parsers. This can be extended from the outside by pushing parsers
// to Highcharts.Color.prototype.parsers.
parsers: [{
// RGBA color
regex: /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,
parse: function(result) {
return [pInt(result[1]), pInt(result[2]), pInt(result[3]), parseFloat(result[4], 10)];
}
}, {
// RGB color
regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
parse: function(result) {
return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
}
}],
// Collection of named colors. Can be extended from the outside by adding
// colors to Highcharts.Color.prototype.names.
names: {
white: '#ffffff',
black: '#000000'
},
/**
* Parse the input color to rgba array
* @param {String} input
*/
init: function(input) {
var result,
rgba,
i,
parser,
len;
this.input = input = this.names[
input && input.toLowerCase ?
input.toLowerCase() :
''
] || input;
// Gradients
if (input && input.stops) {
this.stops = map(input.stops, function(stop) {
return new H.Color(stop[1]);
});
// Solid colors
} else {
// Check if it's possible to do bitmasking instead of regex
if (input && input[0] === '#') {
len = input.length;
input = parseInt(input.substr(1), 16);
// Handle long-form, e.g. #AABBCC
if (len === 7) {
rgba = [
(input & 0xFF0000) >> 16,
(input & 0xFF00) >> 8,
(input & 0xFF),
1
];
// Handle short-form, e.g. #ABC
// In short form, the value is assumed to be the same
// for both nibbles for each component. e.g. #ABC = #AABBCC
} else if (len === 4) {
rgba = [
((input & 0xF00) >> 4) | (input & 0xF00) >> 8,
((input & 0xF0) >> 4) | (input & 0xF0),
((input & 0xF) << 4) | (input & 0xF),
1
];
}
}
// Otherwise, check regex parsers
if (!rgba) {
i = this.parsers.length;
while (i-- && !rgba) {
parser = this.parsers[i];
result = parser.regex.exec(input);
if (result) {
rgba = parser.parse(result);
}
}
}
}
this.rgba = rgba || [];
},
/**
* Return the color a specified format
* @param {String} format
*/
get: function(format) {
var input = this.input,
rgba = this.rgba,
ret;
if (this.stops) {
ret = merge(input);
ret.stops = [].concat(ret.stops);
each(this.stops, function(stop, i) {
ret.stops[i] = [ret.stops[i][0], stop.get(format)];
});
// it's NaN if gradient colors on a column chart
} else if (rgba && isNumber(rgba[0])) {
if (format === 'rgb' || (!format && rgba[3] === 1)) {
ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
} else if (format === 'a') {
ret = rgba[3];
} else {
ret = 'rgba(' + rgba.join(',') + ')';
}
} else {
ret = input;
}
return ret;
},
/**
* Brighten the color
* @param {Number} alpha
*/
brighten: function(alpha) {
var i,
rgba = this.rgba;
if (this.stops) {
each(this.stops, function(stop) {
stop.brighten(alpha);
});
} else if (isNumber(alpha) && alpha !== 0) {
for (i = 0; i < 3; i++) {
rgba[i] += pInt(alpha * 255);
if (rgba[i] < 0) {
rgba[i] = 0;
}
if (rgba[i] > 255) {
rgba[i] = 255;
}
}
}
return this;
},
/**
* Set the color's opacity to a given alpha value
* @param {Number} alpha
*/
setOpacity: function(alpha) {
this.rgba[3] = alpha;
return this;
}
};
H.color = function(input) {
return new H.Color(input);
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var SVGElement,
SVGRenderer,
addEvent = H.addEvent,
animate = H.animate,
attr = H.attr,
charts = H.charts,
color = H.color,
css = H.css,
createElement = H.createElement,
defined = H.defined,
deg2rad = H.deg2rad,
destroyObjectProperties = H.destroyObjectProperties,
doc = H.doc,
each = H.each,
extend = H.extend,
erase = H.erase,
grep = H.grep,
hasTouch = H.hasTouch,
inArray = H.inArray,
isArray = H.isArray,
isFirefox = H.isFirefox,
isMS = H.isMS,
isObject = H.isObject,
isString = H.isString,
isWebKit = H.isWebKit,
merge = H.merge,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
removeEvent = H.removeEvent,
splat = H.splat,
stop = H.stop,
svg = H.svg,
SVG_NS = H.SVG_NS,
symbolSizes = H.symbolSizes,
win = H.win;
/**
* @typedef {Object} SVGDOMElement - An SVG DOM element.
*/
/**
* The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
* rendering layer of Highcharts. Combined with the {@link SVGRenderer} object,
* these prototypes allow freeform annotation in the charts or even in HTML
* pages without instanciating a chart. The SVGElement can also wrap HTML
* labels, when `text` or `label` elements are created with the `useHTML`
* parameter.
*
* The SVGElement instances are created through factory functions on the
* {@link SVGRenderer} object, like [rect]{@link SVGRenderer#rect},
* [path]{@link SVGRenderer#path}, [text]{@link SVGRenderer#text}, [label]{@link
* SVGRenderer#label}, [g]{@link SVGRenderer#g} and more.
*
* @class
*/
SVGElement = H.SVGElement = function() {
return this;
};
SVGElement.prototype = {
// Default base for animation
opacity: 1,
SVG_NS: SVG_NS,
/**
* For labels, these CSS properties are applied to the `text` node directly.
* @type {Array.<string>}
*/
textProps: ['direction', 'fontSize', 'fontWeight', 'fontFamily',
'fontStyle', 'color', 'lineHeight', 'width', 'textAlign',
'textDecoration', 'textOverflow', 'textOutline'
],
/**
* Initialize the SVG renderer. This function only exists to make the
* initiation process overridable. It should not be called directly.
*
* @param {SVGRenderer} renderer The SVGRenderer instance to initialize to.
* @param {String} nodeName The SVG node name.
* @returns {void}
*/
init: function(renderer, nodeName) {
/**
* The DOM node. Each SVGRenderer instance wraps a main DOM node, but
* may also represent more nodes.
* @type {SVGDOMNode|HTMLDOMNode}
*/
this.element = nodeName === 'span' ?
createElement(nodeName) :
doc.createElementNS(this.SVG_NS, nodeName);
/**
* The renderer that the SVGElement belongs to.
* @type {SVGRenderer}
*/
this.renderer = renderer;
},
/**
* Animate to given attributes or CSS properties.
*
* @param {SVGAttributes} params SVG attributes or CSS to animate.
* @param {AnimationOptions} [options] Animation options.
* @param {Function} [complete] Function to perform at the end of animation.
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
animate: function(params, options, complete) {
var animOptions = H.animObject(
pick(options, this.renderer.globalAnimation, true)
);
if (animOptions.duration !== 0) {
if (complete) { // allows using a callback with the global animation without overwriting it
animOptions.complete = complete;
}
animate(this, params, animOptions);
} else {
this.attr(params, null, complete);
if (animOptions.step) {
animOptions.step.call(this);
}
}
return this;
},
/**
* @typedef {Object} GradientOptions
* @property {Object} linearGradient Holds an object that defines the start
* position and the end position relative to the shape.
* @property {Number} linearGradient.x1 Start horizontal position of the
* gradient. Ranges 0-1.
* @property {Number} linearGradient.x2 End horizontal position of the
* gradient. Ranges 0-1.
* @property {Number} linearGradient.y1 Start vertical position of the
* gradient. Ranges 0-1.
* @property {Number} linearGradient.y2 End vertical position of the
* gradient. Ranges 0-1.
* @property {Object} radialGradient Holds an object that defines the center
* position and the radius.
* @property {Number} radialGradient.cx Center horizontal position relative
* to the shape. Ranges 0-1.
* @property {Number} radialGradient.cy Center vertical position relative
* to the shape. Ranges 0-1.
* @property {Number} radialGradient.r Radius relative to the shape. Ranges
* 0-1.
* @property {Array.<Array>} stops The first item in each tuple is the
* position in the gradient, where 0 is the start of the gradient and 1
* is the end of the gradient. Multiple stops can be applied. The second
* item is the color for each stop. This color can also be given in the
* rgba format.
*
* @example
* // Linear gradient used as a color option
* color: {
* linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
* stops: [
* [0, '#003399'], // start
* [0.5, '#ffffff'], // middle
* [1, '#3366AA'] // end
* ]
* }
* }
*/
/**
* Build and apply an SVG gradient out of a common JavaScript configuration
* object. This function is called from the attribute setters.
*
* @private
* @param {GradientOptions} color The gradient options structure.
* @param {string} prop The property to apply, can either be `fill` or
* `stroke`.
* @param {SVGDOMElement} elem SVG DOM element to apply the gradient on.
*/
colorGradient: function(color, prop, elem) {
var renderer = this.renderer,
colorObject,
gradName,
gradAttr,
radAttr,
gradients,
gradientObject,
stops,
stopColor,
stopOpacity,
radialReference,
n,
id,
key = [],
value;
// Apply linear or radial gradients
if (color.radialGradient) {
gradName = 'radialGradient';
} else if (color.linearGradient) {
gradName = 'linearGradient';
}
if (gradName) {
gradAttr = color[gradName];
gradients = renderer.gradients;
stops = color.stops;
radialReference = elem.radialReference;
// Keep < 2.2 kompatibility
if (isArray(gradAttr)) {
color[gradName] = gradAttr = {
x1: gradAttr[0],
y1: gradAttr[1],
x2: gradAttr[2],
y2: gradAttr[3],
gradientUnits: 'userSpaceOnUse'
};
}
// Correct the radial gradient for the radial reference system
if (
gradName === 'radialGradient' &&
radialReference &&
!defined(gradAttr.gradientUnits)
) {
radAttr = gradAttr; // Save the radial attributes for updating
gradAttr = merge(
gradAttr,
renderer.getRadialAttr(radialReference, radAttr), {
gradientUnits: 'userSpaceOnUse'
}
);
}
// Build the unique key to detect whether we need to create a new element (#1282)
for (n in gradAttr) {
if (n !== 'id') {
key.push(n, gradAttr[n]);
}
}
for (n in stops) {
key.push(stops[n]);
}
key = key.join(',');
// Check if a gradient object with the same config object is created within this renderer
if (gradients[key]) {
id = gradients[key].attr('id');
} else {
// Set the id and create the element
gradAttr.id = id = H.uniqueKey();
gradients[key] = gradientObject = renderer.createElement(gradName)
.attr(gradAttr)
.add(renderer.defs);
gradientObject.radAttr = radAttr;
// The gradient needs to keep a list of stops to be able to destroy them
gradientObject.stops = [];
each(stops, function(stop) {
var stopObject;
if (stop[1].indexOf('rgba') === 0) {
colorObject = H.color(stop[1]);
stopColor = colorObject.get('rgb');
stopOpacity = colorObject.get('a');
} else {
stopColor = stop[1];
stopOpacity = 1;
}
stopObject = renderer.createElement('stop').attr({
offset: stop[0],
'stop-color': stopColor,
'stop-opacity': stopOpacity
}).add(gradientObject);
// Add the stop element to the gradient
gradientObject.stops.push(stopObject);
});
}
// Set the reference to the gradient object
value = 'url(' + renderer.url + '#' + id + ')';
elem.setAttribute(prop, value);
elem.gradient = key;
// Allow the color to be concatenated into tooltips formatters etc. (#2995)
color.toString = function() {
return value;
};
}
},
/**
* Apply a text outline through a custom CSS property, by copying the text
* element and apply stroke to the copy. Used internally. Contrast checks
* at http://jsfiddle.net/highcharts/43soe9m1/2/ .
*
* @private
* @param {String} textOutline A custom CSS `text-outline` setting, defined
* by `width color`.
* @example
* // Specific color
* text.css({
* textOutline: '1px black'
* });
* // Automatic contrast
* text.css({
* color: '#000000', // black text
* textOutline: '1px contrast' // => white outline
* });
*/
applyTextOutline: function(textOutline) {
var elem = this.element,
tspans,
tspan,
hasContrast = textOutline.indexOf('contrast') !== -1,
styles = {},
color,
strokeWidth,
firstRealChild,
i;
// When the text shadow is set to contrast, use dark stroke for light
// text and vice versa.
if (hasContrast) {
styles.textOutline = textOutline = textOutline.replace(
/contrast/g,
this.renderer.getContrast(elem.style.fill)
);
}
// Extract the stroke width and color
textOutline = textOutline.split(' ');
color = textOutline[textOutline.length - 1];
strokeWidth = textOutline[0];
if (strokeWidth && strokeWidth !== 'none' && H.svg) {
this.fakeTS = true; // Fake text shadow
tspans = [].slice.call(elem.getElementsByTagName('tspan'));
// In order to get the right y position of the clone,
// copy over the y setter
this.ySetter = this.xSetter;
// Since the stroke is applied on center of the actual outline, we
// need to double it to get the correct stroke-width outside the
// glyphs.
strokeWidth = strokeWidth.replace(
/(^[\d\.]+)(.*?)$/g,
function(match, digit, unit) {
return (2 * digit) + unit;
}
);
// Remove shadows from previous runs. Iterate from the end to
// support removing items inside the cycle (#6472).
i = tspans.length;
while (i--) {
tspan = tspans[i];
if (tspan.getAttribute('class') === 'highcharts-text-outline') {
// Remove then erase
erase(tspans, elem.removeChild(tspan));
}
}
// For each of the tspans, create a stroked copy behind it.
firstRealChild = elem.firstChild;
each(tspans, function(tspan, y) {
var clone;
// Let the first line start at the correct X position
if (y === 0) {
tspan.setAttribute('x', elem.getAttribute('x'));
y = elem.getAttribute('y');
tspan.setAttribute('y', y || 0);
if (y === null) {
elem.setAttribute('y', 0);
}
}
// Create the clone and apply outline properties
clone = tspan.cloneNode(1);
attr(clone, {
'class': 'highcharts-text-outline',
'fill': color,
'stroke': color,
'stroke-width': strokeWidth,
'stroke-linejoin': 'round'
});
elem.insertBefore(clone, firstRealChild);
});
}
},
/**
*
* @typedef {Object} SVGAttributes An object of key-value pairs for SVG
* attributes. Attributes in Highcharts elements for the most parts
* correspond to SVG, but some are specific to Highcharts, like `zIndex`,
* `rotation`, `translateX`, `translateY`, `scaleX` and `scaleY`. SVG
* attributes containing a hyphen are _not_ camel-cased, they should be
* quoted to preserve the hyphen.
* @example
* {
* 'stroke': '#ff0000', // basic
* 'stroke-width': 2, // hyphenated
* 'rotation': 45 // custom
* 'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
* }
*/
/**
* Apply native and custom attributes to the SVG elements.
*
* In order to set the rotation center for rotation, set x and y to 0 and
* use `translateX` and `translateY` attributes to position the element
* instead.
*
* Attributes frequently used in Highcharts are `fill`, `stroke`,
* `stroke-width`.
*
* @param {SVGAttributes|String} hash - The native and custom SVG
* attributes.
* @param {string} [val] - If the type of the first argument is `string`,
* the second can be a value, which will serve as a single attribute
* setter. If the first argument is a string and the second is undefined,
* the function serves as a getter and the current value of the property
* is returned.
* @param {Function} complete - A callback function to execute after setting
* the attributes. This makes the function compliant and interchangeable
* with the {@link SVGElement#animate} function.
* @param {boolean} continueAnimation - Used internally when `.attr` is
* called as part of an animation step. Otherwise, calling `.attr` for an
* attribute will stop animation for that attribute.
*
* @returns {SVGElement|string|number} If used as a setter, it returns the
* current {@link SVGElement} so the calls can be chained. If used as a
* getter, the current value of the attribute is returned.
*
* @example
* // Set multiple attributes
* element.attr({
* stroke: 'red',
* fill: 'blue',
* x: 10,
* y: 10
* });
*
* // Set a single attribute
* element.attr('stroke', 'red');
*
* // Get an attribute
* element.attr('stroke'); // => 'red'
*
*/
attr: function(hash, val, complete, continueAnimation) {
var key,
value,
element = this.element,
hasSetSymbolSize,
ret = this,
skipAttr,
setter;
// single key-value pair
if (typeof hash === 'string' && val !== undefined) {
key = hash;
hash = {};
hash[key] = val;
}
// used as a getter: first argument is a string, second is undefined
if (typeof hash === 'string') {
ret = (this[hash + 'Getter'] || this._defaultGetter).call(this, hash, element);
// setter
} else {
for (key in hash) {
value = hash[key];
skipAttr = false;
// Unless .attr is from the animator update, stop current
// running animation of this property
if (!continueAnimation) {
stop(this, key);
}
// Special handling of symbol attributes
if (
this.symbolName &&
/^(x|y|width|height|r|start|end|innerR|anchorX|anchorY)$/
.test(key)
) {
if (!hasSetSymbolSize) {
this.symbolAttr(hash);
hasSetSymbolSize = true;
}
skipAttr = true;
}
if (this.rotation && (key === 'x' || key === 'y')) {
this.doTransform = true;
}
if (!skipAttr) {
setter = this[key + 'Setter'] || this._defaultSetter;
setter.call(this, value, key, element);
// Let the shadow follow the main element
if (this.shadows && /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) {
this.updateShadows(key, value, setter);
}
}
}
// Update transform. Do this outside the loop to prevent redundant updating for batch setting
// of attributes.
if (this.doTransform) {
this.updateTransform();
this.doTransform = false;
}
}
// In accordance with animate, run a complete callback
if (complete) {
complete();
}
return ret;
},
/**
* Update the shadow elements with new attributes.
*
* @private
* @param {String} key - The attribute name.
* @param {String|Number} value - The value of the attribute.
* @param {Function} setter - The setter function, inherited from the
* parent wrapper
* @returns {void}
*/
updateShadows: function(key, value, setter) {
var shadows = this.shadows,
i = shadows.length;
while (i--) {
setter.call(
shadows[i],
key === 'height' ?
Math.max(value - (shadows[i].cutHeight || 0), 0) :
key === 'd' ? this.d : value,
key,
shadows[i]
);
}
},
/**
* Add a class name to an element.
*
* @param {string} className - The new class name to add.
* @param {boolean} [replace=false] - When true, the existing class name(s)
* will be overwritten with the new one. When false, the new one is
* added.
* @returns {SVGElement} Return the SVG element for chainability.
*/
addClass: function(className, replace) {
var currentClassName = this.attr('class') || '';
if (currentClassName.indexOf(className) === -1) {
if (!replace) {
className =
(currentClassName + (currentClassName ? ' ' : '') +
className).replace(' ', ' ');
}
this.attr('class', className);
}
return this;
},
/**
* Check if an element has the given class name.
* @param {string} className - The class name to check for.
* @return {Boolean}
*/
hasClass: function(className) {
return attr(this.element, 'class').indexOf(className) !== -1;
},
/**
* Remove a class name from the element.
* @param {string} className The class name to remove.
* @return {SVGElement} Returns the SVG element for chainability.
*/
removeClass: function(className) {
attr(this.element, 'class', (attr(this.element, 'class') || '').replace(className, ''));
return this;
},
/**
* If one of the symbol size affecting parameters are changed,
* check all the others only once for each call to an element's
* .attr() method
* @param {Object} hash - The attributes to set.
* @private
*/
symbolAttr: function(hash) {
var wrapper = this;
each(['x', 'y', 'r', 'start', 'end', 'width', 'height', 'innerR', 'anchorX', 'anchorY'], function(key) {
wrapper[key] = pick(hash[key], wrapper[key]);
});
wrapper.attr({
d: wrapper.renderer.symbols[wrapper.symbolName](
wrapper.x,
wrapper.y,
wrapper.width,
wrapper.height,
wrapper
)
});
},
/**
* Apply a clipping rectangle to this element.
*
* @param {ClipRect} [clipRect] - The clipping rectangle. If skipped, the
* current clip is removed.
* @returns {SVGElement} Returns the SVG element to allow chaining.
*/
clip: function(clipRect) {
return this.attr(
'clip-path',
clipRect ?
'url(' + this.renderer.url + '#' + clipRect.id + ')' :
'none'
);
},
/**
* Calculate the coordinates needed for drawing a rectangle crisply and
* return the calculated attributes.
*
* @param {Object} rect - A rectangle.
* @param {number} rect.x - The x position.
* @param {number} rect.y - The y position.
* @param {number} rect.width - The width.
* @param {number} rect.height - The height.
* @param {number} [strokeWidth] - The stroke width to consider when
* computing crisp positioning. It can also be set directly on the rect
* parameter.
*
* @returns {{x: Number, y: Number, width: Number, height: Number}} The
* modified rectangle arguments.
*/
crisp: function(rect, strokeWidth) {
var wrapper = this,
key,
attribs = {},
normalizer;
strokeWidth = strokeWidth || rect.strokeWidth || 0;
normalizer = Math.round(strokeWidth) % 2 / 2; // Math.round because strokeWidth can sometimes have roundoff errors
// normalize for crisp edges
rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
rect.width = Math.floor((rect.width || wrapper.width || 0) - 2 * normalizer);
rect.height = Math.floor((rect.height || wrapper.height || 0) - 2 * normalizer);
if (defined(rect.strokeWidth)) {
rect.strokeWidth = strokeWidth;
}
for (key in rect) {
if (wrapper[key] !== rect[key]) { // only set attribute if changed
wrapper[key] = attribs[key] = rect[key];
}
}
return attribs;
},
/**
* Set styles for the element. In addition to CSS styles supported by
* native SVG and HTML elements, there are also some custom made for
* Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
* elements.
* @param {CSSObject} styles The new CSS styles.
* @returns {SVGElement} Return the SVG element for chaining.
*/
css: function(styles) {
var oldStyles = this.styles,
newStyles = {},
elem = this.element,
textWidth,
n,
serializedCss = '',
hyphenate,
hasNew = !oldStyles,
// These CSS properties are interpreted internally by the SVG
// renderer, but are not supported by SVG and should not be added to
// the DOM. In styled mode, no CSS should find its way to the DOM
// whatsoever (#6173, #6474).
svgPseudoProps = ['textOutline', 'textOverflow', 'width'];
// convert legacy
if (styles && styles.color) {
styles.fill = styles.color;
}
// Filter out existing styles to increase performance (#2640)
if (oldStyles) {
for (n in styles) {
if (styles[n] !== oldStyles[n]) {
newStyles[n] = styles[n];
hasNew = true;
}
}
}
if (hasNew) {
// Merge the new styles with the old ones
if (oldStyles) {
styles = extend(
oldStyles,
newStyles
);
}
// Get the text width from style
textWidth = this.textWidth = (
styles &&
styles.width &&
styles.width !== 'auto' &&
elem.nodeName.toLowerCase() === 'text' &&
pInt(styles.width)
);
// store object
this.styles = styles;
if (textWidth && (!svg && this.renderer.forExport)) {
delete styles.width;
}
// serialize and set style attribute
if (isMS && !svg) {
css(this.element, styles);
} else {
hyphenate = function(a, b) {
return '-' + b.toLowerCase();
};
for (n in styles) {
if (inArray(n, svgPseudoProps) === -1) {
serializedCss +=
n.replace(/([A-Z])/g, hyphenate) + ':' +
styles[n] + ';';
}
}
if (serializedCss) {
attr(elem, 'style', serializedCss); // #1881
}
}
if (this.added) {
// Rebuild text after added. Cache mechanisms in the buildText
// will prevent building if there are no significant changes.
if (this.element.nodeName === 'text') {
this.renderer.buildText(this);
}
// Apply text outline after added
if (styles && styles.textOutline) {
this.applyTextOutline(styles.textOutline);
}
}
}
return this;
},
/**
* Get the current stroke width. In classic mode, the setter registers it
* directly on the element.
* @returns {number} The stroke width in pixels.
* @ignore
*/
strokeWidth: function() {
return this['stroke-width'] || 0;
},
/**
* Add an event listener. This is a simple setter that replaces all other
* events of the same type, opposed to the {@link Highcharts#addEvent}
* function.
* @param {string} eventType - The event type. If the type is `click`,
* Highcharts will internally translate it to a `touchstart` event on
* touch devices, to prevent the browser from waiting for a click event
* from firing.
* @param {Function} handler - The handler callback.
* @returns {SVGElement} The SVGElement for chaining.
*/
on: function(eventType, handler) {
var svgElement = this,
element = svgElement.element;
// touch
if (hasTouch && eventType === 'click') {
element.ontouchstart = function(e) {
svgElement.touchEventFired = Date.now(); // #2269
e.preventDefault();
handler.call(element, e);
};
element.onclick = function(e) {
if (win.navigator.userAgent.indexOf('Android') === -1 ||
Date.now() - (svgElement.touchEventFired || 0) > 1100) {
handler.call(element, e);
}
};
} else {
// simplest possible event model for internal use
element['on' + eventType] = handler;
}
return this;
},
/**
* Set the coordinates needed to draw a consistent radial gradient across
* a shape regardless of positioning inside the chart. Used on pie slices
* to make all the slices have the same radial reference point.
*
* @param {Array} coordinates The center reference. The format is
* `[centerX, centerY, diameter]` in pixels.
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
setRadialReference: function(coordinates) {
var existingGradient = this.renderer.gradients[this.element.gradient];
this.element.radialReference = coordinates;
// On redrawing objects with an existing gradient, the gradient needs
// to be repositioned (#3801)
if (existingGradient && existingGradient.radAttr) {
existingGradient.animate(
this.renderer.getRadialAttr(
coordinates,
existingGradient.radAttr
)
);
}
return this;
},
/**
* Move an object and its children by x and y values.
*
* @param {number} x - The x value.
* @param {number} y - The y value.
*/
translate: function(x, y) {
return this.attr({
translateX: x,
translateY: y
});
},
/**
* Invert a group, rotate and flip. This is used internally on inverted
* charts, where the points and graphs are drawn as if not inverted, then
* the series group elements are inverted.
*
* @param {boolean} inverted - Whether to invert or not. An inverted shape
* can be un-inverted by setting it to false.
* @returns {SVGElement} Return the SVGElement for chaining.
*/
invert: function(inverted) {
var wrapper = this;
wrapper.inverted = inverted;
wrapper.updateTransform();
return wrapper;
},
/**
* Update the transform attribute based on internal properties. Deals with
* the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
* attributes and updates the SVG `transform` attribute.
* @private
* @returns {void}
*/
updateTransform: function() {
var wrapper = this,
translateX = wrapper.translateX || 0,
translateY = wrapper.translateY || 0,
scaleX = wrapper.scaleX,
scaleY = wrapper.scaleY,
inverted = wrapper.inverted,
rotation = wrapper.rotation,
element = wrapper.element,
transform;
// flipping affects translate as adjustment for flipping around the group's axis
if (inverted) {
translateX += wrapper.width;
translateY += wrapper.height;
}
// Apply translate. Nearly all transformed elements have translation, so instead
// of checking for translate = 0, do it always (#1767, #1846).
transform = ['translate(' + translateX + ',' + translateY + ')'];
// apply rotation
if (inverted) {
transform.push('rotate(90) scale(-1,1)');
} else if (rotation) { // text rotation
transform.push('rotate(' + rotation + ' ' + (element.getAttribute('x') || 0) + ' ' + (element.getAttribute('y') || 0) + ')');
// Delete bBox memo when the rotation changes
//delete wrapper.bBox;
}
// apply scale
if (defined(scaleX) || defined(scaleY)) {
transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')');
}
if (transform.length) {
element.setAttribute('transform', transform.join(' '));
}
},
/**
* Bring the element to the front.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
toFront: function() {
var element = this.element;
element.parentNode.appendChild(element);
return this;
},
/**
* Align the element relative to the chart or another box.
* ß
* @param {Object} [alignOptions] The alignment options. The function can be
* called without this parameter in order to re-align an element after the
* box has been updated.
* @param {string} [alignOptions.align=left] Horizontal alignment. Can be
* one of `left`, `center` and `right`.
* @param {string} [alignOptions.verticalAlign=top] Vertical alignment. Can
* be one of `top`, `middle` and `bottom`.
* @param {number} [alignOptions.x=0] Horizontal pixel offset from
* alignment.
* @param {number} [alignOptions.y=0] Vertical pixel offset from alignment.
* @param {Boolean} [alignByTranslate=false] Use the `transform` attribute
* with translateX and translateY custom attributes to align this elements
* rather than `x` and `y` attributes.
* @param {String|Object} box The box to align to, needs a width and height.
* When the box is a string, it refers to an object in the Renderer. For
* example, when box is `spacingBox`, it refers to `Renderer.spacingBox`
* which holds `width`, `height`, `x` and `y` properties.
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
align: function(alignOptions, alignByTranslate, box) {
var align,
vAlign,
x,
y,
attribs = {},
alignTo,
renderer = this.renderer,
alignedObjects = renderer.alignedObjects,
alignFactor,
vAlignFactor;
// First call on instanciate
if (alignOptions) {
this.alignOptions = alignOptions;
this.alignByTranslate = alignByTranslate;
if (!box || isString(box)) { // boxes other than renderer handle this internally
this.alignTo = alignTo = box || 'renderer';
erase(alignedObjects, this); // prevent duplicates, like legendGroup after resize
alignedObjects.push(this);
box = null; // reassign it below
}
// When called on resize, no arguments are supplied
} else {
alignOptions = this.alignOptions;
alignByTranslate = this.alignByTranslate;
alignTo = this.alignTo;
}
box = pick(box, renderer[alignTo], renderer);
// Assign variables
align = alignOptions.align;
vAlign = alignOptions.verticalAlign;
x = (box.x || 0) + (alignOptions.x || 0); // default: left align
y = (box.y || 0) + (alignOptions.y || 0); // default: top align
// Align
if (align === 'right') {
alignFactor = 1;
} else if (align === 'center') {
alignFactor = 2;
}
if (alignFactor) {
x += (box.width - (alignOptions.width || 0)) / alignFactor;
}
attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);
// Vertical align
if (vAlign === 'bottom') {
vAlignFactor = 1;
} else if (vAlign === 'middle') {
vAlignFactor = 2;
}
if (vAlignFactor) {
y += (box.height - (alignOptions.height || 0)) / vAlignFactor;
}
attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);
// Animate only if already placed
this[this.placed ? 'animate' : 'attr'](attribs);
this.placed = true;
this.alignAttr = attribs;
return this;
},
/**
* Get the bounding box (width, height, x and y) for the element. Generally
* used to get rendered text size. Since this is called a lot in charts,
* the results are cached based on text properties, in order to save DOM
* traffic. The returned bounding box includes the rotation, so for example
* a single text line of rotation 90 will report a greater height, and a
* width corresponding to the line-height.
*
* @param {boolean} [reload] Skip the cache and get the updated DOM bouding
* box.
* @param {number} [rot] Override the element's rotation. This is internally
* used on axis labels with a value of 0 to find out what the bounding box
* would be have been if it were not rotated.
* @returns {Object} The bounding box with `x`, `y`, `width` and `height`
* properties.
*/
getBBox: function(reload, rot) {
var wrapper = this,
bBox, // = wrapper.bBox,
renderer = wrapper.renderer,
width,
height,
rotation,
rad,
element = wrapper.element,
styles = wrapper.styles,
fontSize,
textStr = wrapper.textStr,
toggleTextShadowShim,
cache = renderer.cache,
cacheKeys = renderer.cacheKeys,
cacheKey;
rotation = pick(rot, wrapper.rotation);
rad = rotation * deg2rad;
fontSize = styles && styles.fontSize;
if (textStr !== undefined) {
cacheKey = textStr.toString();
// Since numbers are monospaced, and numerical labels appear a lot
// in a chart, we assume that a label of n characters has the same
// bounding box as others of the same length. Unless there is inner
// HTML in the label. In that case, leave the numbers as is (#5899).
if (cacheKey.indexOf('<') === -1) {
cacheKey = cacheKey.replace(/[0-9]/g, '0');
}
// Properties that affect bounding box
cacheKey += [
'',
rotation || 0,
fontSize,
styles && styles.width,
styles && styles.textOverflow // #5968
]
.join(',');
}
if (cacheKey && !reload) {
bBox = cache[cacheKey];
}
// No cache found
if (!bBox) {
// SVG elements
if (element.namespaceURI === wrapper.SVG_NS || renderer.forExport) {
try { // Fails in Firefox if the container has display: none.
// When the text shadow shim is used, we need to hide the fake shadows
// to get the correct bounding box (#3872)
toggleTextShadowShim = this.fakeTS && function(display) {
each(element.querySelectorAll('.highcharts-text-outline'), function(tspan) {
tspan.style.display = display;
});
};
// Workaround for #3842, Firefox reporting wrong bounding box for shadows
if (toggleTextShadowShim) {
toggleTextShadowShim('none');
}
bBox = element.getBBox ?
// SVG: use extend because IE9 is not allowed to change width and height in case
// of rotation (below)
extend({}, element.getBBox()) : {
// Legacy IE in export mode
width: element.offsetWidth,
height: element.offsetHeight
};
// #3842
if (toggleTextShadowShim) {
toggleTextShadowShim('');
}
} catch (e) {}
// If the bBox is not set, the try-catch block above failed. The other condition
// is for Opera that returns a width of -Infinity on hidden elements.
if (!bBox || bBox.width < 0) {
bBox = {
width: 0,
height: 0
};
}
// VML Renderer or useHTML within SVG
} else {
bBox = wrapper.htmlGetBBox();
}
// True SVG elements as well as HTML elements in modern browsers using the .useHTML option
// need to compensated for rotation
if (renderer.isSVG) {
width = bBox.width;
height = bBox.height;
// Workaround for wrong bounding box in IE, Edge and Chrome on
// Windows. With Highcharts' default font, IE and Edge report
// a box height of 16.899 and Chrome rounds it to 17. If this
// stands uncorrected, it results in more padding added below
// the text than above when adding a label border or background.
// Also vertical positioning is affected.
// http://jsfiddle.net/highcharts/em37nvuj/
// (#1101, #1505, #1669, #2568, #6213).
if (
styles &&
styles.fontSize === '11px' &&
Math.round(height) === 17
) {
bBox.height = height = 14;
}
// Adjust for rotated text
if (rotation) {
bBox.width = Math.abs(height * Math.sin(rad)) + Math.abs(width * Math.cos(rad));
bBox.height = Math.abs(height * Math.cos(rad)) + Math.abs(width * Math.sin(rad));
}
}
// Cache it. When loading a chart in a hidden iframe in Firefox and IE/Edge, the
// bounding box height is 0, so don't cache it (#5620).
if (cacheKey && bBox.height > 0) {
// Rotate (#4681)
while (cacheKeys.length > 250) {
delete cache[cacheKeys.shift()];
}
if (!cache[cacheKey]) {
cacheKeys.push(cacheKey);
}
cache[cacheKey] = bBox;
}
}
return bBox;
},
/**
* Show the element after it has been hidden.
*
* @param {boolean} [inherit=false] Set the visibility attribute to
* `inherit` rather than `visible`. The difference is that an element with
* `visibility="visible"` will be visible even if the parent is hidden.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
show: function(inherit) {
return this.attr({
visibility: inherit ? 'inherit' : 'visible'
});
},
/**
* Hide the element, equivalent to setting the `visibility` attribute to
* `hidden`.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*/
hide: function() {
return this.attr({
visibility: 'hidden'
});
},
/**
* Fade out an element by animating its opacity down to 0, and hide it on
* complete. Used internally for the tooltip.
*
* @param {number} [duration=150] The fade duration in milliseconds.
*/
fadeOut: function(duration) {
var elemWrapper = this;
elemWrapper.animate({
opacity: 0
}, {
duration: duration || 150,
complete: function() {
elemWrapper.attr({
y: -9999
}); // #3088, assuming we're only using this for tooltips
}
});
},
/**
* Add the element to the DOM. All elements must be added this way.
*
* @param {SVGElement|SVGDOMElement} [parent] The parent item to add it to.
* If undefined, the element is added to the {@link SVGRenderer.box}.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*
* @sample highcharts/members/renderer-g - Elements added to a group
*/
add: function(parent) {
var renderer = this.renderer,
element = this.element,
inserted;
if (parent) {
this.parentGroup = parent;
}
// mark as inverted
this.parentInverted = parent && parent.inverted;
// build formatted text
if (this.textStr !== undefined) {
renderer.buildText(this);
}
// Mark as added
this.added = true;
// If we're adding to renderer root, or other elements in the group
// have a z index, we need to handle it
if (!parent || parent.handleZ || this.zIndex) {
inserted = this.zIndexSetter();
}
// If zIndex is not handled, append at the end
if (!inserted) {
(parent ? parent.element : renderer.box).appendChild(element);
}
// fire an event for internal hooks
if (this.onAdd) {
this.onAdd();
}
return this;
},
/**
* Removes an element from the DOM.
*
* @private
* @param {SVGDOMElement|HTMLDOMElement} element The DOM node to remove.
*/
safeRemoveChild: function(element) {
var parentNode = element.parentNode;
if (parentNode) {
parentNode.removeChild(element);
}
},
/**
* Destroy the element and element wrapper and clear up the DOM and event
* hooks.
*
* @returns {void}
*/
destroy: function() {
var wrapper = this,
element = wrapper.element || {},
parentToClean = wrapper.renderer.isSVG && element.nodeName === 'SPAN' && wrapper.parentGroup,
grandParent,
key,
i;
// remove events
element.onclick = element.onmouseout = element.onmouseover = element.onmousemove = element.point = null;
stop(wrapper); // stop running animations
if (wrapper.clipPath) {
// Look for existing references to this clipPath and remove them
// before destroying the element (#6196).
each(
wrapper.element.ownerSVGElement.querySelectorAll('[clip-path]'),
function(el) {
if (el.getAttribute('clip-path')
.indexOf(wrapper.clipPath.element.id) > -1) {
el.removeAttribute('clip-path');
}
}
);
wrapper.clipPath = wrapper.clipPath.destroy();
}
// Destroy stops in case this is a gradient object
if (wrapper.stops) {
for (i = 0; i < wrapper.stops.length; i++) {
wrapper.stops[i] = wrapper.stops[i].destroy();
}
wrapper.stops = null;
}
// remove element
wrapper.safeRemoveChild(element);
wrapper.destroyShadows();
// In case of useHTML, clean up empty containers emulating SVG groups (#1960, #2393, #2697).
while (parentToClean && parentToClean.div && parentToClean.div.childNodes.length === 0) {
grandParent = parentToClean.parentGroup;
wrapper.safeRemoveChild(parentToClean.div);
delete parentToClean.div;
parentToClean = grandParent;
}
// remove from alignObjects
if (wrapper.alignTo) {
erase(wrapper.renderer.alignedObjects, wrapper);
}
for (key in wrapper) {
delete wrapper[key];
}
return null;
},
/**
* @typedef {Object} ShadowOptions
* @property {string} [color=#000000] The shadow color.
* @property {number} [offsetX=1] The horizontal offset from the element.
* @property {number} [offsetY=1] The vertical offset from the element.
* @property {number} [opacity=0.15] The shadow opacity.
* @property {number} [width=3] The shadow width or distance from the
* element.
*/
/**
* Add a shadow to the element. Must be called after the element is added to
* the DOM. In styled mode, this method is not used, instead use `defs` and
* filters.
*
* @param {boolean|ShadowOptions} shadowOptions The shadow options. If
* `true`, the default options are applied. If `false`, the current
* shadow will be removed.
* @param {SVGElement} [group] The SVG group element where the shadows will
* be applied. The default is to add it to the same parent as the current
* element. Internally, this is ised for pie slices, where all the
* shadows are added to an element behind all the slices.
* @param {boolean} [cutOff] Used internally for column shadows.
*
* @returns {SVGElement} Returns the SVGElement for chaining.
*
* @example
* renderer.rect(10, 100, 100, 100)
* .attr({ fill: 'red' })
* .shadow(true);
*/
shadow: function(shadowOptions, group, cutOff) {
var shadows = [],
i,
shadow,
element = this.element,
strokeWidth,
shadowWidth,
shadowElementOpacity,
// compensate for inverted plot area
transform;
if (!shadowOptions) {
this.destroyShadows();
} else if (!this.shadows) {
shadowWidth = pick(shadowOptions.width, 3);
shadowElementOpacity = (shadowOptions.opacity || 0.15) / shadowWidth;
transform = this.parentInverted ?
'(-1,-1)' :
'(' + pick(shadowOptions.offsetX, 1) + ', ' + pick(shadowOptions.offsetY, 1) + ')';
for (i = 1; i <= shadowWidth; i++) {
shadow = element.cloneNode(0);
strokeWidth = (shadowWidth * 2) + 1 - (2 * i);
attr(shadow, {
'isShadow': 'true',
'stroke': shadowOptions.color || '#000000',
'stroke-opacity': shadowElementOpacity * i,
'stroke-width': strokeWidth,
'transform': 'translate' + transform,
'fill': 'none'
});
if (cutOff) {
attr(shadow, 'height', Math.max(attr(shadow, 'height') - strokeWidth, 0));
shadow.cutHeight = strokeWidth;
}
if (group) {
group.element.appendChild(shadow);
} else {
element.parentNode.insertBefore(shadow, element);
}
shadows.push(shadow);
}
this.shadows = shadows;
}
return this;
},
/**
* Destroy shadows on the element.
* @private
*/
destroyShadows: function() {
each(this.shadows || [], function(shadow) {
this.safeRemoveChild(shadow);
}, this);
this.shadows = undefined;
},
xGetter: function(key) {
if (this.element.nodeName === 'circle') {
if (key === 'x') {
key = 'cx';
} else if (key === 'y') {
key = 'cy';
}
}
return this._defaultGetter(key);
},
/**
* Get the current value of an attribute or pseudo attribute, used mainly
* for animation. Called internally from the {@link SVGRenderer#attr}
* function.
*
* @private
*/
_defaultGetter: function(key) {
var ret = pick(this[key], this.element ? this.element.getAttribute(key) : null, 0);
if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
ret = parseFloat(ret);
}
return ret;
},
dSetter: function(value, key, element) {
if (value && value.join) { // join path
value = value.join(' ');
}
if (/(NaN| {2}|^$)/.test(value)) {
value = 'M 0 0';
}
element.setAttribute(key, value);
this[key] = value;
},
dashstyleSetter: function(value) {
var i,
strokeWidth = this['stroke-width'];
// If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new strokeWidth
// function, we should be able to use that instead.
if (strokeWidth === 'inherit') {
strokeWidth = 1;
}
value = value && value.toLowerCase();
if (value) {
value = value
.replace('shortdashdotdot', '3,1,1,1,1,1,')
.replace('shortdashdot', '3,1,1,1')
.replace('shortdot', '1,1,')
.replace('shortdash', '3,1,')
.replace('longdash', '8,3,')
.replace(/dot/g, '1,3,')
.replace('dash', '4,3,')
.replace(/,$/, '')
.split(','); // ending comma
i = value.length;
while (i--) {
value[i] = pInt(value[i]) * strokeWidth;
}
value = value.join(',')
.replace(/NaN/g, 'none'); // #3226
this.element.setAttribute('stroke-dasharray', value);
}
},
alignSetter: function(value) {
var convert = {
left: 'start',
center: 'middle',
right: 'end'
};
this.element.setAttribute('text-anchor', convert[value]);
},
opacitySetter: function(value, key, element) {
this[key] = value;
element.setAttribute(key, value);
},
titleSetter: function(value) {
var titleNode = this.element.getElementsByTagName('title')[0];
if (!titleNode) {
titleNode = doc.createElementNS(this.SVG_NS, 'title');
this.element.appendChild(titleNode);
}
// Remove text content if it exists
if (titleNode.firstChild) {
titleNode.removeChild(titleNode.firstChild);
}
titleNode.appendChild(
doc.createTextNode(
(String(pick(value), '')).replace(/<[^>]*>/g, '') // #3276, #3895
)
);
},
textSetter: function(value) {
if (value !== this.textStr) {
// Delete bBox memo when the text changes
delete this.bBox;
this.textStr = value;
if (this.added) {
this.renderer.buildText(this);
}
}
},
fillSetter: function(value, key, element) {
if (typeof value === 'string') {
element.setAttribute(key, value);
} else if (value) {
this.colorGradient(value, key, element);
}
},
visibilitySetter: function(value, key, element) {
// IE9-11 doesn't handle visibilty:inherit well, so we remove the attribute instead (#2881, #3909)
if (value === 'inherit') {
element.removeAttribute(key);
} else {
element.setAttribute(key, value);
}
},
zIndexSetter: function(value, key) {
var renderer = this.renderer,
parentGroup = this.parentGroup,
parentWrapper = parentGroup || renderer,
parentNode = parentWrapper.element || renderer.box,
childNodes,
otherElement,
otherZIndex,
element = this.element,
inserted,
run = this.added,
i;
if (defined(value)) {
element.zIndex = value; // So we can read it for other elements in the group
value = +value;
if (this[key] === value) { // Only update when needed (#3865)
run = false;
}
this[key] = value;
}
// Insert according to this and other elements' zIndex. Before .add() is called,
// nothing is done. Then on add, or by later calls to zIndexSetter, the node
// is placed on the right place in the DOM.
if (run) {
value = this.zIndex;
if (value && parentGroup) {
parentGroup.handleZ = true;
}
childNodes = parentNode.childNodes;
for (i = 0; i < childNodes.length && !inserted; i++) {
otherElement = childNodes[i];
otherZIndex = otherElement.zIndex;
if (otherElement !== element && (
// Insert before the first element with a higher zIndex
pInt(otherZIndex) > value ||
// If no zIndex given, insert before the first element with a zIndex
(!defined(value) && defined(otherZIndex)) ||
// Negative zIndex versus no zIndex:
// On all levels except the highest. If the parent is <svg>,
// then we don't want to put items before <desc> or <defs>
(value < 0 && !defined(otherZIndex) && parentNode !== renderer.box)
)) {
parentNode.insertBefore(element, otherElement);
inserted = true;
}
}
if (!inserted) {
parentNode.appendChild(element);
}
}
return inserted;
},
_defaultSetter: function(value, key, element) {
element.setAttribute(key, value);
}
};
// Some shared setters and getters
SVGElement.prototype.yGetter = SVGElement.prototype.xGetter;
SVGElement.prototype.translateXSetter = SVGElement.prototype.translateYSetter =
SVGElement.prototype.rotationSetter = SVGElement.prototype.verticalAlignSetter =
SVGElement.prototype.scaleXSetter = SVGElement.prototype.scaleYSetter = function(value, key) {
this[key] = value;
this.doTransform = true;
};
// WebKit and Batik have problems with a stroke-width of zero, so in this case we remove the
// stroke attribute altogether. #1270, #1369, #3065, #3072.
SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter = function(value, key, element) {
this[key] = value;
// Only apply the stroke attribute if the stroke width is defined and larger than 0
if (this.stroke && this['stroke-width']) {
SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element); // use prototype as instance may be overridden
element.setAttribute('stroke-width', this['stroke-width']);
this.hasStroke = true;
} else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
element.removeAttribute('stroke');
this.hasStroke = false;
}
};
/**
* Allows direct access to the Highcharts rendering layer in order to draw
* primitive shapes like circles, rectangles, paths or text directly on a chart,
* or independent from any chart. The SVGRenderer represents a wrapper object
* for SVGin modern browsers and through the VMLRenderer, for VML in IE < 8.
*
* An existing chart's renderer can be accessed through {@link Chart#renderer}.
* The renderer can also be used completely decoupled from a chart.
*
* @param {HTMLDOMElement} container - Where to put the SVG in the web page.
* @param {number} width - The width of the SVG.
* @param {number} height - The height of the SVG.
* @param {boolean} [forExport=false] - Whether the rendered content is intended
* for export.
* @param {boolean} [allowHTML=true] - Whether the renderer is allowed to
* include HTML text, which will be projected on top of the SVG.
*
* @example
* // Use directly without a chart object.
* var renderer = new Highcharts.Renderer(parentNode, 600, 400);
*
* @sample highcharts/members/renderer-on-chart - Annotating a chart programmatically.
* @sample highcharts/members/renderer-basic - Independedt SVG drawing.
*
* @class
*/
SVGRenderer = H.SVGRenderer = function() {
this.init.apply(this, arguments);
};
SVGRenderer.prototype = {
/**
* A pointer to the renderer's associated Element class. The VMLRenderer
* will have a pointer to VMLElement here.
* @type {SVGElement}
*/
Element: SVGElement,
SVG_NS: SVG_NS,
/**
* Initialize the SVGRenderer. Overridable initiator function that takes
* the same parameters as the constructor.
*/
init: function(container, width, height, style, forExport, allowHTML) {
var renderer = this,
boxWrapper,
element,
desc;
boxWrapper = renderer.createElement('svg')
.attr({
'version': '1.1',
'class': 'highcharts-root'
})
.css(this.getStyle(style));
element = boxWrapper.element;
container.appendChild(element);
// For browsers other than IE, add the namespace attribute (#1978)
if (container.innerHTML.indexOf('xmlns') === -1) {
attr(element, 'xmlns', this.SVG_NS);
}
// object properties
renderer.isSVG = true;
/**
* The root `svg` node of the renderer.
* @type {SVGDOMElement}
*/
this.box = element;
/**
* The wrapper for the root `svg` node of the renderer.
* @type {SVGElement}
*/
this.boxWrapper = boxWrapper;
renderer.alignedObjects = [];
/**
* Page url used for internal references.
* @type {string}
*/
// #24, #672, #1070
this.url = (isFirefox || isWebKit) && doc.getElementsByTagName('base').length ?
win.location.href
.replace(/#.*?$/, '') // remove the hash
.replace(/<[^>]*>/g, '') // wing cut HTML
.replace(/([\('\)])/g, '\\$1') // escape parantheses and quotes
.replace(/ /g, '%20') : // replace spaces (needed for Safari only)
'';
// Add description
desc = this.createElement('desc').add();
desc.element.appendChild(doc.createTextNode('Created with Highstock 5.0.10'));
renderer.defs = this.createElement('defs').add();
renderer.allowHTML = allowHTML;
renderer.forExport = forExport;
renderer.gradients = {}; // Object where gradient SvgElements are stored
renderer.cache = {}; // Cache for numerical bounding boxes
renderer.cacheKeys = [];
renderer.imgCount = 0;
renderer.setSize(width, height, false);
// Issue 110 workaround:
// In Firefox, if a div is positioned by percentage, its pixel position may land
// between pixels. The container itself doesn't display this, but an SVG element
// inside this container will be drawn at subpixel precision. In order to draw
// sharp lines, this must be compensated for. This doesn't seem to work inside
// iframes though (like in jsFiddle).
var subPixelFix, rect;
if (isFirefox && container.getBoundingClientRect) {
subPixelFix = function() {
css(container, {
left: 0,
top: 0
});
rect = container.getBoundingClientRect();
css(container, {
left: (Math.ceil(rect.left) - rect.left) + 'px',
top: (Math.ceil(rect.top) - rect.top) + 'px'
});
};
// run the fix now
subPixelFix();
// run it on resize
renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
}
},
/**
* Get the global style setting for the renderer.
* @private
* @param {CSSObject} style - Style settings.
* @return {CSSObject} The style settings mixed with defaults.
*/
getStyle: function(style) {
this.style = extend({
fontFamily: '"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif', // default font
fontSize: '12px'
}, style);
return this.style;
},
/**
* Apply the global style on the renderer, mixed with the default styles.
* @param {CSSObject} style - CSS to apply.
*/
setStyle: function(style) {
this.boxWrapper.css(this.getStyle(style));
},
/**
* Detect whether the renderer is hidden. This happens when one of the
* parent elements has display: none. Used internally to detect when we need
* to render preliminarily in another div to get the text bounding boxes
* right.
*
* @returns {boolean} True if it is hidden.
*/
isHidden: function() { // #608
return !this.boxWrapper.getBBox().width;
},
/**
* Destroys the renderer and its allocated members.
*/
destroy: function() {
var renderer = this,
rendererDefs = renderer.defs;
renderer.box = null;
renderer.boxWrapper = renderer.boxWrapper.destroy();
// Call destroy on all gradient elements
destroyObjectProperties(renderer.gradients || {});
renderer.gradients = null;
// Defs are null in VMLRenderer
// Otherwise, destroy them here.
if (rendererDefs) {
renderer.defs = rendererDefs.destroy();
}
// Remove sub pixel fix handler (#982)
if (renderer.unSubPixelFix) {
renderer.unSubPixelFix();
}
renderer.alignedObjects = null;
return null;
},
/**
* Create a wrapper for an SVG element. Serves as a factory for
* {@link SVGElement}, but this function is itself mostly called from
* primitive factories like {@link SVGRenderer#path}, {@link
* SVGRenderer#rect} or {@link SVGRenderer#text}.
*
* @param {string} nodeName - The node name, for example `rect`, `g` etc.
* @returns {SVGElement} The generated SVGElement.
*/
createElement: function(nodeName) {
var wrapper = new this.Element();
wrapper.init(this, nodeName);
return wrapper;
},
/**
* Dummy function for plugins, called every time the renderer is updated.
* Prior to Highcharts 5, this was used for the canvg renderer.
* @function
*/
draw: noop,
/**
* Get converted radial gradient attributes according to the radial
* reference. Used internally from the {@link SVGElement#colorGradient}
* function.
*
* @private
*/
getRadialAttr: function(radialReference, gradAttr) {
return {
cx: (radialReference[0] - radialReference[2] / 2) + gradAttr.cx * radialReference[2],
cy: (radialReference[1] - radialReference[2] / 2) + gradAttr.cy * radialReference[2],
r: gradAttr.r * radialReference[2]
};
},
getSpanWidth: function(wrapper, tspan) {
var renderer = this,
bBox = wrapper.getBBox(true),
actualWidth = bBox.width;
// Old IE cannot measure the actualWidth for SVG elements (#2314)
if (!svg && renderer.forExport) {
actualWidth = renderer.measureSpanWidth(tspan.firstChild.data, wrapper.styles);
}
return actualWidth;
},
applyEllipsis: function(wrapper, tspan, text, width) {
var renderer = this,
actualWidth = renderer.getSpanWidth(wrapper, tspan),
wasTooLong = actualWidth > width,
str = text,
currentIndex,
minIndex = 0,
maxIndex = text.length,
updateTSpan = function(s) {
tspan.removeChild(tspan.firstChild);
if (s) {
tspan.appendChild(doc.createTextNode(s));
}
};
if (wasTooLong) {
while (minIndex <= maxIndex) {
currentIndex = Math.ceil((minIndex + maxIndex) / 2);
str = text.substring(0, currentIndex) + '\u2026';
updateTSpan(str);
actualWidth = renderer.getSpanWidth(wrapper, tspan);
if (minIndex === maxIndex) {
// Complete
minIndex = maxIndex + 1;
} else if (actualWidth > width) {
// Too large. Set max index to current.
maxIndex = currentIndex - 1;
} else {
// Within width. Set min index to current.
minIndex = currentIndex;
}
}
// If max index was 0 it means just ellipsis was also to large.
if (maxIndex === 0) {
// Remove ellipses.
updateTSpan('');
}
}
return wasTooLong;
},
/**
* Parse a simple HTML string into SVG tspans. Called internally when text
* is set on an SVGElement. The function supports a subset of HTML tags,
* CSS text features like `width`, `text-overflow`, `white-space`, and
* also attributes like `href` and `style`.
* @private
* @param {SVGElement} wrapper The parent SVGElement.
*/
buildText: function(wrapper) {
var textNode = wrapper.element,
renderer = this,
forExport = renderer.forExport,
textStr = pick(wrapper.textStr, '').toString(),
hasMarkup = textStr.indexOf('<') !== -1,
lines,
childNodes = textNode.childNodes,
clsRegex,
styleRegex,
hrefRegex,
wasTooLong,
parentX = attr(textNode, 'x'),
textStyles = wrapper.styles,
width = wrapper.textWidth,
textLineHeight = textStyles && textStyles.lineHeight,
textOutline = textStyles && textStyles.textOutline,
ellipsis = textStyles && textStyles.textOverflow === 'ellipsis',
noWrap = textStyles && textStyles.whiteSpace === 'nowrap',
fontSize = textStyles && textStyles.fontSize,
textCache,
isSubsequentLine,
i = childNodes.length,
tempParent = width && !wrapper.added && this.box,
getLineHeight = function(tspan) {
var fontSizeStyle;
fontSizeStyle = /(px|em)$/.test(tspan && tspan.style.fontSize) ?
tspan.style.fontSize :
(fontSize || renderer.style.fontSize || 12);
return textLineHeight ?
pInt(textLineHeight) :
renderer.fontMetrics(
fontSizeStyle,
// Get the computed size from parent if not explicit
tspan.getAttribute('style') ? tspan : textNode
).h;
},
unescapeAngleBrackets = function(inputStr) {
return inputStr.replace(/</g, '<').replace(/>/g, '>');
};
// The buildText code is quite heavy, so if we're not changing something
// that affects the text, skip it (#6113).
textCache = [
textStr,
ellipsis,
noWrap,
textLineHeight,
textOutline,
fontSize,
width
].join(',');
if (textCache === wrapper.textCache) {
return;
}
wrapper.textCache = textCache;
/// remove old text
while (i--) {
textNode.removeChild(childNodes[i]);
}
// Skip tspans, add text directly to text node. The forceTSpan is a hook
// used in text outline hack.
if (!hasMarkup && !textOutline && !ellipsis && !width && textStr.indexOf(' ') === -1) {
textNode.appendChild(doc.createTextNode(unescapeAngleBrackets(textStr)));
// Complex strings, add more logic
} else {
clsRegex = /<.*class="([^"]+)".*>/;
styleRegex = /<.*style="([^"]+)".*>/;
hrefRegex = /<.*href="(http[^"]+)".*>/;
if (tempParent) {
tempParent.appendChild(textNode); // attach it to the DOM to read offset width
}
if (hasMarkup) {
lines = textStr
.replace(/<(b|strong)>/g, '<span style="font-weight:bold">')
.replace(/<(i|em)>/g, '<span style="font-style:italic">')
.replace(/<a/g, '<span')
.replace(/<\/(b|strong|i|em|a)>/g, '</span>')
.split(/<br.*?>/g);
} else {
lines = [textStr];
}
// Trim empty lines (#5261)
lines = grep(lines, function(line) {
return line !== '';
});
// build the lines
each(lines, function buildTextLines(line, lineNo) {
var spans,
spanNo = 0;
line = line
.replace(/^\s+|\s+$/g, '') // Trim to prevent useless/costly process on the spaces (#5258)
.replace(/<span/g, '|||<span')
.replace(/<\/span>/g, '</span>|||');
spans = line.split('|||');
each(spans, function buildTextSpans(span) {
if (span !== '' || spans.length === 1) {
var attributes = {},
tspan = doc.createElementNS(renderer.SVG_NS, 'tspan'),
spanCls,
spanStyle; // #390
if (clsRegex.test(span)) {
spanCls = span.match(clsRegex)[1];
attr(tspan, 'class', spanCls);
}
if (styleRegex.test(span)) {
spanStyle = span.match(styleRegex)[1].replace(/(;| |^)color([ :])/, '$1fill$2');
attr(tspan, 'style', spanStyle);
}
if (hrefRegex.test(span) && !forExport) { // Not for export - #1529
attr(tspan, 'onclick', 'location.href=\"' + span.match(hrefRegex)[1] + '\"');
css(tspan, {
cursor: 'pointer'
});
}
span = unescapeAngleBrackets(span.replace(/<(.|\n)*?>/g, '') || ' ');
// Nested tags aren't supported, and cause crash in Safari (#1596)
if (span !== ' ') {
// add the text node
tspan.appendChild(doc.createTextNode(span));
if (!spanNo) { // first span in a line, align it to the left
if (lineNo && parentX !== null) {
attributes.x = parentX;
}
} else {
attributes.dx = 0; // #16
}
// add attributes
attr(tspan, attributes);
// Append it
textNode.appendChild(tspan);
// first span on subsequent line, add the line height
if (!spanNo && isSubsequentLine) {
// allow getting the right offset height in exporting in IE
if (!svg && forExport) {
css(tspan, {
display: 'block'
});
}
// Set the line height based on the font size of either
// the text element or the tspan element
attr(
tspan,
'dy',
getLineHeight(tspan)
);
}
/*if (width) {
renderer.breakText(wrapper, width);
}*/
// Check width and apply soft breaks or ellipsis
if (width) {
var words = span.replace(/([^\^])-/g, '$1- ').split(' '), // #1273
hasWhiteSpace = spans.length > 1 || lineNo || (words.length > 1 && !noWrap),
tooLong,
rest = [],
actualWidth,
dy = getLineHeight(tspan),
rotation = wrapper.rotation;
if (ellipsis) {
wasTooLong = renderer.applyEllipsis(wrapper, tspan, span, width);
}
while (!ellipsis && hasWhiteSpace && (words.length || rest.length)) {
wrapper.rotation = 0; // discard rotation when computing box
actualWidth = renderer.getSpanWidth(wrapper, tspan);
tooLong = actualWidth > width;
// For ellipsis, do a binary search for the correct string length
if (wasTooLong === undefined) {
wasTooLong = tooLong; // First time
}
// Looping down, this is the first word sequence that is not too long,
// so we can move on to build the next line.
if (!tooLong || words.length === 1) {
words = rest;
rest = [];
if (words.length && !noWrap) {
tspan = doc.createElementNS(SVG_NS, 'tspan');
attr(tspan, {
dy: dy,
x: parentX
});
if (spanStyle) { // #390
attr(tspan, 'style', spanStyle);
}
textNode.appendChild(tspan);
}
if (actualWidth > width) { // a single word is pressing it out
width = actualWidth;
}
} else { // append to existing line tspan
tspan.removeChild(tspan.firstChild);
rest.unshift(words.pop());
}
if (words.length) {
tspan.appendChild(doc.createTextNode(words.join(' ').replace(/- /g, '-')));
}
}
wrapper.rotation = rotation;
}
spanNo++;
}
}
});
// To avoid beginning lines that doesn't add to the textNode (#6144)
isSubsequentLine = isSubsequentLine || textNode.childNodes.length;
});
if (wasTooLong) {
wrapper.attr('title', wrapper.textStr);
}
if (tempParent) {
tempParent.removeChild(textNode); // attach it to the DOM to read offset width
}
// Apply the text outline
if (textOutline && wrapper.applyTextOutline) {
wrapper.applyTextOutline(textOutline);
}
}
},
/*
breakText: function (wrapper, width) {
var bBox = wrapper.getBBox(),
node = wrapper.element,
textLength = node.textContent.length,
pos = Math.round(width * textLength / bBox.width), // try this position first, based on average character width
increment = 0,
finalPos;
if (bBox.width > width) {
while (finalPos === undefined) {
textLength = node.getSubStringLength(0, pos);
if (textLength <= width) {
if (increment === -1) {
finalPos = pos;
} else {
increment = 1;
}
} else {
if (increment === 1) {
finalPos = pos - 1;
} else {
increment = -1;
}
}
pos += increment;
}
}
console.log('width', width, 'stringWidth', node.getSubStringLength(0, finalPos))
},
*/
/**
* Returns white for dark colors and black for bright colors.
*
* @param {ColorString} rgba - The color to get the contrast for.
* @returns {string} The contrast color, either `#000000` or `#FFFFFF`.
*/
getContrast: function(rgba) {
rgba = color(rgba).rgba;
// The threshold may be discussed. Here's a proposal for adding
// different weight to the color channels (#6216)
/*
rgba[0] *= 1; // red
rgba[1] *= 1.2; // green
rgba[2] *= 0.7; // blue
*/
return rgba[0] + rgba[1] + rgba[2] > 2 * 255 ? '#000000' : '#FFFFFF';
},
/**
* Create a button with preset states.
* @param {string} text - The text or HTML to draw.
* @param {number} x - The x position of the button's left side.
* @param {number} y - The y position of the button's top side.
* @param {Function} callback - The function to execute on button click or
* touch.
* @param {SVGAttributes} [normalState] - SVG attributes for the normal
* state.
* @param {SVGAttributes} [hoverState] - SVG attributes for the hover state.
* @param {SVGAttributes} [pressedState] - SVG attributes for the pressed
* state.
* @param {SVGAttributes} [disabledState] - SVG attributes for the disabled
* state.
* @param {Symbol} [shape=rect] - The shape type.
* @returns {SVGRenderer} The button element.
*/
button: function(text, x, y, callback, normalState, hoverState, pressedState, disabledState, shape) {
var label = this.label(text, x, y, shape, null, null, null, null, 'button'),
curState = 0;
// Default, non-stylable attributes
label.attr(merge({
'padding': 8,
'r': 2
}, normalState));
// Presentational
var normalStyle,
hoverStyle,
pressedStyle,
disabledStyle;
// Normal state - prepare the attributes
normalState = merge({
fill: '#f7f7f7',
stroke: '#cccccc',
'stroke-width': 1,
style: {
color: '#333333',
cursor: 'pointer',
fontWeight: 'normal'
}
}, normalState);
normalStyle = normalState.style;
delete normalState.style;
// Hover state
hoverState = merge(normalState, {
fill: '#e6e6e6'
}, hoverState);
hoverStyle = hoverState.style;
delete hoverState.style;
// Pressed state
pressedState = merge(normalState, {
fill: '#e6ebf5',
style: {
color: '#000000',
fontWeight: 'bold'
}
}, pressedState);
pressedStyle = pressedState.style;
delete pressedState.style;
// Disabled state
disabledState = merge(normalState, {
style: {
color: '#cccccc'
}
}, disabledState);
disabledStyle = disabledState.style;
delete disabledState.style;
// Add the events. IE9 and IE10 need mouseover and mouseout to funciton (#667).
addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function() {
if (curState !== 3) {
label.setState(1);
}
});
addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function() {
if (curState !== 3) {
label.setState(curState);
}
});
label.setState = function(state) {
// Hover state is temporary, don't record it
if (state !== 1) {
label.state = curState = state;
}
// Update visuals
label.removeClass(/highcharts-button-(normal|hover|pressed|disabled)/)
.addClass('highcharts-button-' + ['normal', 'hover', 'pressed', 'disabled'][state || 0]);
label.attr([normalState, hoverState, pressedState, disabledState][state || 0])
.css([normalStyle, hoverStyle, pressedStyle, disabledStyle][state || 0]);
};
// Presentational attributes
label
.attr(normalState)
.css(extend({
cursor: 'default'
}, normalStyle));
return label
.on('click', function(e) {
if (curState !== 3) {
callback.call(label, e);
}
});
},
/**
* Make a straight line crisper by not spilling out to neighbour pixels.
*
* @param {Array} points - The original points on the format `['M', 0, 0,
* 'L', 100, 0]`.
* @param {number} width - The width of the line.
* @returns {Array} The original points array, but modified to render
* crisply.
*/
crispLine: function(points, width) {
// normalize to a crisp line
if (points[1] === points[4]) {
// Substract due to #1129. Now bottom and left axis gridlines behave the same.
points[1] = points[4] = Math.round(points[1]) - (width % 2 / 2);
}
if (points[2] === points[5]) {
points[2] = points[5] = Math.round(points[2]) + (width % 2 / 2);
}
return points;
},
/**
* Draw a path, wraps the SVG `path` element.
*
* @param {Array} [path] An SVG path definition in array form.
*
* @example
* var path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
* .attr({ stroke: '#ff00ff' })
* .add();
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw a path, wraps the SVG `path` element.
*
* @param {SVGAttributes} [attribs] The initial attributes.
* @returns {SVGElement} The generated wrapper element.
*/
path: function(path) {
var attribs = {
fill: 'none'
};
if (isArray(path)) {
attribs.d = path;
} else if (isObject(path)) { // attributes
extend(attribs, path);
}
return this.createElement('path').attr(attribs);
},
/**
* Draw a circle, wraps the SVG `circle` element.
*
* @param {number} [x] The center x position.
* @param {number} [y] The center y position.
* @param {number} [r] The radius.
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw a circle, wraps the SVG `circle` element.
*
* @param {SVGAttributes} [attribs] The initial attributes.
* @returns {SVGElement} The generated wrapper element.
*/
circle: function(x, y, r) {
var attribs = isObject(x) ? x : {
x: x,
y: y,
r: r
},
wrapper = this.createElement('circle');
// Setting x or y translates to cx and cy
wrapper.xSetter = wrapper.ySetter = function(value, key, element) {
element.setAttribute('c' + key, value);
};
return wrapper.attr(attribs);
},
/**
* Draw and return an arc.
* @param {number} [x=0] Center X position.
* @param {number} [y=0] Center Y position.
* @param {number} [r=0] The outer radius of the arc.
* @param {number} [innerR=0] Inner radius like used in donut charts.
* @param {number} [start=0] The starting angle of the arc in radians, where
* 0 is to the right and `-Math.PI/2` is up.
* @param {number} [end=0] The ending angle of the arc in radians, where 0
* is to the right and `-Math.PI/2` is up.
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw and return an arc. Overloaded function that takes arguments object.
* @param {SVGAttributes} attribs Initial SVG attributes.
* @returns {SVGElement} The generated wrapper element.
*/
arc: function(x, y, r, innerR, start, end) {
var arc,
options;
if (isObject(x)) {
options = x;
y = options.y;
r = options.r;
innerR = options.innerR;
start = options.start;
end = options.end;
x = options.x;
} else {
options = {
innerR: innerR,
start: start,
end: end
};
}
// Arcs are defined as symbols for the ability to set
// attributes in attr and animate
arc = this.symbol('arc', x, y, r, r, options);
arc.r = r; // #959
return arc;
},
/**
* Draw and return a rectangle.
* @param {number} [x] Left position.
* @param {number} [y] Top position.
* @param {number} [width] Width of the rectangle.
* @param {number} [height] Height of the rectangle.
* @param {number} [r] Border corner radius.
* @param {number} [strokeWidth] A stroke width can be supplied to allow
* crisp drawing.
* @returns {SVGElement} The generated wrapper element.
*/
/**
* Draw and return a rectangle.
* @param {SVGAttributes} [attributes] General SVG attributes for the
* rectangle.
* @returns {SVGElement} The generated wrapper element.
*/
rect: function(x, y, width, height, r, strokeWidth) {
r = isObject(x) ? x.r : r;
var wrapper = this.createElement('rect'),
attribs = isObject(x) ? x : x === undefined ? {} : {
x: x,
y: y,
width: Math.max(width, 0),
height: Math.max(height, 0)
};
if (strokeWidth !== undefined) {
attribs.strokeWidth = strokeWidth;
attribs = wrapper.crisp(attribs);
}
attribs.fill = 'none';
if (r) {
attribs.r = r;
}
wrapper.rSetter = function(value, key, element) {
attr(element, {
rx: value,
ry: value
});
};
return wrapper.attr(attribs);
},
/**
* Resize the {@link SVGRenderer#box} and re-align all aligned child
* elements.
* @param {number} width The new pixel width.
* @param {number} height The new pixel height.
* @param {boolean} animate Whether to animate.
*/
setSize: function(width, height, animate) {
var renderer = this,
alignedObjects = renderer.alignedObjects,
i = alignedObjects.length;
renderer.width = width;
renderer.height = height;
renderer.boxWrapper.animate({
width: width,
height: height
}, {
step: function() {
this.attr({
viewBox: '0 0 ' + this.attr('width') + ' ' + this.attr('height')
});
},
duration: pick(animate, true) ? undefined : 0
});
while (i--) {
alignedObjects[i].align();
}
},
/**
* Create and return an svg group element.
*
* @param {string} [name] The group will be given a class name of
* `highcharts-{name}`. This can be used for styling and scripting.
* @returns {SVGElement} The generated wrapper element.
*/
g: function(name) {
var elem = this.createElement('g');
return name ? elem.attr({
'class': 'highcharts-' + name
}) : elem;
},
/**
* Display an image.
* @param {string} src The image source.
* @param {number} [x] The X position.
* @param {number} [y] The Y position.
* @param {number} [width] The image width. If omitted, it defaults to the
* image file width.
* @param {number} [height] The image height. If omitted it defaults to the
* image file height.
* @returns {SVGElement} The generated wrapper element.
*/
image: function(src, x, y, width, height) {
var attribs = {
preserveAspectRatio: 'none'
},
elemWrapper;
// optional properties
if (arguments.length > 1) {
extend(attribs, {
x: x,
y: y,
width: width,
height: height
});
}
elemWrapper = this.createElement('image').attr(attribs);
// set the href in the xlink namespace
if (elemWrapper.element.setAttributeNS) {
elemWrapper.element.setAttributeNS('http://www.w3.org/1999/xlink',
'href', src);
} else {
// could be exporting in IE
// using href throws "not supported" in ie7 and under, requries regex shim to fix later
elemWrapper.element.setAttribute('hc-svg-href', src);
}
return elemWrapper;
},
/**
* Draw a symbol out of pre-defined shape paths from {@SVGRenderer#symbols}.
* It is used in Highcharts for point makers, which cake a `symbol` option,
* and label and button backgrounds like in the tooltip and stock flags.
*
* @param {Symbol} symbol - The symbol name.
* @param {number} x - The X coordinate for the top left position.
* @param {number} y - The Y coordinate for the top left position.
* @param {number} width - The pixel width.
* @param {number} height - The pixel height.
* @param {Object} [options] - Additional options, depending on the actual
* symbol drawn.
* @param {number} [options.anchorX] - The anchor X position for the
* `callout` symbol. This is where the chevron points to.
* @param {number} [options.anchorY] - The anchor Y position for the
* `callout` symbol. This is where the chevron points to.
* @param {number} [options.end] - The end angle of an `arc` symbol.
* @param {boolean} [options.open] - Whether to draw `arc` symbol open or
* closed.
* @param {number} [options.r] - The radius of an `arc` symbol, or the
* border radius for the `callout` symbol.
* @param {number} [options.start] - The start angle of an `arc` symbol.
*/
symbol: function(symbol, x, y, width, height, options) {
var ren = this,
obj,
// get the symbol definition function
symbolFn = this.symbols[symbol],
// check if there's a path defined for this symbol
path = defined(x) && symbolFn && this.symbols[symbol](
Math.round(x),
Math.round(y),
width,
height,
options
),
imageRegex = /^url\((.*?)\)$/,
imageSrc,
centerImage;
if (symbolFn) {
obj = this.path(path);
obj.attr('fill', 'none');
// expando properties for use in animate and attr
extend(obj, {
symbolName: symbol,
x: x,
y: y,
width: width,
height: height
});
if (options) {
extend(obj, options);
}
// image symbols
} else if (imageRegex.test(symbol)) {
imageSrc = symbol.match(imageRegex)[1];
// Create the image synchronously, add attribs async
obj = this.image(imageSrc);
// The image width is not always the same as the symbol width. The
// image may be centered within the symbol, as is the case when
// image shapes are used as label backgrounds, for example in flags.
obj.imgwidth = pick(
symbolSizes[imageSrc] && symbolSizes[imageSrc].width,
options && options.width
);
obj.imgheight = pick(
symbolSizes[imageSrc] && symbolSizes[imageSrc].height,
options && options.height
);
/**
* Set the size and position
*/
centerImage = function() {
obj.attr({
width: obj.width,
height: obj.height
});
};
/**
* Width and height setters that take both the image's physical size
* and the label size into consideration, and translates the image
* to center within the label.
*/
each(['width', 'height'], function(key) {
obj[key + 'Setter'] = function(value, key) {
var attribs = {},
imgSize = this['img' + key],
trans = key === 'width' ? 'translateX' : 'translateY';
this[key] = value;
if (defined(imgSize)) {
if (this.element) {
this.element.setAttribute(key, imgSize);
}
if (!this.alignByTranslate) {
attribs[trans] = ((this[key] || 0) - imgSize) / 2;
this.attr(attribs);
}
}
};
});
if (defined(x)) {
obj.attr({
x: x,
y: y
});
}
obj.isImg = true;
if (defined(obj.imgwidth) && defined(obj.imgheight)) {
centerImage();
} else {
// Initialize image to be 0 size so export will still function if there's no cached sizes.
obj.attr({
width: 0,
height: 0
});
// Create a dummy JavaScript image to get the width and height. Due to a bug in IE < 8,
// the created element must be assigned to a variable in order to load (#292).
createElement('img', {
onload: function() {
var chart = charts[ren.chartIndex];
// Special case for SVGs on IE11, the width is not accessible until the image is
// part of the DOM (#2854).
if (this.width === 0) {
css(this, {
position: 'absolute',
top: '-999em'
});
doc.body.appendChild(this);
}
// Center the image
symbolSizes[imageSrc] = { // Cache for next
width: this.width,
height: this.height
};
obj.imgwidth = this.width;
obj.imgheight = this.height;
if (obj.element) {
centerImage();
}
// Clean up after #2854 workaround.
if (this.parentNode) {
this.parentNode.removeChild(this);
}
// Fire the load event when all external images are loaded
ren.imgCount--;
if (!ren.imgCount && chart && chart.onload) {
chart.onload();
}
},
src: imageSrc
});
this.imgCount++;
}
}
return obj;
},
/**
* @typedef {string} Symbol
*
* Can be one of `arc`, `callout`, `circle`, `diamond`, `square`,
* `triangle`, `triangle-down`. Symbols are used internally for point
* markers, button and label borders and backgrounds, or custom shapes.
* Extendable by adding to {@link SVGRenderer#symbols}.
*/
/**
* An extendable collection of functions for defining symbol paths.
*/
symbols: {
'circle': function(x, y, w, h) {
// Return a full arc
return this.arc(x + w / 2, y + h / 2, w / 2, h / 2, {
start: 0,
end: Math.PI * 2,
open: false
});
},
'square': function(x, y, w, h) {
return [
'M', x, y,
'L', x + w, y,
x + w, y + h,
x, y + h,
'Z'
];
},
'triangle': function(x, y, w, h) {
return [
'M', x + w / 2, y,
'L', x + w, y + h,
x, y + h,
'Z'
];
},
'triangle-down': function(x, y, w, h) {
return [
'M', x, y,
'L', x + w, y,
x + w / 2, y + h,
'Z'
];
},
'diamond': function(x, y, w, h) {
return [
'M', x + w / 2, y,
'L', x + w, y + h / 2,
x + w / 2, y + h,
x, y + h / 2,
'Z'
];
},
'arc': function(x, y, w, h, options) {
var start = options.start,
rx = options.r || w,
ry = options.r || h || w,
end = options.end - 0.001, // to prevent cos and sin of start and end from becoming equal on 360 arcs (related: #1561)
innerRadius = options.innerR,
open = options.open,
cosStart = Math.cos(start),
sinStart = Math.sin(start),
cosEnd = Math.cos(end),
sinEnd = Math.sin(end),
longArc = options.end - start < Math.PI ? 0 : 1,
arc;
arc = [
'M',
x + rx * cosStart,
y + ry * sinStart,
'A', // arcTo
rx, // x radius
ry, // y radius
0, // slanting
longArc, // long or short arc
1, // clockwise
x + rx * cosEnd,
y + ry * sinEnd
];
if (defined(innerRadius)) {
arc.push(
open ? 'M' : 'L',
x + innerRadius * cosEnd,
y + innerRadius * sinEnd,
'A', // arcTo
innerRadius, // x radius
innerRadius, // y radius
0, // slanting
longArc, // long or short arc
0, // clockwise
x + innerRadius * cosStart,
y + innerRadius * sinStart
);
}
arc.push(open ? '' : 'Z'); // close
return arc;
},
/**
* Callout shape used for default tooltips, also used for rounded rectangles in VML
*/
callout: function(x, y, w, h, options) {
var arrowLength = 6,
halfDistance = 6,
r = Math.min((options && options.r) || 0, w, h),
safeDistance = r + halfDistance,
anchorX = options && options.anchorX,
anchorY = options && options.anchorY,
path;
path = [
'M', x + r, y,
'L', x + w - r, y, // top side
'C', x + w, y, x + w, y, x + w, y + r, // top-right corner
'L', x + w, y + h - r, // right side
'C', x + w, y + h, x + w, y + h, x + w - r, y + h, // bottom-right corner
'L', x + r, y + h, // bottom side
'C', x, y + h, x, y + h, x, y + h - r, // bottom-left corner
'L', x, y + r, // left side
'C', x, y, x, y, x + r, y // top-left corner
];
// Anchor on right side
if (anchorX && anchorX > w) {
// Chevron
if (anchorY > y + safeDistance && anchorY < y + h - safeDistance) {
path.splice(13, 3,
'L', x + w, anchorY - halfDistance,
x + w + arrowLength, anchorY,
x + w, anchorY + halfDistance,
x + w, y + h - r
);
// Simple connector
} else {
path.splice(13, 3,
'L', x + w, h / 2,
anchorX, anchorY,
x + w, h / 2,
x + w, y + h - r
);
}
// Anchor on left side
} else if (anchorX && anchorX < 0) {
// Chevron
if (anchorY > y + safeDistance && anchorY < y + h - safeDistance) {
path.splice(33, 3,
'L', x, anchorY + halfDistance,
x - arrowLength, anchorY,
x, anchorY - halfDistance,
x, y + r
);
// Simple connector
} else {
path.splice(33, 3,
'L', x, h / 2,
anchorX, anchorY,
x, h / 2,
x, y + r
);
}
} else if (anchorY && anchorY > h && anchorX > x + safeDistance && anchorX < x + w - safeDistance) { // replace bottom
path.splice(23, 3,
'L', anchorX + halfDistance, y + h,
anchorX, y + h + arrowLength,
anchorX - halfDistance, y + h,
x + r, y + h
);
} else if (anchorY && anchorY < 0 && anchorX > x + safeDistance && anchorX < x + w - safeDistance) { // replace top
path.splice(3, 3,
'L', anchorX - halfDistance, y,
anchorX, y - arrowLength,
anchorX + halfDistance, y,
w - r, y
);
}
return path;
}
},
/**
* @typedef {SVGElement} ClipRect - A clipping rectangle that can be applied
* to one or more {@link SVGElement} instances. It is instanciated with the
* {@link SVGRenderer#clipRect} function and applied with the {@link
* SVGElement#clip} function.
*
* @example
* var circle = renderer.circle(100, 100, 100)
* .attr({ fill: 'red' })
* .add();
* var clipRect = renderer.clipRect(100, 100, 100, 100);
*
* // Leave only the lower right quarter visible
* circle.clip(clipRect);
*/
/**
* Define a clipping rectangle
* @param {String} id
* @param {number} x
* @param {number} y
* @param {number} width
* @param {number} height
* @returns {ClipRect} A clipping rectangle.
*/
clipRect: function(x, y, width, height) {
var wrapper,
id = H.uniqueKey(),
clipPath = this.createElement('clipPath').attr({
id: id
}).add(this.defs);
wrapper = this.rect(x, y, width, height, 0).add(clipPath);
wrapper.id = id;
wrapper.clipPath = clipPath;
wrapper.count = 0;
return wrapper;
},
/**
* Add text to the SVG object
* @param {String} str
* @param {number} x Left position
* @param {number} y Top position
* @param {Boolean} useHTML Use HTML to render the text
*/
text: function(str, x, y, useHTML) {
// declare variables
var renderer = this,
fakeSVG = !svg && renderer.forExport,
wrapper,
attribs = {};
if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
return renderer.html(str, x, y);
}
attribs.x = Math.round(x || 0); // X is always needed for line-wrap logic
if (y) {
attribs.y = Math.round(y);
}
if (str || str === 0) {
attribs.text = str;
}
wrapper = renderer.createElement('text')
.attr(attribs);
// Prevent wrapping from creating false offsetWidths in export in legacy IE (#1079, #1063)
if (fakeSVG) {
wrapper.css({
position: 'absolute'
});
}
if (!useHTML) {
wrapper.xSetter = function(value, key, element) {
var tspans = element.getElementsByTagName('tspan'),
tspan,
parentVal = element.getAttribute(key),
i;
for (i = 0; i < tspans.length; i++) {
tspan = tspans[i];
// If the x values are equal, the tspan represents a linebreak
if (tspan.getAttribute(key) === parentVal) {
tspan.setAttribute(key, value);
}
}
element.setAttribute(key, value);
};
}
return wrapper;
},
/**
* Utility to return the baseline offset and total line height from the font
* size.
*
* @param {?string} fontSize The current font size to inspect. If not given,
* the font size will be found from the DOM element.
* @param {SVGElement|SVGDOMElement} [elem] The element to inspect for a
* current font size.
* @returns {Object} An object containing `h`: the line height, `b`: the
* baseline relative to the top of the box, and `f`: the font size.
*/
fontMetrics: function(fontSize, elem) {
var lineHeight,
baseline;
fontSize = fontSize ||
// When the elem is a DOM element (#5932)
(elem && elem.style && elem.style.fontSize) ||
// Fall back on the renderer style default
(this.style && this.style.fontSize);
// Handle different units
if (/px/.test(fontSize)) {
fontSize = pInt(fontSize);
} else if (/em/.test(fontSize)) {
// The em unit depends on parent items
fontSize = parseFloat(fontSize) *
(elem ? this.fontMetrics(null, elem.parentNode).f : 16);
} else {
fontSize = 12;
}
// Empirical values found by comparing font size and bounding box
// height. Applies to the default font family.
// http://jsfiddle.net/highcharts/7xvn7/
lineHeight = fontSize < 24 ? fontSize + 3 : Math.round(fontSize * 1.2);
baseline = Math.round(lineHeight * 0.8);
return {
h: lineHeight,
b: baseline,
f: fontSize
};
},
/**
* Correct X and Y positioning of a label for rotation (#1764)
*/
rotCorr: function(baseline, rotation, alterY) {
var y = baseline;
if (rotation && alterY) {
y = Math.max(y * Math.cos(rotation * deg2rad), 4);
}
return {
x: (-baseline / 3) * Math.sin(rotation * deg2rad),
y: y
};
},
/**
* Add a label, a text item that can hold a colored or gradient background
* as well as a border and shadow. Supported custom attributes include
* `padding`.
*
* @param {string} str
* @param {number} x
* @param {number} y
* @param {String} shape
* @param {number} anchorX In case the shape has a pointer, like a flag, this is the
* coordinates it should be pinned to
* @param {number} anchorY
* @param {Boolean} baseline Whether to position the label relative to the text baseline,
* like renderer.text, or to the upper border of the rectangle.
* @param {String} className Class name for the group
*/
label: function(str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
var renderer = this,
wrapper = renderer.g(className !== 'button' && 'label'),
text = wrapper.text = renderer.text('', 0, 0, useHTML)
.attr({
zIndex: 1
}),
box,
bBox,
alignFactor = 0,
padding = 3,
paddingLeft = 0,
width,
height,
wrapperX,
wrapperY,
textAlign,
deferredAttr = {},
strokeWidth,
baselineOffset,
hasBGImage = /^url\((.*?)\)$/.test(shape),
needsBox = hasBGImage,
getCrispAdjust,
updateBoxSize,
updateTextPadding,
boxAttr;
if (className) {
wrapper.addClass('highcharts-' + className);
}
needsBox = hasBGImage;
getCrispAdjust = function() {
return (strokeWidth || 0) % 2 / 2;
};
/**
* This function runs after the label is added to the DOM (when the bounding box is
* available), and after the text of the label is updated to detect the new bounding
* box and reflect it in the border box.
*/
updateBoxSize = function() {
var style = text.element.style,
crispAdjust,
attribs = {};
bBox = (width === undefined || height === undefined || textAlign) && defined(text.textStr) &&
text.getBBox(); //#3295 && 3514 box failure when string equals 0
wrapper.width = (width || bBox.width || 0) + 2 * padding + paddingLeft;
wrapper.height = (height || bBox.height || 0) + 2 * padding;
// Update the label-scoped y offset
baselineOffset = padding + renderer.fontMetrics(style && style.fontSize, text).b;
if (needsBox) {
// Create the border box if it is not already present
if (!box) {
wrapper.box = box = renderer.symbols[shape] || hasBGImage ? // Symbol definition exists (#5324)
renderer.symbol(shape) :
renderer.rect();
box.addClass(
(className === 'button' ? '' : 'highcharts-label-box') + // Don't use label className for buttons
(className ? ' highcharts-' + className + '-box' : '')
);
box.add(wrapper);
crispAdjust = getCrispAdjust();
attribs.x = crispAdjust;
attribs.y = (baseline ? -baselineOffset : 0) + crispAdjust;
}
// Apply the box attributes
attribs.width = Math.round(wrapper.width);
attribs.height = Math.round(wrapper.height);
box.attr(extend(attribs, deferredAttr));
deferredAttr = {};
}
};
/**
* This function runs after setting text or padding, but only if padding is changed
*/
updateTextPadding = function() {
var textX = paddingLeft + padding,
textY;
// determin y based on the baseline
textY = baseline ? 0 : baselineOffset;
// compensate for alignment
if (defined(width) && bBox && (textAlign === 'center' || textAlign === 'right')) {
textX += {
center: 0.5,
right: 1
}[textAlign] * (width - bBox.width);
}
// update if anything changed
if (textX !== text.x || textY !== text.y) {
text.attr('x', textX);
if (textY !== undefined) {
text.attr('y', textY);
}
}
// record current values
text.x = textX;
text.y = textY;
};
/**
* Set a box attribute, or defer it if the box is not yet created
* @param {Object} key
* @param {Object} value
*/
boxAttr = function(key, value) {
if (box) {
box.attr(key, value);
} else {
deferredAttr[key] = value;
}
};
/**
* After the text element is added, get the desired size of the border box
* and add it before the text in the DOM.
*/
wrapper.onAdd = function() {
text.add(wrapper);
wrapper.attr({
text: (str || str === 0) ? str : '', // alignment is available now // #3295: 0 not rendered if given as a value
x: x,
y: y
});
if (box && defined(anchorX)) {
wrapper.attr({
anchorX: anchorX,
anchorY: anchorY
});
}
};
/*
* Add specific attribute setters.
*/
// only change local variables
wrapper.widthSetter = function(value) {
width = H.isNumber(value) ? value : null; // width:auto => null
};
wrapper.heightSetter = function(value) {
height = value;
};
wrapper['text-alignSetter'] = function(value) {
textAlign = value;
};
wrapper.paddingSetter = function(value) {
if (defined(value) && value !== padding) {
padding = wrapper.padding = value;
updateTextPadding();
}
};
wrapper.paddingLeftSetter = function(value) {
if (defined(value) && value !== paddingLeft) {
paddingLeft = value;
updateTextPadding();
}
};
// change local variable and prevent setting attribute on the group
wrapper.alignSetter = function(value) {
value = {
left: 0,
center: 0.5,
right: 1
}[value];
if (value !== alignFactor) {
alignFactor = value;
if (bBox) { // Bounding box exists, means we're dynamically changing
wrapper.attr({
x: wrapperX
}); // #5134
}
}
};
// apply these to the box and the text alike
wrapper.textSetter = function(value) {
if (value !== undefined) {
text.textSetter(value);
}
updateBoxSize();
updateTextPadding();
};
// apply these to the box but not to the text
wrapper['stroke-widthSetter'] = function(value, key) {
if (value) {
needsBox = true;
}
strokeWidth = this['stroke-width'] = value;
boxAttr(key, value);
};
wrapper.strokeSetter = wrapper.fillSetter = wrapper.rSetter = function(value, key) {
if (key === 'fill' && value) {
needsBox = true;
}
boxAttr(key, value);
};
wrapper.anchorXSetter = function(value, key) {
anchorX = value;
boxAttr(key, Math.round(value) - getCrispAdjust() - wrapperX);
};
wrapper.anchorYSetter = function(value, key) {
anchorY = value;
boxAttr(key, value - wrapperY);
};
// rename attributes
wrapper.xSetter = function(value) {
wrapper.x = value; // for animation getter
if (alignFactor) {
value -= alignFactor * ((width || bBox.width) + 2 * padding);
}
wrapperX = Math.round(value);
wrapper.attr('translateX', wrapperX);
};
wrapper.ySetter = function(value) {
wrapperY = wrapper.y = Math.round(value);
wrapper.attr('translateY', wrapperY);
};
// Redirect certain methods to either the box or the text
var baseCss = wrapper.css;
return extend(wrapper, {
/**
* Pick up some properties and apply them to the text instead of the
* wrapper.
* @ignore
*/
css: function(styles) {
if (styles) {
var textStyles = {};
styles = merge(styles); // create a copy to avoid altering the original object (#537)
each(wrapper.textProps, function(prop) {
if (styles[prop] !== undefined) {
textStyles[prop] = styles[prop];
delete styles[prop];
}
});
text.css(textStyles);
}
return baseCss.call(wrapper, styles);
},
/**
* Return the bounding box of the box, not the group.
* @ignore
*/
getBBox: function() {
return {
width: bBox.width + 2 * padding,
height: bBox.height + 2 * padding,
x: bBox.x - padding,
y: bBox.y - padding
};
},
/**
* Apply the shadow to the box.
* @ignore
*/
shadow: function(b) {
if (b) {
updateBoxSize();
if (box) {
box.shadow(b);
}
}
return wrapper;
},
/**
* Destroy and release memory.
* @ignore
*/
destroy: function() {
// Added by button implementation
removeEvent(wrapper.element, 'mouseenter');
removeEvent(wrapper.element, 'mouseleave');
if (text) {
text = text.destroy();
}
if (box) {
box = box.destroy();
}
// Call base implementation to destroy the rest
SVGElement.prototype.destroy.call(wrapper);
// Release local pointers (#1298)
wrapper = renderer = updateBoxSize = updateTextPadding = boxAttr = null;
}
});
}
}; // end SVGRenderer
// general renderer
H.Renderer = SVGRenderer;
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var attr = H.attr,
createElement = H.createElement,
css = H.css,
defined = H.defined,
each = H.each,
extend = H.extend,
isFirefox = H.isFirefox,
isMS = H.isMS,
isWebKit = H.isWebKit,
pInt = H.pInt,
SVGElement = H.SVGElement,
SVGRenderer = H.SVGRenderer,
win = H.win,
wrap = H.wrap;
// Extend SvgElement for useHTML option
extend(SVGElement.prototype, /** @lends SVGElement.prototype */ {
/**
* Apply CSS to HTML elements. This is used in text within SVG rendering and
* by the VML renderer
*/
htmlCss: function(styles) {
var wrapper = this,
element = wrapper.element,
textWidth = styles && element.tagName === 'SPAN' && styles.width;
if (textWidth) {
delete styles.width;
wrapper.textWidth = textWidth;
wrapper.updateTransform();
}
if (styles && styles.textOverflow === 'ellipsis') {
styles.whiteSpace = 'nowrap';
styles.overflow = 'hidden';
}
wrapper.styles = extend(wrapper.styles, styles);
css(wrapper.element, styles);
return wrapper;
},
/**
* VML and useHTML method for calculating the bounding box based on offsets
* @param {Boolean} refresh Whether to force a fresh value from the DOM or to
* use the cached value
*
* @return {Object} A hash containing values for x, y, width and height
*/
htmlGetBBox: function() {
var wrapper = this,
element = wrapper.element;
// faking getBBox in exported SVG in legacy IE
// faking getBBox in exported SVG in legacy IE (is this a duplicate of the fix for #1079?)
if (element.nodeName === 'text') {
element.style.position = 'absolute';
}
return {
x: element.offsetLeft,
y: element.offsetTop,
width: element.offsetWidth,
height: element.offsetHeight
};
},
/**
* VML override private method to update elements based on internal
* properties based on SVG transform
*/
htmlUpdateTransform: function() {
// aligning non added elements is expensive
if (!this.added) {
this.alignOnAdd = true;
return;
}
var wrapper = this,
renderer = wrapper.renderer,
elem = wrapper.element,
translateX = wrapper.translateX || 0,
translateY = wrapper.translateY || 0,
x = wrapper.x || 0,
y = wrapper.y || 0,
align = wrapper.textAlign || 'left',
alignCorrection = {
left: 0,
center: 0.5,
right: 1
}[align],
styles = wrapper.styles;
// apply translate
css(elem, {
marginLeft: translateX,
marginTop: translateY
});
if (wrapper.shadows) { // used in labels/tooltip
each(wrapper.shadows, function(shadow) {
css(shadow, {
marginLeft: translateX + 1,
marginTop: translateY + 1
});
});
}
// apply inversion
if (wrapper.inverted) { // wrapper is a group
each(elem.childNodes, function(child) {
renderer.invertChild(child, elem);
});
}
if (elem.tagName === 'SPAN') {
var rotation = wrapper.rotation,
baseline,
textWidth = pInt(wrapper.textWidth),
whiteSpace = styles && styles.whiteSpace,
currentTextTransform = [rotation, align, elem.innerHTML, wrapper.textWidth, wrapper.textAlign].join(',');
if (currentTextTransform !== wrapper.cTT) { // do the calculations and DOM access only if properties changed
baseline = renderer.fontMetrics(elem.style.fontSize).b;
// Renderer specific handling of span rotation
if (defined(rotation)) {
wrapper.setSpanRotation(rotation, alignCorrection, baseline);
}
// Reset multiline/ellipsis in order to read width (#4928, #5417)
css(elem, {
width: '',
whiteSpace: whiteSpace || 'nowrap'
});
// Update textWidth
if (elem.offsetWidth > textWidth && /[ \-]/.test(elem.textContent || elem.innerText)) { // #983, #1254
css(elem, {
width: textWidth + 'px',
display: 'block',
whiteSpace: whiteSpace || 'normal' // #3331
});
}
wrapper.getSpanCorrection(elem.offsetWidth, baseline, alignCorrection, rotation, align);
}
// apply position with correction
css(elem, {
left: (x + (wrapper.xCorr || 0)) + 'px',
top: (y + (wrapper.yCorr || 0)) + 'px'
});
// force reflow in webkit to apply the left and top on useHTML element (#1249)
if (isWebKit) {
baseline = elem.offsetHeight; // assigned to baseline for lint purpose
}
// record current text transform
wrapper.cTT = currentTextTransform;
}
},
/**
* Set the rotation of an individual HTML span
*/
setSpanRotation: function(rotation, alignCorrection, baseline) {
var rotationStyle = {},
cssTransformKey = isMS ? '-ms-transform' : isWebKit ? '-webkit-transform' : isFirefox ? 'MozTransform' : win.opera ? '-o-transform' : '';
rotationStyle[cssTransformKey] = rotationStyle.transform = 'rotate(' + rotation + 'deg)';
rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] = rotationStyle.transformOrigin = (alignCorrection * 100) + '% ' + baseline + 'px';
css(this.element, rotationStyle);
},
/**
* Get the correction in X and Y positioning as the element is rotated.
*/
getSpanCorrection: function(width, baseline, alignCorrection) {
this.xCorr = -width * alignCorrection;
this.yCorr = -baseline;
}
});
// Extend SvgRenderer for useHTML option.
extend(SVGRenderer.prototype, /** @lends SVGRenderer.prototype */ {
/**
* Create HTML text node. This is used by the VML renderer as well as the SVG
* renderer through the useHTML option.
*
* @param {String} str
* @param {Number} x
* @param {Number} y
*/
html: function(str, x, y) {
var wrapper = this.createElement('span'),
element = wrapper.element,
renderer = wrapper.renderer,
isSVG = renderer.isSVG,
addSetters = function(element, style) {
// These properties are set as attributes on the SVG group, and as
// identical CSS properties on the div. (#3542)
each(['opacity', 'visibility'], function(prop) {
wrap(element, prop + 'Setter', function(proceed, value, key, elem) {
proceed.call(this, value, key, elem);
style[key] = value;
});
});
};
// Text setter
wrapper.textSetter = function(value) {
if (value !== element.innerHTML) {
delete this.bBox;
}
element.innerHTML = this.textStr = value;
wrapper.htmlUpdateTransform();
};
// Add setters for the element itself (#4938)
if (isSVG) { // #4938, only for HTML within SVG
addSetters(wrapper, wrapper.element.style);
}
// Various setters which rely on update transform
wrapper.xSetter = wrapper.ySetter = wrapper.alignSetter = wrapper.rotationSetter = function(value, key) {
if (key === 'align') {
key = 'textAlign'; // Do not overwrite the SVGElement.align method. Same as VML.
}
wrapper[key] = value;
wrapper.htmlUpdateTransform();
};
// Set the default attributes
wrapper
.attr({
text: str,
x: Math.round(x),
y: Math.round(y)
})
.css({
fontFamily: this.style.fontFamily,
fontSize: this.style.fontSize,
position: 'absolute'
});
// Keep the whiteSpace style outside the wrapper.styles collection
element.style.whiteSpace = 'nowrap';
// Use the HTML specific .css method
wrapper.css = wrapper.htmlCss;
// This is specific for HTML within SVG
if (isSVG) {
wrapper.add = function(svgGroupWrapper) {
var htmlGroup,
container = renderer.box.parentNode,
parentGroup,
parents = [];
this.parentGroup = svgGroupWrapper;
// Create a mock group to hold the HTML elements
if (svgGroupWrapper) {
htmlGroup = svgGroupWrapper.div;
if (!htmlGroup) {
// Read the parent chain into an array and read from top down
parentGroup = svgGroupWrapper;
while (parentGroup) {
parents.push(parentGroup);
// Move up to the next parent group
parentGroup = parentGroup.parentGroup;
}
// Ensure dynamically updating position when any parent is translated
each(parents.reverse(), function(parentGroup) {
var htmlGroupStyle,
cls = attr(parentGroup.element, 'class');
if (cls) {
cls = {
className: cls
};
} // else null
// Create a HTML div and append it to the parent div to emulate
// the SVG group structure
htmlGroup = parentGroup.div = parentGroup.div || createElement('div', cls, {
position: 'absolute',
left: (parentGroup.translateX || 0) + 'px',
top: (parentGroup.translateY || 0) + 'px',
display: parentGroup.display,
opacity: parentGroup.opacity, // #5075
pointerEvents: parentGroup.styles && parentGroup.styles.pointerEvents // #5595
}, htmlGroup || container); // the top group is appended to container
// Shortcut
htmlGroupStyle = htmlGroup.style;
// Set listeners to update the HTML div's position whenever the SVG group
// position is changed
extend(parentGroup, {
on: function() {
wrapper.on.apply({
element: parents[0].div
}, arguments);
return parentGroup;
},
translateXSetter: function(value, key) {
htmlGroupStyle.left = value + 'px';
parentGroup[key] = value;
parentGroup.doTransform = true;
},
translateYSetter: function(value, key) {
htmlGroupStyle.top = value + 'px';
parentGroup[key] = value;
parentGroup.doTransform = true;
}
});
addSetters(parentGroup, htmlGroupStyle);
});
}
} else {
htmlGroup = container;
}
htmlGroup.appendChild(element);
// Shared with VML:
wrapper.added = true;
if (wrapper.alignOnAdd) {
wrapper.htmlUpdateTransform();
}
return wrapper;
};
}
return wrapper;
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var VMLRenderer,
VMLRendererExtension,
VMLElement,
createElement = H.createElement,
css = H.css,
defined = H.defined,
deg2rad = H.deg2rad,
discardElement = H.discardElement,
doc = H.doc,
each = H.each,
erase = H.erase,
extend = H.extend,
extendClass = H.extendClass,
isArray = H.isArray,
isNumber = H.isNumber,
isObject = H.isObject,
merge = H.merge,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
svg = H.svg,
SVGElement = H.SVGElement,
SVGRenderer = H.SVGRenderer,
win = H.win;
/* ****************************************************************************
* *
* START OF INTERNET EXPLORER <= 8 SPECIFIC CODE *
* *
* For applications and websites that don't need IE support, like platform *
* targeted mobile apps and web apps, this code can be removed. *
* *
*****************************************************************************/
/**
* @constructor
*/
if (!svg) {
/**
* The VML element wrapper.
*/
VMLElement = {
docMode8: doc && doc.documentMode === 8,
/**
* Initialize a new VML element wrapper. It builds the markup as a string
* to minimize DOM traffic.
* @param {Object} renderer
* @param {Object} nodeName
*/
init: function(renderer, nodeName) {
var wrapper = this,
markup = ['<', nodeName, ' filled="f" stroked="f"'],
style = ['position: ', 'absolute', ';'],
isDiv = nodeName === 'div';
// divs and shapes need size
if (nodeName === 'shape' || isDiv) {
style.push('left:0;top:0;width:1px;height:1px;');
}
style.push('visibility: ', isDiv ? 'hidden' : 'visible');
markup.push(' style="', style.join(''), '"/>');
// create element with default attributes and style
if (nodeName) {
markup = isDiv || nodeName === 'span' || nodeName === 'img' ?
markup.join('') :
renderer.prepVML(markup);
wrapper.element = createElement(markup);
}
wrapper.renderer = renderer;
},
/**
* Add the node to the given parent
* @param {Object} parent
*/
add: function(parent) {
var wrapper = this,
renderer = wrapper.renderer,
element = wrapper.element,
box = renderer.box,
inverted = parent && parent.inverted,
// get the parent node
parentNode = parent ?
parent.element || parent :
box;
if (parent) {
this.parentGroup = parent;
}
// if the parent group is inverted, apply inversion on all children
if (inverted) { // only on groups
renderer.invertChild(element, parentNode);
}
// append it
parentNode.appendChild(element);
// align text after adding to be able to read offset
wrapper.added = true;
if (wrapper.alignOnAdd && !wrapper.deferUpdateTransform) {
wrapper.updateTransform();
}
// fire an event for internal hooks
if (wrapper.onAdd) {
wrapper.onAdd();
}
// IE8 Standards can't set the class name before the element is appended
if (this.className) {
this.attr('class', this.className);
}
return wrapper;
},
/**
* VML always uses htmlUpdateTransform
*/
updateTransform: SVGElement.prototype.htmlUpdateTransform,
/**
* Set the rotation of a span with oldIE's filter
*/
setSpanRotation: function() {
// Adjust for alignment and rotation. Rotation of useHTML content is not yet implemented
// but it can probably be implemented for Firefox 3.5+ on user request. FF3.5+
// has support for CSS3 transform. The getBBox method also needs to be updated
// to compensate for the rotation, like it currently does for SVG.
// Test case: http://jsfiddle.net/highcharts/Ybt44/
var rotation = this.rotation,
costheta = Math.cos(rotation * deg2rad),
sintheta = Math.sin(rotation * deg2rad);
css(this.element, {
filter: rotation ? ['progid:DXImageTransform.Microsoft.Matrix(M11=', costheta,
', M12=', -sintheta, ', M21=', sintheta, ', M22=', costheta,
', sizingMethod=\'auto expand\')'
].join('') : 'none'
});
},
/**
* Get the positioning correction for the span after rotating.
*/
getSpanCorrection: function(width, baseline, alignCorrection, rotation, align) {
var costheta = rotation ? Math.cos(rotation * deg2rad) : 1,
sintheta = rotation ? Math.sin(rotation * deg2rad) : 0,
height = pick(this.elemHeight, this.element.offsetHeight),
quad,
nonLeft = align && align !== 'left';
// correct x and y
this.xCorr = costheta < 0 && -width;
this.yCorr = sintheta < 0 && -height;
// correct for baseline and corners spilling out after rotation
quad = costheta * sintheta < 0;
this.xCorr += sintheta * baseline * (quad ? 1 - alignCorrection : alignCorrection);
this.yCorr -= costheta * baseline * (rotation ? (quad ? alignCorrection : 1 - alignCorrection) : 1);
// correct for the length/height of the text
if (nonLeft) {
this.xCorr -= width * alignCorrection * (costheta < 0 ? -1 : 1);
if (rotation) {
this.yCorr -= height * alignCorrection * (sintheta < 0 ? -1 : 1);
}
css(this.element, {
textAlign: align
});
}
},
/**
* Converts a subset of an SVG path definition to its VML counterpart. Takes an array
* as the parameter and returns a string.
*/
pathToVML: function(value) {
// convert paths
var i = value.length,
path = [];
while (i--) {
// Multiply by 10 to allow subpixel precision.
// Substracting half a pixel seems to make the coordinates
// align with SVG, but this hasn't been tested thoroughly
if (isNumber(value[i])) {
path[i] = Math.round(value[i] * 10) - 5;
} else if (value[i] === 'Z') { // close the path
path[i] = 'x';
} else {
path[i] = value[i];
// When the start X and end X coordinates of an arc are too close,
// they are rounded to the same value above. In this case, substract or
// add 1 from the end X and Y positions. #186, #760, #1371, #1410.
if (value.isArc && (value[i] === 'wa' || value[i] === 'at')) {
// Start and end X
if (path[i + 5] === path[i + 7]) {
path[i + 7] += value[i + 7] > value[i + 5] ? 1 : -1;
}
// Start and end Y
if (path[i + 6] === path[i + 8]) {
path[i + 8] += value[i + 8] > value[i + 6] ? 1 : -1;
}
}
}
}
// Loop up again to handle path shortcuts (#2132)
/*while (i++ < path.length) {
if (path[i] === 'H') { // horizontal line to
path[i] = 'L';
path.splice(i + 2, 0, path[i - 1]);
} else if (path[i] === 'V') { // vertical line to
path[i] = 'L';
path.splice(i + 1, 0, path[i - 2]);
}
}*/
return path.join(' ') || 'x';
},
/**
* Set the element's clipping to a predefined rectangle
*
* @param {String} id The id of the clip rectangle
*/
clip: function(clipRect) {
var wrapper = this,
clipMembers,
cssRet;
if (clipRect) {
clipMembers = clipRect.members;
erase(clipMembers, wrapper); // Ensure unique list of elements (#1258)
clipMembers.push(wrapper);
wrapper.destroyClip = function() {
erase(clipMembers, wrapper);
};
cssRet = clipRect.getCSS(wrapper);
} else {
if (wrapper.destroyClip) {
wrapper.destroyClip();
}
cssRet = {
clip: wrapper.docMode8 ? 'inherit' : 'rect(auto)'
}; // #1214
}
return wrapper.css(cssRet);
},
/**
* Set styles for the element
* @param {Object} styles
*/
css: SVGElement.prototype.htmlCss,
/**
* Removes a child either by removeChild or move to garbageBin.
* Issue 490; in VML removeChild results in Orphaned nodes according to sIEve, discardElement does not.
*/
safeRemoveChild: function(element) {
// discardElement will detach the node from its parent before attaching it
// to the garbage bin. Therefore it is important that the node is attached and have parent.
if (element.parentNode) {
discardElement(element);
}
},
/**
* Extend element.destroy by removing it from the clip members array
*/
destroy: function() {
if (this.destroyClip) {
this.destroyClip();
}
return SVGElement.prototype.destroy.apply(this);
},
/**
* Add an event listener. VML override for normalizing event parameters.
* @param {String} eventType
* @param {Function} handler
*/
on: function(eventType, handler) {
// simplest possible event model for internal use
this.element['on' + eventType] = function() {
var evt = win.event;
evt.target = evt.srcElement;
handler(evt);
};
return this;
},
/**
* In stacked columns, cut off the shadows so that they don't overlap
*/
cutOffPath: function(path, length) {
var len;
path = path.split(/[ ,]/); // The extra comma tricks the trailing comma remover in "gulp scripts" task
len = path.length;
if (len === 9 || len === 11) {
path[len - 4] = path[len - 2] = pInt(path[len - 2]) - 10 * length;
}
return path.join(' ');
},
/**
* Apply a drop shadow by copying elements and giving them different strokes
* @param {Boolean|Object} shadowOptions
*/
shadow: function(shadowOptions, group, cutOff) {
var shadows = [],
i,
element = this.element,
renderer = this.renderer,
shadow,
elemStyle = element.style,
markup,
path = element.path,
strokeWidth,
modifiedPath,
shadowWidth,
shadowElementOpacity;
// some times empty paths are not strings
if (path && typeof path.value !== 'string') {
path = 'x';
}
modifiedPath = path;
if (shadowOptions) {
shadowWidth = pick(shadowOptions.width, 3);
shadowElementOpacity = (shadowOptions.opacity || 0.15) / shadowWidth;
for (i = 1; i <= 3; i++) {
strokeWidth = (shadowWidth * 2) + 1 - (2 * i);
// Cut off shadows for stacked column items
if (cutOff) {
modifiedPath = this.cutOffPath(path.value, strokeWidth + 0.5);
}
markup = ['<shape isShadow="true" strokeweight="', strokeWidth,
'" filled="false" path="', modifiedPath,
'" coordsize="10 10" style="', element.style.cssText, '" />'
];
shadow = createElement(renderer.prepVML(markup),
null, {
left: pInt(elemStyle.left) + pick(shadowOptions.offsetX, 1),
top: pInt(elemStyle.top) + pick(shadowOptions.offsetY, 1)
}
);
if (cutOff) {
shadow.cutOff = strokeWidth + 1;
}
// apply the opacity
markup = [
'<stroke color="',
shadowOptions.color || '#000000',
'" opacity="', shadowElementOpacity * i, '"/>'
];
createElement(renderer.prepVML(markup), null, null, shadow);
// insert it
if (group) {
group.element.appendChild(shadow);
} else {
element.parentNode.insertBefore(shadow, element);
}
// record it
shadows.push(shadow);
}
this.shadows = shadows;
}
return this;
},
updateShadows: noop, // Used in SVG only
setAttr: function(key, value) {
if (this.docMode8) { // IE8 setAttribute bug
this.element[key] = value;
} else {
this.element.setAttribute(key, value);
}
},
classSetter: function(value) {
// IE8 Standards mode has problems retrieving the className unless set like this.
// IE8 Standards can't set the class name before the element is appended.
(this.added ? this.element : this).className = value;
},
dashstyleSetter: function(value, key, element) {
var strokeElem = element.getElementsByTagName('stroke')[0] ||
createElement(this.renderer.prepVML(['<stroke/>']), null, null, element);
strokeElem[key] = value || 'solid';
this[key] = value;
/* because changing stroke-width will change the dash length
and cause an epileptic effect */
},
dSetter: function(value, key, element) {
var i,
shadows = this.shadows;
value = value || [];
this.d = value.join && value.join(' '); // used in getter for animation
element.path = value = this.pathToVML(value);
// update shadows
if (shadows) {
i = shadows.length;
while (i--) {
shadows[i].path = shadows[i].cutOff ? this.cutOffPath(value, shadows[i].cutOff) : value;
}
}
this.setAttr(key, value);
},
fillSetter: function(value, key, element) {
var nodeName = element.nodeName;
if (nodeName === 'SPAN') { // text color
element.style.color = value;
} else if (nodeName !== 'IMG') { // #1336
element.filled = value !== 'none';
this.setAttr('fillcolor', this.renderer.color(value, element, key, this));
}
},
'fill-opacitySetter': function(value, key, element) {
createElement(
this.renderer.prepVML(['<', key.split('-')[0], ' opacity="', value, '"/>']),
null,
null,
element
);
},
opacitySetter: noop, // Don't bother - animation is too slow and filters introduce artifacts
rotationSetter: function(value, key, element) {
var style = element.style;
this[key] = style[key] = value; // style is for #1873
// Correction for the 1x1 size of the shape container. Used in gauge needles.
style.left = -Math.round(Math.sin(value * deg2rad) + 1) + 'px';
style.top = Math.round(Math.cos(value * deg2rad)) + 'px';
},
strokeSetter: function(value, key, element) {
this.setAttr('strokecolor', this.renderer.color(value, element, key, this));
},
'stroke-widthSetter': function(value, key, element) {
element.stroked = !!value; // VML "stroked" attribute
this[key] = value; // used in getter, issue #113
if (isNumber(value)) {
value += 'px';
}
this.setAttr('strokeweight', value);
},
titleSetter: function(value, key) {
this.setAttr(key, value);
},
visibilitySetter: function(value, key, element) {
// Handle inherited visibility
if (value === 'inherit') {
value = 'visible';
}
// Let the shadow follow the main element
if (this.shadows) {
each(this.shadows, function(shadow) {
shadow.style[key] = value;
});
}
// Instead of toggling the visibility CSS property, move the div out of the viewport.
// This works around #61 and #586
if (element.nodeName === 'DIV') {
value = value === 'hidden' ? '-999em' : 0;
// In order to redraw, IE7 needs the div to be visible when tucked away
// outside the viewport. So the visibility is actually opposite of
// the expected value. This applies to the tooltip only.
if (!this.docMode8) {
element.style[key] = value ? 'visible' : 'hidden';
}
key = 'top';
}
element.style[key] = value;
},
xSetter: function(value, key, element) {
this[key] = value; // used in getter
if (key === 'x') {
key = 'left';
} else if (key === 'y') {
key = 'top';
}
/* else {
value = Math.max(0, value); // don't set width or height below zero (#311)
}*/
// clipping rectangle special
if (this.updateClipping) {
this[key] = value; // the key is now 'left' or 'top' for 'x' and 'y'
this.updateClipping();
} else {
// normal
element.style[key] = value;
}
},
zIndexSetter: function(value, key, element) {
element.style[key] = value;
}
};
VMLElement['stroke-opacitySetter'] = VMLElement['fill-opacitySetter'];
H.VMLElement = VMLElement = extendClass(SVGElement, VMLElement);
// Some shared setters
VMLElement.prototype.ySetter =
VMLElement.prototype.widthSetter =
VMLElement.prototype.heightSetter =
VMLElement.prototype.xSetter;
/**
* The VML renderer
*/
VMLRendererExtension = { // inherit SVGRenderer
Element: VMLElement,
isIE8: win.navigator.userAgent.indexOf('MSIE 8.0') > -1,
/**
* Initialize the VMLRenderer
* @param {Object} container
* @param {Number} width
* @param {Number} height
*/
init: function(container, width, height) {
var renderer = this,
boxWrapper,
box,
css;
renderer.alignedObjects = [];
boxWrapper = renderer.createElement('div')
.css({
position: 'relative'
});
box = boxWrapper.element;
container.appendChild(boxWrapper.element);
// generate the containing box
renderer.isVML = true;
renderer.box = box;
renderer.boxWrapper = boxWrapper;
renderer.gradients = {};
renderer.cache = {}; // Cache for numerical bounding boxes
renderer.cacheKeys = [];
renderer.imgCount = 0;
renderer.setSize(width, height, false);
// The only way to make IE6 and IE7 print is to use a global namespace. However,
// with IE8 the only way to make the dynamic shapes visible in screen and print mode
// seems to be to add the xmlns attribute and the behaviour style inline.
if (!doc.namespaces.hcv) {
doc.namespaces.add('hcv', 'urn:schemas-microsoft-com:vml');
// Setup default CSS (#2153, #2368, #2384)
css = 'hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke' +
'{ behavior:url(#default#VML); display: inline-block; } ';
try {
doc.createStyleSheet().cssText = css;
} catch (e) {
doc.styleSheets[0].cssText += css;
}
}
},
/**
* Detect whether the renderer is hidden. This happens when one of the parent elements
* has display: none
*/
isHidden: function() {
return !this.box.offsetWidth;
},
/**
* Define a clipping rectangle. In VML it is accomplished by storing the values
* for setting the CSS style to all associated members.
*
* @param {Number} x
* @param {Number} y
* @param {Number} width
* @param {Number} height
*/
clipRect: function(x, y, width, height) {
// create a dummy element
var clipRect = this.createElement(),
isObj = isObject(x);
// mimic a rectangle with its style object for automatic updating in attr
return extend(clipRect, {
members: [],
count: 0,
left: (isObj ? x.x : x) + 1,
top: (isObj ? x.y : y) + 1,
width: (isObj ? x.width : width) - 1,
height: (isObj ? x.height : height) - 1,
getCSS: function(wrapper) {
var element = wrapper.element,
nodeName = element.nodeName,
isShape = nodeName === 'shape',
inverted = wrapper.inverted,
rect = this,
top = rect.top - (isShape ? element.offsetTop : 0),
left = rect.left,
right = left + rect.width,
bottom = top + rect.height,
ret = {
clip: 'rect(' +
Math.round(inverted ? left : top) + 'px,' +
Math.round(inverted ? bottom : right) + 'px,' +
Math.round(inverted ? right : bottom) + 'px,' +
Math.round(inverted ? top : left) + 'px)'
};
// issue 74 workaround
if (!inverted && wrapper.docMode8 && nodeName === 'DIV') {
extend(ret, {
width: right + 'px',
height: bottom + 'px'
});
}
return ret;
},
// used in attr and animation to update the clipping of all members
updateClipping: function() {
each(clipRect.members, function(member) {
// Member.element is falsy on deleted series, like in
// stock/members/series-remove demo. Should be removed
// from members, but this will do.
if (member.element) {
member.css(clipRect.getCSS(member));
}
});
}
});
},
/**
* Take a color and return it if it's a string, make it a gradient if it's a
* gradient configuration object, and apply opacity.
*
* @param {Object} color The color or config object
*/
color: function(color, elem, prop, wrapper) {
var renderer = this,
colorObject,
regexRgba = /^rgba/,
markup,
fillType,
ret = 'none';
// Check for linear or radial gradient
if (color && color.linearGradient) {
fillType = 'gradient';
} else if (color && color.radialGradient) {
fillType = 'pattern';
}
if (fillType) {
var stopColor,
stopOpacity,
gradient = color.linearGradient || color.radialGradient,
x1,
y1,
x2,
y2,
opacity1,
opacity2,
color1,
color2,
fillAttr = '',
stops = color.stops,
firstStop,
lastStop,
colors = [],
addFillNode = function() {
// Add the fill subnode. When colors attribute is used, the meanings of opacity and o:opacity2
// are reversed.
markup = ['<fill colors="' + colors.join(',') +
'" opacity="', opacity2, '" o:opacity2="',
opacity1, '" type="', fillType, '" ', fillAttr,
'focus="100%" method="any" />'
];
createElement(renderer.prepVML(markup), null, null, elem);
};
// Extend from 0 to 1
firstStop = stops[0];
lastStop = stops[stops.length - 1];
if (firstStop[0] > 0) {
stops.unshift([
0,
firstStop[1]
]);
}
if (lastStop[0] < 1) {
stops.push([
1,
lastStop[1]
]);
}
// Compute the stops
each(stops, function(stop, i) {
if (regexRgba.test(stop[1])) {
colorObject = H.color(stop[1]);
stopColor = colorObject.get('rgb');
stopOpacity = colorObject.get('a');
} else {
stopColor = stop[1];
stopOpacity = 1;
}
// Build the color attribute
colors.push((stop[0] * 100) + '% ' + stopColor);
// Only start and end opacities are allowed, so we use the first and the last
if (!i) {
opacity1 = stopOpacity;
color2 = stopColor;
} else {
opacity2 = stopOpacity;
color1 = stopColor;
}
});
// Apply the gradient to fills only.
if (prop === 'fill') {
// Handle linear gradient angle
if (fillType === 'gradient') {
x1 = gradient.x1 || gradient[0] || 0;
y1 = gradient.y1 || gradient[1] || 0;
x2 = gradient.x2 || gradient[2] || 0;
y2 = gradient.y2 || gradient[3] || 0;
fillAttr = 'angle="' + (90 - Math.atan(
(y2 - y1) / // y vector
(x2 - x1) // x vector
) * 180 / Math.PI) + '"';
addFillNode();
// Radial (circular) gradient
} else {
var r = gradient.r,
sizex = r * 2,
sizey = r * 2,
cx = gradient.cx,
cy = gradient.cy,
radialReference = elem.radialReference,
bBox,
applyRadialGradient = function() {
if (radialReference) {
bBox = wrapper.getBBox();
cx += (radialReference[0] - bBox.x) / bBox.width - 0.5;
cy += (radialReference[1] - bBox.y) / bBox.height - 0.5;
sizex *= radialReference[2] / bBox.width;
sizey *= radialReference[2] / bBox.height;
}
fillAttr = 'src="' + H.getOptions().global.VMLRadialGradientURL + '" ' +
'size="' + sizex + ',' + sizey + '" ' +
'origin="0.5,0.5" ' +
'position="' + cx + ',' + cy + '" ' +
'color2="' + color2 + '" ';
addFillNode();
};
// Apply radial gradient
if (wrapper.added) {
applyRadialGradient();
} else {
// We need to know the bounding box to get the size and position right
wrapper.onAdd = applyRadialGradient;
}
// The fill element's color attribute is broken in IE8 standards mode, so we
// need to set the parent shape's fillcolor attribute instead.
ret = color1;
}
// Gradients are not supported for VML stroke, return the first color. #722.
} else {
ret = stopColor;
}
// If the color is an rgba color, split it and add a fill node
// to hold the opacity component
} else if (regexRgba.test(color) && elem.tagName !== 'IMG') {
colorObject = H.color(color);
wrapper[prop + '-opacitySetter'](colorObject.get('a'), prop, elem);
ret = colorObject.get('rgb');
} else {
var propNodes = elem.getElementsByTagName(prop); // 'stroke' or 'fill' node
if (propNodes.length) {
propNodes[0].opacity = 1;
propNodes[0].type = 'solid';
}
ret = color;
}
return ret;
},
/**
* Take a VML string and prepare it for either IE8 or IE6/IE7.
* @param {Array} markup A string array of the VML markup to prepare
*/
prepVML: function(markup) {
var vmlStyle = 'display:inline-block;behavior:url(#default#VML);',
isIE8 = this.isIE8;
markup = markup.join('');
if (isIE8) { // add xmlns and style inline
markup = markup.replace('/>', ' xmlns="urn:schemas-microsoft-com:vml" />');
if (markup.indexOf('style="') === -1) {
markup = markup.replace('/>', ' style="' + vmlStyle + '" />');
} else {
markup = markup.replace('style="', 'style="' + vmlStyle);
}
} else { // add namespace
markup = markup.replace('<', '<hcv:');
}
return markup;
},
/**
* Create rotated and aligned text
* @param {String} str
* @param {Number} x
* @param {Number} y
*/
text: SVGRenderer.prototype.html,
/**
* Create and return a path element
* @param {Array} path
*/
path: function(path) {
var attr = {
// subpixel precision down to 0.1 (width and height = 1px)
coordsize: '10 10'
};
if (isArray(path)) {
attr.d = path;
} else if (isObject(path)) { // attributes
extend(attr, path);
}
// create the shape
return this.createElement('shape').attr(attr);
},
/**
* Create and return a circle element. In VML circles are implemented as
* shapes, which is faster than v:oval
* @param {Number} x
* @param {Number} y
* @param {Number} r
*/
circle: function(x, y, r) {
var circle = this.symbol('circle');
if (isObject(x)) {
r = x.r;
y = x.y;
x = x.x;
}
circle.isCircle = true; // Causes x and y to mean center (#1682)
circle.r = r;
return circle.attr({
x: x,
y: y
});
},
/**
* Create a group using an outer div and an inner v:group to allow rotating
* and flipping. A simple v:group would have problems with positioning
* child HTML elements and CSS clip.
*
* @param {String} name The name of the group
*/
g: function(name) {
var wrapper,
attribs;
// set the class name
if (name) {
attribs = {
'className': 'highcharts-' + name,
'class': 'highcharts-' + name
};
}
// the div to hold HTML and clipping
wrapper = this.createElement('div').attr(attribs);
return wrapper;
},
/**
* VML override to create a regular HTML image
* @param {String} src
* @param {Number} x
* @param {Number} y
* @param {Number} width
* @param {Number} height
*/
image: function(src, x, y, width, height) {
var obj = this.createElement('img')
.attr({
src: src
});
if (arguments.length > 1) {
obj.attr({
x: x,
y: y,
width: width,
height: height
});
}
return obj;
},
/**
* For rectangles, VML uses a shape for rect to overcome bugs and rotation problems
*/
createElement: function(nodeName) {
return nodeName === 'rect' ?
this.symbol(nodeName) :
SVGRenderer.prototype.createElement.call(this, nodeName);
},
/**
* In the VML renderer, each child of an inverted div (group) is inverted
* @param {Object} element
* @param {Object} parentNode
*/
invertChild: function(element, parentNode) {
var ren = this,
parentStyle = parentNode.style,
imgStyle = element.tagName === 'IMG' && element.style; // #1111
css(element, {
flip: 'x',
left: pInt(parentStyle.width) - (imgStyle ? pInt(imgStyle.top) : 1),
top: pInt(parentStyle.height) - (imgStyle ? pInt(imgStyle.left) : 1),
rotation: -90
});
// Recursively invert child elements, needed for nested composite
// shapes like box plots and error bars. #1680, #1806.
each(element.childNodes, function(child) {
ren.invertChild(child, element);
});
},
/**
* Symbol definitions that override the parent SVG renderer's symbols
*
*/
symbols: {
// VML specific arc function
arc: function(x, y, w, h, options) {
var start = options.start,
end = options.end,
radius = options.r || w || h,
innerRadius = options.innerR,
cosStart = Math.cos(start),
sinStart = Math.sin(start),
cosEnd = Math.cos(end),
sinEnd = Math.sin(end),
ret;
if (end - start === 0) { // no angle, don't show it.
return ['x'];
}
ret = [
'wa', // clockwise arc to
x - radius, // left
y - radius, // top
x + radius, // right
y + radius, // bottom
x + radius * cosStart, // start x
y + radius * sinStart, // start y
x + radius * cosEnd, // end x
y + radius * sinEnd // end y
];
if (options.open && !innerRadius) {
ret.push(
'e',
'M',
x, // - innerRadius,
y // - innerRadius
);
}
ret.push(
'at', // anti clockwise arc to
x - innerRadius, // left
y - innerRadius, // top
x + innerRadius, // right
y + innerRadius, // bottom
x + innerRadius * cosEnd, // start x
y + innerRadius * sinEnd, // start y
x + innerRadius * cosStart, // end x
y + innerRadius * sinStart, // end y
'x', // finish path
'e' // close
);
ret.isArc = true;
return ret;
},
// Add circle symbol path. This performs significantly faster than v:oval.
circle: function(x, y, w, h, wrapper) {
if (wrapper && defined(wrapper.r)) {
w = h = 2 * wrapper.r;
}
// Center correction, #1682
if (wrapper && wrapper.isCircle) {
x -= w / 2;
y -= h / 2;
}
// Return the path
return [
'wa', // clockwisearcto
x, // left
y, // top
x + w, // right
y + h, // bottom
x + w, // start x
y + h / 2, // start y
x + w, // end x
y + h / 2, // end y
//'x', // finish path
'e' // close
];
},
/**
* Add rectangle symbol path which eases rotation and omits arcsize problems
* compared to the built-in VML roundrect shape. When borders are not rounded,
* use the simpler square path, else use the callout path without the arrow.
*/
rect: function(x, y, w, h, options) {
return SVGRenderer.prototype.symbols[!defined(options) || !options.r ? 'square' : 'callout'].call(0, x, y, w, h, options);
}
}
};
H.VMLRenderer = VMLRenderer = function() {
this.init.apply(this, arguments);
};
VMLRenderer.prototype = merge(SVGRenderer.prototype, VMLRendererExtension);
// general renderer
H.Renderer = VMLRenderer;
}
// This method is used with exporting in old IE, when emulating SVG (see #2314)
SVGRenderer.prototype.measureSpanWidth = function(text, styles) {
var measuringSpan = doc.createElement('span'),
offsetWidth,
textNode = doc.createTextNode(text);
measuringSpan.appendChild(textNode);
css(measuringSpan, styles);
this.box.appendChild(measuringSpan);
offsetWidth = measuringSpan.offsetWidth;
discardElement(measuringSpan); // #2463
return offsetWidth;
};
/* ****************************************************************************
* *
* END OF INTERNET EXPLORER <= 8 SPECIFIC CODE *
* *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var color = H.color,
each = H.each,
getTZOffset = H.getTZOffset,
isTouchDevice = H.isTouchDevice,
merge = H.merge,
pick = H.pick,
svg = H.svg,
win = H.win;
/* ****************************************************************************
* Handle the options *
*****************************************************************************/
H.defaultOptions = {
colors: '#7cb5ec #434348 #90ed7d #f7a35c #8085e9 #f15c80 #e4d354 #2b908f #f45b5b #91e8e1'.split(' '),
symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
lang: {
loading: 'Loading...',
months: [
'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'
],
shortMonths: [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
],
weekdays: [
'Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday'
],
// invalidDate: '',
decimalPoint: '.',
numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'], // SI prefixes used in axis labels
resetZoom: 'Reset zoom',
resetZoomTitle: 'Reset zoom level 1:1',
thousandsSep: ' '
},
global: {
useUTC: true,
//timezoneOffset: 0,
VMLRadialGradientURL: 'http://code.highcharts.com/5.0.10/gfx/vml-radial-gradient.png'
},
chart: {
//animation: true,
//alignTicks: false,
//reflow: true,
//className: null,
//events: { load, selection },
//margin: [null],
//marginTop: null,
//marginRight: null,
//marginBottom: null,
//marginLeft: null,
borderRadius: 0,
defaultSeriesType: 'line',
ignoreHiddenSeries: true,
//inverted: false,
spacing: [10, 10, 15, 10],
//spacingTop: 10,
//spacingRight: 10,
//spacingBottom: 15,
//spacingLeft: 10,
//zoomType: ''
resetZoomButton: {
theme: {
zIndex: 20
},
position: {
align: 'right',
x: -10,
//verticalAlign: 'top',
y: 10
}
// relativeTo: 'plot'
},
width: null,
height: null,
borderColor: '#335cad',
//borderWidth: 0,
//style: {
// fontFamily: '"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif', // default font
// fontSize: '12px'
//},
backgroundColor: '#ffffff',
//plotBackgroundColor: null,
plotBorderColor: '#cccccc'
//plotBorderWidth: 0,
//plotShadow: false
},
title: {
text: 'Chart title',
align: 'center',
// floating: false,
margin: 15,
// x: 0,
// verticalAlign: 'top',
// y: null,
// style: {}, // defined inline
widthAdjust: -44
},
subtitle: {
text: '',
align: 'center',
// floating: false
// x: 0,
// verticalAlign: 'top',
// y: null,
// style: {}, // defined inline
widthAdjust: -44
},
plotOptions: {},
labels: {
//items: [],
style: {
//font: defaultFont,
position: 'absolute',
color: '#333333'
}
},
legend: {
enabled: true,
align: 'center',
//floating: false,
layout: 'horizontal',
labelFormatter: function() {
return this.name;
},
//borderWidth: 0,
borderColor: '#999999',
borderRadius: 0,
navigation: {
activeColor: '#003399',
inactiveColor: '#cccccc'
// animation: true,
// arrowSize: 12
// style: {} // text styles
},
// margin: 20,
// reversed: false,
// backgroundColor: null,
/*style: {
padding: '5px'
},*/
itemStyle: {
color: '#333333',
fontSize: '12px',
fontWeight: 'bold'
},
itemHoverStyle: {
//cursor: 'pointer', removed as of #601
color: '#000000'
},
itemHiddenStyle: {
color: '#cccccc'
},
shadow: false,
itemCheckboxStyle: {
position: 'absolute',
width: '13px', // for IE precision
height: '13px'
},
// itemWidth: undefined,
squareSymbol: true,
// symbolRadius: 0,
// symbolWidth: 16,
symbolPadding: 5,
verticalAlign: 'bottom',
// width: undefined,
x: 0,
y: 0,
title: {
//text: null,
style: {
fontWeight: 'bold'
}
}
},
loading: {
// hideDuration: 100,
// showDuration: 0,
labelStyle: {
fontWeight: 'bold',
position: 'relative',
top: '45%'
},
style: {
position: 'absolute',
backgroundColor: '#ffffff',
opacity: 0.5,
textAlign: 'center'
}
},
tooltip: {
enabled: true,
animation: svg,
//crosshairs: null,
borderRadius: 3,
dateTimeLabelFormats: {
millisecond: '%A, %b %e, %H:%M:%S.%L',
second: '%A, %b %e, %H:%M:%S',
minute: '%A, %b %e, %H:%M',
hour: '%A, %b %e, %H:%M',
day: '%A, %b %e, %Y',
week: 'Week from %A, %b %e, %Y',
month: '%B %Y',
year: '%Y'
},
footerFormat: '',
//formatter: defaultFormatter,
/* todo: em font-size when finished comparing against HC4
headerFormat: '<span style="font-size: 0.85em">{point.key}</span><br/>',
*/
padding: 8,
//shape: 'callout',
//shared: false,
snap: isTouchDevice ? 25 : 10,
backgroundColor: color('#f7f7f7').setOpacity(0.85).get(),
borderWidth: 1,
headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',
shadow: true,
style: {
color: '#333333',
cursor: 'default',
fontSize: '12px',
pointerEvents: 'none', // #1686 http://caniuse.com/#feat=pointer-events
whiteSpace: 'nowrap'
}
//xDateFormat: '%A, %b %e, %Y',
//valueDecimals: null,
//valuePrefix: '',
//valueSuffix: ''
},
credits: {
enabled: true,
href: 'http://www.highcharts.com',
position: {
align: 'right',
x: -10,
verticalAlign: 'bottom',
y: -5
},
style: {
cursor: 'pointer',
color: '#999999',
fontSize: '9px'
},
text: 'Highcharts.com'
}
};
/**
* Sets the getTimezoneOffset function. If the timezone option is set, a default
* getTimezoneOffset function with that timezone is returned. If not, the
* specified getTimezoneOffset function is returned. If neither are specified,
* undefined is returned.
* @return {function} a getTimezoneOffset function or undefined
*/
function getTimezoneOffsetOption() {
var globalOptions = H.defaultOptions.global,
moment = win.moment;
if (globalOptions.timezone) {
if (!moment) {
// getTimezoneOffset-function stays undefined because it depends on
// Moment.js
H.error(25);
} else {
return function(timestamp) {
return -moment.tz(
timestamp,
globalOptions.timezone
).utcOffset();
};
}
}
// If not timezone is set, look for the getTimezoneOffset callback
return globalOptions.useUTC && globalOptions.getTimezoneOffset;
}
/**
* Set the time methods globally based on the useUTC option. Time method can be
* either local time or UTC (default). It is called internally on initiating
* Highcharts and after running `Highcharts.setOptions`.
*
* @private
*/
function setTimeMethods() {
var globalOptions = H.defaultOptions.global,
Date,
useUTC = globalOptions.useUTC,
GET = useUTC ? 'getUTC' : 'get',
SET = useUTC ? 'setUTC' : 'set';
H.Date = Date = globalOptions.Date || win.Date; // Allow using a different Date class
Date.hcTimezoneOffset = useUTC && globalOptions.timezoneOffset;
Date.hcGetTimezoneOffset = getTimezoneOffsetOption();
Date.hcMakeTime = function(year, month, date, hours, minutes, seconds) {
var d;
if (useUTC) {
d = Date.UTC.apply(0, arguments);
d += getTZOffset(d);
} else {
d = new Date(
year,
month,
pick(date, 1),
pick(hours, 0),
pick(minutes, 0),
pick(seconds, 0)
).getTime();
}
return d;
};
each(['Minutes', 'Hours', 'Day', 'Date', 'Month', 'FullYear'], function(s) {
Date['hcGet' + s] = GET + s;
});
each(['Milliseconds', 'Seconds', 'Minutes', 'Hours', 'Date', 'Month', 'FullYear'], function(s) {
Date['hcSet' + s] = SET + s;
});
}
/**
* Merge the default options with custom options and return the new options structure
* @param {Object} options The new custom options
*/
H.setOptions = function(options) {
// Copy in the default options
H.defaultOptions = merge(true, H.defaultOptions, options);
// Apply UTC
setTimeMethods();
return H.defaultOptions;
};
/**
* Get the updated default options. Until 3.0.7, merely exposing defaultOptions for outside modules
* wasn't enough because the setOptions method created a new object.
*/
H.getOptions = function() {
return H.defaultOptions;
};
// Series defaults
H.defaultPlotOptions = H.defaultOptions.plotOptions;
// set the default time methods
setTimeMethods();
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
each = H.each,
erase = H.erase,
merge = H.merge,
pick = H.pick;
/*
* The object wrapper for plot lines and plot bands
* @param {Object} options
*/
H.PlotLineOrBand = function(axis, options) {
this.axis = axis;
if (options) {
this.options = options;
this.id = options.id;
}
};
H.PlotLineOrBand.prototype = {
/**
* Render the plot line or plot band. If it is already existing,
* move it.
*/
render: function() {
var plotLine = this,
axis = plotLine.axis,
horiz = axis.horiz,
options = plotLine.options,
optionsLabel = options.label,
label = plotLine.label,
to = options.to,
from = options.from,
value = options.value,
isBand = defined(from) && defined(to),
isLine = defined(value),
svgElem = plotLine.svgElem,
isNew = !svgElem,
path = [],
addEvent,
eventType,
color = options.color,
zIndex = pick(options.zIndex, 0),
events = options.events,
attribs = {
'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') + (options.className || '')
},
groupAttribs = {},
renderer = axis.chart.renderer,
groupName = isBand ? 'bands' : 'lines',
group,
log2lin = axis.log2lin;
// logarithmic conversion
if (axis.isLog) {
from = log2lin(from);
to = log2lin(to);
value = log2lin(value);
}
// Set the presentational attributes
if (isLine) {
attribs = {
stroke: color,
'stroke-width': options.width
};
if (options.dashStyle) {
attribs.dashstyle = options.dashStyle;
}
} else if (isBand) { // plot band
if (color) {
attribs.fill = color;
}
if (options.borderWidth) {
attribs.stroke = options.borderColor;
attribs['stroke-width'] = options.borderWidth;
}
}
// Grouping and zIndex
groupAttribs.zIndex = zIndex;
groupName += '-' + zIndex;
group = axis.plotLinesAndBandsGroups[groupName];
if (!group) {
axis.plotLinesAndBandsGroups[groupName] = group = renderer.g('plot-' + groupName)
.attr(groupAttribs).add();
}
// Create the path
if (isNew) {
plotLine.svgElem = svgElem =
renderer
.path()
.attr(attribs).add(group);
}
// Set the path or return
if (isLine) {
path = axis.getPlotLinePath(value, svgElem.strokeWidth());
} else if (isBand) { // plot band
path = axis.getPlotBandPath(from, to, options);
} else {
return;
}
// common for lines and bands
if (isNew && path && path.length) {
svgElem.attr({
d: path
});
// events
if (events) {
addEvent = function(eventType) {
svgElem.on(eventType, function(e) {
events[eventType].apply(plotLine, [e]);
});
};
for (eventType in events) {
addEvent(eventType);
}
}
} else if (svgElem) {
if (path) {
svgElem.show();
svgElem.animate({
d: path
});
} else {
svgElem.hide();
if (label) {
plotLine.label = label = label.destroy();
}
}
}
// the plot band/line label
if (optionsLabel && defined(optionsLabel.text) && path && path.length &&
axis.width > 0 && axis.height > 0 && !path.flat) {
// apply defaults
optionsLabel = merge({
align: horiz && isBand && 'center',
x: horiz ? !isBand && 4 : 10,
verticalAlign: !horiz && isBand && 'middle',
y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
rotation: horiz && !isBand && 90
}, optionsLabel);
this.renderLabel(optionsLabel, path, isBand, zIndex);
} else if (label) { // move out of sight
label.hide();
}
// chainable
return plotLine;
},
/**
* Render and align label for plot line or band.
*/
renderLabel: function(optionsLabel, path, isBand, zIndex) {
var plotLine = this,
label = plotLine.label,
renderer = plotLine.axis.chart.renderer,
attribs,
xs,
ys,
x,
y;
// add the SVG element
if (!label) {
attribs = {
align: optionsLabel.textAlign || optionsLabel.align,
rotation: optionsLabel.rotation,
'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') + '-label ' + (optionsLabel.className || '')
};
attribs.zIndex = zIndex;
plotLine.label = label = renderer.text(
optionsLabel.text,
0,
0,
optionsLabel.useHTML
)
.attr(attribs)
.add();
label.css(optionsLabel.style);
}
// get the bounding box and align the label
// #3000 changed to better handle choice between plotband or plotline
xs = [path[1], path[4], (isBand ? path[6] : path[1])];
ys = [path[2], path[5], (isBand ? path[7] : path[2])];
x = arrayMin(xs);
y = arrayMin(ys);
label.align(optionsLabel, false, {
x: x,
y: y,
width: arrayMax(xs) - x,
height: arrayMax(ys) - y
});
label.show();
},
/**
* Remove the plot line or band
*/
destroy: function() {
// remove it from the lookup
erase(this.axis.plotLinesAndBands, this);
delete this.axis;
destroyObjectProperties(this);
}
};
/**
* Object with members for extending the Axis prototype
* @todo Extend directly instead of adding object to Highcharts first
*/
H.AxisPlotLineOrBandExtension = {
/**
* Create the path for a plot band
*/
getPlotBandPath: function(from, to) {
var toPath = this.getPlotLinePath(to, null, null, true),
path = this.getPlotLinePath(from, null, null, true),
// #4964 check if chart is inverted or plotband is on yAxis
horiz = this.horiz,
plus = 1,
outside =
(from < this.min && to < this.min) ||
(from > this.max && to > this.max);
if (path && toPath) {
// Flat paths don't need labels (#3836)
if (outside) {
path.flat = path.toString() === toPath.toString();
plus = 0;
}
// Add 1 pixel, when coordinates are the same
path.push(
horiz && toPath[4] === path[4] ? toPath[4] + plus : toPath[4], !horiz && toPath[5] === path[5] ? toPath[5] + plus : toPath[5],
horiz && toPath[1] === path[1] ? toPath[1] + plus : toPath[1], !horiz && toPath[2] === path[2] ? toPath[2] + plus : toPath[2]
);
} else { // outside the axis area
path = null;
}
return path;
},
addPlotBand: function(options) {
return this.addPlotBandOrLine(options, 'plotBands');
},
addPlotLine: function(options) {
return this.addPlotBandOrLine(options, 'plotLines');
},
/**
* Add a plot band or plot line after render time
*
* @param options {Object} The plotBand or plotLine configuration object
*/
addPlotBandOrLine: function(options, coll) {
var obj = new H.PlotLineOrBand(this, options).render(),
userOptions = this.userOptions;
if (obj) { // #2189
// Add it to the user options for exporting and Axis.update
if (coll) {
userOptions[coll] = userOptions[coll] || [];
userOptions[coll].push(options);
}
this.plotLinesAndBands.push(obj);
}
return obj;
},
/**
* Remove a plot band or plot line from the chart by id
* @param {Object} id
*/
removePlotBandOrLine: function(id) {
var plotLinesAndBands = this.plotLinesAndBands,
options = this.options,
userOptions = this.userOptions,
i = plotLinesAndBands.length;
while (i--) {
if (plotLinesAndBands[i].id === id) {
plotLinesAndBands[i].destroy();
}
}
each([options.plotLines || [], userOptions.plotLines || [], options.plotBands || [], userOptions.plotBands || []], function(arr) {
i = arr.length;
while (i--) {
if (arr[i].id === id) {
erase(arr, arr[i]);
}
}
});
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var correctFloat = H.correctFloat,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
isNumber = H.isNumber,
merge = H.merge,
pick = H.pick,
deg2rad = H.deg2rad;
/**
* The Tick class
*/
H.Tick = function(axis, pos, type, noLabel) {
this.axis = axis;
this.pos = pos;
this.type = type || '';
this.isNew = true;
if (!type && !noLabel) {
this.addLabel();
}
};
H.Tick.prototype = {
/**
* Write the tick label
*/
addLabel: function() {
var tick = this,
axis = tick.axis,
options = axis.options,
chart = axis.chart,
categories = axis.categories,
names = axis.names,
pos = tick.pos,
labelOptions = options.labels,
str,
tickPositions = axis.tickPositions,
isFirst = pos === tickPositions[0],
isLast = pos === tickPositions[tickPositions.length - 1],
value = categories ?
pick(categories[pos], names[pos], pos) :
pos,
label = tick.label,
tickPositionInfo = tickPositions.info,
dateTimeLabelFormat;
// Set the datetime label format. If a higher rank is set for this position, use that. If not,
// use the general format.
if (axis.isDatetimeAxis && tickPositionInfo) {
dateTimeLabelFormat =
options.dateTimeLabelFormats[
tickPositionInfo.higherRanks[pos] || tickPositionInfo.unitName
];
}
// set properties for access in render method
tick.isFirst = isFirst;
tick.isLast = isLast;
// get the string
str = axis.labelFormatter.call({
axis: axis,
chart: chart,
isFirst: isFirst,
isLast: isLast,
dateTimeLabelFormat: dateTimeLabelFormat,
value: axis.isLog ? correctFloat(axis.lin2log(value)) : value
});
// prepare CSS
//css = width && { width: Math.max(1, Math.round(width - 2 * (labelOptions.padding || 10))) + 'px' };
// first call
if (!defined(label)) {
tick.label = label =
defined(str) && labelOptions.enabled ?
chart.renderer.text(
str,
0,
0,
labelOptions.useHTML
)
// without position absolute, IE export sometimes is wrong
.css(merge(labelOptions.style))
.add(axis.labelGroup) :
null;
tick.labelLength = label && label.getBBox().width; // Un-rotated length
tick.rotation = 0; // Base value to detect change for new calls to getBBox
// update
} else if (label) {
label.attr({
text: str
});
}
},
/**
* Get the offset height or width of the label
*/
getLabelSize: function() {
return this.label ?
this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
0;
},
/**
* Handle the label overflow by adjusting the labels to the left and right edge, or
* hide them if they collide into the neighbour label.
*/
handleOverflow: function(xy) {
var axis = this.axis,
pxPos = xy.x,
chartWidth = axis.chart.chartWidth,
spacing = axis.chart.spacing,
leftBound = pick(axis.labelLeft, Math.min(axis.pos, spacing[3])),
rightBound = pick(axis.labelRight, Math.max(axis.pos + axis.len, chartWidth - spacing[1])),
label = this.label,
rotation = this.rotation,
factor = {
left: 0,
center: 0.5,
right: 1
}[axis.labelAlign],
labelWidth = label.getBBox().width,
slotWidth = axis.getSlotWidth(),
modifiedSlotWidth = slotWidth,
xCorrection = factor,
goRight = 1,
leftPos,
rightPos,
textWidth,
css = {};
// Check if the label overshoots the chart spacing box. If it does, move it.
// If it now overshoots the slotWidth, add ellipsis.
if (!rotation) {
leftPos = pxPos - factor * labelWidth;
rightPos = pxPos + (1 - factor) * labelWidth;
if (leftPos < leftBound) {
modifiedSlotWidth = xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
} else if (rightPos > rightBound) {
modifiedSlotWidth = rightBound - xy.x + modifiedSlotWidth * factor;
goRight = -1;
}
modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
xy.x += goRight * (slotWidth - modifiedSlotWidth - xCorrection *
(slotWidth - Math.min(labelWidth, modifiedSlotWidth)));
}
// If the label width exceeds the available space, set a text width to be
// picked up below. Also, if a width has been set before, we need to set a new
// one because the reported labelWidth will be limited by the box (#3938).
if (labelWidth > modifiedSlotWidth || (axis.autoRotation && (label.styles || {}).width)) {
textWidth = modifiedSlotWidth;
}
// Add ellipsis to prevent rotated labels to be clipped against the edge of the chart
} else if (rotation < 0 && pxPos - factor * labelWidth < leftBound) {
textWidth = Math.round(pxPos / Math.cos(rotation * deg2rad) - leftBound);
} else if (rotation > 0 && pxPos + factor * labelWidth > rightBound) {
textWidth = Math.round((chartWidth - pxPos) / Math.cos(rotation * deg2rad));
}
if (textWidth) {
css.width = textWidth;
if (!(axis.options.labels.style || {}).textOverflow) {
css.textOverflow = 'ellipsis';
}
label.css(css);
}
},
/**
* Get the x and y position for ticks and labels
*/
getPosition: function(horiz, pos, tickmarkOffset, old) {
var axis = this.axis,
chart = axis.chart,
cHeight = (old && chart.oldChartHeight) || chart.chartHeight;
return {
x: horiz ?
axis.translate(pos + tickmarkOffset, null, null, old) + axis.transB : axis.left + axis.offset +
(axis.opposite ?
((old && chart.oldChartWidth) || chart.chartWidth) - axis.right - axis.left :
0
),
y: horiz ?
cHeight - axis.bottom + axis.offset - (axis.opposite ? axis.height : 0) : cHeight - axis.translate(pos + tickmarkOffset, null, null, old) - axis.transB
};
},
/**
* Get the x, y position of the tick label
*/
getLabelPosition: function(x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
var axis = this.axis,
transA = axis.transA,
reversed = axis.reversed,
staggerLines = axis.staggerLines,
rotCorr = axis.tickRotCorr || {
x: 0,
y: 0
},
yOffset = labelOptions.y,
line;
if (!defined(yOffset)) {
if (axis.side === 0) {
yOffset = label.rotation ? -8 : -label.getBBox().height;
} else if (axis.side === 2) {
yOffset = rotCorr.y + 8;
} else {
// #3140, #3140
yOffset = Math.cos(label.rotation * deg2rad) * (rotCorr.y - label.getBBox(false, 0).height / 2);
}
}
x = x + labelOptions.x + rotCorr.x - (tickmarkOffset && horiz ?
tickmarkOffset * transA * (reversed ? -1 : 1) : 0);
y = y + yOffset - (tickmarkOffset && !horiz ?
tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
// Correct for staggered labels
if (staggerLines) {
line = (index / (step || 1) % staggerLines);
if (axis.opposite) {
line = staggerLines - line - 1;
}
y += line * (axis.labelOffset / staggerLines);
}
return {
x: x,
y: Math.round(y)
};
},
/**
* Extendible method to return the path of the marker
*/
getMarkPath: function(x, y, tickLength, tickWidth, horiz, renderer) {
return renderer.crispLine([
'M',
x,
y,
'L',
x + (horiz ? 0 : -tickLength),
y + (horiz ? tickLength : 0)
], tickWidth);
},
/**
* Renders the gridLine.
* @param {Boolean} old Whether or not the tick is old
* @param {number} opacity The opacity of the grid line
* @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
* @return {undefined}
*/
renderGridLine: function(old, opacity, reverseCrisp) {
var tick = this,
axis = tick.axis,
options = axis.options,
gridLine = tick.gridLine,
gridLinePath,
attribs = {},
pos = tick.pos,
type = tick.type,
tickmarkOffset = axis.tickmarkOffset,
renderer = axis.chart.renderer;
var gridPrefix = type ? type + 'Grid' : 'grid',
gridLineWidth = options[gridPrefix + 'LineWidth'],
gridLineColor = options[gridPrefix + 'LineColor'],
dashStyle = options[gridPrefix + 'LineDashStyle'];
if (!gridLine) {
attribs.stroke = gridLineColor;
attribs['stroke-width'] = gridLineWidth;
if (dashStyle) {
attribs.dashstyle = dashStyle;
}
if (!type) {
attribs.zIndex = 1;
}
if (old) {
attribs.opacity = 0;
}
tick.gridLine = gridLine = renderer.path()
.attr(attribs)
.addClass(
'highcharts-' + (type ? type + '-' : '') + 'grid-line'
)
.add(axis.gridGroup);
}
// If the parameter 'old' is set, the current call will be followed
// by another call, therefore do not do any animations this time
if (!old && gridLine) {
gridLinePath = axis.getPlotLinePath(
pos + tickmarkOffset,
gridLine.strokeWidth() * reverseCrisp,
old, true
);
if (gridLinePath) {
gridLine[tick.isNew ? 'attr' : 'animate']({
d: gridLinePath,
opacity: opacity
});
}
}
},
/**
* Renders the tick mark.
* @param {Object} xy The position vector of the mark
* @param {number} xy.x The x position of the mark
* @param {number} xy.y The y position of the mark
* @param {number} opacity The opacity of the mark
* @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
* @return {undefined}
*/
renderMark: function(xy, opacity, reverseCrisp) {
var tick = this,
axis = tick.axis,
options = axis.options,
renderer = axis.chart.renderer,
type = tick.type,
tickPrefix = type ? type + 'Tick' : 'tick',
tickSize = axis.tickSize(tickPrefix),
mark = tick.mark,
isNewMark = !mark,
x = xy.x,
y = xy.y;
var tickWidth = pick(
options[tickPrefix + 'Width'], !type && axis.isXAxis ? 1 : 0
), // X axis defaults to 1
tickColor = options[tickPrefix + 'Color'];
if (tickSize) {
// negate the length
if (axis.opposite) {
tickSize[0] = -tickSize[0];
}
// First time, create it
if (isNewMark) {
tick.mark = mark = renderer.path()
.addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
.add(axis.axisGroup);
mark.attr({
stroke: tickColor,
'stroke-width': tickWidth
});
}
mark[isNewMark ? 'attr' : 'animate']({
d: tick.getMarkPath(
x,
y,
tickSize[0],
mark.strokeWidth() * reverseCrisp,
axis.horiz,
renderer),
opacity: opacity
});
}
},
/**
* Renders the tick label.
* Note: The label should already be created in init(), so it should only
* have to be moved into place.
* @param {Object} xy The position vector of the label
* @param {number} xy.x The x position of the label
* @param {number} xy.y The y position of the label
* @param {Boolean} old Whether or not the tick is old
* @param {number} opacity The opacity of the label
* @param {number} index The index of the tick
* @return {undefined}
*/
renderLabel: function(xy, old, opacity, index) {
var tick = this,
axis = tick.axis,
horiz = axis.horiz,
options = axis.options,
label = tick.label,
labelOptions = options.labels,
step = labelOptions.step,
tickmarkOffset = axis.tickmarkOffset,
show = true,
x = xy.x,
y = xy.y;
if (label && isNumber(x)) {
label.xy = xy = tick.getLabelPosition(
x,
y,
label,
horiz,
labelOptions,
tickmarkOffset,
index,
step
);
// Apply show first and show last. If the tick is both first and
// last, it is a single centered tick, in which case we show the
// label anyway (#2100).
if (
(
tick.isFirst &&
!tick.isLast &&
!pick(options.showFirstLabel, 1)
) ||
(
tick.isLast &&
!tick.isFirst &&
!pick(options.showLastLabel, 1)
)
) {
show = false;
// Handle label overflow and show or hide accordingly
} else if (horiz && !axis.isRadial && !labelOptions.step &&
!labelOptions.rotation && !old && opacity !== 0) {
tick.handleOverflow(xy);
}
// apply step
if (step && index % step) {
// show those indices dividable by step
show = false;
}
// Set the new position, and show or hide
if (show && isNumber(xy.y)) {
xy.opacity = opacity;
label[tick.isNew ? 'attr' : 'animate'](xy);
} else {
label.attr('y', -9999); // #1338
}
tick.isNew = false;
}
},
/**
* Put everything in place
*
* @param index {Number}
* @param old {Boolean} Use old coordinates to prepare an animation into new
* position
*/
render: function(index, old, opacity) {
var tick = this,
axis = tick.axis,
horiz = axis.horiz,
pos = tick.pos,
tickmarkOffset = axis.tickmarkOffset,
xy = tick.getPosition(horiz, pos, tickmarkOffset, old),
x = xy.x,
y = xy.y,
reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
(!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687
opacity = pick(opacity, 1);
this.isActive = true;
// Create the grid line
this.renderGridLine(old, opacity, reverseCrisp);
// create the tick mark
this.renderMark(xy, opacity, reverseCrisp);
// the label is created on init - now move it into place
this.renderLabel(xy, old, opacity, index);
},
/**
* Destructor for the tick prototype
*/
destroy: function() {
destroyObjectProperties(this, this.axis);
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animObject = H.animObject,
arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
AxisPlotLineOrBandExtension = H.AxisPlotLineOrBandExtension,
color = H.color,
correctFloat = H.correctFloat,
defaultOptions = H.defaultOptions,
defined = H.defined,
deg2rad = H.deg2rad,
destroyObjectProperties = H.destroyObjectProperties,
each = H.each,
extend = H.extend,
fireEvent = H.fireEvent,
format = H.format,
getMagnitude = H.getMagnitude,
grep = H.grep,
inArray = H.inArray,
isArray = H.isArray,
isNumber = H.isNumber,
isString = H.isString,
merge = H.merge,
normalizeTickInterval = H.normalizeTickInterval,
pick = H.pick,
PlotLineOrBand = H.PlotLineOrBand,
removeEvent = H.removeEvent,
splat = H.splat,
syncTimeout = H.syncTimeout,
Tick = H.Tick;
/**
* Create a new axis object.
* @constructor Axis
* @param {Object} chart
* @param {Object} options
*/
H.Axis = function() {
this.init.apply(this, arguments);
};
H.Axis.prototype = {
/**
* Default options for the X axis - the Y axis has extended defaults
*/
defaultOptions: {
// allowDecimals: null,
// alternateGridColor: null,
// categories: [],
dateTimeLabelFormats: {
millisecond: '%H:%M:%S.%L',
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%e. %b',
week: '%e. %b',
month: '%b \'%y',
year: '%Y'
},
endOnTick: false,
// reversed: false,
labels: {
enabled: true,
// rotation: 0,
// align: 'center',
// step: null,
style: {
color: '#666666',
cursor: 'default',
fontSize: '11px'
},
x: 0
//y: undefined
/*formatter: function () {
return this.value;
},*/
},
//linkedTo: null,
//max: undefined,
//min: undefined,
minPadding: 0.01,
maxPadding: 0.01,
//minRange: null,
//minorTickInterval: null,
minorTickLength: 2,
minorTickPosition: 'outside', // inside or outside
//opposite: false,
//offset: 0,
//plotBands: [{
// events: {},
// zIndex: 1,
// labels: { align, x, verticalAlign, y, style, rotation, textAlign }
//}],
//plotLines: [{
// events: {}
// dashStyle: {}
// zIndex:
// labels: { align, x, verticalAlign, y, style, rotation, textAlign }
//}],
//reversed: false,
// showFirstLabel: true,
// showLastLabel: true,
startOfWeek: 1,
startOnTick: false,
//tickInterval: null,
tickLength: 10,
tickmarkPlacement: 'between', // on or between
tickPixelInterval: 100,
tickPosition: 'outside',
title: {
//text: null,
align: 'middle', // low, middle or high
//margin: 0 for horizontal, 10 for vertical axes,
//rotation: 0,
//side: 'outside',
style: {
color: '#666666'
}
//x: 0,
//y: 0
},
type: 'linear', // linear, logarithmic or datetime
//visible: true
minorGridLineColor: '#f2f2f2',
// minorGridLineDashStyle: null,
minorGridLineWidth: 1,
minorTickColor: '#999999',
//minorTickWidth: 0,
lineColor: '#ccd6eb',
lineWidth: 1,
gridLineColor: '#e6e6e6',
// gridLineDashStyle: 'solid',
// gridLineWidth: 0,
tickColor: '#ccd6eb'
// tickWidth: 1
},
/**
* This options set extends the defaultOptions for Y axes
*/
defaultYAxisOptions: {
endOnTick: true,
tickPixelInterval: 72,
showLastLabel: true,
labels: {
x: -8
},
maxPadding: 0.05,
minPadding: 0.05,
startOnTick: true,
title: {
rotation: 270,
text: 'Values'
},
stackLabels: {
enabled: false,
//align: dynamic,
//y: dynamic,
//x: dynamic,
//verticalAlign: dynamic,
//textAlign: dynamic,
//rotation: 0,
formatter: function() {
return H.numberFormat(this.total, -1);
},
style: {
fontSize: '11px',
fontWeight: 'bold',
color: '#000000',
textOutline: '1px contrast'
}
},
gridLineWidth: 1,
lineWidth: 0
// tickWidth: 0
},
/**
* These options extend the defaultOptions for left axes
*/
defaultLeftAxisOptions: {
labels: {
x: -15
},
title: {
rotation: 270
}
},
/**
* These options extend the defaultOptions for right axes
*/
defaultRightAxisOptions: {
labels: {
x: 15
},
title: {
rotation: 90
}
},
/**
* These options extend the defaultOptions for bottom axes
*/
defaultBottomAxisOptions: {
labels: {
autoRotation: [-45],
x: 0
// overflow: undefined,
// staggerLines: null
},
title: {
rotation: 0
}
},
/**
* These options extend the defaultOptions for top axes
*/
defaultTopAxisOptions: {
labels: {
autoRotation: [-45],
x: 0
// overflow: undefined
// staggerLines: null
},
title: {
rotation: 0
}
},
/**
* Initialize the axis
*/
init: function(chart, userOptions) {
var isXAxis = userOptions.isX,
axis = this;
axis.chart = chart;
// Flag, is the axis horizontal
axis.horiz = chart.inverted ? !isXAxis : isXAxis;
// Flag, isXAxis
axis.isXAxis = isXAxis;
axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
axis.opposite = userOptions.opposite; // needed in setOptions
axis.side = userOptions.side || (axis.horiz ?
(axis.opposite ? 0 : 2) : // top : bottom
(axis.opposite ? 1 : 3)); // right : left
axis.setOptions(userOptions);
var options = this.options,
type = options.type,
isDatetimeAxis = type === 'datetime';
axis.labelFormatter = options.labels.formatter || axis.defaultLabelFormatter; // can be overwritten by dynamic format
// Flag, stagger lines or not
axis.userOptions = userOptions;
//axis.axisTitleMargin = undefined,// = options.title.margin,
axis.minPixelPadding = 0;
axis.reversed = options.reversed;
axis.visible = options.visible !== false;
axis.zoomEnabled = options.zoomEnabled !== false;
// Initial categories
axis.hasNames = type === 'category' || options.categories === true;
axis.categories = options.categories || axis.hasNames;
axis.names = axis.names || []; // Preserve on update (#3830)
// Elements
//axis.axisGroup = undefined;
//axis.gridGroup = undefined;
//axis.axisTitle = undefined;
//axis.axisLine = undefined;
// Placeholder for plotlines and plotbands groups
axis.plotLinesAndBandsGroups = {};
// Shorthand types
axis.isLog = type === 'logarithmic';
axis.isDatetimeAxis = isDatetimeAxis;
axis.positiveValuesOnly = axis.isLog && !axis.allowNegativeLog;
// Flag, if axis is linked to another axis
axis.isLinked = defined(options.linkedTo);
// Linked axis.
//axis.linkedParent = undefined;
// Tick positions
//axis.tickPositions = undefined; // array containing predefined positions
// Tick intervals
//axis.tickInterval = undefined;
//axis.minorTickInterval = undefined;
// Major ticks
axis.ticks = {};
axis.labelEdge = [];
// Minor ticks
axis.minorTicks = {};
// List of plotLines/Bands
axis.plotLinesAndBands = [];
// Alternate bands
axis.alternateBands = {};
// Axis metrics
//axis.left = undefined;
//axis.top = undefined;
//axis.width = undefined;
//axis.height = undefined;
//axis.bottom = undefined;
//axis.right = undefined;
//axis.transA = undefined;
//axis.transB = undefined;
//axis.oldTransA = undefined;
axis.len = 0;
//axis.oldMin = undefined;
//axis.oldMax = undefined;
//axis.oldUserMin = undefined;
//axis.oldUserMax = undefined;
//axis.oldAxisLength = undefined;
axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
axis.range = options.range;
axis.offset = options.offset || 0;
// Dictionary for stacks
axis.stacks = {};
axis.oldStacks = {};
axis.stacksTouched = 0;
// Min and max in the data
//axis.dataMin = undefined,
//axis.dataMax = undefined,
// The axis range
axis.max = null;
axis.min = null;
// User set min and max
//axis.userMin = undefined,
//axis.userMax = undefined,
// Crosshair options
axis.crosshair = pick(options.crosshair, splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1], false);
// Run Axis
var eventType,
events = axis.options.events;
// Register
if (inArray(axis, chart.axes) === -1) { // don't add it again on Axis.update()
if (isXAxis) { // #2713
chart.axes.splice(chart.xAxis.length, 0, axis);
} else {
chart.axes.push(axis);
}
chart[axis.coll].push(axis);
}
axis.series = axis.series || []; // populated by Series
// inverted charts have reversed xAxes as default
if (chart.inverted && isXAxis && axis.reversed === undefined) {
axis.reversed = true;
}
axis.removePlotBand = axis.removePlotBandOrLine;
axis.removePlotLine = axis.removePlotBandOrLine;
// register event listeners
for (eventType in events) {
addEvent(axis, eventType, events[eventType]);
}
// extend logarithmic axis
axis.lin2log = options.linearToLogConverter || axis.lin2log;
if (axis.isLog) {
axis.val2lin = axis.log2lin;
axis.lin2val = axis.lin2log;
}
},
/**
* Merge and set options
*/
setOptions: function(userOptions) {
this.options = merge(
this.defaultOptions,
this.coll === 'yAxis' && this.defaultYAxisOptions, [this.defaultTopAxisOptions, this.defaultRightAxisOptions,
this.defaultBottomAxisOptions, this.defaultLeftAxisOptions
][this.side],
merge(
defaultOptions[this.coll], // if set in setOptions (#1053)
userOptions
)
);
},
/**
* The default label formatter. The context is a special config object for the label.
*/
defaultLabelFormatter: function() {
var axis = this.axis,
value = this.value,
categories = axis.categories,
dateTimeLabelFormat = this.dateTimeLabelFormat,
lang = defaultOptions.lang,
numericSymbols = lang.numericSymbols,
numSymMagnitude = lang.numericSymbolMagnitude || 1000,
i = numericSymbols && numericSymbols.length,
multi,
ret,
formatOption = axis.options.labels.format,
// make sure the same symbol is added for all labels on a linear axis
numericSymbolDetector = axis.isLog ? Math.abs(value) : axis.tickInterval;
if (formatOption) {
ret = format(formatOption, this);
} else if (categories) {
ret = value;
} else if (dateTimeLabelFormat) { // datetime axis
ret = H.dateFormat(dateTimeLabelFormat, value);
} else if (i && numericSymbolDetector >= 1000) {
// Decide whether we should add a numeric symbol like k (thousands) or M (millions).
// If we are to enable this in tooltip or other places as well, we can move this
// logic to the numberFormatter and enable it by a parameter.
while (i-- && ret === undefined) {
multi = Math.pow(numSymMagnitude, i + 1);
if (numericSymbolDetector >= multi && (value * 10) % multi === 0 && numericSymbols[i] !== null && value !== 0) { // #5480
ret = H.numberFormat(value / multi, -1) + numericSymbols[i];
}
}
}
if (ret === undefined) {
if (Math.abs(value) >= 10000) { // add thousands separators
ret = H.numberFormat(value, -1);
} else { // small numbers
ret = H.numberFormat(value, -1, undefined, ''); // #2466
}
}
return ret;
},
/**
* Get the minimum and maximum for the series of each axis
*/
getSeriesExtremes: function() {
var axis = this,
chart = axis.chart;
axis.hasVisibleSeries = false;
// Reset properties in case we're redrawing (#3353)
axis.dataMin = axis.dataMax = axis.threshold = null;
axis.softThreshold = !axis.isXAxis;
if (axis.buildStacks) {
axis.buildStacks();
}
// loop through this axis' series
each(axis.series, function(series) {
if (series.visible || !chart.options.chart.ignoreHiddenSeries) {
var seriesOptions = series.options,
xData,
threshold = seriesOptions.threshold,
seriesDataMin,
seriesDataMax;
axis.hasVisibleSeries = true;
// Validate threshold in logarithmic axes
if (axis.positiveValuesOnly && threshold <= 0) {
threshold = null;
}
// Get dataMin and dataMax for X axes
if (axis.isXAxis) {
xData = series.xData;
if (xData.length) {
// If xData contains values which is not numbers, then filter them out.
// To prevent performance hit, we only do this after we have already
// found seriesDataMin because in most cases all data is valid. #5234.
seriesDataMin = arrayMin(xData);
if (!isNumber(seriesDataMin) && !(seriesDataMin instanceof Date)) { // Date for #5010
xData = grep(xData, function(x) {
return isNumber(x);
});
seriesDataMin = arrayMin(xData); // Do it again with valid data
}
axis.dataMin = Math.min(pick(axis.dataMin, xData[0]), seriesDataMin);
axis.dataMax = Math.max(pick(axis.dataMax, xData[0]), arrayMax(xData));
}
// Get dataMin and dataMax for Y axes, as well as handle stacking and processed data
} else {
// Get this particular series extremes
series.getExtremes();
seriesDataMax = series.dataMax;
seriesDataMin = series.dataMin;
// Get the dataMin and dataMax so far. If percentage is used, the min and max are
// always 0 and 100. If seriesDataMin and seriesDataMax is null, then series
// doesn't have active y data, we continue with nulls
if (defined(seriesDataMin) && defined(seriesDataMax)) {
axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
}
// Adjust to threshold
if (defined(threshold)) {
axis.threshold = threshold;
}
// If any series has a hard threshold, it takes precedence
if (!seriesOptions.softThreshold || axis.positiveValuesOnly) {
axis.softThreshold = false;
}
}
}
});
},
/**
* Translate from axis value to pixel position on the chart, or back
*
*/
translate: function(val, backwards, cvsCoord, old, handleLog, pointPlacement) {
var axis = this.linkedParent || this, // #1417
sign = 1,
cvsOffset = 0,
localA = old ? axis.oldTransA : axis.transA,
localMin = old ? axis.oldMin : axis.min,
returnValue,
minPixelPadding = axis.minPixelPadding,
doPostTranslate = (axis.isOrdinal || axis.isBroken || (axis.isLog && handleLog)) && axis.lin2val;
if (!localA) {
localA = axis.transA;
}
// In vertical axes, the canvas coordinates start from 0 at the top like in
// SVG.
if (cvsCoord) {
sign *= -1; // canvas coordinates inverts the value
cvsOffset = axis.len;
}
// Handle reversed axis
if (axis.reversed) {
sign *= -1;
cvsOffset -= sign * (axis.sector || axis.len);
}
// From pixels to value
if (backwards) { // reverse translation
val = val * sign + cvsOffset;
val -= minPixelPadding;
returnValue = val / localA + localMin; // from chart pixel to value
if (doPostTranslate) { // log and ordinal axes
returnValue = axis.lin2val(returnValue);
}
// From value to pixels
} else {
if (doPostTranslate) { // log and ordinal axes
val = axis.val2lin(val);
}
returnValue = sign * (val - localMin) * localA + cvsOffset +
(sign * minPixelPadding) +
(isNumber(pointPlacement) ? localA * pointPlacement : 0);
}
return returnValue;
},
/**
* Utility method to translate an axis value to pixel position.
* @param {Number} value A value in terms of axis units
* @param {Boolean} paneCoordinates Whether to return the pixel coordinate relative to the chart
* or just the axis/pane itself.
*/
toPixels: function(value, paneCoordinates) {
return this.translate(value, false, !this.horiz, null, true) + (paneCoordinates ? 0 : this.pos);
},
/**
* Utility method to translate a pixel position in to an axis value.
* @param {Number} pixel The pixel value coordinate
* @param {Boolean} paneCoordiantes Whether the input pixel is relative to the chart or just the
* axis/pane itself.
*/
toValue: function(pixel, paneCoordinates) {
return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
},
/**
* Create the path for a plot line that goes from the given value on
* this axis, across the plot to the opposite side
* @param {Number} value
* @param {Number} lineWidth Used for calculation crisp line
* @param {Number] old Use old coordinates (for resizing and rescaling)
*/
getPlotLinePath: function(value, lineWidth, old, force, translatedValue) {
var axis = this,
chart = axis.chart,
axisLeft = axis.left,
axisTop = axis.top,
x1,
y1,
x2,
y2,
cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
cWidth = (old && chart.oldChartWidth) || chart.chartWidth,
skip,
transB = axis.transB,
/**
* Check if x is between a and b. If not, either move to a/b or skip,
* depending on the force parameter.
*/
between = function(x, a, b) {
if (x < a || x > b) {
if (force) {
x = Math.min(Math.max(a, x), b);
} else {
skip = true;
}
}
return x;
};
translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
x1 = x2 = Math.round(translatedValue + transB);
y1 = y2 = Math.round(cHeight - translatedValue - transB);
if (!isNumber(translatedValue)) { // no min or max
skip = true;
} else if (axis.horiz) {
y1 = axisTop;
y2 = cHeight - axis.bottom;
x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
} else {
x1 = axisLeft;
x2 = cWidth - axis.right;
y1 = y2 = between(y1, axisTop, axisTop + axis.height);
}
return skip && !force ?
null :
chart.renderer.crispLine(['M', x1, y1, 'L', x2, y2], lineWidth || 1);
},
/**
* Set the tick positions of a linear axis to round values like whole tens or every five.
*/
getLinearTickPositions: function(tickInterval, min, max) {
var pos,
lastPos,
roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval),
roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval),
tickPositions = [];
// For single points, add a tick regardless of the relative position
// (#2662, #6274)
if (this.single) {
return [min];
}
// Populate the intermediate values
pos = roundedMin;
while (pos <= roundedMax) {
// Place the tick on the rounded value
tickPositions.push(pos);
// Always add the raw tickInterval, not the corrected one.
pos = correctFloat(pos + tickInterval);
// If the interval is not big enough in the current min - max range to actually increase
// the loop variable, we need to break out to prevent endless loop. Issue #619
if (pos === lastPos) {
break;
}
// Record the last value
lastPos = pos;
}
return tickPositions;
},
/**
* Return the minor tick positions. For logarithmic axes, reuse the same logic
* as for major ticks.
*/
getMinorTickPositions: function() {
var axis = this,
options = axis.options,
tickPositions = axis.tickPositions,
minorTickInterval = axis.minorTickInterval,
minorTickPositions = [],
pos,
pointRangePadding = axis.pointRangePadding || 0,
min = axis.min - pointRangePadding, // #1498
max = axis.max + pointRangePadding, // #1498
range = max - min;
// If minor ticks get too dense, they are hard to read, and may cause long running script. So we don't draw them.
if (range && range / minorTickInterval < axis.len / 3) { // #3875
if (axis.isLog) {
// For each interval in the major ticks, compute the minor ticks
// separately.
each(this.paddedTicks, function(pos, i, paddedTicks) {
if (i) {
minorTickPositions.push.apply(
minorTickPositions,
axis.getLogTickPositions(
minorTickInterval,
paddedTicks[i - 1],
paddedTicks[i],
true
)
);
}
});
} else if (axis.isDatetimeAxis && options.minorTickInterval === 'auto') { // #1314
minorTickPositions = minorTickPositions.concat(
axis.getTimeTicks(
axis.normalizeTimeTickInterval(minorTickInterval),
min,
max,
options.startOfWeek
)
);
} else {
for (
pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval
) {
// Very, very, tight grid lines (#5771)
if (pos === minorTickPositions[0]) {
break;
}
minorTickPositions.push(pos);
}
}
}
if (minorTickPositions.length !== 0) {
axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
}
return minorTickPositions;
},
/**
* Adjust the min and max for the minimum range. Keep in mind that the series data is
* not yet processed, so we don't have information on data cropping and grouping, or
* updated axis.pointRange or series.pointRange. The data can't be processed until
* we have finally established min and max.
*/
adjustForMinRange: function() {
var axis = this,
options = axis.options,
min = axis.min,
max = axis.max,
zoomOffset,
spaceAvailable = axis.dataMax - axis.dataMin >= axis.minRange,
closestDataRange,
i,
distance,
xData,
loopLength,
minArgs,
maxArgs,
minRange;
// Set the automatic minimum range based on the closest point distance
if (axis.isXAxis && axis.minRange === undefined && !axis.isLog) {
if (defined(options.min) || defined(options.max)) {
axis.minRange = null; // don't do this again
} else {
// Find the closest distance between raw data points, as opposed to
// closestPointRange that applies to processed points (cropped and grouped)
each(axis.series, function(series) {
xData = series.xData;
loopLength = series.xIncrement ? 1 : xData.length - 1;
for (i = loopLength; i > 0; i--) {
distance = xData[i] - xData[i - 1];
if (closestDataRange === undefined || distance < closestDataRange) {
closestDataRange = distance;
}
}
});
axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
}
}
// if minRange is exceeded, adjust
if (max - min < axis.minRange) {
minRange = axis.minRange;
zoomOffset = (minRange - max + min) / 2;
// if min and max options have been set, don't go beyond it
minArgs = [min - zoomOffset, pick(options.min, min - zoomOffset)];
if (spaceAvailable) { // if space is available, stay within the data range
minArgs[2] = axis.isLog ? axis.log2lin(axis.dataMin) : axis.dataMin;
}
min = arrayMax(minArgs);
maxArgs = [min + minRange, pick(options.max, min + minRange)];
if (spaceAvailable) { // if space is availabe, stay within the data range
maxArgs[2] = axis.isLog ? axis.log2lin(axis.dataMax) : axis.dataMax;
}
max = arrayMin(maxArgs);
// now if the max is adjusted, adjust the min back
if (max - min < minRange) {
minArgs[0] = max - minRange;
minArgs[1] = pick(options.min, max - minRange);
min = arrayMax(minArgs);
}
}
// Record modified extremes
axis.min = min;
axis.max = max;
},
/**
* Find the closestPointRange across all series
*/
getClosest: function() {
var ret;
if (this.categories) {
ret = 1;
} else {
each(this.series, function(series) {
var seriesClosest = series.closestPointRange,
visible = series.visible ||
!series.chart.options.chart.ignoreHiddenSeries;
if (!series.noSharedTooltip &&
defined(seriesClosest) &&
visible
) {
ret = defined(ret) ?
Math.min(ret, seriesClosest) :
seriesClosest;
}
});
}
return ret;
},
/**
* When a point name is given and no x, search for the name in the existing categories,
* or if categories aren't provided, search names or create a new category (#2522).
*/
nameToX: function(point) {
var explicitCategories = isArray(this.categories),
names = explicitCategories ? this.categories : this.names,
nameX = point.options.x,
x;
point.series.requireSorting = false;
if (!defined(nameX)) {
nameX = this.options.uniqueNames === false ?
point.series.autoIncrement() :
inArray(point.name, names);
}
if (nameX === -1) { // The name is not found in currenct categories
if (!explicitCategories) {
x = names.length;
}
} else {
x = nameX;
}
// Write the last point's name to the names array
if (x !== undefined) {
this.names[x] = point.name;
}
return x;
},
/**
* When changes have been done to series data, update the axis.names.
*/
updateNames: function() {
var axis = this;
if (this.names.length > 0) {
this.names.length = 0;
this.minRange = undefined;
each(this.series || [], function(series) {
// Reset incrementer (#5928)
series.xIncrement = null;
// When adding a series, points are not yet generated
if (!series.points || series.isDirtyData) {
series.processData();
series.generatePoints();
}
each(series.points, function(point, i) {
var x;
if (point.options) {
x = axis.nameToX(point);
if (x !== undefined && x !== point.x) {
point.x = x;
series.xData[i] = x;
}
}
});
});
}
},
/**
* Update translation information
*/
setAxisTranslation: function(saveOld) {
var axis = this,
range = axis.max - axis.min,
pointRange = axis.axisPointRange || 0,
closestPointRange,
minPointOffset = 0,
pointRangePadding = 0,
linkedParent = axis.linkedParent,
ordinalCorrection,
hasCategories = !!axis.categories,
transA = axis.transA,
isXAxis = axis.isXAxis;
// Adjust translation for padding. Y axis with categories need to go through the same (#1784).
if (isXAxis || hasCategories || pointRange) {
// Get the closest points
closestPointRange = axis.getClosest();
if (linkedParent) {
minPointOffset = linkedParent.minPointOffset;
pointRangePadding = linkedParent.pointRangePadding;
} else {
each(axis.series, function(series) {
var seriesPointRange = hasCategories ?
1 :
(isXAxis ?
pick(series.options.pointRange, closestPointRange, 0) :
(axis.axisPointRange || 0)), // #2806
pointPlacement = series.options.pointPlacement;
pointRange = Math.max(pointRange, seriesPointRange);
if (!axis.single) {
// minPointOffset is the value padding to the left of the axis in order to make
// room for points with a pointRange, typically columns. When the pointPlacement option
// is 'between' or 'on', this padding does not apply.
minPointOffset = Math.max(
minPointOffset,
isString(pointPlacement) ? 0 : seriesPointRange / 2
);
// Determine the total padding needed to the length of the axis to make room for the
// pointRange. If the series' pointPlacement is 'on', no padding is added.
pointRangePadding = Math.max(
pointRangePadding,
pointPlacement === 'on' ? 0 : seriesPointRange
);
}
});
}
// Record minPointOffset and pointRangePadding
ordinalCorrection = axis.ordinalSlope && closestPointRange ? axis.ordinalSlope / closestPointRange : 1; // #988, #1853
axis.minPointOffset = minPointOffset = minPointOffset * ordinalCorrection;
axis.pointRangePadding = pointRangePadding = pointRangePadding * ordinalCorrection;
// pointRange means the width reserved for each point, like in a column chart
axis.pointRange = Math.min(pointRange, range);
// closestPointRange means the closest distance between points. In columns
// it is mostly equal to pointRange, but in lines pointRange is 0 while closestPointRange
// is some other value
if (isXAxis) {
axis.closestPointRange = closestPointRange;
}
}
// Secondary values
if (saveOld) {
axis.oldTransA = transA;
}
axis.translationSlope = axis.transA = transA =
axis.options.staticScale ||
axis.len / ((range + pointRangePadding) || 1);
axis.transB = axis.horiz ? axis.left : axis.bottom; // translation addend
axis.minPixelPadding = transA * minPointOffset;
},
minFromRange: function() {
return this.max - this.range;
},
/**
* Set the tick positions to round values and optionally extend the extremes
* to the nearest tick
*/
setTickInterval: function(secondPass) {
var axis = this,
chart = axis.chart,
options = axis.options,
isLog = axis.isLog,
log2lin = axis.log2lin,
isDatetimeAxis = axis.isDatetimeAxis,
isXAxis = axis.isXAxis,
isLinked = axis.isLinked,
maxPadding = options.maxPadding,
minPadding = options.minPadding,
length,
linkedParentExtremes,
tickIntervalOption = options.tickInterval,
minTickInterval,
tickPixelIntervalOption = options.tickPixelInterval,
categories = axis.categories,
threshold = axis.threshold,
softThreshold = axis.softThreshold,
thresholdMin,
thresholdMax,
hardMin,
hardMax;
if (!isDatetimeAxis && !categories && !isLinked) {
this.getTickAmount();
}
// Min or max set either by zooming/setExtremes or initial options
hardMin = pick(axis.userMin, options.min);
hardMax = pick(axis.userMax, options.max);
// Linked axis gets the extremes from the parent axis
if (isLinked) {
axis.linkedParent = chart[axis.coll][options.linkedTo];
linkedParentExtremes = axis.linkedParent.getExtremes();
axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
if (options.type !== axis.linkedParent.options.type) {
H.error(11, 1); // Can't link axes of different type
}
// Initial min and max from the extreme data values
} else {
// Adjust to hard threshold
if (!softThreshold && defined(threshold)) {
if (axis.dataMin >= threshold) {
thresholdMin = threshold;
minPadding = 0;
} else if (axis.dataMax <= threshold) {
thresholdMax = threshold;
maxPadding = 0;
}
}
axis.min = pick(hardMin, thresholdMin, axis.dataMin);
axis.max = pick(hardMax, thresholdMax, axis.dataMax);
}
if (isLog) {
if (
axis.positiveValuesOnly &&
!secondPass &&
Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0
) { // #978
H.error(10, 1); // Can't plot negative values on log axis
}
// The correctFloat cures #934, float errors on full tens. But it
// was too aggressive for #4360 because of conversion back to lin,
// therefore use precision 15.
axis.min = correctFloat(log2lin(axis.min), 15);
axis.max = correctFloat(log2lin(axis.max), 15);
}
// handle zoomed range
if (axis.range && defined(axis.max)) {
axis.userMin = axis.min = hardMin = Math.max(axis.min, axis.minFromRange()); // #618
axis.userMax = hardMax = axis.max;
axis.range = null; // don't use it when running setExtremes
}
// Hook for Highstock Scroller. Consider combining with beforePadding.
fireEvent(axis, 'foundExtremes');
// Hook for adjusting this.min and this.max. Used by bubble series.
if (axis.beforePadding) {
axis.beforePadding();
}
// adjust min and max for the minimum range
axis.adjustForMinRange();
// Pad the values to get clear of the chart's edges. To avoid tickInterval taking the padding
// into account, we do this after computing tick interval (#1337).
if (!categories && !axis.axisPointRange && !axis.usePercentage && !isLinked && defined(axis.min) && defined(axis.max)) {
length = axis.max - axis.min;
if (length) {
if (!defined(hardMin) && minPadding) {
axis.min -= length * minPadding;
}
if (!defined(hardMax) && maxPadding) {
axis.max += length * maxPadding;
}
}
}
// Handle options for floor, ceiling, softMin and softMax (#6359)
if (isNumber(options.softMin)) {
axis.min = Math.min(axis.min, options.softMin);
}
if (isNumber(options.softMax)) {
axis.max = Math.max(axis.max, options.softMax);
}
if (isNumber(options.floor)) {
axis.min = Math.max(axis.min, options.floor);
}
if (isNumber(options.ceiling)) {
axis.max = Math.min(axis.max, options.ceiling);
}
// When the threshold is soft, adjust the extreme value only if
// the data extreme and the padded extreme land on either side of the threshold. For example,
// a series of [0, 1, 2, 3] would make the yAxis add a tick for -1 because of the
// default minPadding and startOnTick options. This is prevented by the softThreshold
// option.
if (softThreshold && defined(axis.dataMin)) {
threshold = threshold || 0;
if (!defined(hardMin) && axis.min < threshold && axis.dataMin >= threshold) {
axis.min = threshold;
} else if (!defined(hardMax) && axis.max > threshold && axis.dataMax <= threshold) {
axis.max = threshold;
}
}
// get tickInterval
if (axis.min === axis.max || axis.min === undefined || axis.max === undefined) {
axis.tickInterval = 1;
} else if (isLinked && !tickIntervalOption &&
tickPixelIntervalOption === axis.linkedParent.options.tickPixelInterval) {
axis.tickInterval = tickIntervalOption = axis.linkedParent.tickInterval;
} else {
axis.tickInterval = pick(
tickIntervalOption,
this.tickAmount ? ((axis.max - axis.min) / Math.max(this.tickAmount - 1, 1)) : undefined,
categories ? // for categoried axis, 1 is default, for linear axis use tickPix
1 :
// don't let it be more than the data range
(axis.max - axis.min) * tickPixelIntervalOption / Math.max(axis.len, tickPixelIntervalOption)
);
}
// Now we're finished detecting min and max, crop and group series data. This
// is in turn needed in order to find tick positions in ordinal axes.
if (isXAxis && !secondPass) {
each(axis.series, function(series) {
series.processData(axis.min !== axis.oldMin || axis.max !== axis.oldMax);
});
}
// set the translation factor used in translate function
axis.setAxisTranslation(true);
// hook for ordinal axes and radial axes
if (axis.beforeSetTickPositions) {
axis.beforeSetTickPositions();
}
// hook for extensions, used in Highstock ordinal axes
if (axis.postProcessTickInterval) {
axis.tickInterval = axis.postProcessTickInterval(axis.tickInterval);
}
// In column-like charts, don't cramp in more ticks than there are points (#1943, #4184)
if (axis.pointRange && !tickIntervalOption) {
axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
}
// Before normalizing the tick interval, handle minimum tick interval. This applies only if tickInterval is not defined.
minTickInterval = pick(options.minTickInterval, axis.isDatetimeAxis && axis.closestPointRange);
if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
axis.tickInterval = minTickInterval;
}
// for linear axes, get magnitude and normalize the interval
if (!isDatetimeAxis && !isLog && !tickIntervalOption) {
axis.tickInterval = normalizeTickInterval(
axis.tickInterval,
null,
getMagnitude(axis.tickInterval),
// If the tick interval is between 0.5 and 5 and the axis max is in the order of
// thousands, chances are we are dealing with years. Don't allow decimals. #3363.
pick(options.allowDecimals, !(axis.tickInterval > 0.5 && axis.tickInterval < 5 && axis.max > 1000 && axis.max < 9999)), !!this.tickAmount
);
}
// Prevent ticks from getting so close that we can't draw the labels
if (!this.tickAmount) {
axis.tickInterval = axis.unsquish();
}
this.setTickPositions();
},
/**
* Now we have computed the normalized tickInterval, get the tick positions
*/
setTickPositions: function() {
var options = this.options,
tickPositions,
tickPositionsOption = options.tickPositions,
tickPositioner = options.tickPositioner,
startOnTick = options.startOnTick,
endOnTick = options.endOnTick;
// Set the tickmarkOffset
this.tickmarkOffset = (this.categories && options.tickmarkPlacement === 'between' &&
this.tickInterval === 1) ? 0.5 : 0; // #3202
// get minorTickInterval
this.minorTickInterval = options.minorTickInterval === 'auto' && this.tickInterval ?
this.tickInterval / 5 : options.minorTickInterval;
// When there is only one point, or all points have the same value on
// this axis, then min and max are equal and tickPositions.length is 0
// or 1. In this case, add some padding in order to center the point,
// but leave it with one tick. #1337.
this.single = this.min === this.max && defined(this.min) &&
!this.tickAmount && options.allowDecimals !== false;
// Find the tick positions
this.tickPositions = tickPositions = tickPositionsOption && tickPositionsOption.slice(); // Work on a copy (#1565)
if (!tickPositions) {
if (this.isDatetimeAxis) {
tickPositions = this.getTimeTicks(
this.normalizeTimeTickInterval(this.tickInterval, options.units),
this.min,
this.max,
options.startOfWeek,
this.ordinalPositions,
this.closestPointRange,
true
);
} else if (this.isLog) {
tickPositions = this.getLogTickPositions(this.tickInterval, this.min, this.max);
} else {
tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
}
// Too dense ticks, keep only the first and last (#4477)
if (tickPositions.length > this.len) {
tickPositions = [tickPositions[0], tickPositions.pop()];
}
this.tickPositions = tickPositions;
// Run the tick positioner callback, that allows modifying auto tick positions.
if (tickPositioner) {
tickPositioner = tickPositioner.apply(this, [this.min, this.max]);
if (tickPositioner) {
this.tickPositions = tickPositions = tickPositioner;
}
}
}
// Reset min/max or remove extremes based on start/end on tick
this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
this.trimTicks(tickPositions, startOnTick, endOnTick);
if (!this.isLinked) {
// Substract half a unit (#2619, #2846, #2515, #3390)
if (this.single) {
this.min -= 0.5;
this.max += 0.5;
}
if (!tickPositionsOption && !tickPositioner) {
this.adjustTickAmount();
}
}
},
/**
* Handle startOnTick and endOnTick by either adapting to padding min/max or rounded min/max
*/
trimTicks: function(tickPositions, startOnTick, endOnTick) {
var roundedMin = tickPositions[0],
roundedMax = tickPositions[tickPositions.length - 1],
minPointOffset = this.minPointOffset || 0;
if (!this.isLinked) {
if (startOnTick && roundedMin !== -Infinity) { // #6502
this.min = roundedMin;
} else {
while (this.min - minPointOffset > tickPositions[0]) {
tickPositions.shift();
}
}
if (endOnTick) {
this.max = roundedMax;
} else {
while (this.max + minPointOffset < tickPositions[tickPositions.length - 1]) {
tickPositions.pop();
}
}
// If no tick are left, set one tick in the middle (#3195)
if (tickPositions.length === 0 && defined(roundedMin)) {
tickPositions.push((roundedMax + roundedMin) / 2);
}
}
},
/**
* Check if there are multiple axes in the same pane
* @returns {Boolean} There are other axes
*/
alignToOthers: function() {
var others = {}, // Whether there is another axis to pair with this one
hasOther,
options = this.options;
if (
// Only if alignTicks is true
this.chart.options.chart.alignTicks !== false &&
options.alignTicks !== false &&
// Don't try to align ticks on a log axis, they are not evenly
// spaced (#6021)
!this.isLog
) {
each(this.chart[this.coll], function(axis) {
var otherOptions = axis.options,
horiz = axis.horiz,
key = [
horiz ? otherOptions.left : otherOptions.top,
otherOptions.width,
otherOptions.height,
otherOptions.pane
].join(',');
if (axis.series.length) { // #4442
if (others[key]) {
hasOther = true; // #4201
} else {
others[key] = 1;
}
}
});
}
return hasOther;
},
/**
* Set the max ticks of either the x and y axis collection
*/
getTickAmount: function() {
var options = this.options,
tickAmount = options.tickAmount,
tickPixelInterval = options.tickPixelInterval;
if (!defined(options.tickInterval) && this.len < tickPixelInterval && !this.isRadial &&
!this.isLog && options.startOnTick && options.endOnTick) {
tickAmount = 2;
}
if (!tickAmount && this.alignToOthers()) {
// Add 1 because 4 tick intervals require 5 ticks (including first and last)
tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
}
// For tick amounts of 2 and 3, compute five ticks and remove the intermediate ones. This
// prevents the axis from adding ticks that are too far away from the data extremes.
if (tickAmount < 4) {
this.finalTickAmt = tickAmount;
tickAmount = 5;
}
this.tickAmount = tickAmount;
},
/**
* When using multiple axes, adjust the number of ticks to match the highest
* number of ticks in that group
*/
adjustTickAmount: function() {
var tickInterval = this.tickInterval,
tickPositions = this.tickPositions,
tickAmount = this.tickAmount,
finalTickAmt = this.finalTickAmt,
currentTickAmount = tickPositions && tickPositions.length,
i,
len;
if (currentTickAmount < tickAmount) {
while (tickPositions.length < tickAmount) {
tickPositions.push(correctFloat(
tickPositions[tickPositions.length - 1] + tickInterval
));
}
this.transA *= (currentTickAmount - 1) / (tickAmount - 1);
this.max = tickPositions[tickPositions.length - 1];
// We have too many ticks, run second pass to try to reduce ticks
} else if (currentTickAmount > tickAmount) {
this.tickInterval *= 2;
this.setTickPositions();
}
// The finalTickAmt property is set in getTickAmount
if (defined(finalTickAmt)) {
i = len = tickPositions.length;
while (i--) {
if (
(finalTickAmt === 3 && i % 2 === 1) || // Remove every other tick
(finalTickAmt <= 2 && i > 0 && i < len - 1) // Remove all but first and last
) {
tickPositions.splice(i, 1);
}
}
this.finalTickAmt = undefined;
}
},
/**
* Set the scale based on data min and max, user set min and max or options
*
*/
setScale: function() {
var axis = this,
isDirtyData,
isDirtyAxisLength;
axis.oldMin = axis.min;
axis.oldMax = axis.max;
axis.oldAxisLength = axis.len;
// set the new axisLength
axis.setAxisSize();
//axisLength = horiz ? axisWidth : axisHeight;
isDirtyAxisLength = axis.len !== axis.oldAxisLength;
// is there new data?
each(axis.series, function(series) {
if (series.isDirtyData || series.isDirty ||
series.xAxis.isDirty) { // when x axis is dirty, we need new data extremes for y as well
isDirtyData = true;
}
});
// do we really need to go through all this?
if (isDirtyAxisLength || isDirtyData || axis.isLinked || axis.forceRedraw ||
axis.userMin !== axis.oldUserMin || axis.userMax !== axis.oldUserMax || axis.alignToOthers()) {
if (axis.resetStacks) {
axis.resetStacks();
}
axis.forceRedraw = false;
// get data extremes if needed
axis.getSeriesExtremes();
// get fixed positions based on tickInterval
axis.setTickInterval();
// record old values to decide whether a rescale is necessary later on (#540)
axis.oldUserMin = axis.userMin;
axis.oldUserMax = axis.userMax;
// Mark as dirty if it is not already set to dirty and extremes have changed. #595.
if (!axis.isDirty) {
axis.isDirty = isDirtyAxisLength || axis.min !== axis.oldMin || axis.max !== axis.oldMax;
}
} else if (axis.cleanStacks) {
axis.cleanStacks();
}
},
/**
* Set the extremes and optionally redraw
* @param {Number} newMin
* @param {Number} newMax
* @param {Boolean} redraw
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
* @param {Object} eventArguments
*
*/
setExtremes: function(newMin, newMax, redraw, animation, eventArguments) {
var axis = this,
chart = axis.chart;
redraw = pick(redraw, true); // defaults to true
each(axis.series, function(serie) {
delete serie.kdTree;
});
// Extend the arguments with min and max
eventArguments = extend(eventArguments, {
min: newMin,
max: newMax
});
// Fire the event
fireEvent(axis, 'setExtremes', eventArguments, function() { // the default event handler
axis.userMin = newMin;
axis.userMax = newMax;
axis.eventArgs = eventArguments;
if (redraw) {
chart.redraw(animation);
}
});
},
/**
* Overridable method for zooming chart. Pulled out in a separate method to allow overriding
* in stock charts.
*/
zoom: function(newMin, newMax) {
var dataMin = this.dataMin,
dataMax = this.dataMax,
options = this.options,
min = Math.min(dataMin, pick(options.min, dataMin)),
max = Math.max(dataMax, pick(options.max, dataMax));
if (newMin !== this.min || newMax !== this.max) { // #5790
// Prevent pinch zooming out of range. Check for defined is for #1946. #1734.
if (!this.allowZoomOutside) {
// #6014, sometimes newMax will be smaller than min (or newMin will be larger than max).
if (defined(dataMin)) {
if (newMin < min) {
newMin = min;
}
if (newMin > max) {
newMin = max;
}
}
if (defined(dataMax)) {
if (newMax < min) {
newMax = min;
}
if (newMax > max) {
newMax = max;
}
}
}
// In full view, displaying the reset zoom button is not required
this.displayBtn = newMin !== undefined || newMax !== undefined;
// Do it
this.setExtremes(
newMin,
newMax,
false,
undefined, {
trigger: 'zoom'
}
);
}
return true;
},
/**
* Update the axis metrics
*/
setAxisSize: function() {
var chart = this.chart,
options = this.options,
offsets = options.offsets || [0, 0, 0, 0], // top / right / bottom / left
horiz = this.horiz,
width = pick(options.width, chart.plotWidth - offsets[3] + offsets[1]),
height = pick(options.height, chart.plotHeight - offsets[0] + offsets[2]),
top = pick(options.top, chart.plotTop + offsets[0]),
left = pick(options.left, chart.plotLeft + offsets[3]),
percentRegex = /%$/;
// Check for percentage based input values. Rounding fixes problems with
// column overflow and plot line filtering (#4898, #4899)
if (percentRegex.test(height)) {
height = Math.round(parseFloat(height) / 100 * chart.plotHeight);
}
if (percentRegex.test(top)) {
top = Math.round(parseFloat(top) / 100 * chart.plotHeight + chart.plotTop);
}
// Expose basic values to use in Series object and navigator
this.left = left;
this.top = top;
this.width = width;
this.height = height;
this.bottom = chart.chartHeight - height - top;
this.right = chart.chartWidth - width - left;
// Direction agnostic properties
this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
this.pos = horiz ? left : top; // distance from SVG origin
},
/**
* Get the actual axis extremes
*/
getExtremes: function() {
var axis = this,
isLog = axis.isLog,
lin2log = axis.lin2log;
return {
min: isLog ? correctFloat(lin2log(axis.min)) : axis.min,
max: isLog ? correctFloat(lin2log(axis.max)) : axis.max,
dataMin: axis.dataMin,
dataMax: axis.dataMax,
userMin: axis.userMin,
userMax: axis.userMax
};
},
/**
* Get the zero plane either based on zero or on the min or max value.
* Used in bar and area plots
*/
getThreshold: function(threshold) {
var axis = this,
isLog = axis.isLog,
lin2log = axis.lin2log,
realMin = isLog ? lin2log(axis.min) : axis.min,
realMax = isLog ? lin2log(axis.max) : axis.max;
if (threshold === null) {
threshold = realMin;
} else if (realMin > threshold) {
threshold = realMin;
} else if (realMax < threshold) {
threshold = realMax;
}
return axis.translate(threshold, 0, 1, 0, 1);
},
/**
* Compute auto alignment for the axis label based on which side the axis is on
* and the given rotation for the label
*/
autoLabelAlign: function(rotation) {
var ret,
angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360;
if (angle > 15 && angle < 165) {
ret = 'right';
} else if (angle > 195 && angle < 345) {
ret = 'left';
} else {
ret = 'center';
}
return ret;
},
/**
* Get the tick length and width for the axis.
* @param {String} prefix 'tick' or 'minorTick'
* @returns {Array} An array of tickLength and tickWidth
*/
tickSize: function(prefix) {
var options = this.options,
tickLength = options[prefix + 'Length'],
tickWidth = pick(options[prefix + 'Width'], prefix === 'tick' && this.isXAxis ? 1 : 0); // X axis defaults to 1
if (tickWidth && tickLength) {
// Negate the length
if (options[prefix + 'Position'] === 'inside') {
tickLength = -tickLength;
}
return [tickLength, tickWidth];
}
},
/**
* Return the size of the labels
*/
labelMetrics: function() {
return this.chart.renderer.fontMetrics(
this.options.labels.style && this.options.labels.style.fontSize,
this.ticks[0] && this.ticks[0].label
);
},
/**
* Prevent the ticks from getting so close we can't draw the labels. On a horizontal
* axis, this is handled by rotating the labels, removing ticks and adding ellipsis.
* On a vertical axis remove ticks and add ellipsis.
*/
unsquish: function() {
var labelOptions = this.options.labels,
horiz = this.horiz,
tickInterval = this.tickInterval,
newTickInterval = tickInterval,
slotSize = this.len / (((this.categories ? 1 : 0) + this.max - this.min) / tickInterval),
rotation,
rotationOption = labelOptions.rotation,
labelMetrics = this.labelMetrics(),
step,
bestScore = Number.MAX_VALUE,
autoRotation,
// Return the multiple of tickInterval that is needed to avoid collision
getStep = function(spaceNeeded) {
var step = spaceNeeded / (slotSize || 1);
step = step > 1 ? Math.ceil(step) : 1;
return step * tickInterval;
};
if (horiz) {
autoRotation = !labelOptions.staggerLines && !labelOptions.step && ( // #3971
defined(rotationOption) ? [rotationOption] :
slotSize < pick(labelOptions.autoRotationLimit, 80) && labelOptions.autoRotation
);
if (autoRotation) {
// Loop over the given autoRotation options, and determine which gives the best score. The
// best score is that with the lowest number of steps and a rotation closest to horizontal.
each(autoRotation, function(rot) {
var score;
if (rot === rotationOption || (rot && rot >= -90 && rot <= 90)) { // #3891
step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
score = step + Math.abs(rot / 360);
if (score < bestScore) {
bestScore = score;
rotation = rot;
newTickInterval = step;
}
}
});
}
} else if (!labelOptions.step) { // #4411
newTickInterval = getStep(labelMetrics.h);
}
this.autoRotation = autoRotation;
this.labelRotation = pick(rotation, rotationOption);
return newTickInterval;
},
/**
* Get the general slot width for this axis. This may change between the pre-render (from Axis.getOffset)
* and the final tick rendering and placement (#5086).
*/
getSlotWidth: function() {
var chart = this.chart,
horiz = this.horiz,
labelOptions = this.options.labels,
slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1),
marginLeft = chart.margin[3];
return (
horiz &&
(labelOptions.step || 0) < 2 &&
!labelOptions.rotation && // #4415
((this.staggerLines || 1) * this.len) / slotCount
) || (!horiz && (
(marginLeft && (marginLeft - chart.spacing[3])) ||
chart.chartWidth * 0.33
)); // #1580, #1931
},
/**
* Render the axis labels and determine whether ellipsis or rotation need to be applied
*/
renderUnsquish: function() {
var chart = this.chart,
renderer = chart.renderer,
tickPositions = this.tickPositions,
ticks = this.ticks,
labelOptions = this.options.labels,
horiz = this.horiz,
slotWidth = this.getSlotWidth(),
innerWidth = Math.max(1, Math.round(slotWidth - 2 * (labelOptions.padding || 5))),
attr = {},
labelMetrics = this.labelMetrics(),
textOverflowOption = labelOptions.style && labelOptions.style.textOverflow,
css,
maxLabelLength = 0,
label,
i,
pos;
// Set rotation option unless it is "auto", like in gauges
if (!isString(labelOptions.rotation)) {
attr.rotation = labelOptions.rotation || 0; // #4443
}
// Get the longest label length
each(tickPositions, function(tick) {
tick = ticks[tick];
if (tick && tick.labelLength > maxLabelLength) {
maxLabelLength = tick.labelLength;
}
});
this.maxLabelLength = maxLabelLength;
// Handle auto rotation on horizontal axis
if (this.autoRotation) {
// Apply rotation only if the label is too wide for the slot, and
// the label is wider than its height.
if (maxLabelLength > innerWidth && maxLabelLength > labelMetrics.h) {
attr.rotation = this.labelRotation;
} else {
this.labelRotation = 0;
}
// Handle word-wrap or ellipsis on vertical axis
} else if (slotWidth) {
// For word-wrap or ellipsis
css = {
width: innerWidth + 'px'
};
if (!textOverflowOption) {
css.textOverflow = 'clip';
// On vertical axis, only allow word wrap if there is room for more lines.
i = tickPositions.length;
while (!horiz && i--) {
pos = tickPositions[i];
label = ticks[pos].label;
if (label) {
// Reset ellipsis in order to get the correct bounding box (#4070)
if (label.styles && label.styles.textOverflow === 'ellipsis') {
label.css({
textOverflow: 'clip'
});
// Set the correct width in order to read the bounding box height (#4678, #5034)
} else if (ticks[pos].labelLength > slotWidth) {
label.css({
width: slotWidth + 'px'
});
}
if (label.getBBox().height > this.len / tickPositions.length - (labelMetrics.h - labelMetrics.f)) {
label.specCss = {
textOverflow: 'ellipsis'
};
}
}
}
}
}
// Add ellipsis if the label length is significantly longer than ideal
if (attr.rotation) {
css = {
width: (maxLabelLength > chart.chartHeight * 0.5 ? chart.chartHeight * 0.33 : chart.chartHeight) + 'px'
};
if (!textOverflowOption) {
css.textOverflow = 'ellipsis';
}
}
// Set the explicit or automatic label alignment
this.labelAlign = labelOptions.align || this.autoLabelAlign(this.labelRotation);
if (this.labelAlign) {
attr.align = this.labelAlign;
}
// Apply general and specific CSS
each(tickPositions, function(pos) {
var tick = ticks[pos],
label = tick && tick.label;
if (label) {
label.attr(attr); // This needs to go before the CSS in old IE (#4502)
if (css) {
label.css(merge(css, label.specCss));
}
delete label.specCss;
tick.rotation = attr.rotation;
}
});
// Note: Why is this not part of getLabelPosition?
this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
},
/**
* Return true if the axis has associated data
*/
hasData: function() {
return this.hasVisibleSeries || (defined(this.min) && defined(this.max) && !!this.tickPositions);
},
/**
* Adds the title defined in axis.options.title.
* @param {Boolean} display - whether or not to display the title
*/
addTitle: function(display) {
var axis = this,
renderer = axis.chart.renderer,
horiz = axis.horiz,
opposite = axis.opposite,
options = axis.options,
axisTitleOptions = options.title,
textAlign;
if (!axis.axisTitle) {
textAlign = axisTitleOptions.textAlign;
if (!textAlign) {
textAlign = (horiz ? {
low: 'left',
middle: 'center',
high: 'right'
} : {
low: opposite ? 'right' : 'left',
middle: 'center',
high: opposite ? 'left' : 'right'
})[axisTitleOptions.align];
}
axis.axisTitle = renderer.text(
axisTitleOptions.text,
0,
0,
axisTitleOptions.useHTML
)
.attr({
zIndex: 7,
rotation: axisTitleOptions.rotation || 0,
align: textAlign
})
.addClass('highcharts-axis-title')
.css(axisTitleOptions.style)
.add(axis.axisGroup);
axis.axisTitle.isNew = true;
}
// hide or show the title depending on whether showEmpty is set
axis.axisTitle[display ? 'show' : 'hide'](true);
},
/**
* Generates a tick for initial positioning.
* @param {number} pos - The tick position in axis values.
* @param {number} i - The index of the tick in axis.tickPositions.
*/
generateTick: function(pos) {
var ticks = this.ticks;
if (!ticks[pos]) {
ticks[pos] = new Tick(this, pos);
} else {
ticks[pos].addLabel(); // update labels depending on tick interval
}
},
/**
* Render the tick labels to a preliminary position to get their sizes
*/
getOffset: function() {
var axis = this,
chart = axis.chart,
renderer = chart.renderer,
options = axis.options,
tickPositions = axis.tickPositions,
ticks = axis.ticks,
horiz = axis.horiz,
side = axis.side,
invertedSide = chart.inverted ? [1, 0, 3, 2][side] : side,
hasData,
showAxis,
titleOffset = 0,
titleOffsetOption,
titleMargin = 0,
axisTitleOptions = options.title,
labelOptions = options.labels,
labelOffset = 0, // reset
labelOffsetPadded,
axisOffset = chart.axisOffset,
clipOffset = chart.clipOffset,
clip,
directionFactor = [-1, 1, 1, -1][side],
n,
className = options.className,
axisParent = axis.axisParent, // Used in color axis
lineHeightCorrection,
tickSize = this.tickSize('tick');
// For reuse in Axis.render
hasData = axis.hasData();
axis.showAxis = showAxis = hasData || pick(options.showEmpty, true);
// Set/reset staggerLines
axis.staggerLines = axis.horiz && labelOptions.staggerLines;
// Create the axisGroup and gridGroup elements on first iteration
if (!axis.axisGroup) {
axis.gridGroup = renderer.g('grid')
.attr({
zIndex: options.gridZIndex || 1
})
.addClass('highcharts-' + this.coll.toLowerCase() + '-grid ' + (className || ''))
.add(axisParent);
axis.axisGroup = renderer.g('axis')
.attr({
zIndex: options.zIndex || 2
})
.addClass('highcharts-' + this.coll.toLowerCase() + ' ' + (className || ''))
.add(axisParent);
axis.labelGroup = renderer.g('axis-labels')
.attr({
zIndex: labelOptions.zIndex || 7
})
.addClass('highcharts-' + axis.coll.toLowerCase() + '-labels ' + (className || ''))
.add(axisParent);
}
if (hasData || axis.isLinked) {
// Generate ticks
each(tickPositions, function(pos, i) {
// i is not used here, but may be used in overrides
axis.generateTick(pos, i);
});
axis.renderUnsquish();
// Left side must be align: right and right side must have align: left for labels
if (labelOptions.reserveSpace !== false && (side === 0 || side === 2 || {
1: 'left',
3: 'right'
}[side] === axis.labelAlign || axis.labelAlign === 'center')) {
each(tickPositions, function(pos) {
// get the highest offset
labelOffset = Math.max(
ticks[pos].getLabelSize(),
labelOffset
);
});
}
if (axis.staggerLines) {
labelOffset *= axis.staggerLines;
axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
}
} else { // doesn't have data
for (n in ticks) {
ticks[n].destroy();
delete ticks[n];
}
}
if (axisTitleOptions && axisTitleOptions.text && axisTitleOptions.enabled !== false) {
axis.addTitle(showAxis);
if (showAxis) {
titleOffset = axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
titleOffsetOption = axisTitleOptions.offset;
titleMargin = defined(titleOffsetOption) ? 0 : pick(axisTitleOptions.margin, horiz ? 5 : 10);
}
}
// Render the axis line
axis.renderLine();
// handle automatic or user set offset
axis.offset = directionFactor * pick(options.offset, axisOffset[side]);
axis.tickRotCorr = axis.tickRotCorr || {
x: 0,
y: 0
}; // polar
if (side === 0) {
lineHeightCorrection = -axis.labelMetrics().h;
} else if (side === 2) {
lineHeightCorrection = axis.tickRotCorr.y;
} else {
lineHeightCorrection = 0;
}
// Find the padded label offset
labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
if (labelOffset) {
labelOffsetPadded -= lineHeightCorrection;
labelOffsetPadded += directionFactor * (horiz ? pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) : labelOptions.x);
}
axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
axisOffset[side] = Math.max(
axisOffset[side],
axis.axisTitleMargin + titleOffset + directionFactor * axis.offset,
labelOffsetPadded, // #3027
hasData && tickPositions.length && tickSize ?
tickSize[0] + directionFactor * axis.offset :
0 // #4866
);
// Decide the clipping needed to keep the graph inside the plot area and axis lines
clip = options.offset ? 0 : Math.floor(axis.axisLine.strokeWidth() / 2) * 2; // #4308, #4371
clipOffset[invertedSide] = Math.max(clipOffset[invertedSide], clip);
},
/**
* Get the path for the axis line
*/
getLinePath: function(lineWidth) {
var chart = this.chart,
opposite = this.opposite,
offset = this.offset,
horiz = this.horiz,
lineLeft = this.left + (opposite ? this.width : 0) + offset,
lineTop = chart.chartHeight - this.bottom - (opposite ? this.height : 0) + offset;
if (opposite) {
lineWidth *= -1; // crispify the other way - #1480, #1687
}
return chart.renderer
.crispLine([
'M',
horiz ?
this.left :
lineLeft,
horiz ?
lineTop :
this.top,
'L',
horiz ?
chart.chartWidth - this.right :
lineLeft,
horiz ?
lineTop :
chart.chartHeight - this.bottom
], lineWidth);
},
/**
* Render the axis line
*/
renderLine: function() {
if (!this.axisLine) {
this.axisLine = this.chart.renderer.path()
.addClass('highcharts-axis-line')
.add(this.axisGroup);
this.axisLine.attr({
stroke: this.options.lineColor,
'stroke-width': this.options.lineWidth,
zIndex: 7
});
}
},
/**
* Position the title
*/
getTitlePosition: function() {
// compute anchor points for each of the title align options
var horiz = this.horiz,
axisLeft = this.left,
axisTop = this.top,
axisLength = this.len,
axisTitleOptions = this.options.title,
margin = horiz ? axisLeft : axisTop,
opposite = this.opposite,
offset = this.offset,
xOption = axisTitleOptions.x || 0,
yOption = axisTitleOptions.y || 0,
fontSize = this.chart.renderer.fontMetrics(axisTitleOptions.style && axisTitleOptions.style.fontSize, this.axisTitle).f,
// the position in the length direction of the axis
alongAxis = {
low: margin + (horiz ? 0 : axisLength),
middle: margin + axisLength / 2,
high: margin + (horiz ? axisLength : 0)
}[axisTitleOptions.align],
// the position in the perpendicular direction of the axis
offAxis = (horiz ? axisTop + this.height : axisLeft) +
(horiz ? 1 : -1) * // horizontal axis reverses the margin
(opposite ? -1 : 1) * // so does opposite axes
this.axisTitleMargin +
(this.side === 2 ? fontSize : 0);
return {
x: horiz ?
alongAxis + xOption : offAxis + (opposite ? this.width : 0) + offset + xOption,
y: horiz ?
offAxis + yOption - (opposite ? this.height : 0) + offset : alongAxis + yOption
};
},
/**
* Render a minor tick into the given position. If a minor tick already
* exists in this position, move it.
* @param {number} pos - The position in axis values.
*/
renderMinorTick: function(pos) {
var slideInTicks = this.chart.hasRendered && isNumber(this.oldMin),
minorTicks = this.minorTicks;
if (!minorTicks[pos]) {
minorTicks[pos] = new Tick(this, pos, 'minor');
}
// Render new ticks in old position
if (slideInTicks && minorTicks[pos].isNew) {
minorTicks[pos].render(null, true);
}
minorTicks[pos].render(null, false, 1);
},
/**
* Render a major tick into the given position. If a tick already exists
* in this position, move it.
* @param {number} pos - The position in axis values
* @param {number} i - The tick index
*/
renderTick: function(pos, i) {
var isLinked = this.isLinked,
ticks = this.ticks,
slideInTicks = this.chart.hasRendered && isNumber(this.oldMin);
// Linked axes need an extra check to find out if
if (!isLinked || (pos >= this.min && pos <= this.max)) {
if (!ticks[pos]) {
ticks[pos] = new Tick(this, pos);
}
// render new ticks in old position
if (slideInTicks && ticks[pos].isNew) {
ticks[pos].render(i, true, 0.1);
}
ticks[pos].render(i);
}
},
/**
* Render the axis
*/
render: function() {
var axis = this,
chart = axis.chart,
renderer = chart.renderer,
options = axis.options,
isLog = axis.isLog,
lin2log = axis.lin2log,
isLinked = axis.isLinked,
tickPositions = axis.tickPositions,
axisTitle = axis.axisTitle,
ticks = axis.ticks,
minorTicks = axis.minorTicks,
alternateBands = axis.alternateBands,
stackLabelOptions = options.stackLabels,
alternateGridColor = options.alternateGridColor,
tickmarkOffset = axis.tickmarkOffset,
axisLine = axis.axisLine,
showAxis = axis.showAxis,
animation = animObject(renderer.globalAnimation),
from,
to;
// Reset
axis.labelEdge.length = 0;
//axis.justifyToPlot = overflow === 'justify';
axis.overlap = false;
// Mark all elements inActive before we go over and mark the active ones
each([ticks, minorTicks, alternateBands], function(coll) {
var pos;
for (pos in coll) {
coll[pos].isActive = false;
}
});
// If the series has data draw the ticks. Else only the line and title
if (axis.hasData() || isLinked) {
// minor ticks
if (axis.minorTickInterval && !axis.categories) {
each(axis.getMinorTickPositions(), function(pos) {
axis.renderMinorTick(pos);
});
}
// Major ticks. Pull out the first item and render it last so that
// we can get the position of the neighbour label. #808.
if (tickPositions.length) { // #1300
each(tickPositions, function(pos, i) {
axis.renderTick(pos, i);
});
// In a categorized axis, the tick marks are displayed between labels. So
// we need to add a tick mark and grid line at the left edge of the X axis.
if (tickmarkOffset && (axis.min === 0 || axis.single)) {
if (!ticks[-1]) {
ticks[-1] = new Tick(axis, -1, null, true);
}
ticks[-1].render(-1);
}
}
// alternate grid color
if (alternateGridColor) {
each(tickPositions, function(pos, i) {
to = tickPositions[i + 1] !== undefined ? tickPositions[i + 1] + tickmarkOffset : axis.max - tickmarkOffset;
if (i % 2 === 0 && pos < axis.max && to <= axis.max + (chart.polar ? -tickmarkOffset : tickmarkOffset)) { // #2248, #4660
if (!alternateBands[pos]) {
alternateBands[pos] = new PlotLineOrBand(axis);
}
from = pos + tickmarkOffset; // #949
alternateBands[pos].options = {
from: isLog ? lin2log(from) : from,
to: isLog ? lin2log(to) : to,
color: alternateGridColor
};
alternateBands[pos].render();
alternateBands[pos].isActive = true;
}
});
}
// custom plot lines and bands
if (!axis._addedPlotLB) { // only first time
each((options.plotLines || []).concat(options.plotBands || []), function(plotLineOptions) {
axis.addPlotBandOrLine(plotLineOptions);
});
axis._addedPlotLB = true;
}
} // end if hasData
// Remove inactive ticks
each([ticks, minorTicks, alternateBands], function(coll) {
var pos,
i,
forDestruction = [],
delay = animation.duration,
destroyInactiveItems = function() {
i = forDestruction.length;
while (i--) {
// When resizing rapidly, the same items may be destroyed in different timeouts,
// or the may be reactivated
if (coll[forDestruction[i]] && !coll[forDestruction[i]].isActive) {
coll[forDestruction[i]].destroy();
delete coll[forDestruction[i]];
}
}
};
for (pos in coll) {
if (!coll[pos].isActive) {
// Render to zero opacity
coll[pos].render(pos, false, 0);
coll[pos].isActive = false;
forDestruction.push(pos);
}
}
// When the objects are finished fading out, destroy them
syncTimeout(
destroyInactiveItems,
coll === alternateBands || !chart.hasRendered || !delay ? 0 : delay
);
});
// Set the axis line path
if (axisLine) {
axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
d: this.getLinePath(axisLine.strokeWidth())
});
axisLine.isPlaced = true;
// Show or hide the line depending on options.showEmpty
axisLine[showAxis ? 'show' : 'hide'](true);
}
if (axisTitle && showAxis) {
axisTitle[axisTitle.isNew ? 'attr' : 'animate'](
axis.getTitlePosition()
);
axisTitle.isNew = false;
}
// Stacked totals:
if (stackLabelOptions && stackLabelOptions.enabled) {
axis.renderStackTotals();
}
// End stacked totals
axis.isDirty = false;
},
/**
* Redraw the axis to reflect changes in the data or axis extremes
*/
redraw: function() {
if (this.visible) {
// render the axis
this.render();
// move plot lines and bands
each(this.plotLinesAndBands, function(plotLine) {
plotLine.render();
});
}
// mark associated series as dirty and ready for redraw
each(this.series, function(series) {
series.isDirty = true;
});
},
// Properties to survive after destroy, needed for Axis.update (#4317,
// #5773, #5881).
keepProps: ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'],
/**
* Destroys an Axis instance.
*/
destroy: function(keepEvents) {
var axis = this,
stacks = axis.stacks,
stackKey,
plotLinesAndBands = axis.plotLinesAndBands,
plotGroup,
i,
n;
// Remove the events
if (!keepEvents) {
removeEvent(axis);
}
// Destroy each stack total
for (stackKey in stacks) {
destroyObjectProperties(stacks[stackKey]);
stacks[stackKey] = null;
}
// Destroy collections
each([axis.ticks, axis.minorTicks, axis.alternateBands], function(coll) {
destroyObjectProperties(coll);
});
if (plotLinesAndBands) {
i = plotLinesAndBands.length;
while (i--) { // #1975
plotLinesAndBands[i].destroy();
}
}
// Destroy local variables
each(['stackTotalGroup', 'axisLine', 'axisTitle', 'axisGroup', 'gridGroup', 'labelGroup', 'cross'], function(prop) {
if (axis[prop]) {
axis[prop] = axis[prop].destroy();
}
});
// Destroy each generated group for plotlines and plotbands
for (plotGroup in axis.plotLinesAndBandsGroups) {
axis.plotLinesAndBandsGroups[plotGroup] = axis.plotLinesAndBandsGroups[plotGroup].destroy();
}
// Delete all properties and fall back to the prototype.
for (n in axis) {
if (axis.hasOwnProperty(n) && inArray(n, axis.keepProps) === -1) {
delete axis[n];
}
}
},
/**
* Draw the crosshair
*
* @param {Object} e The event arguments from the modified pointer event
* @param {Object} point The Point object
*/
drawCrosshair: function(e, point) {
var path,
options = this.crosshair,
snap = pick(options.snap, true),
pos,
categorized,
graphic = this.cross;
// Use last available event when updating non-snapped crosshairs without
// mouse interaction (#5287)
if (!e) {
e = this.cross && this.cross.e;
}
if (
// Disabled in options
!this.crosshair ||
// Snap
((defined(point) || !snap) === false)
) {
this.hideCrosshair();
} else {
// Get the path
if (!snap) {
pos = e && (this.horiz ? e.chartX - this.pos : this.len - e.chartY + this.pos);
} else if (defined(point)) {
pos = this.isXAxis ? point.plotX : this.len - point.plotY; // #3834
}
if (defined(pos)) {
path = this.getPlotLinePath(
// First argument, value, only used on radial
point && (this.isXAxis ? point.x : pick(point.stackY, point.y)),
null,
null,
null,
pos // Translated position
) || null; // #3189
}
if (!defined(path)) {
this.hideCrosshair();
return;
}
categorized = this.categories && !this.isRadial;
// Draw the cross
if (!graphic) {
this.cross = graphic = this.chart.renderer
.path()
.addClass('highcharts-crosshair highcharts-crosshair-' +
(categorized ? 'category ' : 'thin ') + options.className)
.attr({
zIndex: pick(options.zIndex, 2)
})
.add();
// Presentational attributes
graphic.attr({
'stroke': options.color || (categorized ? color('#ccd6eb').setOpacity(0.25).get() : '#cccccc'),
'stroke-width': pick(options.width, 1)
});
if (options.dashStyle) {
graphic.attr({
dashstyle: options.dashStyle
});
}
}
graphic.show().attr({
d: path
});
if (categorized && !options.width) {
graphic.attr({
'stroke-width': this.transA
});
}
this.cross.e = e;
}
},
/**
* Hide the crosshair.
*/
hideCrosshair: function() {
if (this.cross) {
this.cross.hide();
}
}
}; // end Axis
extend(H.Axis.prototype, AxisPlotLineOrBandExtension);
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
Date = H.Date,
dateFormat = H.dateFormat,
defaultOptions = H.defaultOptions,
defined = H.defined,
each = H.each,
extend = H.extend,
getMagnitude = H.getMagnitude,
getTZOffset = H.getTZOffset,
normalizeTickInterval = H.normalizeTickInterval,
pick = H.pick,
timeUnits = H.timeUnits;
/**
* Set the tick positions to a time unit that makes sense, for example
* on the first of each month or on every Monday. Return an array
* with the time positions. Used in datetime axes as well as for grouping
* data on a datetime axis.
*
* @param {Object} normalizedInterval The interval in axis values (ms) and the count
* @param {Number} min The minimum in axis values
* @param {Number} max The maximum in axis values
* @param {Number} startOfWeek
*/
Axis.prototype.getTimeTicks = function(normalizedInterval, min, max, startOfWeek) {
var tickPositions = [],
i,
higherRanks = {},
useUTC = defaultOptions.global.useUTC,
minYear, // used in months and years as a basis for Date.UTC()
minDate = new Date(min - Math.abs(getTZOffset(min))), // #6278
makeTime = Date.hcMakeTime,
interval = normalizedInterval.unitRange,
count = normalizedInterval.count,
variableDayLength;
if (defined(min)) { // #1300
minDate[Date.hcSetMilliseconds](interval >= timeUnits.second ? 0 : // #3935
count * Math.floor(minDate.getMilliseconds() / count)); // #3652, #3654
if (interval >= timeUnits.second) { // second
minDate[Date.hcSetSeconds](interval >= timeUnits.minute ? 0 : // #3935
count * Math.floor(minDate.getSeconds() / count));
}
if (interval >= timeUnits.minute) { // minute
minDate[Date.hcSetMinutes](interval >= timeUnits.hour ? 0 :
count * Math.floor(minDate[Date.hcGetMinutes]() / count));
}
if (interval >= timeUnits.hour) { // hour
minDate[Date.hcSetHours](interval >= timeUnits.day ? 0 :
count * Math.floor(minDate[Date.hcGetHours]() / count));
}
if (interval >= timeUnits.day) { // day
minDate[Date.hcSetDate](interval >= timeUnits.month ? 1 :
count * Math.floor(minDate[Date.hcGetDate]() / count));
}
if (interval >= timeUnits.month) { // month
minDate[Date.hcSetMonth](interval >= timeUnits.year ? 0 :
count * Math.floor(minDate[Date.hcGetMonth]() / count));
minYear = minDate[Date.hcGetFullYear]();
}
if (interval >= timeUnits.year) { // year
minYear -= minYear % count;
minDate[Date.hcSetFullYear](minYear);
}
// week is a special case that runs outside the hierarchy
if (interval === timeUnits.week) {
// get start of current week, independent of count
minDate[Date.hcSetDate](minDate[Date.hcGetDate]() - minDate[Date.hcGetDay]() +
pick(startOfWeek, 1));
}
// Get basics for variable time spans
minYear = minDate[Date.hcGetFullYear]();
var minMonth = minDate[Date.hcGetMonth](),
minDateDate = minDate[Date.hcGetDate](),
minHours = minDate[Date.hcGetHours]();
// Handle local timezone offset
if (Date.hcTimezoneOffset || Date.hcGetTimezoneOffset) {
// Detect whether we need to take the DST crossover into
// consideration. If we're crossing over DST, the day length may be
// 23h or 25h and we need to compute the exact clock time for each
// tick instead of just adding hours. This comes at a cost, so first
// we found out if it is needed. #4951.
variableDayLength =
(!useUTC || !!Date.hcGetTimezoneOffset) &&
(
// Long range, assume we're crossing over.
max - min > 4 * timeUnits.month ||
// Short range, check if min and max are in different time
// zones.
getTZOffset(min) !== getTZOffset(max)
);
// Adjust minDate to the offset date
minDate = minDate.getTime();
minDate = new Date(minDate + getTZOffset(minDate));
}
// Iterate and add tick positions at appropriate values
var time = minDate.getTime();
i = 1;
while (time < max) {
tickPositions.push(time);
// if the interval is years, use Date.UTC to increase years
if (interval === timeUnits.year) {
time = makeTime(minYear + i * count, 0);
// if the interval is months, use Date.UTC to increase months
} else if (interval === timeUnits.month) {
time = makeTime(minYear, minMonth + i * count);
// if we're using global time, the interval is not fixed as it jumps
// one hour at the DST crossover
} else if (variableDayLength && (interval === timeUnits.day || interval === timeUnits.week)) {
time = makeTime(minYear, minMonth, minDateDate +
i * count * (interval === timeUnits.day ? 1 : 7));
} else if (variableDayLength && interval === timeUnits.hour) {
time = makeTime(minYear, minMonth, minDateDate, minHours + i * count);
// else, the interval is fixed and we use simple addition
} else {
time += interval * count;
}
i++;
}
// push the last time
tickPositions.push(time);
// Handle higher ranks. Mark new days if the time is on midnight
// (#950, #1649, #1760, #3349). Use a reasonable dropout threshold to
// prevent looping over dense data grouping (#6156).
if (interval <= timeUnits.hour && tickPositions.length < 10000) {
each(tickPositions, function(time) {
if (
// Speed optimization, no need to run dateFormat unless
// we're on a full or half hour
time % 1800000 === 0 &&
// Check for local or global midnight
dateFormat('%H%M%S%L', time) === '000000000'
) {
higherRanks[time] = 'day';
}
});
}
}
// record information on the chosen unit - for dynamic label formatter
tickPositions.info = extend(normalizedInterval, {
higherRanks: higherRanks,
totalRange: interval * count
});
return tickPositions;
};
/**
* Get a normalized tick interval for dates. Returns a configuration object with
* unit range (interval), count and name. Used to prepare data for getTimeTicks.
* Previously this logic was part of getTimeTicks, but as getTimeTicks now runs
* of segments in stock charts, the normalizing logic was extracted in order to
* prevent it for running over again for each segment having the same interval.
* #662, #697.
*/
Axis.prototype.normalizeTimeTickInterval = function(tickInterval, unitsOption) {
var units = unitsOption || [
[
'millisecond', // unit name
[1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
],
[
'second', [1, 2, 5, 10, 15, 30]
],
[
'minute', [1, 2, 5, 10, 15, 30]
],
[
'hour', [1, 2, 3, 4, 6, 8, 12]
],
[
'day', [1, 2]
],
[
'week', [1, 2]
],
[
'month', [1, 2, 3, 4, 6]
],
[
'year',
null
]
],
unit = units[units.length - 1], // default unit is years
interval = timeUnits[unit[0]],
multiples = unit[1],
count,
i;
// loop through the units to find the one that best fits the tickInterval
for (i = 0; i < units.length; i++) {
unit = units[i];
interval = timeUnits[unit[0]];
multiples = unit[1];
if (units[i + 1]) {
// lessThan is in the middle between the highest multiple and the next unit.
var lessThan = (interval * multiples[multiples.length - 1] +
timeUnits[units[i + 1][0]]) / 2;
// break and keep the current unit
if (tickInterval <= lessThan) {
break;
}
}
}
// prevent 2.5 years intervals, though 25, 250 etc. are allowed
if (interval === timeUnits.year && tickInterval < 5 * interval) {
multiples = [1, 2, 5];
}
// get the count
count = normalizeTickInterval(
tickInterval / interval,
multiples,
unit[0] === 'year' ? Math.max(getMagnitude(tickInterval / interval), 1) : 1 // #1913, #2360
);
return {
unitRange: interval,
count: count,
unitName: unit[0]
};
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
getMagnitude = H.getMagnitude,
map = H.map,
normalizeTickInterval = H.normalizeTickInterval,
pick = H.pick;
/**
* Methods defined on the Axis prototype
*/
/**
* Set the tick positions of a logarithmic axis
*/
Axis.prototype.getLogTickPositions = function(interval, min, max, minor) {
var axis = this,
options = axis.options,
axisLength = axis.len,
lin2log = axis.lin2log,
log2lin = axis.log2lin,
// Since we use this method for both major and minor ticks,
// use a local variable and return the result
positions = [];
// Reset
if (!minor) {
axis._minorAutoInterval = null;
}
// First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
if (interval >= 0.5) {
interval = Math.round(interval);
positions = axis.getLinearTickPositions(interval, min, max);
// Second case: We need intermediary ticks. For example
// 1, 2, 4, 6, 8, 10, 20, 40 etc.
} else if (interval >= 0.08) {
var roundedMin = Math.floor(min),
intermediate,
i,
j,
len,
pos,
lastPos,
break2;
if (interval > 0.3) {
intermediate = [1, 2, 4];
} else if (interval > 0.15) { // 0.2 equals five minor ticks per 1, 10, 100 etc
intermediate = [1, 2, 4, 6, 8];
} else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
}
for (i = roundedMin; i < max + 1 && !break2; i++) {
len = intermediate.length;
for (j = 0; j < len && !break2; j++) {
pos = log2lin(lin2log(i) * intermediate[j]);
if (pos > min && (!minor || lastPos <= max) && lastPos !== undefined) { // #1670, lastPos is #3113
positions.push(lastPos);
}
if (lastPos > max) {
break2 = true;
}
lastPos = pos;
}
}
// Third case: We are so deep in between whole logarithmic values that
// we might as well handle the tick positions like a linear axis. For
// example 1.01, 1.02, 1.03, 1.04.
} else {
var realMin = lin2log(min),
realMax = lin2log(max),
tickIntervalOption = options[minor ? 'minorTickInterval' : 'tickInterval'],
filteredTickIntervalOption = tickIntervalOption === 'auto' ? null : tickIntervalOption,
tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1),
totalPixelLength = minor ? axisLength / axis.tickPositions.length : axisLength;
interval = pick(
filteredTickIntervalOption,
axis._minorAutoInterval,
(realMax - realMin) * tickPixelIntervalOption / (totalPixelLength || 1)
);
interval = normalizeTickInterval(
interval,
null,
getMagnitude(interval)
);
positions = map(axis.getLinearTickPositions(
interval,
realMin,
realMax
), log2lin);
if (!minor) {
axis._minorAutoInterval = interval / 5;
}
}
// Set the axis-level tickInterval variable
if (!minor) {
axis.tickInterval = interval;
}
return positions;
};
Axis.prototype.log2lin = function(num) {
return Math.log(num) / Math.LN10;
};
Axis.prototype.lin2log = function(num) {
return Math.pow(10, num);
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var dateFormat = H.dateFormat,
each = H.each,
extend = H.extend,
format = H.format,
isNumber = H.isNumber,
map = H.map,
merge = H.merge,
pick = H.pick,
splat = H.splat,
syncTimeout = H.syncTimeout,
timeUnits = H.timeUnits;
/**
* The tooltip object
* @param {Object} chart The chart instance
* @param {Object} options Tooltip options
*/
H.Tooltip = function() {
this.init.apply(this, arguments);
};
H.Tooltip.prototype = {
init: function(chart, options) {
// Save the chart and options
this.chart = chart;
this.options = options;
// Keep track of the current series
//this.currentSeries = undefined;
// List of crosshairs
this.crosshairs = [];
// Current values of x and y when animating
this.now = {
x: 0,
y: 0
};
// The tooltip is initially hidden
this.isHidden = true;
// Public property for getting the shared state.
this.split = options.split && !chart.inverted;
this.shared = options.shared || this.split;
},
/**
* Destroy the single tooltips in a split tooltip.
* If the tooltip is active then it is not destroyed, unless forced to.
* @param {boolean} force Force destroy all tooltips.
* @return {undefined}
*/
cleanSplit: function(force) {
each(this.chart.series, function(series) {
var tt = series && series.tt;
if (tt) {
if (!tt.isActive || force) {
series.tt = tt.destroy();
} else {
tt.isActive = false;
}
}
});
},
/**
* Create the Tooltip label element if it doesn't exist, then return the
* label.
*/
getLabel: function() {
var renderer = this.chart.renderer,
options = this.options;
if (!this.label) {
// Create the label
if (this.split) {
this.label = renderer.g('tooltip');
} else {
this.label = renderer.label(
'',
0,
0,
options.shape || 'callout',
null,
null,
options.useHTML,
null,
'tooltip'
)
.attr({
padding: options.padding,
r: options.borderRadius
});
this.label
.attr({
'fill': options.backgroundColor,
'stroke-width': options.borderWidth
})
// #2301, #2657
.css(options.style)
.shadow(options.shadow);
}
this.label
.attr({
zIndex: 8
})
.add();
}
return this.label;
},
update: function(options) {
this.destroy();
this.init(this.chart, merge(true, this.options, options));
},
/**
* Destroy the tooltip and its elements.
*/
destroy: function() {
// Destroy and clear local variables
if (this.label) {
this.label = this.label.destroy();
}
if (this.split && this.tt) {
this.cleanSplit(this.chart, true);
this.tt = this.tt.destroy();
}
clearTimeout(this.hideTimer);
clearTimeout(this.tooltipTimeout);
},
/**
* Provide a soft movement for the tooltip
*
* @param {Number} x
* @param {Number} y
* @private
*/
move: function(x, y, anchorX, anchorY) {
var tooltip = this,
now = tooltip.now,
animate = tooltip.options.animation !== false && !tooltip.isHidden &&
// When we get close to the target position, abort animation and land on the right place (#3056)
(Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
skipAnchor = tooltip.followPointer || tooltip.len > 1;
// Get intermediate values for animation
extend(now, {
x: animate ? (2 * now.x + x) / 3 : x,
y: animate ? (now.y + y) / 2 : y,
anchorX: skipAnchor ? undefined : animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
anchorY: skipAnchor ? undefined : animate ? (now.anchorY + anchorY) / 2 : anchorY
});
// Move to the intermediate value
tooltip.getLabel().attr(now);
// Run on next tick of the mouse tracker
if (animate) {
// Never allow two timeouts
clearTimeout(this.tooltipTimeout);
// Set the fixed interval ticking for the smooth tooltip
this.tooltipTimeout = setTimeout(function() {
// The interval function may still be running during destroy,
// so check that the chart is really there before calling.
if (tooltip) {
tooltip.move(x, y, anchorX, anchorY);
}
}, 32);
}
},
/**
* Hide the tooltip
*/
hide: function(delay) {
var tooltip = this;
clearTimeout(this.hideTimer); // disallow duplicate timers (#1728, #1766)
delay = pick(delay, this.options.hideDelay, 500);
if (!this.isHidden) {
this.hideTimer = syncTimeout(function() {
tooltip.getLabel()[delay ? 'fadeOut' : 'hide']();
tooltip.isHidden = true;
}, delay);
}
},
/**
* Extendable method to get the anchor position of the tooltip
* from a point or set of points
*/
getAnchor: function(points, mouseEvent) {
var ret,
chart = this.chart,
inverted = chart.inverted,
plotTop = chart.plotTop,
plotLeft = chart.plotLeft,
plotX = 0,
plotY = 0,
yAxis,
xAxis;
points = splat(points);
// Pie uses a special tooltipPos
ret = points[0].tooltipPos;
// When tooltip follows mouse, relate the position to the mouse
if (this.followPointer && mouseEvent) {
if (mouseEvent.chartX === undefined) {
mouseEvent = chart.pointer.normalize(mouseEvent);
}
ret = [
mouseEvent.chartX - chart.plotLeft,
mouseEvent.chartY - plotTop
];
}
// When shared, use the average position
if (!ret) {
each(points, function(point) {
yAxis = point.series.yAxis;
xAxis = point.series.xAxis;
plotX += point.plotX + (!inverted && xAxis ? xAxis.left - plotLeft : 0);
plotY += (point.plotLow ? (point.plotLow + point.plotHigh) / 2 : point.plotY) +
(!inverted && yAxis ? yAxis.top - plotTop : 0); // #1151
});
plotX /= points.length;
plotY /= points.length;
ret = [
inverted ? chart.plotWidth - plotY : plotX,
this.shared && !inverted && points.length > 1 && mouseEvent ?
mouseEvent.chartY - plotTop : // place shared tooltip next to the mouse (#424)
inverted ? chart.plotHeight - plotX : plotY
];
}
return map(ret, Math.round);
},
/**
* Place the tooltip in a chart without spilling over
* and not covering the point it self.
*/
getPosition: function(boxWidth, boxHeight, point) {
var chart = this.chart,
distance = this.distance,
ret = {},
h = point.h || 0, // #4117
swapped,
first = ['y', chart.chartHeight, boxHeight,
point.plotY + chart.plotTop, chart.plotTop,
chart.plotTop + chart.plotHeight
],
second = ['x', chart.chartWidth, boxWidth,
point.plotX + chart.plotLeft, chart.plotLeft,
chart.plotLeft + chart.plotWidth
],
// The far side is right or bottom
preferFarSide = !this.followPointer && pick(point.ttBelow, !chart.inverted === !!point.negative), // #4984
/**
* Handle the preferred dimension. When the preferred dimension is tooltip
* on top or bottom of the point, it will look for space there.
*/
firstDimension = function(dim, outerSize, innerSize, point, min, max) {
var roomLeft = innerSize < point - distance,
roomRight = point + distance + innerSize < outerSize,
alignedLeft = point - distance - innerSize,
alignedRight = point + distance;
if (preferFarSide && roomRight) {
ret[dim] = alignedRight;
} else if (!preferFarSide && roomLeft) {
ret[dim] = alignedLeft;
} else if (roomLeft) {
ret[dim] = Math.min(max - innerSize, alignedLeft - h < 0 ? alignedLeft : alignedLeft - h);
} else if (roomRight) {
ret[dim] = Math.max(
min,
alignedRight + h + innerSize > outerSize ?
alignedRight :
alignedRight + h
);
} else {
return false;
}
},
/**
* Handle the secondary dimension. If the preferred dimension is tooltip
* on top or bottom of the point, the second dimension is to align the tooltip
* above the point, trying to align center but allowing left or right
* align within the chart box.
*/
secondDimension = function(dim, outerSize, innerSize, point) {
var retVal;
// Too close to the edge, return false and swap dimensions
if (point < distance || point > outerSize - distance) {
retVal = false;
// Align left/top
} else if (point < innerSize / 2) {
ret[dim] = 1;
// Align right/bottom
} else if (point > outerSize - innerSize / 2) {
ret[dim] = outerSize - innerSize - 2;
// Align center
} else {
ret[dim] = point - innerSize / 2;
}
return retVal;
},
/**
* Swap the dimensions
*/
swap = function(count) {
var temp = first;
first = second;
second = temp;
swapped = count;
},
run = function() {
if (firstDimension.apply(0, first) !== false) {
if (secondDimension.apply(0, second) === false && !swapped) {
swap(true);
run();
}
} else if (!swapped) {
swap(true);
run();
} else {
ret.x = ret.y = 0;
}
};
// Under these conditions, prefer the tooltip on the side of the point
if (chart.inverted || this.len > 1) {
swap();
}
run();
return ret;
},
/**
* In case no user defined formatter is given, this will be used. Note that the context
* here is an object holding point, series, x, y etc.
*
* @returns {String|Array<String>}
*/
defaultFormatter: function(tooltip) {
var items = this.points || splat(this),
s;
// Build the header
s = [tooltip.tooltipFooterHeaderFormatter(items[0])];
// build the values
s = s.concat(tooltip.bodyFormatter(items));
// footer
s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));
return s;
},
/**
* Refresh the tooltip's text and position.
* @param {Object|Array} pointOrPoints Rither a point or an array of points
*/
refresh: function(pointOrPoints, mouseEvent) {
var tooltip = this,
label,
options = tooltip.options,
x,
y,
point = pointOrPoints,
anchor,
textConfig = {},
text,
pointConfig = [],
formatter = options.formatter || tooltip.defaultFormatter,
shared = tooltip.shared,
currentSeries;
clearTimeout(this.hideTimer);
// get the reference point coordinates (pie charts use tooltipPos)
tooltip.followPointer = splat(point)[0].series.tooltipOptions.followPointer;
anchor = tooltip.getAnchor(point, mouseEvent);
x = anchor[0];
y = anchor[1];
// shared tooltip, array is sent over
if (shared && !(point.series && point.series.noSharedTooltip)) {
each(point, function(item) {
item.setState('hover');
pointConfig.push(item.getLabelConfig());
});
textConfig = {
x: point[0].category,
y: point[0].y
};
textConfig.points = pointConfig;
point = point[0];
// single point tooltip
} else {
textConfig = point.getLabelConfig();
}
this.len = pointConfig.length; // #6128
text = formatter.call(textConfig, tooltip);
// register the current series
currentSeries = point.series;
this.distance = pick(currentSeries.tooltipOptions.distance, 16);
// update the inner HTML
if (text === false) {
this.hide();
} else {
label = tooltip.getLabel();
// show it
if (tooltip.isHidden) {
label.attr({
opacity: 1
}).show();
}
// update text
if (tooltip.split) {
this.renderSplit(text, pointOrPoints);
} else {
label.attr({
text: text && text.join ? text.join('') : text
});
// Set the stroke color of the box to reflect the point
label.removeClass(/highcharts-color-[\d]+/g)
.addClass('highcharts-color-' + pick(point.colorIndex, currentSeries.colorIndex));
label.attr({
stroke: options.borderColor || point.color || currentSeries.color || '#666666'
});
tooltip.updatePosition({
plotX: x,
plotY: y,
negative: point.negative,
ttBelow: point.ttBelow,
h: anchor[2] || 0
});
}
this.isHidden = false;
}
},
/**
* Render the split tooltip. Loops over each point's text and adds
* a label next to the point, then uses the distribute function to
* find best non-overlapping positions.
*/
renderSplit: function(labels, points) {
var tooltip = this,
boxes = [],
chart = this.chart,
ren = chart.renderer,
rightAligned = true,
options = this.options,
headerHeight,
tooltipLabel = this.getLabel();
// Create the individual labels for header and points, ignore footer
each(labels.slice(0, points.length + 1), function(str, i) {
var point = points[i - 1] ||
// Item 0 is the header. Instead of this, we could also use the crosshair label
{
isHeader: true,
plotX: points[0].plotX
},
owner = point.series || tooltip,
tt = owner.tt,
series = point.series || {},
colorClass = 'highcharts-color-' + pick(point.colorIndex, series.colorIndex, 'none'),
target,
x,
bBox,
boxWidth;
// Store the tooltip referance on the series
if (!tt) {
owner.tt = tt = ren.label(null, null, null, 'callout')
.addClass('highcharts-tooltip-box ' + colorClass)
.attr({
'padding': options.padding,
'r': options.borderRadius,
'fill': options.backgroundColor,
'stroke': point.color || series.color || '#333333',
'stroke-width': options.borderWidth
})
.add(tooltipLabel);
}
tt.isActive = true;
tt.attr({
text: str
});
tt.css(options.style);
// Get X position now, so we can move all to the other side in case of overflow
bBox = tt.getBBox();
boxWidth = bBox.width + tt.strokeWidth();
if (point.isHeader) {
headerHeight = bBox.height;
x = Math.max(
0, // No left overflow
Math.min(
point.plotX + chart.plotLeft - boxWidth / 2,
chart.chartWidth - boxWidth // No right overflow (#5794)
)
);
} else {
x = point.plotX + chart.plotLeft - pick(options.distance, 16) -
boxWidth;
}
// If overflow left, we don't use this x in the next loop
if (x < 0) {
rightAligned = false;
}
// Prepare for distribution
target = (point.series && point.series.yAxis && point.series.yAxis.pos) + (point.plotY || 0);
target -= chart.plotTop;
boxes.push({
target: point.isHeader ? chart.plotHeight + headerHeight : target,
rank: point.isHeader ? 1 : 0,
size: owner.tt.getBBox().height + 1,
point: point,
x: x,
tt: tt
});
});
// Clean previous run (for missing points)
this.cleanSplit();
// Distribute and put in place
H.distribute(boxes, chart.plotHeight + headerHeight);
each(boxes, function(box) {
var point = box.point,
series = point.series;
// Put the label in place
box.tt.attr({
visibility: box.pos === undefined ? 'hidden' : 'inherit',
x: (rightAligned || point.isHeader ?
box.x :
point.plotX + chart.plotLeft + pick(options.distance, 16)),
y: box.pos + chart.plotTop,
anchorX: point.isHeader ?
point.plotX + chart.plotLeft : point.plotX + series.xAxis.pos,
anchorY: point.isHeader ?
box.pos + chart.plotTop - 15 : point.plotY + series.yAxis.pos
});
});
},
/**
* Find the new position and perform the move
*/
updatePosition: function(point) {
var chart = this.chart,
label = this.getLabel(),
pos = (this.options.positioner || this.getPosition).call(
this,
label.width,
label.height,
point
);
// do the move
this.move(
Math.round(pos.x),
Math.round(pos.y || 0), // can be undefined (#3977)
point.plotX + chart.plotLeft,
point.plotY + chart.plotTop
);
},
/**
* Get the optimal date format for a point, based on a range.
* @param {number} range - The time range
* @param {number|Date} date - The date of the point in question
* @param {number} startOfWeek - An integer representing the first day of
* the week, where 0 is Sunday
* @param {Object} dateTimeLabelFormats - A map of time units to formats
* @return {string} - the optimal date format for a point
*/
getDateFormat: function(range, date, startOfWeek, dateTimeLabelFormats) {
var dateStr = dateFormat('%m-%d %H:%M:%S.%L', date),
format,
n,
blank = '01-01 00:00:00.000',
strpos = {
millisecond: 15,
second: 12,
minute: 9,
hour: 6,
day: 3
},
lastN = 'millisecond'; // for sub-millisecond data, #4223
for (n in timeUnits) {
// If the range is exactly one week and we're looking at a Sunday/Monday, go for the week format
if (range === timeUnits.week && +dateFormat('%w', date) === startOfWeek &&
dateStr.substr(6) === blank.substr(6)) {
n = 'week';
break;
}
// The first format that is too great for the range
if (timeUnits[n] > range) {
n = lastN;
break;
}
// If the point is placed every day at 23:59, we need to show
// the minutes as well. #2637.
if (strpos[n] && dateStr.substr(strpos[n]) !== blank.substr(strpos[n])) {
break;
}
// Weeks are outside the hierarchy, only apply them on Mondays/Sundays like in the first condition
if (n !== 'week') {
lastN = n;
}
}
if (n) {
format = dateTimeLabelFormats[n];
}
return format;
},
/**
* Get the best X date format based on the closest point range on the axis.
*/
getXDateFormat: function(point, options, xAxis) {
var xDateFormat,
dateTimeLabelFormats = options.dateTimeLabelFormats,
closestPointRange = xAxis && xAxis.closestPointRange;
if (closestPointRange) {
xDateFormat = this.getDateFormat(
closestPointRange,
point.x,
xAxis.options.startOfWeek,
dateTimeLabelFormats
);
} else {
xDateFormat = dateTimeLabelFormats.day;
}
return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
},
/**
* Format the footer/header of the tooltip
* #3397: abstraction to enable formatting of footer and header
*/
tooltipFooterHeaderFormatter: function(labelConfig, isFooter) {
var footOrHead = isFooter ? 'footer' : 'header',
series = labelConfig.series,
tooltipOptions = series.tooltipOptions,
xDateFormat = tooltipOptions.xDateFormat,
xAxis = series.xAxis,
isDateTime = xAxis && xAxis.options.type === 'datetime' && isNumber(labelConfig.key),
formatString = tooltipOptions[footOrHead + 'Format'];
// Guess the best date format based on the closest point distance (#568, #3418)
if (isDateTime && !xDateFormat) {
xDateFormat = this.getXDateFormat(labelConfig, tooltipOptions, xAxis);
}
// Insert the footer date format if any
if (isDateTime && xDateFormat) {
formatString = formatString.replace('{point.key}', '{point.key:' + xDateFormat + '}');
}
return format(formatString, {
point: labelConfig,
series: series
});
},
/**
* Build the body (lines) of the tooltip by iterating over the items and returning one entry for each item,
* abstracting this functionality allows to easily overwrite and extend it.
*/
bodyFormatter: function(items) {
return map(items, function(item) {
var tooltipOptions = item.series.tooltipOptions;
return (tooltipOptions.pointFormatter || item.point.tooltipFormatter)
.call(item.point, tooltipOptions.pointFormat);
});
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
attr = H.attr,
charts = H.charts,
color = H.color,
css = H.css,
defined = H.defined,
doc = H.doc,
each = H.each,
extend = H.extend,
fireEvent = H.fireEvent,
offset = H.offset,
pick = H.pick,
removeEvent = H.removeEvent,
splat = H.splat,
Tooltip = H.Tooltip,
win = H.win;
/**
* The mouse tracker object. All methods starting with "on" are primary DOM
* event handlers. Subsequent methods should be named differently from what they
* are doing.
*
* @constructor Pointer
* @param {Object} chart The Chart instance
* @param {Object} options The root options object
*/
H.Pointer = function(chart, options) {
this.init(chart, options);
};
H.Pointer.prototype = {
/**
* Initialize Pointer
*/
init: function(chart, options) {
// Store references
this.options = options;
this.chart = chart;
// Do we need to handle click on a touch device?
this.runChartClick = options.chart.events && !!options.chart.events.click;
this.pinchDown = [];
this.lastValidTouch = {};
if (Tooltip && options.tooltip.enabled) {
chart.tooltip = new Tooltip(chart, options.tooltip);
this.followTouchMove = pick(options.tooltip.followTouchMove, true);
}
this.setDOMEvents();
},
/**
* Resolve the zoomType option, this is reset on all touch start and mouse
* down events.
*/
zoomOption: function(e) {
var chart = this.chart,
options = chart.options.chart,
zoomType = options.zoomType || '',
inverted = chart.inverted,
zoomX,
zoomY;
// Look for the pinchType option
if (/touch/.test(e.type)) {
zoomType = pick(options.pinchType, zoomType);
}
this.zoomX = zoomX = /x/.test(zoomType);
this.zoomY = zoomY = /y/.test(zoomType);
this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
this.hasZoom = zoomX || zoomY;
},
/**
* Add crossbrowser support for chartX and chartY
* @param {Object} e The event object in standard browsers
*/
normalize: function(e, chartPosition) {
var chartX,
chartY,
ePos;
// IE normalizing
e = e || win.event;
if (!e.target) {
e.target = e.srcElement;
}
// iOS (#2757)
ePos = e.touches ? (e.touches.length ? e.touches.item(0) : e.changedTouches[0]) : e;
// Get mouse position
if (!chartPosition) {
this.chartPosition = chartPosition = offset(this.chart.container);
}
// chartX and chartY
if (ePos.pageX === undefined) { // IE < 9. #886.
chartX = Math.max(e.x, e.clientX - chartPosition.left); // #2005, #2129: the second case is
// for IE10 quirks mode within framesets
chartY = e.y;
} else {
chartX = ePos.pageX - chartPosition.left;
chartY = ePos.pageY - chartPosition.top;
}
return extend(e, {
chartX: Math.round(chartX),
chartY: Math.round(chartY)
});
},
/**
* Get the click position in terms of axis values.
*
* @param {Object} e A pointer event
*/
getCoordinates: function(e) {
var coordinates = {
xAxis: [],
yAxis: []
};
each(this.chart.axes, function(axis) {
coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
axis: axis,
value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
});
});
return coordinates;
},
/**
* Collects the points closest to a mouseEvent
* @param {Array} series Array of series to gather points from
* @param {Boolean} shared True if shared tooltip, otherwise false
* @param {Object} e Mouse event which possess a position to compare against
* @return {Array} KDPoints sorted by distance
*/
getKDPoints: function(series, shared, e) {
var kdpoints = [],
noSharedTooltip,
directTouch,
kdpointT,
i;
// Find nearest points on all series
each(series, function(s) {
// Skip hidden series
noSharedTooltip = s.noSharedTooltip && shared;
directTouch = !shared && s.directTouch;
if (s.visible && !directTouch && pick(s.options.enableMouseTracking, true)) { // #3821
// #3828
kdpointT = s.searchPoint(
e, !noSharedTooltip && s.options.findNearestPointBy.indexOf('y') < 0
);
if (kdpointT && kdpointT.series) { // Point.series becomes null when reset and before redraw (#5197)
kdpoints.push(kdpointT);
}
}
});
// Sort kdpoints by distance to mouse pointer
kdpoints.sort(function(p1, p2) {
var isCloserX = p1.distX - p2.distX,
isCloser = p1.dist - p2.dist,
isAbove =
(p2.series.group && p2.series.group.zIndex) -
(p1.series.group && p1.series.group.zIndex),
result;
// We have two points which are not in the same place on xAxis and shared tooltip:
if (isCloserX !== 0 && shared) { // #5721
result = isCloserX;
// Points are not exactly in the same place on x/yAxis:
} else if (isCloser !== 0) {
result = isCloser;
// The same xAxis and yAxis position, sort by z-index:
} else if (isAbove !== 0) {
result = isAbove;
// The same zIndex, sort by array index:
} else {
result = p1.series.index > p2.series.index ? -1 : 1;
}
return result;
});
// Remove points with different x-positions, required for shared tooltip and crosshairs (#4645):
if (shared && kdpoints[0] && !kdpoints[0].series.noSharedTooltip) {
i = kdpoints.length;
while (i--) {
if (kdpoints[i].x !== kdpoints[0].x || kdpoints[i].series.noSharedTooltip) {
kdpoints.splice(i, 1);
}
}
}
return kdpoints;
},
getPointFromEvent: function(e) {
var target = e.target,
point;
while (target && !point) {
point = target.point;
target = target.parentNode;
}
return point;
},
getHoverData: function(existingHoverPoint, existingHoverSeries, series, isDirectTouch, shared, e) {
var hoverPoint = existingHoverPoint,
hoverSeries = existingHoverSeries,
searchSeries,
hoverPoints;
// If it has a hoverPoint and that series requires direct touch (like columns, #3899), or we're on
// a noSharedTooltip series among shared tooltip series (#4546), use the hoverPoint . Otherwise,
// search the k-d tree.
// Handle shared tooltip or cases where a series is not yet hovered
if (isDirectTouch) {
if (shared) {
hoverPoints = [];
each(series, function(s) {
// Skip hidden series
var noSharedTooltip = s.noSharedTooltip && shared,
directTouch = !shared && s.directTouch,
kdpointT;
if (s.visible && !noSharedTooltip && !directTouch && pick(s.options.enableMouseTracking, true)) { // #3821
kdpointT = s.searchKDTree({
clientX: hoverPoint.clientX,
plotY: hoverPoint.plotY
}, !noSharedTooltip && s.kdDimensions === 1);
if (kdpointT && kdpointT.series) { // Point.series becomes null when reset and before redraw (#5197)
hoverPoints.push(kdpointT);
}
}
});
// If kdTree is not built
if (hoverPoints.length === 0) {
hoverPoints = [hoverPoint];
}
} else {
hoverPoints = [hoverPoint];
}
// When the hovered series has stickyTracking false.
} else if (hoverSeries && !hoverSeries.stickyTracking) {
if (!shared) {
series = [hoverSeries];
}
hoverPoints = this.getKDPoints(series, shared, e);
hoverPoint = H.find(hoverPoints, function(p) {
return p.series === hoverSeries;
});
// When the hoverSeries has stickyTracking or there is no series hovered.
} else {
// Avoid series with stickyTracking
searchSeries = H.grep(series, function(s) {
return s.stickyTracking;
});
hoverPoints = this.getKDPoints(searchSeries, shared, e);
hoverPoint = hoverPoints[0];
hoverSeries = hoverPoint && hoverPoint.series;
// If
if (shared) {
hoverPoints = this.getKDPoints(series, shared, e);
}
}
// Keep the order of series in tooltip
// Must be done after assigning of hoverPoint
hoverPoints.sort(function(p1, p2) {
return p1.series.index - p2.series.index;
});
return {
hoverPoint: hoverPoint,
hoverSeries: hoverSeries,
hoverPoints: hoverPoints
};
},
/**
* With line type charts with a single tracker, get the point closest to the mouse.
* Run Point.onMouseOver and display tooltip for the point or points.
*/
runPointActions: function(e, p) {
var pointer = this,
chart = pointer.chart,
series = chart.series,
tooltip = chart.tooltip,
shared = tooltip ? tooltip.shared : false,
hoverPoint = p || chart.hoverPoint,
hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries,
// onMouseOver or already hovering a series with directTouch
isDirectTouch = !!p || (!shared && hoverSeries && hoverSeries.directTouch),
hoverData = this.getHoverData(hoverPoint, hoverSeries, series, isDirectTouch, shared, e),
useSharedTooltip,
followPointer,
anchor,
points;
// Update variables from hoverData.
hoverPoint = hoverData.hoverPoint;
hoverSeries = hoverData.hoverSeries;
followPointer = hoverSeries && hoverSeries.tooltipOptions.followPointer;
useSharedTooltip = shared && hoverPoint && !hoverPoint.series.noSharedTooltip;
points = (useSharedTooltip ?
hoverData.hoverPoints :
(hoverPoint ? [hoverPoint] : [])
);
// Refresh tooltip for kdpoint if new hover point or tooltip was hidden // #3926, #4200
if (
hoverPoint &&
// !(hoverSeries && hoverSeries.directTouch) &&
(hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))
) {
each(chart.hoverPoints || [], function(p) {
if (H.inArray(p, points) === -1) {
p.setState();
}
});
// Do mouseover on all points (#3919, #3985, #4410, #5622)
each(points || [], function(p) {
p.setState('hover');
});
// set normal state to previous series
if (chart.hoverSeries !== hoverSeries) {
hoverSeries.onMouseOver();
}
// If tracking is on series in stead of on each point,
// fire mouseOver on hover point.
if (hoverSeries && !hoverSeries.directTouch) { // #4448
if (chart.hoverPoint) {
chart.hoverPoint.firePointEvent('mouseOut');
}
hoverPoint.firePointEvent('mouseOver');
}
chart.hoverPoints = points;
chart.hoverPoint = hoverPoint;
// Draw tooltip if necessary
if (tooltip) {
tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
}
// Update positions (regardless of kdpoint or hoverPoint)
} else if (followPointer && tooltip && !tooltip.isHidden) {
anchor = tooltip.getAnchor([{}], e);
tooltip.updatePosition({
plotX: anchor[0],
plotY: anchor[1]
});
}
// Start the event listener to pick up the tooltip and crosshairs
if (!pointer.unDocMouseMove) {
pointer.unDocMouseMove = addEvent(doc, 'mousemove', function(e) {
var chart = charts[H.hoverChartIndex];
if (chart) {
chart.pointer.onDocumentMouseMove(e);
}
});
}
// Draw crosshairs (#4927, #5269 #5066, #5658)
each(chart.axes, function drawAxisCrosshair(axis) {
// Snap is true. For each hover point, loop over the axes and draw a
// crosshair if that point belongs to the axis.
// @todo Consider only one crosshair per axis.
if (pick(axis.crosshair.snap, true)) {
each(points, function(p) {
if (p.series[axis.coll] === axis) {
axis.drawCrosshair(e, p);
}
});
} else {
axis.drawCrosshair(e);
}
});
},
/**
* Reset the tracking by hiding the tooltip, the hover series state and the hover point
*
* @param allowMove {Boolean} Instead of destroying the tooltip altogether, allow moving it if possible
*/
reset: function(allowMove, delay) {
var pointer = this,
chart = pointer.chart,
hoverSeries = chart.hoverSeries,
hoverPoint = chart.hoverPoint,
hoverPoints = chart.hoverPoints,
tooltip = chart.tooltip,
tooltipPoints = tooltip && tooltip.shared ? hoverPoints : hoverPoint;
// Check if the points have moved outside the plot area (#1003, #4736, #5101)
if (allowMove && tooltipPoints) {
each(splat(tooltipPoints), function(point) {
if (point.series.isCartesian && point.plotX === undefined) {
allowMove = false;
}
});
}
// Just move the tooltip, #349
if (allowMove) {
if (tooltip && tooltipPoints) {
tooltip.refresh(tooltipPoints);
if (hoverPoint) { // #2500
hoverPoint.setState(hoverPoint.state, true);
each(chart.axes, function(axis) {
if (axis.crosshair) {
axis.drawCrosshair(null, hoverPoint);
}
});
}
}
// Full reset
} else {
if (hoverPoint) {
hoverPoint.onMouseOut();
}
if (hoverPoints) {
each(hoverPoints, function(point) {
point.setState();
});
}
if (hoverSeries) {
hoverSeries.onMouseOut();
}
if (tooltip) {
tooltip.hide(delay);
}
if (pointer.unDocMouseMove) {
pointer.unDocMouseMove = pointer.unDocMouseMove();
}
// Remove crosshairs
each(chart.axes, function(axis) {
axis.hideCrosshair();
});
pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
}
},
/**
* Scale series groups to a certain scale and translation
*/
scaleGroups: function(attribs, clip) {
var chart = this.chart,
seriesAttribs;
// Scale each series
each(chart.series, function(series) {
seriesAttribs = attribs || series.getPlotBox(); // #1701
if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
series.group.attr(seriesAttribs);
if (series.markerGroup) {
series.markerGroup.attr(seriesAttribs);
series.markerGroup.clip(clip ? chart.clipRect : null);
}
if (series.dataLabelsGroup) {
series.dataLabelsGroup.attr(seriesAttribs);
}
}
});
// Clip
chart.clipRect.attr(clip || chart.clipBox);
},
/**
* Start a drag operation
*/
dragStart: function(e) {
var chart = this.chart;
// Record the start position
chart.mouseIsDown = e.type;
chart.cancelClick = false;
chart.mouseDownX = this.mouseDownX = e.chartX;
chart.mouseDownY = this.mouseDownY = e.chartY;
},
/**
* Perform a drag operation in response to a mousemove event while the mouse is down
*/
drag: function(e) {
var chart = this.chart,
chartOptions = chart.options.chart,
chartX = e.chartX,
chartY = e.chartY,
zoomHor = this.zoomHor,
zoomVert = this.zoomVert,
plotLeft = chart.plotLeft,
plotTop = chart.plotTop,
plotWidth = chart.plotWidth,
plotHeight = chart.plotHeight,
clickedInside,
size,
selectionMarker = this.selectionMarker,
mouseDownX = this.mouseDownX,
mouseDownY = this.mouseDownY,
panKey = chartOptions.panKey && e[chartOptions.panKey + 'Key'];
// If the device supports both touch and mouse (like IE11), and we are touch-dragging
// inside the plot area, don't handle the mouse event. #4339.
if (selectionMarker && selectionMarker.touch) {
return;
}
// If the mouse is outside the plot area, adjust to cooordinates
// inside to prevent the selection marker from going outside
if (chartX < plotLeft) {
chartX = plotLeft;
} else if (chartX > plotLeft + plotWidth) {
chartX = plotLeft + plotWidth;
}
if (chartY < plotTop) {
chartY = plotTop;
} else if (chartY > plotTop + plotHeight) {
chartY = plotTop + plotHeight;
}
// determine if the mouse has moved more than 10px
this.hasDragged = Math.sqrt(
Math.pow(mouseDownX - chartX, 2) +
Math.pow(mouseDownY - chartY, 2)
);
if (this.hasDragged > 10) {
clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop);
// make a selection
if (chart.hasCartesianSeries && (this.zoomX || this.zoomY) && clickedInside && !panKey) {
if (!selectionMarker) {
this.selectionMarker = selectionMarker = chart.renderer.rect(
plotLeft,
plotTop,
zoomHor ? 1 : plotWidth,
zoomVert ? 1 : plotHeight,
0
)
.attr({
fill: chartOptions.selectionMarkerFill || color('#335cad').setOpacity(0.25).get(),
'class': 'highcharts-selection-marker',
'zIndex': 7
})
.add();
}
}
// adjust the width of the selection marker
if (selectionMarker && zoomHor) {
size = chartX - mouseDownX;
selectionMarker.attr({
width: Math.abs(size),
x: (size > 0 ? 0 : size) + mouseDownX
});
}
// adjust the height of the selection marker
if (selectionMarker && zoomVert) {
size = chartY - mouseDownY;
selectionMarker.attr({
height: Math.abs(size),
y: (size > 0 ? 0 : size) + mouseDownY
});
}
// panning
if (clickedInside && !selectionMarker && chartOptions.panning) {
chart.pan(e, chartOptions.panning);
}
}
},
/**
* On mouse up or touch end across the entire document, drop the selection.
*/
drop: function(e) {
var pointer = this,
chart = this.chart,
hasPinched = this.hasPinched;
if (this.selectionMarker) {
var selectionData = {
originalEvent: e, // #4890
xAxis: [],
yAxis: []
},
selectionBox = this.selectionMarker,
selectionLeft = selectionBox.attr ? selectionBox.attr('x') : selectionBox.x,
selectionTop = selectionBox.attr ? selectionBox.attr('y') : selectionBox.y,
selectionWidth = selectionBox.attr ? selectionBox.attr('width') : selectionBox.width,
selectionHeight = selectionBox.attr ? selectionBox.attr('height') : selectionBox.height,
runZoom;
// a selection has been made
if (this.hasDragged || hasPinched) {
// record each axis' min and max
each(chart.axes, function(axis) {
if (axis.zoomEnabled && defined(axis.min) && (hasPinched || pointer[{
xAxis: 'zoomX',
yAxis: 'zoomY'
}[axis.coll]])) { // #859, #3569
var horiz = axis.horiz,
minPixelPadding = e.type === 'touchend' ? axis.minPixelPadding : 0, // #1207, #3075
selectionMin = axis.toValue((horiz ? selectionLeft : selectionTop) + minPixelPadding),
selectionMax = axis.toValue((horiz ? selectionLeft + selectionWidth : selectionTop + selectionHeight) - minPixelPadding);
selectionData[axis.coll].push({
axis: axis,
min: Math.min(selectionMin, selectionMax), // for reversed axes
max: Math.max(selectionMin, selectionMax)
});
runZoom = true;
}
});
if (runZoom) {
fireEvent(chart, 'selection', selectionData, function(args) {
chart.zoom(extend(args, hasPinched ? {
animation: false
} : null));
});
}
}
this.selectionMarker = this.selectionMarker.destroy();
// Reset scaling preview
if (hasPinched) {
this.scaleGroups();
}
}
// Reset all
if (chart) { // it may be destroyed on mouse up - #877
css(chart.container, {
cursor: chart._cursor
});
chart.cancelClick = this.hasDragged > 10; // #370
chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
this.pinchDown = [];
}
},
onContainerMouseDown: function(e) {
e = this.normalize(e);
this.zoomOption(e);
// issue #295, dragging not always working in Firefox
if (e.preventDefault) {
e.preventDefault();
}
this.dragStart(e);
},
onDocumentMouseUp: function(e) {
if (charts[H.hoverChartIndex]) {
charts[H.hoverChartIndex].pointer.drop(e);
}
},
/**
* Special handler for mouse move that will hide the tooltip when the mouse leaves the plotarea.
* Issue #149 workaround. The mouseleave event does not always fire.
*/
onDocumentMouseMove: function(e) {
var chart = this.chart,
chartPosition = this.chartPosition;
e = this.normalize(e, chartPosition);
// If we're outside, hide the tooltip
if (chartPosition && !this.inClass(e.target, 'highcharts-tracker') &&
!chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
this.reset();
}
},
/**
* When mouse leaves the container, hide the tooltip.
*/
onContainerMouseLeave: function(e) {
var chart = charts[H.hoverChartIndex];
if (chart && (e.relatedTarget || e.toElement)) { // #4886, MS Touch end fires mouseleave but with no related target
chart.pointer.reset();
chart.pointer.chartPosition = null; // also reset the chart position, used in #149 fix
}
},
// The mousemove, touchmove and touchstart event handler
onContainerMouseMove: function(e) {
var chart = this.chart;
if (!defined(H.hoverChartIndex) || !charts[H.hoverChartIndex] || !charts[H.hoverChartIndex].mouseIsDown) {
H.hoverChartIndex = chart.index;
}
e = this.normalize(e);
e.returnValue = false; // #2251, #3224
if (chart.mouseIsDown === 'mousedown') {
this.drag(e);
}
// Show the tooltip and run mouse over events (#977)
if ((this.inClass(e.target, 'highcharts-tracker') ||
chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) && !chart.openMenu) {
this.runPointActions(e);
}
},
/**
* Utility to detect whether an element has, or has a parent with, a specific
* class name. Used on detection of tracker objects and on deciding whether
* hovering the tooltip should cause the active series to mouse out.
*/
inClass: function(element, className) {
var elemClassName;
while (element) {
elemClassName = attr(element, 'class');
if (elemClassName) {
if (elemClassName.indexOf(className) !== -1) {
return true;
}
if (elemClassName.indexOf('highcharts-container') !== -1) {
return false;
}
}
element = element.parentNode;
}
},
onTrackerMouseOut: function(e) {
var series = this.chart.hoverSeries,
relatedTarget = e.relatedTarget || e.toElement;
if (series && relatedTarget && !series.stickyTracking &&
!this.inClass(relatedTarget, 'highcharts-tooltip') &&
(!this.inClass(relatedTarget, 'highcharts-series-' + series.index) || // #2499, #4465
!this.inClass(relatedTarget, 'highcharts-tracker') // #5553
)
) {
series.onMouseOut();
}
},
onContainerClick: function(e) {
var chart = this.chart,
hoverPoint = chart.hoverPoint,
plotLeft = chart.plotLeft,
plotTop = chart.plotTop;
e = this.normalize(e);
if (!chart.cancelClick) {
// On tracker click, fire the series and point events. #783, #1583
if (hoverPoint && this.inClass(e.target, 'highcharts-tracker')) {
// the series click event
fireEvent(hoverPoint.series, 'click', extend(e, {
point: hoverPoint
}));
// the point click event
if (chart.hoverPoint) { // it may be destroyed (#1844)
hoverPoint.firePointEvent('click', e);
}
// When clicking outside a tracker, fire a chart event
} else {
extend(e, this.getCoordinates(e));
// fire a click event in the chart
if (chart.isInsidePlot(e.chartX - plotLeft, e.chartY - plotTop)) {
fireEvent(chart, 'click', e);
}
}
}
},
/**
* Set the JS DOM events on the container and document. This method should contain
* a one-to-one assignment between methods and their handlers. Any advanced logic should
* be moved to the handler reflecting the event's name.
*/
setDOMEvents: function() {
var pointer = this,
container = pointer.chart.container;
container.onmousedown = function(e) {
pointer.onContainerMouseDown(e);
};
container.onmousemove = function(e) {
pointer.onContainerMouseMove(e);
};
container.onclick = function(e) {
pointer.onContainerClick(e);
};
addEvent(container, 'mouseleave', pointer.onContainerMouseLeave);
if (H.chartCount === 1) {
addEvent(doc, 'mouseup', pointer.onDocumentMouseUp);
}
if (H.hasTouch) {
container.ontouchstart = function(e) {
pointer.onContainerTouchStart(e);
};
container.ontouchmove = function(e) {
pointer.onContainerTouchMove(e);
};
if (H.chartCount === 1) {
addEvent(doc, 'touchend', pointer.onDocumentTouchEnd);
}
}
},
/**
* Destroys the Pointer object and disconnects DOM events.
*/
destroy: function() {
var prop;
if (this.unDocMouseMove) {
this.unDocMouseMove();
}
removeEvent(
this.chart.container,
'mouseleave',
this.onContainerMouseLeave
);
if (!H.chartCount) {
removeEvent(doc, 'mouseup', this.onDocumentMouseUp);
removeEvent(doc, 'touchend', this.onDocumentTouchEnd);
}
// memory and CPU leak
clearInterval(this.tooltipTimeout);
for (prop in this) {
this[prop] = null;
}
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var charts = H.charts,
each = H.each,
extend = H.extend,
map = H.map,
noop = H.noop,
pick = H.pick,
Pointer = H.Pointer;
/* Support for touch devices */
extend(Pointer.prototype, /** @lends Pointer.prototype */ {
/**
* Run translation operations
*/
pinchTranslate: function(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
if (this.zoomHor) {
this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
}
if (this.zoomVert) {
this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
}
},
/**
* Run translation operations for each direction (horizontal and vertical) independently
*/
pinchTranslateDirection: function(horiz, pinchDown, touches, transform,
selectionMarker, clip, lastValidTouch, forcedScale) {
var chart = this.chart,
xy = horiz ? 'x' : 'y',
XY = horiz ? 'X' : 'Y',
sChartXY = 'chart' + XY,
wh = horiz ? 'width' : 'height',
plotLeftTop = chart['plot' + (horiz ? 'Left' : 'Top')],
selectionWH,
selectionXY,
clipXY,
scale = forcedScale || 1,
inverted = chart.inverted,
bounds = chart.bounds[horiz ? 'h' : 'v'],
singleTouch = pinchDown.length === 1,
touch0Start = pinchDown[0][sChartXY],
touch0Now = touches[0][sChartXY],
touch1Start = !singleTouch && pinchDown[1][sChartXY],
touch1Now = !singleTouch && touches[1][sChartXY],
outOfBounds,
transformScale,
scaleKey,
setScale = function() {
// Don't zoom if fingers are too close on this axis
if (!singleTouch && Math.abs(touch0Start - touch1Start) > 20) {
scale = forcedScale || Math.abs(touch0Now - touch1Now) / Math.abs(touch0Start - touch1Start);
}
clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale;
};
// Set the scale, first pass
setScale();
selectionXY = clipXY; // the clip position (x or y) is altered if out of bounds, the selection position is not
// Out of bounds
if (selectionXY < bounds.min) {
selectionXY = bounds.min;
outOfBounds = true;
} else if (selectionXY + selectionWH > bounds.max) {
selectionXY = bounds.max - selectionWH;
outOfBounds = true;
}
// Is the chart dragged off its bounds, determined by dataMin and dataMax?
if (outOfBounds) {
// Modify the touchNow position in order to create an elastic drag movement. This indicates
// to the user that the chart is responsive but can't be dragged further.
touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
if (!singleTouch) {
touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
}
// Set the scale, second pass to adapt to the modified touchNow positions
setScale();
} else {
lastValidTouch[xy] = [touch0Now, touch1Now];
}
// Set geometry for clipping, selection and transformation
if (!inverted) {
clip[xy] = clipXY - plotLeftTop;
clip[wh] = selectionWH;
}
scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
transformScale = inverted ? 1 / scale : scale;
selectionMarker[wh] = selectionWH;
selectionMarker[xy] = selectionXY;
transform[scaleKey] = scale;
transform['translate' + XY] = (transformScale * plotLeftTop) + (touch0Now - (transformScale * touch0Start));
},
/**
* Handle touch events with two touches
*/
pinch: function(e) {
var self = this,
chart = self.chart,
pinchDown = self.pinchDown,
touches = e.touches,
touchesLength = touches.length,
lastValidTouch = self.lastValidTouch,
hasZoom = self.hasZoom,
selectionMarker = self.selectionMarker,
transform = {},
fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, 'highcharts-tracker') &&
chart.runTrackerClick) || self.runChartClick),
clip = {};
// Don't initiate panning until the user has pinched. This prevents us from
// blocking page scrolling as users scroll down a long page (#4210).
if (touchesLength > 1) {
self.initiated = true;
}
// On touch devices, only proceed to trigger click if a handler is defined
if (hasZoom && self.initiated && !fireClickEvent) {
e.preventDefault();
}
// Normalize each touch
map(touches, function(e) {
return self.normalize(e);
});
// Register the touch start position
if (e.type === 'touchstart') {
each(touches, function(e, i) {
pinchDown[i] = {
chartX: e.chartX,
chartY: e.chartY
};
});
lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] && pinchDown[1].chartX];
lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] && pinchDown[1].chartY];
// Identify the data bounds in pixels
each(chart.axes, function(axis) {
if (axis.zoomEnabled) {
var bounds = chart.bounds[axis.horiz ? 'h' : 'v'],
minPixelPadding = axis.minPixelPadding,
min = axis.toPixels(pick(axis.options.min, axis.dataMin)),
max = axis.toPixels(pick(axis.options.max, axis.dataMax)),
absMin = Math.min(min, max),
absMax = Math.max(min, max);
// Store the bounds for use in the touchmove handler
bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
bounds.max = Math.max(axis.pos + axis.len, absMax + minPixelPadding);
}
});
self.res = true; // reset on next move
// Optionally move the tooltip on touchmove
} else if (self.followTouchMove && touchesLength === 1) {
this.runPointActions(self.normalize(e));
// Event type is touchmove, handle panning and pinching
} else if (pinchDown.length) { // can be 0 when releasing, if touchend fires first
// Set the marker
if (!selectionMarker) {
self.selectionMarker = selectionMarker = extend({
destroy: noop,
touch: true
}, chart.plotBox);
}
self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
self.hasPinched = hasZoom;
// Scale and translate the groups to provide visual feedback during pinching
self.scaleGroups(transform, clip);
if (self.res) {
self.res = false;
this.reset(false, 0);
}
}
},
/**
* General touch handler shared by touchstart and touchmove.
*/
touch: function(e, start) {
var chart = this.chart,
hasMoved,
pinchDown,
isInside;
if (chart.index !== H.hoverChartIndex) {
this.onContainerMouseLeave({
relatedTarget: true
});
}
H.hoverChartIndex = chart.index;
if (e.touches.length === 1) {
e = this.normalize(e);
isInside = chart.isInsidePlot(
e.chartX - chart.plotLeft,
e.chartY - chart.plotTop
);
if (isInside && !chart.openMenu) {
// Run mouse events and display tooltip etc
if (start) {
this.runPointActions(e);
}
// Android fires touchmove events after the touchstart even if the
// finger hasn't moved, or moved only a pixel or two. In iOS however,
// the touchmove doesn't fire unless the finger moves more than ~4px.
// So we emulate this behaviour in Android by checking how much it
// moved, and cancelling on small distances. #3450.
if (e.type === 'touchmove') {
pinchDown = this.pinchDown;
hasMoved = pinchDown[0] ? Math.sqrt( // #5266
Math.pow(pinchDown[0].chartX - e.chartX, 2) +
Math.pow(pinchDown[0].chartY - e.chartY, 2)
) >= 4 : false;
}
if (pick(hasMoved, true)) {
this.pinch(e);
}
} else if (start) {
// Hide the tooltip on touching outside the plot area (#1203)
this.reset();
}
} else if (e.touches.length === 2) {
this.pinch(e);
}
},
onContainerTouchStart: function(e) {
this.zoomOption(e);
this.touch(e, true);
},
onContainerTouchMove: function(e) {
this.touch(e);
},
onDocumentTouchEnd: function(e) {
if (charts[H.hoverChartIndex]) {
charts[H.hoverChartIndex].pointer.drop(e);
}
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
charts = H.charts,
css = H.css,
doc = H.doc,
extend = H.extend,
noop = H.noop,
Pointer = H.Pointer,
removeEvent = H.removeEvent,
win = H.win,
wrap = H.wrap;
if (win.PointerEvent || win.MSPointerEvent) {
// The touches object keeps track of the points being touched at all times
var touches = {},
hasPointerEvent = !!win.PointerEvent,
getWebkitTouches = function() {
var key,
fake = [];
fake.item = function(i) {
return this[i];
};
for (key in touches) {
if (touches.hasOwnProperty(key)) {
fake.push({
pageX: touches[key].pageX,
pageY: touches[key].pageY,
target: touches[key].target
});
}
}
return fake;
},
translateMSPointer = function(e, method, wktype, func) {
var p;
if ((e.pointerType === 'touch' || e.pointerType === e.MSPOINTER_TYPE_TOUCH) && charts[H.hoverChartIndex]) {
func(e);
p = charts[H.hoverChartIndex].pointer;
p[method]({
type: wktype,
target: e.currentTarget,
preventDefault: noop,
touches: getWebkitTouches()
});
}
};
/**
* Extend the Pointer prototype with methods for each event handler and more
*/
extend(Pointer.prototype, /** @lends Pointer.prototype */ {
onContainerPointerDown: function(e) {
translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function(e) {
touches[e.pointerId] = {
pageX: e.pageX,
pageY: e.pageY,
target: e.currentTarget
};
});
},
onContainerPointerMove: function(e) {
translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function(e) {
touches[e.pointerId] = {
pageX: e.pageX,
pageY: e.pageY
};
if (!touches[e.pointerId].target) {
touches[e.pointerId].target = e.currentTarget;
}
});
},
onDocumentPointerUp: function(e) {
translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function(e) {
delete touches[e.pointerId];
});
},
/**
* Add or remove the MS Pointer specific events
*/
batchMSEvents: function(fn) {
fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
}
});
// Disable default IE actions for pinch and such on chart element
wrap(Pointer.prototype, 'init', function(proceed, chart, options) {
proceed.call(this, chart, options);
if (this.hasZoom) { // #4014
css(chart.container, {
'-ms-touch-action': 'none',
'touch-action': 'none'
});
}
});
// Add IE specific touch events to chart
wrap(Pointer.prototype, 'setDOMEvents', function(proceed) {
proceed.apply(this);
if (this.hasZoom || this.followTouchMove) {
this.batchMSEvents(addEvent);
}
});
// Destroy MS events also
wrap(Pointer.prototype, 'destroy', function(proceed) {
this.batchMSEvents(removeEvent);
proceed.call(this);
});
}
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Legend,
addEvent = H.addEvent,
css = H.css,
discardElement = H.discardElement,
defined = H.defined,
each = H.each,
isFirefox = H.isFirefox,
marginNames = H.marginNames,
merge = H.merge,
pick = H.pick,
setAnimation = H.setAnimation,
stableSort = H.stableSort,
win = H.win,
wrap = H.wrap;
/**
* The overview of the chart's series.
* @class
*/
Legend = H.Legend = function(chart, options) {
this.init(chart, options);
};
Legend.prototype = {
/**
* Initialize the legend
*/
init: function(chart, options) {
this.chart = chart;
this.setOptions(options);
if (options.enabled) {
// Render it
this.render();
// move checkboxes
addEvent(this.chart, 'endResize', function() {
this.legend.positionCheckboxes();
});
}
},
setOptions: function(options) {
var padding = pick(options.padding, 8);
this.options = options;
this.itemStyle = options.itemStyle;
this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
this.itemMarginTop = options.itemMarginTop || 0;
this.padding = padding;
this.initialItemY = padding - 5; // 5 is pixels above the text
this.maxItemWidth = 0;
this.itemHeight = 0;
this.symbolWidth = pick(options.symbolWidth, 16);
this.pages = [];
},
/**
* Update the legend with new options. Equivalent to running chart.update
* with a legend configuration option.
* @param {Object} options Legend options
* @param {Boolean} redraw Whether to redraw the chart, defaults to true.
*/
update: function(options, redraw) {
var chart = this.chart;
this.setOptions(merge(true, this.options, options));
this.destroy();
chart.isDirtyLegend = chart.isDirtyBox = true;
if (pick(redraw, true)) {
chart.redraw();
}
},
/**
* Set the colors for the legend item
* @param {Object} item A Series or Point instance
* @param {Object} visible Dimmed or colored
*/
colorizeItem: function(item, visible) {
item.legendGroup[visible ? 'removeClass' : 'addClass'](
'highcharts-legend-item-hidden'
);
var legend = this,
options = legend.options,
legendItem = item.legendItem,
legendLine = item.legendLine,
legendSymbol = item.legendSymbol,
hiddenColor = legend.itemHiddenStyle.color,
textColor = visible ? options.itemStyle.color : hiddenColor,
symbolColor = visible ? (item.color || hiddenColor) : hiddenColor,
markerOptions = item.options && item.options.marker,
symbolAttr = {
fill: symbolColor
},
key;
if (legendItem) {
legendItem.css({
fill: textColor,
color: textColor // #1553, oldIE
});
}
if (legendLine) {
legendLine.attr({
stroke: symbolColor
});
}
if (legendSymbol) {
// Apply marker options
if (markerOptions && legendSymbol.isMarker) { // #585
//symbolAttr.stroke = symbolColor;
symbolAttr = item.pointAttribs();
if (!visible) {
for (key in symbolAttr) {
symbolAttr[key] = hiddenColor;
}
}
}
legendSymbol.attr(symbolAttr);
}
},
/**
* Position the legend item
* @param {Object} item A Series or Point instance
*/
positionItem: function(item) {
var legend = this,
options = legend.options,
symbolPadding = options.symbolPadding,
ltr = !options.rtl,
legendItemPos = item._legendItemPos,
itemX = legendItemPos[0],
itemY = legendItemPos[1],
checkbox = item.checkbox,
legendGroup = item.legendGroup;
if (legendGroup && legendGroup.element) {
legendGroup.translate(
ltr ?
itemX :
legend.legendWidth - itemX - 2 * symbolPadding - 4,
itemY
);
}
if (checkbox) {
checkbox.x = itemX;
checkbox.y = itemY;
}
},
/**
* Destroy a single legend item
* @param {Object} item The series or point
*/
destroyItem: function(item) {
var checkbox = item.checkbox;
// destroy SVG elements
each(
['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'],
function(key) {
if (item[key]) {
item[key] = item[key].destroy();
}
}
);
if (checkbox) {
discardElement(item.checkbox);
}
},
/**
* Destroys the legend.
*/
destroy: function() {
function destroyItems(key) {
if (this[key]) {
this[key] = this[key].destroy();
}
}
// Destroy items
each(this.getAllItems(), function(item) {
each(['legendItem', 'legendGroup'], destroyItems, item);
});
// Destroy legend elements
each([
'clipRect',
'up',
'down',
'pager',
'nav',
'box',
'title',
'group'
], destroyItems, this);
this.display = null; // Reset in .render on update.
},
/**
* Position the checkboxes after the width is determined
*/
positionCheckboxes: function(scrollOffset) {
var alignAttr = this.group && this.group.alignAttr,
translateY,
clipHeight = this.clipHeight || this.legendHeight,
titleHeight = this.titleHeight;
if (alignAttr) {
translateY = alignAttr.translateY;
each(this.allItems, function(item) {
var checkbox = item.checkbox,
top;
if (checkbox) {
top = translateY + titleHeight + checkbox.y +
(scrollOffset || 0) + 3;
css(checkbox, {
left: (alignAttr.translateX + item.checkboxOffset +
checkbox.x - 20) + 'px',
top: top + 'px',
display: top > translateY - 6 && top < translateY +
clipHeight - 6 ? '' : 'none'
});
}
});
}
},
/**
* Render the legend title on top of the legend
*/
renderTitle: function() {
var options = this.options,
padding = this.padding,
titleOptions = options.title,
titleHeight = 0,
bBox;
if (titleOptions.text) {
if (!this.title) {
this.title = this.chart.renderer.label(
titleOptions.text,
padding - 3,
padding - 4,
null,
null,
null,
null,
null,
'legend-title'
)
.attr({
zIndex: 1
})
.css(titleOptions.style)
.add(this.group);
}
bBox = this.title.getBBox();
titleHeight = bBox.height;
this.offsetWidth = bBox.width; // #1717
this.contentGroup.attr({
translateY: titleHeight
});
}
this.titleHeight = titleHeight;
},
/**
* Set the legend item text
*/
setText: function(item) {
var options = this.options;
item.legendItem.attr({
text: options.labelFormat ?
H.format(options.labelFormat, item) : options.labelFormatter.call(item)
});
},
/**
* Render a single specific legend item
* @param {Object} item A series or point
*/
renderItem: function(item) {
var legend = this,
chart = legend.chart,
renderer = chart.renderer,
options = legend.options,
horizontal = options.layout === 'horizontal',
symbolWidth = legend.symbolWidth,
symbolPadding = options.symbolPadding,
itemStyle = legend.itemStyle,
itemHiddenStyle = legend.itemHiddenStyle,
padding = legend.padding,
itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
ltr = !options.rtl,
itemHeight,
widthOption = options.width,
itemMarginBottom = options.itemMarginBottom || 0,
itemMarginTop = legend.itemMarginTop,
bBox,
itemWidth,
li = item.legendItem,
isSeries = !item.series,
series = !isSeries && item.series.drawLegendSymbol ?
item.series :
item,
seriesOptions = series.options,
showCheckbox = legend.createCheckboxForItem &&
seriesOptions &&
seriesOptions.showCheckbox,
useHTML = options.useHTML,
fontSize = 12,
itemClassName = item.options.className;
if (!li) { // generate it once, later move it
// Generate the group box, a group to hold the symbol and text. Text
// is to be appended in Legend class.
item.legendGroup = renderer.g('legend-item')
.addClass(
'highcharts-' + series.type + '-series ' +
'highcharts-color-' + item.colorIndex +
(itemClassName ? ' ' + itemClassName : '') +
(isSeries ? ' highcharts-series-' + item.index : '')
)
.attr({
zIndex: 1
})
.add(legend.scrollGroup);
// Generate the list item text and add it to the group
item.legendItem = li = renderer.text(
'',
ltr ? symbolWidth + symbolPadding : -symbolPadding,
legend.baseline || 0,
useHTML
)
// merge to prevent modifying original (#1021)
.css(merge(item.visible ? itemStyle : itemHiddenStyle))
.attr({
align: ltr ? 'left' : 'right',
zIndex: 2
})
.add(item.legendGroup);
// Get the baseline for the first item - the font size is equal for
// all
if (!legend.baseline) {
fontSize = itemStyle.fontSize;
legend.fontMetrics = renderer.fontMetrics(
fontSize,
li
);
legend.baseline = legend.fontMetrics.f + 3 + itemMarginTop;
li.attr('y', legend.baseline);
}
// Draw the legend symbol inside the group box
legend.symbolHeight = options.symbolHeight || legend.fontMetrics.f;
series.drawLegendSymbol(legend, item);
if (legend.setItemEvents) {
legend.setItemEvents(item, li, useHTML);
}
// add the HTML checkbox on top
if (showCheckbox) {
legend.createCheckboxForItem(item);
}
}
// Colorize the items
legend.colorizeItem(item, item.visible);
// Always update the text
legend.setText(item);
// calculate the positions for the next line
bBox = li.getBBox();
itemWidth = item.checkboxOffset =
options.itemWidth ||
item.legendItemWidth ||
symbolWidth + symbolPadding + bBox.width + itemDistance +
(showCheckbox ? 20 : 0);
legend.itemHeight = itemHeight = Math.round(
item.legendItemHeight || bBox.height || legend.symbolHeight
);
// If the item exceeds the width, start a new line
if (
horizontal &&
legend.itemX - padding + itemWidth > (
widthOption || (
chart.spacingBox.width - 2 * padding - options.x
)
)
) {
legend.itemX = padding;
legend.itemY += itemMarginTop + legend.lastLineHeight +
itemMarginBottom;
legend.lastLineHeight = 0; // reset for next line (#915, #3976)
}
// If the item exceeds the height, start a new column
/*if (!horizontal && legend.itemY + options.y +
itemHeight > chart.chartHeight - spacingTop - spacingBottom) {
legend.itemY = legend.initialItemY;
legend.itemX += legend.maxItemWidth;
legend.maxItemWidth = 0;
}*/
// Set the edge positions
legend.maxItemWidth = Math.max(legend.maxItemWidth, itemWidth);
legend.lastItemY = itemMarginTop + legend.itemY + itemMarginBottom;
legend.lastLineHeight = Math.max( // #915
itemHeight,
legend.lastLineHeight
);
// cache the position of the newly generated or reordered items
item._legendItemPos = [legend.itemX, legend.itemY];
// advance
if (horizontal) {
legend.itemX += itemWidth;
} else {
legend.itemY += itemMarginTop + itemHeight + itemMarginBottom;
legend.lastLineHeight = itemHeight;
}
// the width of the widest item
legend.offsetWidth = widthOption || Math.max(
(horizontal ? legend.itemX - padding - itemDistance : itemWidth) +
padding,
legend.offsetWidth
);
},
/**
* Get all items, which is one item per series for normal series and one
* item per point for pie series.
*/
getAllItems: function() {
var allItems = [];
each(this.chart.series, function(series) {
var seriesOptions = series && series.options;
// Handle showInLegend. If the series is linked to another series,
// defaults to false.
if (series && pick(
seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? undefined : false, true
)) {
// Use points or series for the legend item depending on
// legendType
allItems = allItems.concat(
series.legendItems ||
(
seriesOptions.legendType === 'point' ?
series.data :
series
)
);
}
});
return allItems;
},
/**
* Adjust the chart margins by reserving space for the legend on only one
* side of the chart. If the position is set to a corner, top or bottom is
* reserved for horizontal legends and left or right for vertical ones.
*/
adjustMargins: function(margin, spacing) {
var chart = this.chart,
options = this.options,
// Use the first letter of each alignment option in order to detect
// the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
alignment = options.align.charAt(0) +
options.verticalAlign.charAt(0) +
options.layout.charAt(0);
if (!options.floating) {
each([
/(lth|ct|rth)/,
/(rtv|rm|rbv)/,
/(rbh|cb|lbh)/,
/(lbv|lm|ltv)/
], function(alignments, side) {
if (alignments.test(alignment) && !defined(margin[side])) {
// Now we have detected on which side of the chart we should
// reserve space for the legend
chart[marginNames[side]] = Math.max(
chart[marginNames[side]],
(
chart.legend[
(side + 1) % 2 ? 'legendHeight' : 'legendWidth'
] + [1, -1, -1, 1][side] * options[
(side % 2) ? 'x' : 'y'
] +
pick(options.margin, 12) +
spacing[side]
)
);
}
});
}
},
/**
* Render the legend. This method can be called both before and after
* chart.render. If called after, it will only rearrange items instead
* of creating new ones.
*/
render: function() {
var legend = this,
chart = legend.chart,
renderer = chart.renderer,
legendGroup = legend.group,
allItems,
display,
legendWidth,
legendHeight,
box = legend.box,
options = legend.options,
padding = legend.padding;
legend.itemX = padding;
legend.itemY = legend.initialItemY;
legend.offsetWidth = 0;
legend.lastItemY = 0;
if (!legendGroup) {
legend.group = legendGroup = renderer.g('legend')
.attr({
zIndex: 7
})
.add();
legend.contentGroup = renderer.g()
.attr({
zIndex: 1
}) // above background
.add(legendGroup);
legend.scrollGroup = renderer.g()
.add(legend.contentGroup);
}
legend.renderTitle();
// add each series or point
allItems = legend.getAllItems();
// sort by legendIndex
stableSort(allItems, function(a, b) {
return ((a.options && a.options.legendIndex) || 0) -
((b.options && b.options.legendIndex) || 0);
});
// reversed legend
if (options.reversed) {
allItems.reverse();
}
legend.allItems = allItems;
legend.display = display = !!allItems.length;
// render the items
legend.lastLineHeight = 0;
each(allItems, function(item) {
legend.renderItem(item);
});
// Get the box
legendWidth = (options.width || legend.offsetWidth) + padding;
legendHeight = legend.lastItemY + legend.lastLineHeight +
legend.titleHeight;
legendHeight = legend.handleOverflow(legendHeight);
legendHeight += padding;
// Draw the border and/or background
if (!box) {
legend.box = box = renderer.rect()
.addClass('highcharts-legend-box')
.attr({
r: options.borderRadius
})
.add(legendGroup);
box.isNew = true;
}
// Presentational
box
.attr({
stroke: options.borderColor,
'stroke-width': options.borderWidth || 0,
fill: options.backgroundColor || 'none'
})
.shadow(options.shadow);
if (legendWidth > 0 && legendHeight > 0) {
box[box.isNew ? 'attr' : 'animate'](
box.crisp({
x: 0,
y: 0,
width: legendWidth,
height: legendHeight
}, box.strokeWidth())
);
box.isNew = false;
}
// hide the border if no items
box[display ? 'show' : 'hide']();
legend.legendWidth = legendWidth;
legend.legendHeight = legendHeight;
// Now that the legend width and height are established, put the items
// in the final position
each(allItems, function(item) {
legend.positionItem(item);
});
// 1.x compatibility: positioning based on style
/*var props = ['left', 'right', 'top', 'bottom'],
prop,
i = 4;
while (i--) {
prop = props[i];
if (options.style[prop] && options.style[prop] !== 'auto') {
options[i < 2 ? 'align' : 'verticalAlign'] = prop;
options[i < 2 ? 'x' : 'y'] =
pInt(options.style[prop]) * (i % 2 ? -1 : 1);
}
}*/
if (display) {
legendGroup.align(merge(options, {
width: legendWidth,
height: legendHeight
}), true, 'spacingBox');
}
if (!chart.isResizing) {
this.positionCheckboxes();
}
},
/**
* Set up the overflow handling by adding navigation with up and down arrows
* below the legend.
*/
handleOverflow: function(legendHeight) {
var legend = this,
chart = this.chart,
renderer = chart.renderer,
options = this.options,
optionsY = options.y,
alignTop = options.verticalAlign === 'top',
padding = this.padding,
spaceHeight = chart.spacingBox.height +
(alignTop ? -optionsY : optionsY) - padding,
maxHeight = options.maxHeight,
clipHeight,
clipRect = this.clipRect,
navOptions = options.navigation,
animation = pick(navOptions.animation, true),
arrowSize = navOptions.arrowSize || 12,
nav = this.nav,
pages = this.pages,
lastY,
allItems = this.allItems,
clipToHeight = function(height) {
if (height) {
clipRect.attr({
height: height
});
} else if (clipRect) { // Reset (#5912)
legend.clipRect = clipRect.destroy();
legend.contentGroup.clip();
}
// useHTML
if (legend.contentGroup.div) {
legend.contentGroup.div.style.clip = height ?
'rect(' + padding + 'px,9999px,' +
(padding + height) + 'px,0)' :
'auto';
}
};
// Adjust the height
if (
options.layout === 'horizontal' &&
options.verticalAlign !== 'middle' &&
!options.floating
) {
spaceHeight /= 2;
}
if (maxHeight) {
spaceHeight = Math.min(spaceHeight, maxHeight);
}
// Reset the legend height and adjust the clipping rectangle
pages.length = 0;
if (legendHeight > spaceHeight && navOptions.enabled !== false) {
this.clipHeight = clipHeight =
Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
this.currentPage = pick(this.currentPage, 1);
this.fullHeight = legendHeight;
// Fill pages with Y positions so that the top of each a legend item
// defines the scroll top for each page (#2098)
each(allItems, function(item, i) {
var y = item._legendItemPos[1],
h = Math.round(item.legendItem.getBBox().height),
len = pages.length;
if (!len || (y - pages[len - 1] > clipHeight &&
(lastY || y) !== pages[len - 1])) {
pages.push(lastY || y);
len++;
}
if (i === allItems.length - 1 &&
y + h - pages[len - 1] > clipHeight) {
pages.push(y);
}
if (y !== lastY) {
lastY = y;
}
});
// Only apply clipping if needed. Clipping causes blurred legend in
// PDF export (#1787)
if (!clipRect) {
clipRect = legend.clipRect =
renderer.clipRect(0, padding, 9999, 0);
legend.contentGroup.clip(clipRect);
}
clipToHeight(clipHeight);
// Add navigation elements
if (!nav) {
this.nav = nav = renderer.g()
.attr({
zIndex: 1
})
.add(this.group);
this.up = renderer
.symbol(
'triangle',
0,
0,
arrowSize,
arrowSize
)
.on('click', function() {
legend.scroll(-1, animation);
})
.add(nav);
this.pager = renderer.text('', 15, 10)
.addClass('highcharts-legend-navigation')
.css(navOptions.style)
.add(nav);
this.down = renderer
.symbol(
'triangle-down',
0,
0,
arrowSize,
arrowSize
)
.on('click', function() {
legend.scroll(1, animation);
})
.add(nav);
}
// Set initial position
legend.scroll(0);
legendHeight = spaceHeight;
// Reset
} else if (nav) {
clipToHeight();
this.nav = nav.destroy(); // #6322
this.scrollGroup.attr({
translateY: 1
});
this.clipHeight = 0; // #1379
}
return legendHeight;
},
/**
* Scroll the legend by a number of pages
* @param {Object} scrollBy
* @param {Object} animation
*/
scroll: function(scrollBy, animation) {
var pages = this.pages,
pageCount = pages.length,
currentPage = this.currentPage + scrollBy,
clipHeight = this.clipHeight,
navOptions = this.options.navigation,
pager = this.pager,
padding = this.padding,
scrollOffset;
// When resizing while looking at the last page
if (currentPage > pageCount) {
currentPage = pageCount;
}
if (currentPage > 0) {
if (animation !== undefined) {
setAnimation(animation, this.chart);
}
this.nav.attr({
translateX: padding,
translateY: clipHeight + this.padding + 7 + this.titleHeight,
visibility: 'visible'
});
this.up.attr({
'class': currentPage === 1 ?
'highcharts-legend-nav-inactive' : 'highcharts-legend-nav-active'
});
pager.attr({
text: currentPage + '/' + pageCount
});
this.down.attr({
'x': 18 + this.pager.getBBox().width, // adjust to text width
'class': currentPage === pageCount ?
'highcharts-legend-nav-inactive' : 'highcharts-legend-nav-active'
});
this.up
.attr({
fill: currentPage === 1 ?
navOptions.inactiveColor : navOptions.activeColor
})
.css({
cursor: currentPage === 1 ? 'default' : 'pointer'
});
this.down
.attr({
fill: currentPage === pageCount ?
navOptions.inactiveColor : navOptions.activeColor
})
.css({
cursor: currentPage === pageCount ? 'default' : 'pointer'
});
scrollOffset = -pages[currentPage - 1] + this.initialItemY;
this.scrollGroup.animate({
translateY: scrollOffset
});
this.currentPage = currentPage;
this.positionCheckboxes(scrollOffset);
}
}
};
/*
* LegendSymbolMixin
*/
H.LegendSymbolMixin = {
/**
* Get the series' symbol in the legend
*
* @param {Object} legend The legend object
* @param {Object} item The series (this) or point
*/
drawRectangle: function(legend, item) {
var options = legend.options,
symbolHeight = legend.symbolHeight,
square = options.squareSymbol,
symbolWidth = square ? symbolHeight : legend.symbolWidth;
item.legendSymbol = this.chart.renderer.rect(
square ? (legend.symbolWidth - symbolHeight) / 2 : 0,
legend.baseline - symbolHeight + 1, // #3988
symbolWidth,
symbolHeight,
pick(legend.options.symbolRadius, symbolHeight / 2)
)
.addClass('highcharts-point')
.attr({
zIndex: 3
}).add(item.legendGroup);
},
/**
* Get the series' symbol in the legend. This method should be overridable
* to create custom symbols through
* Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
*
* @param {Object} legend The legend object
*/
drawLineMarker: function(legend) {
var options = this.options,
markerOptions = options.marker,
radius,
legendSymbol,
symbolWidth = legend.symbolWidth,
symbolHeight = legend.symbolHeight,
generalRadius = symbolHeight / 2,
renderer = this.chart.renderer,
legendItemGroup = this.legendGroup,
verticalCenter = legend.baseline -
Math.round(legend.fontMetrics.b * 0.3),
attr = {};
// Draw the line
attr = {
'stroke-width': options.lineWidth || 0
};
if (options.dashStyle) {
attr.dashstyle = options.dashStyle;
}
this.legendLine = renderer.path([
'M',
0,
verticalCenter,
'L',
symbolWidth,
verticalCenter
])
.addClass('highcharts-graph')
.attr(attr)
.add(legendItemGroup);
// Draw the marker
if (markerOptions && markerOptions.enabled !== false) {
// Do not allow the marker to be larger than the symbolHeight
radius = Math.min(
pick(markerOptions.radius, generalRadius),
generalRadius
);
// Restrict symbol markers size
if (this.symbol.indexOf('url') === 0) {
markerOptions = merge(markerOptions, {
width: symbolHeight,
height: symbolHeight
});
radius = 0;
}
this.legendSymbol = legendSymbol = renderer.symbol(
this.symbol,
(symbolWidth / 2) - radius,
verticalCenter - radius,
2 * radius,
2 * radius,
markerOptions
)
.addClass('highcharts-point')
.add(legendItemGroup);
legendSymbol.isMarker = true;
}
}
};
// Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
// and for #2580, a similar drawing flaw in Firefox 26.
// Explore if there's a general cause for this. The problem may be related
// to nested group elements, as the legend item texts are within 4 group
// elements.
if (/Trident\/7\.0/.test(win.navigator.userAgent) || isFirefox) {
wrap(Legend.prototype, 'positionItem', function(proceed, item) {
var legend = this,
// If chart destroyed in sync, this is undefined (#2030)
runPositionItem = function() {
if (item._legendItemPos) {
proceed.call(legend, item);
}
};
// Do it now, for export and to get checkbox placement
runPositionItem();
// Do it after to work around the core issue
setTimeout(runPositionItem);
});
}
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animate = H.animate,
animObject = H.animObject,
attr = H.attr,
doc = H.doc,
Axis = H.Axis, // @todo add as requirement
createElement = H.createElement,
defaultOptions = H.defaultOptions,
discardElement = H.discardElement,
charts = H.charts,
css = H.css,
defined = H.defined,
each = H.each,
extend = H.extend,
find = H.find,
fireEvent = H.fireEvent,
getStyle = H.getStyle,
grep = H.grep,
isNumber = H.isNumber,
isObject = H.isObject,
isString = H.isString,
Legend = H.Legend, // @todo add as requirement
marginNames = H.marginNames,
merge = H.merge,
Pointer = H.Pointer, // @todo add as requirement
pick = H.pick,
pInt = H.pInt,
removeEvent = H.removeEvent,
seriesTypes = H.seriesTypes,
splat = H.splat,
svg = H.svg,
syncTimeout = H.syncTimeout,
win = H.win,
Renderer = H.Renderer;
/**
* The Chart class.
* @class Highcharts.Chart
* @memberOf Highcharts
* @param {String|HTMLDOMElement} renderTo - The DOM element to render to, or its
* id.
* @param {ChartOptions} options - The chart options structure.
* @param {Function} callback - Function to run when the chart has loaded.
*/
var Chart = H.Chart = function() {
this.getArgs.apply(this, arguments);
};
H.chart = function(a, b, c) {
return new Chart(a, b, c);
};
Chart.prototype = {
/**
* Hook for modules
*/
callbacks: [],
/**
* Handle the arguments passed to the constructor
* @returns {Array} Arguments without renderTo
*/
getArgs: function() {
var args = [].slice.call(arguments);
// Remove the optional first argument, renderTo, and
// set it on this.
if (isString(args[0]) || args[0].nodeName) {
this.renderTo = args.shift();
}
this.init(args[0], args[1]);
},
/**
* Initialize the chart
*/
init: function(userOptions, callback) {
// Handle regular options
var options,
seriesOptions = userOptions.series; // skip merging data points to increase performance
userOptions.series = null;
options = merge(defaultOptions, userOptions); // do the merge
options.series = userOptions.series = seriesOptions; // set back the series data
this.userOptions = userOptions;
var optionsChart = options.chart;
var chartEvents = optionsChart.events;
this.margin = [];
this.spacing = [];
//this.runChartClick = chartEvents && !!chartEvents.click;
this.bounds = {
h: {},
v: {}
}; // Pixel data bounds for touch zoom
this.callback = callback;
this.isResizing = 0;
this.options = options;
//chartTitleOptions = undefined;
//chartSubtitleOptions = undefined;
this.axes = [];
this.series = [];
this.hasCartesianSeries = optionsChart.showAxes;
//this.axisOffset = undefined;
//this.inverted = undefined;
//this.loadingShown = undefined;
//this.container = undefined;
//this.chartWidth = undefined;
//this.chartHeight = undefined;
//this.marginRight = undefined;
//this.marginBottom = undefined;
//this.containerWidth = undefined;
//this.containerHeight = undefined;
//this.oldChartWidth = undefined;
//this.oldChartHeight = undefined;
//this.renderTo = undefined;
//this.renderToClone = undefined;
//this.spacingBox = undefined
//this.legend = undefined;
// Elements
//this.chartBackground = undefined;
//this.plotBackground = undefined;
//this.plotBGImage = undefined;
//this.plotBorder = undefined;
//this.loadingDiv = undefined;
//this.loadingSpan = undefined;
var chart = this,
eventType;
// Add the chart to the global lookup
chart.index = charts.length;
charts.push(chart);
H.chartCount++;
// Chart event handlers
if (chartEvents) {
for (eventType in chartEvents) {
addEvent(chart, eventType, chartEvents[eventType]);
}
}
chart.xAxis = [];
chart.yAxis = [];
chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;
chart.firstRender();
},
/**
* Initialize an individual series, called internally before render time
*/
initSeries: function(options) {
var chart = this,
optionsChart = chart.options.chart,
type = options.type || optionsChart.type || optionsChart.defaultSeriesType,
series,
Constr = seriesTypes[type];
// No such series type
if (!Constr) {
H.error(17, true);
}
series = new Constr();
series.init(this, options);
return series;
},
/**
* Order all series above a given index. When series are added and ordered
* by configuration, only the last series is handled (#248, #1123, #2456,
* #6112). This function is called on series initialization and destroy.
*
* @param {number} fromIndex - If this is given, only the series above this
* index are handled.
*/
orderSeries: function(fromIndex) {
var series = this.series,
i = fromIndex || 0;
for (; i < series.length; i++) {
if (series[i]) {
series[i].index = i;
series[i].name = series[i].name ||
'Series ' + (series[i].index + 1);
}
}
},
/**
* Check whether a given point is within the plot area
*
* @param {Number} plotX Pixel x relative to the plot area
* @param {Number} plotY Pixel y relative to the plot area
* @param {Boolean} inverted Whether the chart is inverted
*/
isInsidePlot: function(plotX, plotY, inverted) {
var x = inverted ? plotY : plotX,
y = inverted ? plotX : plotY;
return x >= 0 &&
x <= this.plotWidth &&
y >= 0 &&
y <= this.plotHeight;
},
/**
* Redraw legend, axes or series based on updated data
*
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
redraw: function(animation) {
var chart = this,
axes = chart.axes,
series = chart.series,
pointer = chart.pointer,
legend = chart.legend,
redrawLegend = chart.isDirtyLegend,
hasStackedSeries,
hasDirtyStacks,
hasCartesianSeries = chart.hasCartesianSeries,
isDirtyBox = chart.isDirtyBox,
i,
serie,
renderer = chart.renderer,
isHiddenChart = renderer.isHidden(),
afterRedraw = [];
// Handle responsive rules, not only on resize (#6130)
if (chart.setResponsive) {
chart.setResponsive(false);
}
H.setAnimation(animation, chart);
if (isHiddenChart) {
chart.cloneRenderTo();
}
// Adjust title layout (reflow multiline text)
chart.layOutTitles();
// link stacked series
i = series.length;
while (i--) {
serie = series[i];
if (serie.options.stacking) {
hasStackedSeries = true;
if (serie.isDirty) {
hasDirtyStacks = true;
break;
}
}
}
if (hasDirtyStacks) { // mark others as dirty
i = series.length;
while (i--) {
serie = series[i];
if (serie.options.stacking) {
serie.isDirty = true;
}
}
}
// Handle updated data in the series
each(series, function(serie) {
if (serie.isDirty) {
if (serie.options.legendType === 'point') {
if (serie.updateTotals) {
serie.updateTotals();
}
redrawLegend = true;
}
}
if (serie.isDirtyData) {
fireEvent(serie, 'updatedData');
}
});
// handle added or removed series
if (redrawLegend && legend.options.enabled) { // series or pie points are added or removed
// draw legend graphics
legend.render();
chart.isDirtyLegend = false;
}
// reset stacks
if (hasStackedSeries) {
chart.getStacks();
}
if (hasCartesianSeries) {
// set axes scales
each(axes, function(axis) {
axis.updateNames();
axis.setScale();
});
}
chart.getMargins(); // #3098
if (hasCartesianSeries) {
// If one axis is dirty, all axes must be redrawn (#792, #2169)
each(axes, function(axis) {
if (axis.isDirty) {
isDirtyBox = true;
}
});
// redraw axes
each(axes, function(axis) {
// Fire 'afterSetExtremes' only if extremes are set
var key = axis.min + ',' + axis.max;
if (axis.extKey !== key) { // #821, #4452
axis.extKey = key;
afterRedraw.push(function() { // prevent a recursive call to chart.redraw() (#1119)
fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
delete axis.eventArgs;
});
}
if (isDirtyBox || hasStackedSeries) {
axis.redraw();
}
});
}
// the plot areas size has changed
if (isDirtyBox) {
chart.drawChartBox();
}
// Fire an event before redrawing series, used by the boost module to
// clear previous series renderings.
fireEvent(chart, 'predraw');
// redraw affected series
each(series, function(serie) {
if ((isDirtyBox || serie.isDirty) && serie.visible) {
serie.redraw();
}
// Set it here, otherwise we will have unlimited 'updatedData' calls
// for a hidden series after setData(). Fixes #6012
serie.isDirtyData = false;
});
// move tooltip or reset
if (pointer) {
pointer.reset(true);
}
// redraw if canvas
renderer.draw();
// Fire the events
fireEvent(chart, 'redraw');
fireEvent(chart, 'render');
if (isHiddenChart) {
chart.cloneRenderTo(true);
}
// Fire callbacks that are put on hold until after the redraw
each(afterRedraw, function(callback) {
callback.call();
});
},
/**
* Get an axis, series or point object by id.
* @param id {String} The id as given in the configuration options
*/
get: function(id) {
var ret,
series = this.series,
i;
function itemById(item) {
return item.id === id || (item.options && item.options.id === id);
}
ret =
// Search axes
find(this.axes, itemById) ||
// Search series
find(this.series, itemById);
// Search points
for (i = 0; !ret && i < series.length; i++) {
ret = find(series[i].points || [], itemById);
}
return ret;
},
/**
* Create the Axis instances based on the config options
*/
getAxes: function() {
var chart = this,
options = this.options,
xAxisOptions = options.xAxis = splat(options.xAxis || {}),
yAxisOptions = options.yAxis = splat(options.yAxis || {}),
optionsArray;
// make sure the options are arrays and add some members
each(xAxisOptions, function(axis, i) {
axis.index = i;
axis.isX = true;
});
each(yAxisOptions, function(axis, i) {
axis.index = i;
});
// concatenate all axis options into one array
optionsArray = xAxisOptions.concat(yAxisOptions);
each(optionsArray, function(axisOptions) {
new Axis(chart, axisOptions); // eslint-disable-line no-new
});
},
/**
* Get the currently selected points from all series
*/
getSelectedPoints: function() {
var points = [];
each(this.series, function(serie) {
points = points.concat(grep(serie.points || [], function(point) {
return point.selected;
}));
});
return points;
},
/**
* Get the currently selected series
*/
getSelectedSeries: function() {
return grep(this.series, function(serie) {
return serie.selected;
});
},
/**
* Show the title and subtitle of the chart
*
* @param titleOptions {Object} New title options
* @param subtitleOptions {Object} New subtitle options
*
*/
setTitle: function(titleOptions, subtitleOptions, redraw) {
var chart = this,
options = chart.options,
chartTitleOptions,
chartSubtitleOptions;
chartTitleOptions = options.title = merge(
// Default styles
{
style: {
color: '#333333',
fontSize: options.isStock ? '16px' : '18px' // #2944
}
},
options.title,
titleOptions
);
chartSubtitleOptions = options.subtitle = merge(
// Default styles
{
style: {
color: '#666666'
}
},
options.subtitle,
subtitleOptions
);
// add title and subtitle
each([
['title', titleOptions, chartTitleOptions],
['subtitle', subtitleOptions, chartSubtitleOptions]
], function(arr, i) {
var name = arr[0],
title = chart[name],
titleOptions = arr[1],
chartTitleOptions = arr[2];
if (title && titleOptions) {
chart[name] = title = title.destroy(); // remove old
}
if (chartTitleOptions && chartTitleOptions.text && !title) {
chart[name] = chart.renderer.text(
chartTitleOptions.text,
0,
0,
chartTitleOptions.useHTML
)
.attr({
align: chartTitleOptions.align,
'class': 'highcharts-' + name,
zIndex: chartTitleOptions.zIndex || 4
})
.add();
// Update methods, shortcut to Chart.setTitle
chart[name].update = function(o) {
chart.setTitle(!i && o, i && o);
};
// Presentational
chart[name].css(chartTitleOptions.style);
}
});
chart.layOutTitles(redraw);
},
/**
* Lay out the chart titles and cache the full offset height for use
* in getMargins
*/
layOutTitles: function(redraw) {
var titleOffset = 0,
requiresDirtyBox,
renderer = this.renderer,
spacingBox = this.spacingBox;
// Lay out the title and the subtitle respectively
each(['title', 'subtitle'], function(key) {
var title = this[key],
titleOptions = this.options[key],
titleSize;
if (title) {
titleSize = titleOptions.style.fontSize;
titleSize = renderer.fontMetrics(titleSize, title).b;
title
.css({
width: (titleOptions.width ||
spacingBox.width + titleOptions.widthAdjust) + 'px'
})
.align(extend({
y: titleOffset + titleSize + (key === 'title' ? -3 : 2)
}, titleOptions), false, 'spacingBox');
if (!titleOptions.floating && !titleOptions.verticalAlign) {
titleOffset = Math.ceil(
titleOffset +
// Skip the cache for HTML (#3481)
title.getBBox(titleOptions.useHTML).height
);
}
}
}, this);
requiresDirtyBox = this.titleOffset !== titleOffset;
this.titleOffset = titleOffset; // used in getMargins
if (!this.isDirtyBox && requiresDirtyBox) {
this.isDirtyBox = requiresDirtyBox;
// Redraw if necessary (#2719, #2744)
if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
this.redraw();
}
}
},
/**
* Get chart width and height according to options and container size
*/
getChartSize: function() {
var chart = this,
optionsChart = chart.options.chart,
widthOption = optionsChart.width,
heightOption = optionsChart.height,
renderTo = chart.renderToClone || chart.renderTo;
// Get inner width and height
if (!defined(widthOption)) {
chart.containerWidth = getStyle(renderTo, 'width');
}
if (!defined(heightOption)) {
chart.containerHeight = getStyle(renderTo, 'height');
}
chart.chartWidth = Math.max( // #1393
0,
widthOption || chart.containerWidth || 600 // #1460
);
chart.chartHeight = Math.max(
0,
H.relativeLength(
heightOption,
chart.chartWidth
) || chart.containerHeight || 400
);
},
/**
* Create a clone of the chart's renderTo div and place it outside the viewport to allow
* size computation on chart.render and chart.redraw
*/
cloneRenderTo: function(revert) {
var clone = this.renderToClone,
container = this.container;
// Destroy the clone and bring the container back to the real renderTo div
if (revert) {
if (clone) {
while (clone.childNodes.length) { // #5231
this.renderTo.appendChild(clone.firstChild);
}
discardElement(clone);
delete this.renderToClone;
}
// Set up the clone
} else {
if (container && container.parentNode === this.renderTo) {
this.renderTo.removeChild(container); // do not clone this
}
this.renderToClone = clone = this.renderTo.cloneNode(0);
css(clone, {
position: 'absolute',
top: '-9999px',
display: 'block' // #833
});
if (clone.style.setProperty) { // #2631
clone.style.setProperty('display', 'block', 'important');
}
doc.body.appendChild(clone);
if (container) {
clone.appendChild(container);
}
}
},
/**
* Setter for the chart class name
*/
setClassName: function(className) {
this.container.className = 'highcharts-container ' + (className || '');
},
/**
* Get the containing element, determine the size and create the inner container
* div to hold the chart
*/
getContainer: function() {
var chart = this,
container,
options = chart.options,
optionsChart = options.chart,
chartWidth,
chartHeight,
renderTo = chart.renderTo,
indexAttrName = 'data-highcharts-chart',
oldChartIndex,
Ren,
containerId = H.uniqueKey(),
containerStyle,
key;
if (!renderTo) {
chart.renderTo = renderTo = optionsChart.renderTo;
}
if (isString(renderTo)) {
chart.renderTo = renderTo = doc.getElementById(renderTo);
}
// Display an error if the renderTo is wrong
if (!renderTo) {
H.error(13, true);
}
// If the container already holds a chart, destroy it. The check for hasRendered is there
// because web pages that are saved to disk from the browser, will preserve the data-highcharts-chart
// attribute and the SVG contents, but not an interactive chart. So in this case,
// charts[oldChartIndex] will point to the wrong chart if any (#2609).
oldChartIndex = pInt(attr(renderTo, indexAttrName));
if (isNumber(oldChartIndex) && charts[oldChartIndex] && charts[oldChartIndex].hasRendered) {
charts[oldChartIndex].destroy();
}
// Make a reference to the chart from the div
attr(renderTo, indexAttrName, chart.index);
// remove previous chart
renderTo.innerHTML = '';
// If the container doesn't have an offsetWidth, it has or is a child of
// a node that has display:none. We need to temporarily move it out to a
// visible state to determine the size, else the legend and tooltips
// won't render properly. The skipClone option is used in sparklines as
// a micro optimization, saving about 1-2 ms each chart.
if (!optionsChart.skipClone && !renderTo.offsetWidth) {
chart.cloneRenderTo();
}
// get the width and height
chart.getChartSize();
chartWidth = chart.chartWidth;
chartHeight = chart.chartHeight;
// Create the inner container
containerStyle = extend({
position: 'relative',
overflow: 'hidden', // needed for context menu (avoid scrollbars) and
// content overflow in IE
width: chartWidth + 'px',
height: chartHeight + 'px',
textAlign: 'left',
lineHeight: 'normal', // #427
zIndex: 0, // #1072
'-webkit-tap-highlight-color': 'rgba(0,0,0,0)'
}, optionsChart.style);
chart.container = container = createElement(
'div', {
id: containerId
},
containerStyle,
chart.renderToClone || renderTo
);
// cache the cursor (#1650)
chart._cursor = container.style.cursor;
// Initialize the renderer
Ren = H[optionsChart.renderer] || Renderer;
chart.renderer = new Ren(
container,
chartWidth,
chartHeight,
null,
optionsChart.forExport,
options.exporting && options.exporting.allowHTML
);
chart.setClassName(optionsChart.className);
chart.renderer.setStyle(optionsChart.style);
// Add a reference to the charts index
chart.renderer.chartIndex = chart.index;
},
/**
* Calculate margins by rendering axis labels in a preliminary position. Title,
* subtitle and legend have already been rendered at this stage, but will be
* moved into their final positions
*/
getMargins: function(skipAxes) {
var chart = this,
spacing = chart.spacing,
margin = chart.margin,
titleOffset = chart.titleOffset;
chart.resetMargins();
// Adjust for title and subtitle
if (titleOffset && !defined(margin[0])) {
chart.plotTop = Math.max(chart.plotTop, titleOffset + chart.options.title.margin + spacing[0]);
}
// Adjust for legend
if (chart.legend.display) {
chart.legend.adjustMargins(margin, spacing);
}
// adjust for scroller
if (chart.extraMargin) {
chart[chart.extraMargin.type] = (chart[chart.extraMargin.type] || 0) + chart.extraMargin.value;
}
if (chart.extraTopMargin) {
chart.plotTop += chart.extraTopMargin;
}
if (!skipAxes) {
this.getAxisMargins();
}
},
getAxisMargins: function() {
var chart = this,
axisOffset = chart.axisOffset = [0, 0, 0, 0], // top, right, bottom, left
margin = chart.margin;
// pre-render axes to get labels offset width
if (chart.hasCartesianSeries) {
each(chart.axes, function(axis) {
if (axis.visible) {
axis.getOffset();
}
});
}
// Add the axis offsets
each(marginNames, function(m, side) {
if (!defined(margin[side])) {
chart[m] += axisOffset[side];
}
});
chart.setChartSize();
},
/**
* Resize the chart to its container if size is not explicitly set
*/
reflow: function(e) {
var chart = this,
optionsChart = chart.options.chart,
renderTo = chart.renderTo,
hasUserWidth = defined(optionsChart.width),
width = optionsChart.width || getStyle(renderTo, 'width'),
height = optionsChart.height || getStyle(renderTo, 'height'),
target = e ? e.target : win;
// Width and height checks for display:none. Target is doc in IE8 and Opera,
// win in Firefox, Chrome and IE9.
if (!hasUserWidth && !chart.isPrinting && width && height && (target === win || target === doc)) { // #1093
if (width !== chart.containerWidth || height !== chart.containerHeight) {
clearTimeout(chart.reflowTimeout);
// When called from window.resize, e is set, else it's called directly (#2224)
chart.reflowTimeout = syncTimeout(function() {
if (chart.container) { // It may have been destroyed in the meantime (#1257)
chart.setSize(undefined, undefined, false);
}
}, e ? 100 : 0);
}
chart.containerWidth = width;
chart.containerHeight = height;
}
},
/**
* Add the event handlers necessary for auto resizing
*/
initReflow: function() {
var chart = this,
unbind;
unbind = addEvent(win, 'resize', function(e) {
chart.reflow(e);
});
addEvent(chart, 'destroy', unbind);
// The following will add listeners to re-fit the chart before and after
// printing (#2284). However it only works in WebKit. Should have worked
// in Firefox, but not supported in IE.
/*
if (win.matchMedia) {
win.matchMedia('print').addListener(function reflow() {
chart.reflow();
});
}
*/
},
/**
* Resize the chart to a given width and height
* @param {Number} width
* @param {Number} height
* @param {Object|Boolean} animation
*/
setSize: function(width, height, animation) {
var chart = this,
renderer = chart.renderer,
globalAnimation;
// Handle the isResizing counter
chart.isResizing += 1;
// set the animation for the current process
H.setAnimation(animation, chart);
chart.oldChartHeight = chart.chartHeight;
chart.oldChartWidth = chart.chartWidth;
if (width !== undefined) {
chart.options.chart.width = width;
}
if (height !== undefined) {
chart.options.chart.height = height;
}
chart.getChartSize();
// Resize the container with the global animation applied if enabled (#2503)
globalAnimation = renderer.globalAnimation;
(globalAnimation ? animate : css)(chart.container, {
width: chart.chartWidth + 'px',
height: chart.chartHeight + 'px'
}, globalAnimation);
chart.setChartSize(true);
renderer.setSize(chart.chartWidth, chart.chartHeight, animation);
// handle axes
each(chart.axes, function(axis) {
axis.isDirty = true;
axis.setScale();
});
chart.isDirtyLegend = true; // force legend redraw
chart.isDirtyBox = true; // force redraw of plot and chart border
chart.layOutTitles(); // #2857
chart.getMargins();
chart.redraw(animation);
chart.oldChartHeight = null;
fireEvent(chart, 'resize');
// Fire endResize and set isResizing back. If animation is disabled, fire without delay
syncTimeout(function() {
if (chart) {
fireEvent(chart, 'endResize', null, function() {
chart.isResizing -= 1;
});
}
}, animObject(globalAnimation).duration);
},
/**
* Set the public chart properties. This is done before and after the pre-render
* to determine margin sizes
*/
setChartSize: function(skipAxes) {
var chart = this,
inverted = chart.inverted,
renderer = chart.renderer,
chartWidth = chart.chartWidth,
chartHeight = chart.chartHeight,
optionsChart = chart.options.chart,
spacing = chart.spacing,
clipOffset = chart.clipOffset,
clipX,
clipY,
plotLeft,
plotTop,
plotWidth,
plotHeight,
plotBorderWidth;
chart.plotLeft = plotLeft = Math.round(chart.plotLeft);
chart.plotTop = plotTop = Math.round(chart.plotTop);
chart.plotWidth = plotWidth = Math.max(0, Math.round(chartWidth - plotLeft - chart.marginRight));
chart.plotHeight = plotHeight = Math.max(0, Math.round(chartHeight - plotTop - chart.marginBottom));
chart.plotSizeX = inverted ? plotHeight : plotWidth;
chart.plotSizeY = inverted ? plotWidth : plotHeight;
chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;
// Set boxes used for alignment
chart.spacingBox = renderer.spacingBox = {
x: spacing[3],
y: spacing[0],
width: chartWidth - spacing[3] - spacing[1],
height: chartHeight - spacing[0] - spacing[2]
};
chart.plotBox = renderer.plotBox = {
x: plotLeft,
y: plotTop,
width: plotWidth,
height: plotHeight
};
plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2);
clipX = Math.ceil(Math.max(plotBorderWidth, clipOffset[3]) / 2);
clipY = Math.ceil(Math.max(plotBorderWidth, clipOffset[0]) / 2);
chart.clipBox = {
x: clipX,
y: clipY,
width: Math.floor(chart.plotSizeX - Math.max(plotBorderWidth, clipOffset[1]) / 2 - clipX),
height: Math.max(0, Math.floor(chart.plotSizeY - Math.max(plotBorderWidth, clipOffset[2]) / 2 - clipY))
};
if (!skipAxes) {
each(chart.axes, function(axis) {
axis.setAxisSize();
axis.setAxisTranslation();
});
}
},
/**
* Initial margins before auto size margins are applied
*/
resetMargins: function() {
var chart = this,
chartOptions = chart.options.chart;
// Create margin and spacing array
each(['margin', 'spacing'], function splashArrays(target) {
var value = chartOptions[target],
values = isObject(value) ? value : [value, value, value, value];
each(['Top', 'Right', 'Bottom', 'Left'], function(sideName, side) {
chart[target][side] = pick(chartOptions[target + sideName], values[side]);
});
});
// Set margin names like chart.plotTop, chart.plotLeft, chart.marginRight, chart.marginBottom.
each(marginNames, function(m, side) {
chart[m] = pick(chart.margin[side], chart.spacing[side]);
});
chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
chart.clipOffset = [0, 0, 0, 0];
},
/**
* Draw the borders and backgrounds for chart and plot area
*/
drawChartBox: function() {
var chart = this,
optionsChart = chart.options.chart,
renderer = chart.renderer,
chartWidth = chart.chartWidth,
chartHeight = chart.chartHeight,
chartBackground = chart.chartBackground,
plotBackground = chart.plotBackground,
plotBorder = chart.plotBorder,
chartBorderWidth,
plotBGImage = chart.plotBGImage,
chartBackgroundColor = optionsChart.backgroundColor,
plotBackgroundColor = optionsChart.plotBackgroundColor,
plotBackgroundImage = optionsChart.plotBackgroundImage,
mgn,
bgAttr,
plotLeft = chart.plotLeft,
plotTop = chart.plotTop,
plotWidth = chart.plotWidth,
plotHeight = chart.plotHeight,
plotBox = chart.plotBox,
clipRect = chart.clipRect,
clipBox = chart.clipBox,
verb = 'animate';
// Chart area
if (!chartBackground) {
chart.chartBackground = chartBackground = renderer.rect()
.addClass('highcharts-background')
.add();
verb = 'attr';
}
// Presentational
chartBorderWidth = optionsChart.borderWidth || 0;
mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
bgAttr = {
fill: chartBackgroundColor || 'none'
};
if (chartBorderWidth || chartBackground['stroke-width']) { // #980
bgAttr.stroke = optionsChart.borderColor;
bgAttr['stroke-width'] = chartBorderWidth;
}
chartBackground
.attr(bgAttr)
.shadow(optionsChart.shadow);
chartBackground[verb]({
x: mgn / 2,
y: mgn / 2,
width: chartWidth - mgn - chartBorderWidth % 2,
height: chartHeight - mgn - chartBorderWidth % 2,
r: optionsChart.borderRadius
});
// Plot background
verb = 'animate';
if (!plotBackground) {
verb = 'attr';
chart.plotBackground = plotBackground = renderer.rect()
.addClass('highcharts-plot-background')
.add();
}
plotBackground[verb](plotBox);
// Presentational attributes for the background
plotBackground
.attr({
fill: plotBackgroundColor || 'none'
})
.shadow(optionsChart.plotShadow);
// Create the background image
if (plotBackgroundImage) {
if (!plotBGImage) {
chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight)
.add();
} else {
plotBGImage.animate(plotBox);
}
}
// Plot clip
if (!clipRect) {
chart.clipRect = renderer.clipRect(clipBox);
} else {
clipRect.animate({
width: clipBox.width,
height: clipBox.height
});
}
// Plot area border
verb = 'animate';
if (!plotBorder) {
verb = 'attr';
chart.plotBorder = plotBorder = renderer.rect()
.addClass('highcharts-plot-border')
.attr({
zIndex: 1 // Above the grid
})
.add();
}
// Presentational
plotBorder.attr({
stroke: optionsChart.plotBorderColor,
'stroke-width': optionsChart.plotBorderWidth || 0,
fill: 'none'
});
plotBorder[verb](plotBorder.crisp({
x: plotLeft,
y: plotTop,
width: plotWidth,
height: plotHeight
}, -plotBorder.strokeWidth())); //#3282 plotBorder should be negative;
// reset
chart.isDirtyBox = false;
},
/**
* Detect whether a certain chart property is needed based on inspecting its options
* and series. This mainly applies to the chart.inverted property, and in extensions to
* the chart.angular and chart.polar properties.
*/
propFromSeries: function() {
var chart = this,
optionsChart = chart.options.chart,
klass,
seriesOptions = chart.options.series,
i,
value;
each(['inverted', 'angular', 'polar'], function(key) {
// The default series type's class
klass = seriesTypes[optionsChart.type || optionsChart.defaultSeriesType];
// Get the value from available chart-wide properties
value =
optionsChart[key] || // It is set in the options
(klass && klass.prototype[key]); // The default series class requires it
// 4. Check if any the chart's series require it
i = seriesOptions && seriesOptions.length;
while (!value && i--) {
klass = seriesTypes[seriesOptions[i].type];
if (klass && klass.prototype[key]) {
value = true;
}
}
// Set the chart property
chart[key] = value;
});
},
/**
* Link two or more series together. This is done initially from Chart.render,
* and after Chart.addSeries and Series.remove.
*/
linkSeries: function() {
var chart = this,
chartSeries = chart.series;
// Reset links
each(chartSeries, function(series) {
series.linkedSeries.length = 0;
});
// Apply new links
each(chartSeries, function(series) {
var linkedTo = series.options.linkedTo;
if (isString(linkedTo)) {
if (linkedTo === ':previous') {
linkedTo = chart.series[series.index - 1];
} else {
linkedTo = chart.get(linkedTo);
}
if (linkedTo && linkedTo.linkedParent !== series) { // #3341 avoid mutual linking
linkedTo.linkedSeries.push(series);
series.linkedParent = linkedTo;
series.visible = pick(series.options.visible, linkedTo.options.visible, series.visible); // #3879
}
}
});
},
/**
* Render series for the chart
*/
renderSeries: function() {
each(this.series, function(serie) {
serie.translate();
serie.render();
});
},
/**
* Render labels for the chart
*/
renderLabels: function() {
var chart = this,
labels = chart.options.labels;
if (labels.items) {
each(labels.items, function(label) {
var style = extend(labels.style, label.style),
x = pInt(style.left) + chart.plotLeft,
y = pInt(style.top) + chart.plotTop + 12;
// delete to prevent rewriting in IE
delete style.left;
delete style.top;
chart.renderer.text(
label.html,
x,
y
)
.attr({
zIndex: 2
})
.css(style)
.add();
});
}
},
/**
* Render all graphics for the chart
*/
render: function() {
var chart = this,
axes = chart.axes,
renderer = chart.renderer,
options = chart.options,
tempWidth,
tempHeight,
redoHorizontal,
redoVertical;
// Title
chart.setTitle();
// Legend
chart.legend = new Legend(chart, options.legend);
// Get stacks
if (chart.getStacks) {
chart.getStacks();
}
// Get chart margins
chart.getMargins(true);
chart.setChartSize();
// Record preliminary dimensions for later comparison
tempWidth = chart.plotWidth;
tempHeight = chart.plotHeight = chart.plotHeight - 21; // 21 is the most common correction for X axis labels
// Get margins by pre-rendering axes
each(axes, function(axis) {
axis.setScale();
});
chart.getAxisMargins();
// If the plot area size has changed significantly, calculate tick positions again
redoHorizontal = tempWidth / chart.plotWidth > 1.1;
redoVertical = tempHeight / chart.plotHeight > 1.05; // Height is more sensitive
if (redoHorizontal || redoVertical) {
each(axes, function(axis) {
if ((axis.horiz && redoHorizontal) || (!axis.horiz && redoVertical)) {
axis.setTickInterval(true); // update to reflect the new margins
}
});
chart.getMargins(); // second pass to check for new labels
}
// Draw the borders and backgrounds
chart.drawChartBox();
// Axes
if (chart.hasCartesianSeries) {
each(axes, function(axis) {
if (axis.visible) {
axis.render();
}
});
}
// The series
if (!chart.seriesGroup) {
chart.seriesGroup = renderer.g('series-group')
.attr({
zIndex: 3
})
.add();
}
chart.renderSeries();
// Labels
chart.renderLabels();
// Credits
chart.addCredits();
// Handle responsiveness
if (chart.setResponsive) {
chart.setResponsive();
}
// Set flag
chart.hasRendered = true;
},
/**
* Show chart credits based on config options
*/
addCredits: function(credits) {
var chart = this;
credits = merge(true, this.options.credits, credits);
if (credits.enabled && !this.credits) {
this.credits = this.renderer.text(
credits.text + (this.mapCredits || ''),
0,
0
)
.addClass('highcharts-credits')
.on('click', function() {
if (credits.href) {
win.location.href = credits.href;
}
})
.attr({
align: credits.position.align,
zIndex: 8
})
.css(credits.style)
.add()
.align(credits.position);
// Dynamically update
this.credits.update = function(options) {
chart.credits = chart.credits.destroy();
chart.addCredits(options);
};
}
},
/**
* Clean up memory usage
*/
destroy: function() {
var chart = this,
axes = chart.axes,
series = chart.series,
container = chart.container,
i,
parentNode = container && container.parentNode;
// fire the chart.destoy event
fireEvent(chart, 'destroy');
// Delete the chart from charts lookup array
charts[chart.index] = undefined;
H.chartCount--;
chart.renderTo.removeAttribute('data-highcharts-chart');
// remove events
removeEvent(chart);
// ==== Destroy collections:
// Destroy axes
i = axes.length;
while (i--) {
axes[i] = axes[i].destroy();
}
// Destroy scroller & scroller series before destroying base series
if (this.scroller && this.scroller.destroy) {
this.scroller.destroy();
}
// Destroy each series
i = series.length;
while (i--) {
series[i] = series[i].destroy();
}
// ==== Destroy chart properties:
each([
'title', 'subtitle', 'chartBackground', 'plotBackground',
'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
'renderer'
], function(name) {
var prop = chart[name];
if (prop && prop.destroy) {
chart[name] = prop.destroy();
}
});
// remove container and all SVG
if (container) { // can break in IE when destroyed before finished loading
container.innerHTML = '';
removeEvent(container);
if (parentNode) {
discardElement(container);
}
}
// clean it all up
for (i in chart) {
delete chart[i];
}
},
/**
* VML namespaces can't be added until after complete. Listening
* for Perini's doScroll hack is not enough.
*/
isReadyToRender: function() {
var chart = this;
// Note: win == win.top is required
if ((!svg && (win == win.top && doc.readyState !== 'complete'))) { // eslint-disable-line eqeqeq
doc.attachEvent('onreadystatechange', function() {
doc.detachEvent('onreadystatechange', chart.firstRender);
if (doc.readyState === 'complete') {
chart.firstRender();
}
});
return false;
}
return true;
},
/**
* Prepare for first rendering after all data are loaded
*/
firstRender: function() {
var chart = this,
options = chart.options;
// Check whether the chart is ready to render
if (!chart.isReadyToRender()) {
return;
}
// Create the container
chart.getContainer();
// Run an early event after the container and renderer are established
fireEvent(chart, 'init');
chart.resetMargins();
chart.setChartSize();
// Set the common chart properties (mainly invert) from the given series
chart.propFromSeries();
// get axes
chart.getAxes();
// Initialize the series
each(options.series || [], function(serieOptions) {
chart.initSeries(serieOptions);
});
chart.linkSeries();
// Run an event after axes and series are initialized, but before render. At this stage,
// the series data is indexed and cached in the xData and yData arrays, so we can access
// those before rendering. Used in Highstock.
fireEvent(chart, 'beforeRender');
// depends on inverted and on margins being set
if (Pointer) {
chart.pointer = new Pointer(chart, options);
}
chart.render();
// Fire the load event if there are no external images
if (!chart.renderer.imgCount && chart.onload) {
chart.onload();
}
// If the chart was rendered outside the top container, put it back in (#3679)
chart.cloneRenderTo(true);
},
/**
* On chart load
*/
onload: function() {
// Run callbacks
each([this.callback].concat(this.callbacks), function(fn) {
if (fn && this.index !== undefined) { // Chart destroyed in its own callback (#3600)
fn.apply(this, [this]);
}
}, this);
fireEvent(this, 'load');
fireEvent(this, 'render');
// Set up auto resize, check for not destroyed (#6068)
if (defined(this.index) && this.options.chart.reflow !== false) {
this.initReflow();
}
// Don't run again
this.onload = null;
}
}; // end Chart
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Point,
each = H.each,
extend = H.extend,
erase = H.erase,
fireEvent = H.fireEvent,
format = H.format,
isArray = H.isArray,
isNumber = H.isNumber,
pick = H.pick,
removeEvent = H.removeEvent;
/**
* The Point object. The point objects are generated from the series.data
* configuration objects or raw numbers. They can be accessed from the
* Series.points array.
* @constructor Point
*/
Point = H.Point = function() {};
Point.prototype = {
/**
* Initialize the point. Called internally based on the series.data option.
* @function #init
* @memberOf Point
* @param {Object} series The series object containing this point.
* @param {Object} options The data in either number, array or object
* format.
* @param {Number} x Optionally, the X value of the.
* @returns {Object} The Point instance.
*/
init: function(series, options, x) {
var point = this,
colors,
colorCount = series.chart.options.chart.colorCount,
colorIndex;
point.series = series;
point.color = series.color; // #3445
point.applyOptions(options, x);
if (series.options.colorByPoint) {
colors = series.options.colors || series.chart.options.colors;
point.color = point.color || colors[series.colorCounter];
colorCount = colors.length;
colorIndex = series.colorCounter;
series.colorCounter++;
// loop back to zero
if (series.colorCounter === colorCount) {
series.colorCounter = 0;
}
} else {
colorIndex = series.colorIndex;
}
point.colorIndex = pick(point.colorIndex, colorIndex);
series.chart.pointCount++;
return point;
},
/**
* Apply the options containing the x and y data and possible some extra
* properties. Called on point init or from point.update.
*
* @function #applyOptions
* @memberOf Point
* @param {Object} options The point options as defined in series.data.
* @param {Number} x Optionally, the X value.
* @returns {Object} The Point instance.
*/
applyOptions: function(options, x) {
var point = this,
series = point.series,
pointValKey = series.options.pointValKey || series.pointValKey;
options = Point.prototype.optionsToObject.call(this, options);
// copy options directly to point
extend(point, options);
point.options = point.options ? extend(point.options, options) : options;
// Since options are copied into the Point instance, some accidental options must be shielded (#5681)
if (options.group) {
delete point.group;
}
// For higher dimension series types. For instance, for ranges, point.y is mapped to point.low.
if (pointValKey) {
point.y = point[pointValKey];
}
point.isNull = pick(
point.isValid && !point.isValid(),
point.x === null || !isNumber(point.y, true)
); // #3571, check for NaN
// The point is initially selected by options (#5777)
if (point.selected) {
point.state = 'select';
}
// If no x is set by now, get auto incremented value. All points must have an
// x value, however the y value can be null to create a gap in the series
if ('name' in point && x === undefined && series.xAxis && series.xAxis.hasNames) {
point.x = series.xAxis.nameToX(point);
}
if (point.x === undefined && series) {
if (x === undefined) {
point.x = series.autoIncrement(point);
} else {
point.x = x;
}
}
return point;
},
/**
* Transform number or array configs into objects
*/
optionsToObject: function(options) {
var ret = {},
series = this.series,
keys = series.options.keys,
pointArrayMap = keys || series.pointArrayMap || ['y'],
valueCount = pointArrayMap.length,
firstItemType,
i = 0,
j = 0;
if (isNumber(options) || options === null) {
ret[pointArrayMap[0]] = options;
} else if (isArray(options)) {
// with leading x value
if (!keys && options.length > valueCount) {
firstItemType = typeof options[0];
if (firstItemType === 'string') {
ret.name = options[0];
} else if (firstItemType === 'number') {
ret.x = options[0];
}
i++;
}
while (j < valueCount) {
if (!keys || options[i] !== undefined) { // Skip undefined positions for keys
ret[pointArrayMap[j]] = options[i];
}
i++;
j++;
}
} else if (typeof options === 'object') {
ret = options;
// This is the fastest way to detect if there are individual point dataLabels that need
// to be considered in drawDataLabels. These can only occur in object configs.
if (options.dataLabels) {
series._hasPointLabels = true;
}
// Same approach as above for markers
if (options.marker) {
series._hasPointMarkers = true;
}
}
return ret;
},
/**
* Get the CSS class names for individual points
* @returns {String} The class name
*/
getClassName: function() {
return 'highcharts-point' +
(this.selected ? ' highcharts-point-select' : '') +
(this.negative ? ' highcharts-negative' : '') +
(this.isNull ? ' highcharts-null-point' : '') +
(this.colorIndex !== undefined ? ' highcharts-color-' +
this.colorIndex : '') +
(this.options.className ? ' ' + this.options.className : '') +
(this.zone && this.zone.className ? ' ' +
this.zone.className.replace('highcharts-negative', '') : '');
},
/**
* Return the zone that the point belongs to
*/
getZone: function() {
var series = this.series,
zones = series.zones,
zoneAxis = series.zoneAxis || 'y',
i = 0,
zone;
zone = zones[i];
while (this[zoneAxis] >= zone.value) {
zone = zones[++i];
}
if (zone && zone.color && !this.options.color) {
this.color = zone.color;
}
return zone;
},
/**
* Destroy a point to clear memory. Its reference still stays in series.data.
*/
destroy: function() {
var point = this,
series = point.series,
chart = series.chart,
hoverPoints = chart.hoverPoints,
prop;
chart.pointCount--;
if (hoverPoints) {
point.setState();
erase(hoverPoints, point);
if (!hoverPoints.length) {
chart.hoverPoints = null;
}
}
if (point === chart.hoverPoint) {
point.onMouseOut();
}
// remove all events
if (point.graphic || point.dataLabel) { // removeEvent and destroyElements are performance expensive
removeEvent(point);
point.destroyElements();
}
if (point.legendItem) { // pies have legend items
chart.legend.destroyItem(point);
}
for (prop in point) {
point[prop] = null;
}
},
/**
* Destroy SVG elements associated with the point
*/
destroyElements: function() {
var point = this,
props = ['graphic', 'dataLabel', 'dataLabelUpper', 'connector', 'shadowGroup'],
prop,
i = 6;
while (i--) {
prop = props[i];
if (point[prop]) {
point[prop] = point[prop].destroy();
}
}
},
/**
* Return the configuration hash needed for the data label and tooltip formatters
*/
getLabelConfig: function() {
return {
x: this.category,
y: this.y,
color: this.color,
colorIndex: this.colorIndex,
key: this.name || this.category,
series: this.series,
point: this,
percentage: this.percentage,
total: this.total || this.stackTotal
};
},
/**
* Extendable method for formatting each point's tooltip line
*
* @return {String} A string to be concatenated in to the common tooltip text
*/
tooltipFormatter: function(pointFormat) {
// Insert options for valueDecimals, valuePrefix, and valueSuffix
var series = this.series,
seriesTooltipOptions = series.tooltipOptions,
valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''),
valuePrefix = seriesTooltipOptions.valuePrefix || '',
valueSuffix = seriesTooltipOptions.valueSuffix || '';
// Loop over the point array map and replace unformatted values with sprintf formatting markup
each(series.pointArrayMap || ['y'], function(key) {
key = '{point.' + key; // without the closing bracket
if (valuePrefix || valueSuffix) {
pointFormat = pointFormat.replace(key + '}', valuePrefix + key + '}' + valueSuffix);
}
pointFormat = pointFormat.replace(key + '}', key + ':,.' + valueDecimals + 'f}');
});
return format(pointFormat, {
point: this,
series: this.series
});
},
/**
* Fire an event on the Point object.
* @param {String} eventType
* @param {Object} eventArgs Additional event arguments
* @param {Function} defaultFunction Default event handler
*/
firePointEvent: function(eventType, eventArgs, defaultFunction) {
var point = this,
series = this.series,
seriesOptions = series.options;
// load event handlers on demand to save time on mouseover/out
if (seriesOptions.point.events[eventType] || (point.options && point.options.events && point.options.events[eventType])) {
this.importEvents();
}
// add default handler if in selection mode
if (eventType === 'click' && seriesOptions.allowPointSelect) {
defaultFunction = function(event) {
// Control key is for Windows, meta (= Cmd key) for Mac, Shift for Opera
if (point.select) { // Could be destroyed by prior event handlers (#2911)
point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
}
};
}
fireEvent(this, eventType, eventArgs, defaultFunction);
},
visible: true
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animObject = H.animObject,
arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
correctFloat = H.correctFloat,
Date = H.Date,
defaultOptions = H.defaultOptions,
defaultPlotOptions = H.defaultPlotOptions,
defined = H.defined,
each = H.each,
erase = H.erase,
extend = H.extend,
fireEvent = H.fireEvent,
grep = H.grep,
isArray = H.isArray,
isNumber = H.isNumber,
isString = H.isString,
LegendSymbolMixin = H.LegendSymbolMixin, // @todo add as a requirement
merge = H.merge,
pick = H.pick,
Point = H.Point, // @todo add as a requirement
removeEvent = H.removeEvent,
splat = H.splat,
SVGElement = H.SVGElement,
syncTimeout = H.syncTimeout,
win = H.win;
/**
* The base function which all other series types inherit from. The data in the series is stored
* in various arrays.
*
* - First, series.options.data contains all the original config options for
* each point whether added by options or methods like series.addPoint.
* - Next, series.data contains those values converted to points, but in case the series data length
* exceeds the cropThreshold, or if the data is grouped, series.data doesn't contain all the points. It
* only contains the points that have been created on demand.
* - Then there's series.points that contains all currently visible point objects. In case of cropping,
* the cropped-away points are not part of this array. The series.points array starts at series.cropStart
* compared to series.data and series.options.data. If however the series data is grouped, these can't
* be correlated one to one.
* - series.xData and series.processedXData contain clean x values, equivalent to series.data and series.points.
* - series.yData and series.processedYData contain clean y values, equivalent to series.data and series.points.
*
* @constructor Series
* @param {Object} chart - The chart instance.
* @param {Object} options - The series options.
*/
H.Series = H.seriesType('line', null, { // base series options
//cursor: 'default',
//dashStyle: null,
//linecap: 'round',
lineWidth: 2,
//shadow: false,
allowPointSelect: false,
showCheckbox: false,
animation: {
duration: 1000
},
//clip: true,
//connectNulls: false,
//enableMouseTracking: true,
events: {},
//legendIndex: 0,
// stacking: null,
marker: {
lineWidth: 0,
lineColor: '#ffffff',
//fillColor: null,
//enabled: true,
//symbol: null,
radius: 4,
states: { // states for a single point
hover: {
animation: {
duration: 50
},
enabled: true,
radiusPlus: 2,
lineWidthPlus: 1
},
select: {
fillColor: '#cccccc',
lineColor: '#000000',
lineWidth: 2
}
}
},
point: {
events: {}
},
dataLabels: {
align: 'center',
// defer: true,
// enabled: false,
formatter: function() {
return this.y === null ? '' : H.numberFormat(this.y, -1);
},
style: {
fontSize: '11px',
fontWeight: 'bold',
color: 'contrast',
textOutline: '1px contrast'
},
// backgroundColor: undefined,
// borderColor: undefined,
// borderWidth: undefined,
// shadow: false
verticalAlign: 'bottom', // above singular point
x: 0,
y: 0,
// borderRadius: undefined,
padding: 5
},
cropThreshold: 300, // draw points outside the plot area when the number of points is less than this
pointRange: 0,
//pointStart: 0,
//pointInterval: 1,
//showInLegend: null, // auto: true for standalone series, false for linked series
softThreshold: true,
states: { // states for the entire series
hover: {
//enabled: false,
animation: {
duration: 50
},
lineWidthPlus: 1,
marker: {
// lineWidth: base + 1,
// radius: base + 1
},
halo: {
size: 10,
opacity: 0.25
}
},
select: {
marker: {}
}
},
stickyTracking: true,
//tooltip: {
//pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b>'
//valueDecimals: null,
//xDateFormat: '%A, %b %e, %Y',
//valuePrefix: '',
//ySuffix: ''
//}
turboThreshold: 1000,
// zIndex: null
findNearestPointBy: 'x'
}, /** @lends Series.prototype */ {
isCartesian: true,
pointClass: Point,
sorted: true, // requires the data to be sorted
requireSorting: true,
directTouch: false,
axisTypes: ['xAxis', 'yAxis'],
colorCounter: 0,
parallelArrays: ['x', 'y'], // each point's x and y values are stored in this.xData and this.yData
coll: 'series',
init: function(chart, options) {
var series = this,
eventType,
events,
chartSeries = chart.series,
lastSeries;
series.chart = chart;
series.options = options = series.setOptions(options); // merge with plotOptions
series.linkedSeries = [];
// bind the axes
series.bindAxes();
// set some variables
extend(series, {
name: options.name,
state: '',
visible: options.visible !== false, // true by default
selected: options.selected === true // false by default
});
// register event listeners
events = options.events;
for (eventType in events) {
addEvent(series, eventType, events[eventType]);
}
if (
(events && events.click) ||
(options.point && options.point.events && options.point.events.click) ||
options.allowPointSelect
) {
chart.runTrackerClick = true;
}
series.getColor();
series.getSymbol();
// Set the data
each(series.parallelArrays, function(key) {
series[key + 'Data'] = [];
});
series.setData(options.data, false);
// Mark cartesian
if (series.isCartesian) {
chart.hasCartesianSeries = true;
}
// Get the index and register the series in the chart. The index is one
// more than the current latest series index (#5960).
if (chartSeries.length) {
lastSeries = chartSeries[chartSeries.length - 1];
}
series._i = pick(lastSeries && lastSeries._i, -1) + 1;
// Insert the series and re-order all series above the insertion point.
chart.orderSeries(this.insert(chartSeries));
},
/**
* Insert the series in a collection with other series, either the chart
* series or yAxis series, in the correct order according to the index
* option.
* @param {Array} collection A collection of series.
* @returns {Number} The index of the series in the collection.
*/
insert: function(collection) {
var indexOption = this.options.index,
i;
// Insert by index option
if (isNumber(indexOption)) {
i = collection.length;
while (i--) {
// Loop down until the interted element has higher index
if (indexOption >=
pick(collection[i].options.index, collection[i]._i)) {
collection.splice(i + 1, 0, this);
break;
}
}
if (i === -1) {
collection.unshift(this);
}
i = i + 1;
// Or just push it to the end
} else {
collection.push(this);
}
return pick(i, collection.length - 1);
},
/**
* Set the xAxis and yAxis properties of cartesian series, and register the
* series in the `axis.series` array.
*
* @function #bindAxes
* @memberOf Series
* @returns {void}
*/
bindAxes: function() {
var series = this,
seriesOptions = series.options,
chart = series.chart,
axisOptions;
each(series.axisTypes || [], function(AXIS) { // repeat for xAxis and yAxis
each(chart[AXIS], function(axis) { // loop through the chart's axis objects
axisOptions = axis.options;
// apply if the series xAxis or yAxis option mathches the number of the
// axis, or if undefined, use the first axis
if ((seriesOptions[AXIS] === axisOptions.index) ||
(seriesOptions[AXIS] !== undefined && seriesOptions[AXIS] === axisOptions.id) ||
(seriesOptions[AXIS] === undefined && axisOptions.index === 0)) {
// register this series in the axis.series lookup
series.insert(axis.series);
// set this series.xAxis or series.yAxis reference
series[AXIS] = axis;
// mark dirty for redraw
axis.isDirty = true;
}
});
// The series needs an X and an Y axis
if (!series[AXIS] && series.optionalAxis !== AXIS) {
H.error(18, true);
}
});
},
/**
* For simple series types like line and column, the data values are held in arrays like
* xData and yData for quick lookup to find extremes and more. For multidimensional series
* like bubble and map, this can be extended with arrays like zData and valueData by
* adding to the series.parallelArrays array.
*/
updateParallelArrays: function(point, i) {
var series = point.series,
args = arguments,
fn = isNumber(i) ?
// Insert the value in the given position
function(key) {
var val = key === 'y' && series.toYData ? series.toYData(point) : point[key];
series[key + 'Data'][i] = val;
} :
// Apply the method specified in i with the following arguments as arguments
function(key) {
Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
};
each(series.parallelArrays, fn);
},
/**
* Return an auto incremented x value based on the pointStart and pointInterval options.
* This is only used if an x value is not given for the point that calls autoIncrement.
*/
autoIncrement: function() {
var options = this.options,
xIncrement = this.xIncrement,
date,
pointInterval,
pointIntervalUnit = options.pointIntervalUnit;
xIncrement = pick(xIncrement, options.pointStart, 0);
this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
// Added code for pointInterval strings
if (pointIntervalUnit) {
date = new Date(xIncrement);
if (pointIntervalUnit === 'day') {
date = +date[Date.hcSetDate](date[Date.hcGetDate]() + pointInterval);
} else if (pointIntervalUnit === 'month') {
date = +date[Date.hcSetMonth](date[Date.hcGetMonth]() + pointInterval);
} else if (pointIntervalUnit === 'year') {
date = +date[Date.hcSetFullYear](date[Date.hcGetFullYear]() + pointInterval);
}
pointInterval = date - xIncrement;
}
this.xIncrement = xIncrement + pointInterval;
return xIncrement;
},
/**
* Set the series options by merging from the options tree
* @param {Object} itemOptions
*/
setOptions: function(itemOptions) {
var chart = this.chart,
chartOptions = chart.options,
plotOptions = chartOptions.plotOptions,
userOptions = chart.userOptions || {},
userPlotOptions = userOptions.plotOptions || {},
typeOptions = plotOptions[this.type],
options,
zones;
this.userOptions = itemOptions;
// General series options take precedence over type options because otherwise, default
// type options like column.animation would be overwritten by the general option.
// But issues have been raised here (#3881), and the solution may be to distinguish
// between default option and userOptions like in the tooltip below.
options = merge(
typeOptions,
plotOptions.series,
itemOptions
);
// The tooltip options are merged between global and series specific options
this.tooltipOptions = merge(
defaultOptions.tooltip,
defaultOptions.plotOptions[this.type].tooltip,
userOptions.tooltip,
userPlotOptions.series && userPlotOptions.series.tooltip,
userPlotOptions[this.type] && userPlotOptions[this.type].tooltip,
itemOptions.tooltip
);
// When shared tooltip, stickyTracking is true by default,
// unless user says otherwise.
this.stickyTracking = pick(
itemOptions.stickyTracking,
userPlotOptions[this.type] && userPlotOptions[this.type].stickyTracking,
userPlotOptions.series && userPlotOptions.series.stickyTracking,
(
this.tooltipOptions.shared && !this.noSharedTooltip ?
true :
options.stickyTracking
)
);
// Delete marker object if not allowed (#1125)
if (typeOptions.marker === null) {
delete options.marker;
}
// Handle color zones
this.zoneAxis = options.zoneAxis;
zones = this.zones = (options.zones || []).slice();
if ((options.negativeColor || options.negativeFillColor) && !options.zones) {
zones.push({
value: options[this.zoneAxis + 'Threshold'] || options.threshold || 0,
className: 'highcharts-negative',
color: options.negativeColor,
fillColor: options.negativeFillColor
});
}
if (zones.length) { // Push one extra zone for the rest
if (defined(zones[zones.length - 1].value)) {
zones.push({
color: this.color,
fillColor: this.fillColor
});
}
}
return options;
},
getCyclic: function(prop, value, defaults) {
var i,
chart = this.chart,
userOptions = this.userOptions,
indexName = prop + 'Index',
counterName = prop + 'Counter',
len = defaults ? defaults.length : pick(
chart.options.chart[prop + 'Count'],
chart[prop + 'Count']
),
setting;
if (!value) {
// Pick up either the colorIndex option, or the _colorIndex after Series.update()
setting = pick(userOptions[indexName], userOptions['_' + indexName]);
if (defined(setting)) { // after Series.update()
i = setting;
} else {
// #6138
if (!chart.series.length) {
chart[counterName] = 0;
}
userOptions['_' + indexName] = i = chart[counterName] % len;
chart[counterName] += 1;
}
if (defaults) {
value = defaults[i];
}
}
// Set the colorIndex
if (i !== undefined) {
this[indexName] = i;
}
this[prop] = value;
},
/**
* Get the series' color
*/
getColor: function() {
if (this.options.colorByPoint) {
this.options.color = null; // #4359, selected slice got series.color even when colorByPoint was set.
} else {
this.getCyclic('color', this.options.color || defaultPlotOptions[this.type].color, this.chart.options.colors);
}
},
/**
* Get the series' symbol
*/
getSymbol: function() {
var seriesMarkerOption = this.options.marker;
this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
},
drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
/**
* Replace the series data with a new set of data
* @param {Object} data
* @param {Object} redraw
*/
setData: function(data, redraw, animation, updatePoints) {
var series = this,
oldData = series.points,
oldDataLength = (oldData && oldData.length) || 0,
dataLength,
options = series.options,
chart = series.chart,
firstPoint = null,
xAxis = series.xAxis,
i,
turboThreshold = options.turboThreshold,
pt,
xData = this.xData,
yData = this.yData,
pointArrayMap = series.pointArrayMap,
valueCount = pointArrayMap && pointArrayMap.length;
data = data || [];
dataLength = data.length;
redraw = pick(redraw, true);
// If the point count is the same as is was, just run Point.update which is
// cheaper, allows animation, and keeps references to points.
if (updatePoints !== false && dataLength && oldDataLength === dataLength && !series.cropped && !series.hasGroupedData && series.visible) {
each(data, function(point, i) {
// .update doesn't exist on a linked, hidden series (#3709)
if (oldData[i].update && point !== options.data[i]) {
oldData[i].update(point, false, null, false);
}
});
} else {
// Reset properties
series.xIncrement = null;
series.colorCounter = 0; // for series with colorByPoint (#1547)
// Update parallel arrays
each(this.parallelArrays, function(key) {
series[key + 'Data'].length = 0;
});
// In turbo mode, only one- or twodimensional arrays of numbers are allowed. The
// first value is tested, and we assume that all the rest are defined the same
// way. Although the 'for' loops are similar, they are repeated inside each
// if-else conditional for max performance.
if (turboThreshold && dataLength > turboThreshold) {
// find the first non-null point
i = 0;
while (firstPoint === null && i < dataLength) {
firstPoint = data[i];
i++;
}
if (isNumber(firstPoint)) { // assume all points are numbers
for (i = 0; i < dataLength; i++) {
xData[i] = this.autoIncrement();
yData[i] = data[i];
}
} else if (isArray(firstPoint)) { // assume all points are arrays
if (valueCount) { // [x, low, high] or [x, o, h, l, c]
for (i = 0; i < dataLength; i++) {
pt = data[i];
xData[i] = pt[0];
yData[i] = pt.slice(1, valueCount + 1);
}
} else { // [x, y]
for (i = 0; i < dataLength; i++) {
pt = data[i];
xData[i] = pt[0];
yData[i] = pt[1];
}
}
} else {
H.error(12); // Highcharts expects configs to be numbers or arrays in turbo mode
}
} else {
for (i = 0; i < dataLength; i++) {
if (data[i] !== undefined) { // stray commas in oldIE
pt = {
series: series
};
series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
series.updateParallelArrays(pt, i);
}
}
}
// Forgetting to cast strings to numbers is a common caveat when handling CSV or JSON
if (isString(yData[0])) {
H.error(14, true);
}
series.data = [];
series.options.data = series.userOptions.data = data;
// destroy old points
i = oldDataLength;
while (i--) {
if (oldData[i] && oldData[i].destroy) {
oldData[i].destroy();
}
}
// reset minRange (#878)
if (xAxis) {
xAxis.minRange = xAxis.userMinRange;
}
// redraw
series.isDirty = chart.isDirtyBox = true;
series.isDirtyData = !!oldData;
animation = false;
}
// Typically for pie series, points need to be processed and generated
// prior to rendering the legend
if (options.legendType === 'point') {
this.processData();
this.generatePoints();
}
if (redraw) {
chart.redraw(animation);
}
},
/**
* Process the data by cropping away unused data points if the series is longer
* than the crop threshold. This saves computing time for large series.
*/
processData: function(force) {
var series = this,
processedXData = series.xData, // copied during slice operation below
processedYData = series.yData,
dataLength = processedXData.length,
croppedData,
cropStart = 0,
cropped,
distance,
closestPointRange,
xAxis = series.xAxis,
i, // loop variable
options = series.options,
cropThreshold = options.cropThreshold,
getExtremesFromAll = series.getExtremesFromAll || options.getExtremesFromAll, // #4599
isCartesian = series.isCartesian,
xExtremes,
val2lin = xAxis && xAxis.val2lin,
isLog = xAxis && xAxis.isLog,
min,
max;
// If the series data or axes haven't changed, don't go through this. Return false to pass
// the message on to override methods like in data grouping.
if (isCartesian && !series.isDirty && !xAxis.isDirty && !series.yAxis.isDirty && !force) {
return false;
}
if (xAxis) {
xExtremes = xAxis.getExtremes(); // corrected for log axis (#3053)
min = xExtremes.min;
max = xExtremes.max;
}
// optionally filter out points outside the plot area
if (isCartesian && series.sorted && !getExtremesFromAll && (!cropThreshold || dataLength > cropThreshold || series.forceCrop)) {
// it's outside current extremes
if (processedXData[dataLength - 1] < min || processedXData[0] > max) {
processedXData = [];
processedYData = [];
// only crop if it's actually spilling out
} else if (processedXData[0] < min || processedXData[dataLength - 1] > max) {
croppedData = this.cropData(series.xData, series.yData, min, max);
processedXData = croppedData.xData;
processedYData = croppedData.yData;
cropStart = croppedData.start;
cropped = true;
}
}
// Find the closest distance between processed points
i = processedXData.length || 1;
while (--i) {
distance = isLog ?
val2lin(processedXData[i]) - val2lin(processedXData[i - 1]) :
processedXData[i] - processedXData[i - 1];
if (distance > 0 && (closestPointRange === undefined || distance < closestPointRange)) {
closestPointRange = distance;
// Unsorted data is not supported by the line tooltip, as well as data grouping and
// navigation in Stock charts (#725) and width calculation of columns (#1900)
} else if (distance < 0 && series.requireSorting) {
H.error(15);
}
}
// Record the properties
series.cropped = cropped; // undefined or true
series.cropStart = cropStart;
series.processedXData = processedXData;
series.processedYData = processedYData;
series.closestPointRange = closestPointRange;
},
/**
* Iterate over xData and crop values between min and max. Returns object containing crop start/end
* cropped xData with corresponding part of yData, dataMin and dataMax within the cropped range
*/
cropData: function(xData, yData, min, max) {
var dataLength = xData.length,
cropStart = 0,
cropEnd = dataLength,
cropShoulder = pick(this.cropShoulder, 1), // line-type series need one point outside
i,
j;
// iterate up to find slice start
for (i = 0; i < dataLength; i++) {
if (xData[i] >= min) {
cropStart = Math.max(0, i - cropShoulder);
break;
}
}
// proceed to find slice end
for (j = i; j < dataLength; j++) {
if (xData[j] > max) {
cropEnd = j + cropShoulder;
break;
}
}
return {
xData: xData.slice(cropStart, cropEnd),
yData: yData.slice(cropStart, cropEnd),
start: cropStart,
end: cropEnd
};
},
/**
* Generate the data point after the data has been processed by cropping away
* unused points and optionally grouped in Highcharts Stock.
*/
generatePoints: function() {
var series = this,
options = series.options,
dataOptions = options.data,
data = series.data,
dataLength,
processedXData = series.processedXData,
processedYData = series.processedYData,
PointClass = series.pointClass,
processedDataLength = processedXData.length,
cropStart = series.cropStart || 0,
cursor,
hasGroupedData = series.hasGroupedData,
point,
points = [],
i;
if (!data && !hasGroupedData) {
var arr = [];
arr.length = dataOptions.length;
data = series.data = arr;
}
for (i = 0; i < processedDataLength; i++) {
cursor = cropStart + i;
if (!hasGroupedData) {
point = data[cursor];
if (!point && dataOptions[cursor] !== undefined) { // #970
data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
}
} else {
// splat the y data in case of ohlc data array
point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
point.dataGroup = series.groupMap[i];
}
if (point) { // #6279
point.index = cursor; // For faster access in Point.update
points[i] = point;
}
}
// Hide cropped-away points - this only runs when the number of points is above cropThreshold, or when
// swithching view from non-grouped data to grouped data (#637)
if (data && (processedDataLength !== (dataLength = data.length) || hasGroupedData)) {
for (i = 0; i < dataLength; i++) {
if (i === cropStart && !hasGroupedData) { // when has grouped data, clear all points
i += processedDataLength;
}
if (data[i]) {
data[i].destroyElements();
data[i].plotX = undefined; // #1003
}
}
}
series.data = data;
series.points = points;
},
/**
* Calculate Y extremes for visible data
*/
getExtremes: function(yData) {
var xAxis = this.xAxis,
yAxis = this.yAxis,
xData = this.processedXData,
yDataLength,
activeYData = [],
activeCounter = 0,
xExtremes = xAxis.getExtremes(), // #2117, need to compensate for log X axis
xMin = xExtremes.min,
xMax = xExtremes.max,
validValue,
withinRange,
x,
y,
i,
j;
yData = yData || this.stackedYData || this.processedYData || [];
yDataLength = yData.length;
for (i = 0; i < yDataLength; i++) {
x = xData[i];
y = yData[i];
// For points within the visible range, including the first point outside the
// visible range, consider y extremes
validValue = (isNumber(y, true) || isArray(y)) && (!yAxis.positiveValuesOnly || (y.length || y > 0));
withinRange = this.getExtremesFromAll || this.options.getExtremesFromAll || this.cropped ||
((xData[i] || x) >= xMin && (xData[i] || x) <= xMax);
if (validValue && withinRange) {
j = y.length;
if (j) { // array, like ohlc or range data
while (j--) {
if (y[j] !== null) {
activeYData[activeCounter++] = y[j];
}
}
} else {
activeYData[activeCounter++] = y;
}
}
}
this.dataMin = arrayMin(activeYData);
this.dataMax = arrayMax(activeYData);
},
/**
* Translate data points from raw data values to chart specific positioning
* data needed later in drawPoints, drawGraph and drawTracker.
*
* @function #translate
* @memberOf Series
* @returns {void}
*/
translate: function() {
if (!this.processedXData) { // hidden series
this.processData();
}
this.generatePoints();
var series = this,
options = series.options,
stacking = options.stacking,
xAxis = series.xAxis,
categories = xAxis.categories,
yAxis = series.yAxis,
points = series.points,
dataLength = points.length,
hasModifyValue = !!series.modifyValue,
i,
pointPlacement = options.pointPlacement,
dynamicallyPlaced = pointPlacement === 'between' || isNumber(pointPlacement),
threshold = options.threshold,
stackThreshold = options.startFromThreshold ? threshold : 0,
plotX,
plotY,
lastPlotX,
stackIndicator,
closestPointRangePx = Number.MAX_VALUE;
// Point placement is relative to each series pointRange (#5889)
if (pointPlacement === 'between') {
pointPlacement = 0.5;
}
if (isNumber(pointPlacement)) {
pointPlacement *= pick(options.pointRange || xAxis.pointRange);
}
// Translate each point
for (i = 0; i < dataLength; i++) {
var point = points[i],
xValue = point.x,
yValue = point.y,
yBottom = point.low,
stack = stacking && yAxis.stacks[(series.negStacks && yValue < (stackThreshold ? 0 : threshold) ? '-' : '') + series.stackKey],
pointStack,
stackValues;
// Discard disallowed y values for log axes (#3434)
if (yAxis.positiveValuesOnly && yValue !== null && yValue <= 0) {
point.isNull = true;
}
// Get the plotX translation
point.plotX = plotX = correctFloat( // #5236
Math.min(Math.max(-1e5, xAxis.translate(
xValue,
0,
0,
0,
1,
pointPlacement,
this.type === 'flags'
)), 1e5) // #3923
);
// Calculate the bottom y value for stacked series
if (stacking && series.visible && !point.isNull && stack && stack[xValue]) {
stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
pointStack = stack[xValue];
stackValues = pointStack.points[stackIndicator.key];
yBottom = stackValues[0];
yValue = stackValues[1];
if (yBottom === stackThreshold && stackIndicator.key === stack[xValue].base) {
yBottom = pick(threshold, yAxis.min);
}
if (yAxis.positiveValuesOnly && yBottom <= 0) { // #1200, #1232
yBottom = null;
}
point.total = point.stackTotal = pointStack.total;
point.percentage = pointStack.total && (point.y / pointStack.total * 100);
point.stackY = yValue;
// Place the stack label
pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
}
// Set translated yBottom or remove it
point.yBottom = defined(yBottom) ?
yAxis.translate(yBottom, 0, 1, 0, 1) :
null;
// general hook, used for Highstock compare mode
if (hasModifyValue) {
yValue = series.modifyValue(yValue, point);
}
// Set the the plotY value, reset it for redraws
point.plotY = plotY = (typeof yValue === 'number' && yValue !== Infinity) ?
Math.min(Math.max(-1e5, yAxis.translate(yValue, 0, 1, 0, 1)), 1e5) : // #3201
undefined;
point.isInside = plotY !== undefined && plotY >= 0 && plotY <= yAxis.len && // #3519
plotX >= 0 && plotX <= xAxis.len;
// Set client related positions for mouse tracking
point.clientX = dynamicallyPlaced ? correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) : plotX; // #1514, #5383, #5518
point.negative = point.y < (threshold || 0);
// some API data
point.category = categories && categories[point.x] !== undefined ?
categories[point.x] : point.x;
// Determine auto enabling of markers (#3635, #5099)
if (!point.isNull) {
if (lastPlotX !== undefined) {
closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
}
lastPlotX = plotX;
}
// Find point zone
point.zone = this.zones.length && point.getZone();
}
series.closestPointRangePx = closestPointRangePx;
},
/**
* Return the series points with null points filtered out
*/
getValidPoints: function(points, insideOnly) {
var chart = this.chart;
return grep(points || this.points || [], function isValidPoint(point) { // #3916, #5029
if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, chart.inverted)) { // #5085
return false;
}
return !point.isNull;
});
},
/**
* Set the clipping for the series. For animated series it is called twice, first to initiate
* animating the clip then the second time without the animation to set the final clip.
*/
setClip: function(animation) {
var chart = this.chart,
options = this.options,
renderer = chart.renderer,
inverted = chart.inverted,
seriesClipBox = this.clipBox,
clipBox = seriesClipBox || chart.clipBox,
sharedClipKey = this.sharedClipKey || ['_sharedClip', animation && animation.duration, animation && animation.easing, clipBox.height, options.xAxis, options.yAxis].join(','), // #4526
clipRect = chart[sharedClipKey],
markerClipRect = chart[sharedClipKey + 'm'];
// If a clipping rectangle with the same properties is currently present in the chart, use that.
if (!clipRect) {
// When animation is set, prepare the initial positions
if (animation) {
clipBox.width = 0;
chart[sharedClipKey + 'm'] = markerClipRect = renderer.clipRect(-99, // include the width of the first marker
inverted ? -chart.plotLeft : -chart.plotTop,
99,
inverted ? chart.chartWidth : chart.chartHeight
);
}
chart[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
// Create hashmap for series indexes
clipRect.count = {
length: 0
};
}
if (animation) {
if (!clipRect.count[this.index]) {
clipRect.count[this.index] = true;
clipRect.count.length += 1;
}
}
if (options.clip !== false) {
this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
this.markerGroup.clip(markerClipRect);
this.sharedClipKey = sharedClipKey;
}
// Remove the shared clipping rectangle when all series are shown
if (!animation) {
if (clipRect.count[this.index]) {
delete clipRect.count[this.index];
clipRect.count.length -= 1;
}
if (clipRect.count.length === 0 && sharedClipKey && chart[sharedClipKey]) {
if (!seriesClipBox) {
chart[sharedClipKey] = chart[sharedClipKey].destroy();
}
if (chart[sharedClipKey + 'm']) {
chart[sharedClipKey + 'm'] = chart[sharedClipKey + 'm'].destroy();
}
}
}
},
/**
* Animate in the series
*/
animate: function(init) {
var series = this,
chart = series.chart,
clipRect,
animation = animObject(series.options.animation),
sharedClipKey;
// Initialize the animation. Set up the clipping rectangle.
if (init) {
series.setClip(animation);
// Run the animation
} else {
sharedClipKey = this.sharedClipKey;
clipRect = chart[sharedClipKey];
if (clipRect) {
clipRect.animate({
width: chart.plotSizeX
}, animation);
}
if (chart[sharedClipKey + 'm']) {
chart[sharedClipKey + 'm'].animate({
width: chart.plotSizeX + 99
}, animation);
}
// Delete this function to allow it only once
series.animate = null;
}
},
/**
* This runs after animation to land on the final plot clipping
*/
afterAnimate: function() {
this.setClip();
fireEvent(this, 'afterAnimate');
},
/**
* Draw the markers.
*
* @function #drawPoints
* @memberOf Series
* @returns {void}
*/
drawPoints: function() {
var series = this,
points = series.points,
chart = series.chart,
plotY,
i,
point,
symbol,
graphic,
options = series.options,
seriesMarkerOptions = options.marker,
pointMarkerOptions,
hasPointMarker,
enabled,
isInside,
markerGroup = series.markerGroup,
xAxis = series.xAxis,
markerAttribs,
globallyEnabled = pick(
seriesMarkerOptions.enabled,
xAxis.isRadial ? true : null,
// Use larger or equal as radius is null in bubbles (#6321)
series.closestPointRangePx >= 2 * seriesMarkerOptions.radius
);
if (seriesMarkerOptions.enabled !== false || series._hasPointMarkers) {
for (i = 0; i < points.length; i++) {
point = points[i];
plotY = point.plotY;
graphic = point.graphic;
pointMarkerOptions = point.marker || {};
hasPointMarker = !!point.marker;
enabled = (globallyEnabled && pointMarkerOptions.enabled === undefined) || pointMarkerOptions.enabled;
isInside = point.isInside;
// only draw the point if y is defined
if (enabled && isNumber(plotY) && point.y !== null) {
// Shortcuts
symbol = pick(pointMarkerOptions.symbol, series.symbol);
point.hasImage = symbol.indexOf('url') === 0;
markerAttribs = series.markerAttribs(
point,
point.selected && 'select'
);
if (graphic) { // update
graphic[isInside ? 'show' : 'hide'](true) // Since the marker group isn't clipped, each individual marker must be toggled
.animate(markerAttribs);
} else if (isInside && (markerAttribs.width > 0 || point.hasImage)) {
point.graphic = graphic = chart.renderer.symbol(
symbol,
markerAttribs.x,
markerAttribs.y,
markerAttribs.width,
markerAttribs.height,
hasPointMarker ? pointMarkerOptions : seriesMarkerOptions
)
.add(markerGroup);
}
// Presentational attributes
if (graphic) {
graphic.attr(series.pointAttribs(point, point.selected && 'select'));
}
if (graphic) {
graphic.addClass(point.getClassName(), true);
}
} else if (graphic) {
point.graphic = graphic.destroy(); // #1269
}
}
}
},
/**
* Get non-presentational attributes for the point.
*/
markerAttribs: function(point, state) {
var seriesMarkerOptions = this.options.marker,
seriesStateOptions,
pointMarkerOptions = point.marker || {},
pointStateOptions,
radius = pick(
pointMarkerOptions.radius,
seriesMarkerOptions.radius
),
attribs;
// Handle hover and select states
if (state) {
seriesStateOptions = seriesMarkerOptions.states[state];
pointStateOptions = pointMarkerOptions.states &&
pointMarkerOptions.states[state];
radius = pick(
pointStateOptions && pointStateOptions.radius,
seriesStateOptions && seriesStateOptions.radius,
radius + (seriesStateOptions && seriesStateOptions.radiusPlus || 0)
);
}
if (point.hasImage) {
radius = 0; // and subsequently width and height is not set
}
attribs = {
x: Math.floor(point.plotX) - radius, // Math.floor for #1843
y: point.plotY - radius
};
if (radius) {
attribs.width = attribs.height = 2 * radius;
}
return attribs;
},
/**
* Get presentational attributes for marker-based series (line, spline, scatter, bubble, mappoint...)
*/
pointAttribs: function(point, state) {
var seriesMarkerOptions = this.options.marker,
seriesStateOptions,
pointOptions = point && point.options,
pointMarkerOptions = (pointOptions && pointOptions.marker) || {},
pointStateOptions,
color = this.color,
pointColorOption = pointOptions && pointOptions.color,
pointColor = point && point.color,
strokeWidth = pick(
pointMarkerOptions.lineWidth,
seriesMarkerOptions.lineWidth
),
zoneColor = point && point.zone && point.zone.color,
fill,
stroke;
color = pointColorOption || zoneColor || pointColor || color;
fill = pointMarkerOptions.fillColor || seriesMarkerOptions.fillColor || color;
stroke = pointMarkerOptions.lineColor || seriesMarkerOptions.lineColor || color;
// Handle hover and select states
if (state) {
seriesStateOptions = seriesMarkerOptions.states[state];
pointStateOptions = (pointMarkerOptions.states && pointMarkerOptions.states[state]) || {};
strokeWidth = pick(
pointStateOptions.lineWidth,
seriesStateOptions.lineWidth,
strokeWidth + pick(
pointStateOptions.lineWidthPlus,
seriesStateOptions.lineWidthPlus,
0
)
);
fill = pointStateOptions.fillColor || seriesStateOptions.fillColor || fill;
stroke = pointStateOptions.lineColor || seriesStateOptions.lineColor || stroke;
}
return {
'stroke': stroke,
'stroke-width': strokeWidth,
'fill': fill
};
},
/**
* Clear DOM objects and free up memory
*/
destroy: function() {
var series = this,
chart = series.chart,
issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent),
destroy,
i,
data = series.data || [],
point,
prop,
axis;
// add event hook
fireEvent(series, 'destroy');
// remove all events
removeEvent(series);
// erase from axes
each(series.axisTypes || [], function(AXIS) {
axis = series[AXIS];
if (axis && axis.series) {
erase(axis.series, series);
axis.isDirty = axis.forceRedraw = true;
}
});
// remove legend items
if (series.legendItem) {
series.chart.legend.destroyItem(series);
}
// destroy all points with their elements
i = data.length;
while (i--) {
point = data[i];
if (point && point.destroy) {
point.destroy();
}
}
series.points = null;
// Clear the animation timeout if we are destroying the series during initial animation
clearTimeout(series.animationTimeout);
// Destroy all SVGElements associated to the series
for (prop in series) {
if (series[prop] instanceof SVGElement && !series[prop].survive) { // Survive provides a hook for not destroying
// issue 134 workaround
destroy = issue134 && prop === 'group' ?
'hide' :
'destroy';
series[prop][destroy]();
}
}
// remove from hoverSeries
if (chart.hoverSeries === series) {
chart.hoverSeries = null;
}
erase(chart.series, series);
chart.orderSeries();
// clear all members
for (prop in series) {
delete series[prop];
}
},
/**
* Get the graph path
*/
getGraphPath: function(points, nullsAsZeroes, connectCliffs) {
var series = this,
options = series.options,
step = options.step,
reversed,
graphPath = [],
xMap = [],
gap;
points = points || series.points;
// Bottom of a stack is reversed
reversed = points.reversed;
if (reversed) {
points.reverse();
}
// Reverse the steps (#5004)
step = {
right: 1,
center: 2
}[step] || (step && 3);
if (step && reversed) {
step = 4 - step;
}
// Remove invalid points, especially in spline (#5015)
if (options.connectNulls && !nullsAsZeroes && !connectCliffs) {
points = this.getValidPoints(points);
}
// Build the line
each(points, function(point, i) {
var plotX = point.plotX,
plotY = point.plotY,
lastPoint = points[i - 1],
pathToPoint; // the path to this point from the previous
if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) && !connectCliffs) {
gap = true; // ... and continue
}
// Line series, nullsAsZeroes is not handled
if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
gap = !options.connectNulls;
// Area series, nullsAsZeroes is set
} else if (point.isNull && !nullsAsZeroes) {
gap = true;
} else {
if (i === 0 || gap) {
pathToPoint = ['M', point.plotX, point.plotY];
} else if (series.getPointSpline) { // generate the spline as defined in the SplineSeries object
pathToPoint = series.getPointSpline(points, point, i);
} else if (step) {
if (step === 1) { // right
pathToPoint = [
'L',
lastPoint.plotX,
plotY
];
} else if (step === 2) { // center
pathToPoint = [
'L',
(lastPoint.plotX + plotX) / 2,
lastPoint.plotY,
'L',
(lastPoint.plotX + plotX) / 2,
plotY
];
} else {
pathToPoint = [
'L',
plotX,
lastPoint.plotY
];
}
pathToPoint.push('L', plotX, plotY);
} else {
// normal line to next point
pathToPoint = [
'L',
plotX,
plotY
];
}
// Prepare for animation. When step is enabled, there are two path nodes for each x value.
xMap.push(point.x);
if (step) {
xMap.push(point.x);
}
graphPath.push.apply(graphPath, pathToPoint);
gap = false;
}
});
graphPath.xMap = xMap;
series.graphPath = graphPath;
return graphPath;
},
/**
* Draw the actual graph
*/
drawGraph: function() {
var series = this,
options = this.options,
graphPath = (this.gappedPath || this.getGraphPath).call(this),
props = [
[
'graph',
'highcharts-graph',
options.lineColor || this.color,
options.dashStyle
]
];
// Add the zone properties if any
each(this.zones, function(zone, i) {
props.push([
'zone-graph-' + i,
'highcharts-graph highcharts-zone-graph-' + i + ' ' + (zone.className || ''),
zone.color || series.color,
zone.dashStyle || options.dashStyle
]);
});
// Draw the graph
each(props, function(prop, i) {
var graphKey = prop[0],
graph = series[graphKey],
attribs;
if (graph) {
graph.endX = graphPath.xMap;
graph.animate({
d: graphPath
});
} else if (graphPath.length) { // #1487
series[graphKey] = series.chart.renderer.path(graphPath)
.addClass(prop[1])
.attr({
zIndex: 1
}) // #1069
.add(series.group);
attribs = {
'stroke': prop[2],
'stroke-width': options.lineWidth,
'fill': (series.fillGraph && series.color) || 'none' // Polygon series use filled graph
};
if (prop[3]) {
attribs.dashstyle = prop[3];
} else if (options.linecap !== 'square') {
attribs['stroke-linecap'] = attribs['stroke-linejoin'] = 'round';
}
graph = series[graphKey]
.attr(attribs)
.shadow((i < 2) && options.shadow); // add shadow to normal series (0) or to first zone (1) #3932
}
// Helpers for animation
if (graph) {
graph.startX = graphPath.xMap;
//graph.shiftUnit = options.step ? 2 : 1;
graph.isArea = graphPath.isArea; // For arearange animation
}
});
},
/**
* Clip the graphs into the positive and negative coloured graphs
*/
applyZones: function() {
var series = this,
chart = this.chart,
renderer = chart.renderer,
zones = this.zones,
translatedFrom,
translatedTo,
clips = this.clips || [],
clipAttr,
graph = this.graph,
area = this.area,
chartSizeMax = Math.max(chart.chartWidth, chart.chartHeight),
axis = this[(this.zoneAxis || 'y') + 'Axis'],
extremes,
reversed,
inverted = chart.inverted,
horiz,
pxRange,
pxPosMin,
pxPosMax,
ignoreZones = false;
if (zones.length && (graph || area) && axis && axis.min !== undefined) {
reversed = axis.reversed;
horiz = axis.horiz;
// The use of the Color Threshold assumes there are no gaps
// so it is safe to hide the original graph and area
if (graph) {
graph.hide();
}
if (area) {
area.hide();
}
// Create the clips
extremes = axis.getExtremes();
each(zones, function(threshold, i) {
translatedFrom = reversed ?
(horiz ? chart.plotWidth : 0) :
(horiz ? 0 : axis.toPixels(extremes.min));
translatedFrom = Math.min(Math.max(pick(translatedTo, translatedFrom), 0), chartSizeMax);
translatedTo = Math.min(Math.max(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true)), 0), chartSizeMax);
if (ignoreZones) {
translatedFrom = translatedTo = axis.toPixels(extremes.max);
}
pxRange = Math.abs(translatedFrom - translatedTo);
pxPosMin = Math.min(translatedFrom, translatedTo);
pxPosMax = Math.max(translatedFrom, translatedTo);
if (axis.isXAxis) {
clipAttr = {
x: inverted ? pxPosMax : pxPosMin,
y: 0,
width: pxRange,
height: chartSizeMax
};
if (!horiz) {
clipAttr.x = chart.plotHeight - clipAttr.x;
}
} else {
clipAttr = {
x: 0,
y: inverted ? pxPosMax : pxPosMin,
width: chartSizeMax,
height: pxRange
};
if (horiz) {
clipAttr.y = chart.plotWidth - clipAttr.y;
}
}
/// VML SUPPPORT
if (inverted && renderer.isVML) {
if (axis.isXAxis) {
clipAttr = {
x: 0,
y: reversed ? pxPosMin : pxPosMax,
height: clipAttr.width,
width: chart.chartWidth
};
} else {
clipAttr = {
x: clipAttr.y - chart.plotLeft - chart.spacingBox.x,
y: 0,
width: clipAttr.height,
height: chart.chartHeight
};
}
}
/// END OF VML SUPPORT
if (clips[i]) {
clips[i].animate(clipAttr);
} else {
clips[i] = renderer.clipRect(clipAttr);
if (graph) {
series['zone-graph-' + i].clip(clips[i]);
}
if (area) {
series['zone-area-' + i].clip(clips[i]);
}
}
// if this zone extends out of the axis, ignore the others
ignoreZones = threshold.value > extremes.max;
});
this.clips = clips;
}
},
/**
* Initialize and perform group inversion on series.group and series.markerGroup
*/
invertGroups: function(inverted) {
var series = this,
chart = series.chart,
remover;
function setInvert() {
each(['group', 'markerGroup'], function(groupName) {
if (series[groupName]) {
// VML/HTML needs explicit attributes for flipping
if (chart.renderer.isVML) {
series[groupName].attr({
width: series.yAxis.len,
height: series.xAxis.len
});
}
series[groupName].width = series.yAxis.len;
series[groupName].height = series.xAxis.len;
series[groupName].invert(inverted);
}
});
}
// Pie, go away (#1736)
if (!series.xAxis) {
return;
}
// A fixed size is needed for inversion to work
remover = addEvent(chart, 'resize', setInvert);
addEvent(series, 'destroy', remover);
// Do it now
setInvert(inverted); // do it now
// On subsequent render and redraw, just do setInvert without setting up events again
series.invertGroups = setInvert;
},
/**
* General abstraction for creating plot groups like series.group, series.dataLabelsGroup and
* series.markerGroup. On subsequent calls, the group will only be adjusted to the updated plot size.
*/
plotGroup: function(prop, name, visibility, zIndex, parent) {
var group = this[prop],
isNew = !group;
// Generate it on first call
if (isNew) {
this[prop] = group = this.chart.renderer.g(name)
.attr({
zIndex: zIndex || 0.1 // IE8 and pointer logic use this
})
.add(parent);
group.addClass('highcharts-series-' + this.index + ' highcharts-' + this.type + '-series highcharts-color-' + this.colorIndex +
' ' + (this.options.className || ''));
}
// Place it on first and subsequent (redraw) calls
group.attr({
visibility: visibility
})[isNew ? 'attr' : 'animate'](this.getPlotBox());
return group;
},
/**
* Get the translation and scale for the plot area of this series
*/
getPlotBox: function() {
var chart = this.chart,
xAxis = this.xAxis,
yAxis = this.yAxis;
// Swap axes for inverted (#2339)
if (chart.inverted) {
xAxis = yAxis;
yAxis = this.xAxis;
}
return {
translateX: xAxis ? xAxis.left : chart.plotLeft,
translateY: yAxis ? yAxis.top : chart.plotTop,
scaleX: 1, // #1623
scaleY: 1
};
},
/**
* Render the graph and markers
*/
render: function() {
var series = this,
chart = series.chart,
group,
options = series.options,
// Animation doesn't work in IE8 quirks when the group div is hidden,
// and looks bad in other oldIE
animDuration = !!series.animate && chart.renderer.isSVG && animObject(options.animation).duration,
visibility = series.visible ? 'inherit' : 'hidden', // #2597
zIndex = options.zIndex,
hasRendered = series.hasRendered,
chartSeriesGroup = chart.seriesGroup,
inverted = chart.inverted;
// the group
group = series.plotGroup(
'group',
'series',
visibility,
zIndex,
chartSeriesGroup
);
series.markerGroup = series.plotGroup(
'markerGroup',
'markers',
visibility,
zIndex,
chartSeriesGroup
);
// initiate the animation
if (animDuration) {
series.animate(true);
}
// SVGRenderer needs to know this before drawing elements (#1089, #1795)
group.inverted = series.isCartesian ? inverted : false;
// draw the graph if any
if (series.drawGraph) {
series.drawGraph();
series.applyZones();
}
/* each(series.points, function (point) {
if (point.redraw) {
point.redraw();
}
});*/
// draw the data labels (inn pies they go before the points)
if (series.drawDataLabels) {
series.drawDataLabels();
}
// draw the points
if (series.visible) {
series.drawPoints();
}
// draw the mouse tracking area
if (series.drawTracker && series.options.enableMouseTracking !== false) {
series.drawTracker();
}
// Handle inverted series and tracker groups
series.invertGroups(inverted);
// Initial clipping, must be defined after inverting groups for VML. Applies to columns etc. (#3839).
if (options.clip !== false && !series.sharedClipKey && !hasRendered) {
group.clip(chart.clipRect);
}
// Run the animation
if (animDuration) {
series.animate();
}
// Call the afterAnimate function on animation complete (but don't overwrite the animation.complete option
// which should be available to the user).
if (!hasRendered) {
series.animationTimeout = syncTimeout(function() {
series.afterAnimate();
}, animDuration);
}
series.isDirty = false; // means data is in accordance with what you see
// (See #322) series.isDirty = series.isDirtyData = false; // means data is in accordance with what you see
series.hasRendered = true;
},
/**
* Redraw the series after an update in the axes.
*/
redraw: function() {
var series = this,
chart = series.chart,
wasDirty = series.isDirty || series.isDirtyData, // cache it here as it is set to false in render, but used after
group = series.group,
xAxis = series.xAxis,
yAxis = series.yAxis;
// reposition on resize
if (group) {
if (chart.inverted) {
group.attr({
width: chart.plotWidth,
height: chart.plotHeight
});
}
group.animate({
translateX: pick(xAxis && xAxis.left, chart.plotLeft),
translateY: pick(yAxis && yAxis.top, chart.plotTop)
});
}
series.translate();
series.render();
if (wasDirty) { // #3868, #3945
delete this.kdTree;
}
},
/**
* KD Tree && PointSearching Implementation
*/
kdAxisArray: ['clientX', 'plotY'],
searchPoint: function(e, compareX) {
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis,
inverted = series.chart.inverted;
return this.searchKDTree({
clientX: inverted ? xAxis.len - e.chartY + xAxis.pos : e.chartX - xAxis.pos,
plotY: inverted ? yAxis.len - e.chartX + yAxis.pos : e.chartY - yAxis.pos
}, compareX);
},
/**
* Build the k-d-tree that is used by mouse and touch interaction to get the
* closest point. Line-like series typically have a one-dimensional tree
* where points are searched along the X axis, while scatter-like series
* typically search in two dimensions, X and Y.
*/
buildKDTree: function() {
// Prevent multiple k-d-trees from being built simultaneously (#6235)
this.buildingKdTree = true;
var series = this,
dimensions = series.options.findNearestPointBy.indexOf('y') > -1 ?
2 : 1;
// Internal function
function _kdtree(points, depth, dimensions) {
var axis,
median,
length = points && points.length;
if (length) {
// alternate between the axis
axis = series.kdAxisArray[depth % dimensions];
// sort point array
points.sort(function(a, b) {
return a[axis] - b[axis];
});
median = Math.floor(length / 2);
// build and return nod
return {
point: points[median],
left: _kdtree(points.slice(0, median), depth + 1, dimensions),
right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
};
}
}
// Start the recursive build process with a clone of the points array and null points filtered out (#3873)
function startRecursive() {
series.kdTree = _kdtree(
series.getValidPoints(
null, !series.directTouch // For line-type series restrict to plot area, but column-type series not (#3916, #4511)
),
dimensions,
dimensions
);
series.buildingKdTree = false;
}
delete series.kdTree;
// For testing tooltips, don't build async
syncTimeout(startRecursive, series.options.kdNow ? 0 : 1);
},
searchKDTree: function(point, compareX) {
var series = this,
kdX = this.kdAxisArray[0],
kdY = this.kdAxisArray[1],
kdComparer = compareX ? 'distX' : 'dist',
kdDimensions = series.options.findNearestPointBy.indexOf('y') > -1 ?
2 : 1;
// Set the one and two dimensional distance on the point object
function setDistance(p1, p2) {
var x = (defined(p1[kdX]) && defined(p2[kdX])) ? Math.pow(p1[kdX] - p2[kdX], 2) : null,
y = (defined(p1[kdY]) && defined(p2[kdY])) ? Math.pow(p1[kdY] - p2[kdY], 2) : null,
r = (x || 0) + (y || 0);
p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
}
function _search(search, tree, depth, dimensions) {
var point = tree.point,
axis = series.kdAxisArray[depth % dimensions],
tdist,
sideA,
sideB,
ret = point,
nPoint1,
nPoint2;
setDistance(search, point);
// Pick side based on distance to splitting point
tdist = search[axis] - point[axis];
sideA = tdist < 0 ? 'left' : 'right';
sideB = tdist < 0 ? 'right' : 'left';
// End of tree
if (tree[sideA]) {
nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
ret = (nPoint1[kdComparer] < ret[kdComparer] ? nPoint1 : point);
}
if (tree[sideB]) {
// compare distance to current best to splitting point to decide wether to check side B or not
if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
ret = (nPoint2[kdComparer] < ret[kdComparer] ? nPoint2 : ret);
}
}
return ret;
}
if (!this.kdTree && !this.buildingKdTree) {
this.buildKDTree();
}
if (this.kdTree) {
return _search(point, this.kdTree, kdDimensions, kdDimensions);
}
}
}); // end Series prototype
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
Chart = H.Chart,
correctFloat = H.correctFloat,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
each = H.each,
format = H.format,
pick = H.pick,
Series = H.Series;
/**
* The class for stacks. Each stack, on a specific X value and either negative
* or positive, has its own stack item.
*
* @class
*/
function StackItem(axis, options, isNegative, x, stackOption) {
var inverted = axis.chart.inverted;
this.axis = axis;
// Tells if the stack is negative
this.isNegative = isNegative;
// Save the options to be able to style the label
this.options = options;
// Save the x value to be able to position the label later
this.x = x;
// Initialize total value
this.total = null;
// This will keep each points' extremes stored by series.index and point
// index
this.points = {};
// Save the stack option on the series configuration object, and whether to
// treat it as percent
this.stack = stackOption;
this.leftCliff = 0;
this.rightCliff = 0;
// The align options and text align varies on whether the stack is negative
// and if the chart is inverted or not.
// First test the user supplied value, then use the dynamic.
this.alignOptions = {
align: options.align ||
(inverted ? (isNegative ? 'left' : 'right') : 'center'),
verticalAlign: options.verticalAlign ||
(inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
y: pick(options.y, inverted ? 4 : (isNegative ? 14 : -6)),
x: pick(options.x, inverted ? (isNegative ? -6 : 6) : 0)
};
this.textAlign = options.textAlign ||
(inverted ? (isNegative ? 'right' : 'left') : 'center');
}
StackItem.prototype = {
destroy: function() {
destroyObjectProperties(this, this.axis);
},
/**
* Renders the stack total label and adds it to the stack label group.
*/
render: function(group) {
var options = this.options,
formatOption = options.format,
str = formatOption ?
format(formatOption, this) :
options.formatter.call(this); // format the text in the label
// Change the text to reflect the new total and set visibility to hidden
// in case the serie is hidden
if (this.label) {
this.label.attr({
text: str,
visibility: 'hidden'
});
// Create new label
} else {
this.label =
this.axis.chart.renderer.text(str, null, null, options.useHTML)
.css(options.style)
.attr({
align: this.textAlign,
rotation: options.rotation,
visibility: 'hidden' // hidden until setOffset is called
})
.add(group); // add to the labels-group
}
},
/**
* Sets the offset that the stack has from the x value and repositions the
* label.
*/
setOffset: function(xOffset, xWidth) {
var stackItem = this,
axis = stackItem.axis,
chart = axis.chart,
inverted = chart.inverted,
reversed = axis.reversed,
neg = (this.isNegative && !reversed) ||
(!this.isNegative && reversed), // #4056
// stack value translated mapped to chart coordinates
y = axis.translate(
axis.usePercentage ? 100 : this.total,
0,
0,
0,
1
),
yZero = axis.translate(0), // stack origin
h = Math.abs(y - yZero), // stack height
x = chart.xAxis[0].translate(this.x) + xOffset, // stack x position
plotHeight = chart.plotHeight,
stackBox = { // this is the box for the complete stack
x: inverted ? (neg ? y : y - h) : x,
y: inverted ?
plotHeight - x - xWidth : (neg ? (plotHeight - y - h) :
plotHeight - y),
width: inverted ? h : xWidth,
height: inverted ? xWidth : h
},
label = this.label,
alignAttr;
if (label) {
// Align the label to the box
label.align(this.alignOptions, null, stackBox);
// Set visibility (#678)
alignAttr = label.alignAttr;
label[
this.options.crop === false || chart.isInsidePlot(
alignAttr.x,
alignAttr.y
) ? 'show' : 'hide'](true);
}
}
};
/**
* Generate stacks for each series and calculate stacks total values
*/
Chart.prototype.getStacks = function() {
var chart = this;
// reset stacks for each yAxis
each(chart.yAxis, function(axis) {
if (axis.stacks && axis.hasVisibleSeries) {
axis.oldStacks = axis.stacks;
}
});
each(chart.series, function(series) {
if (series.options.stacking && (series.visible === true ||
chart.options.chart.ignoreHiddenSeries === false)) {
series.stackKey = series.type + pick(series.options.stack, '');
}
});
};
// Stacking methods defined on the Axis prototype
/**
* Build the stacks from top down
*/
Axis.prototype.buildStacks = function() {
var axisSeries = this.series,
series,
reversedStacks = pick(this.options.reversedStacks, true),
len = axisSeries.length,
i;
if (!this.isXAxis) {
this.usePercentage = false;
i = len;
while (i--) {
axisSeries[reversedStacks ? i : len - i - 1].setStackedPoints();
}
i = len;
while (i--) {
series = axisSeries[reversedStacks ? i : len - i - 1];
if (series.setStackCliffs) {
series.setStackCliffs();
}
}
// Loop up again to compute percent stack
if (this.usePercentage) {
for (i = 0; i < len; i++) {
axisSeries[i].setPercentStacks();
}
}
}
};
Axis.prototype.renderStackTotals = function() {
var axis = this,
chart = axis.chart,
renderer = chart.renderer,
stacks = axis.stacks,
stackKey,
oneStack,
stackCategory,
stackTotalGroup = axis.stackTotalGroup;
// Create a separate group for the stack total labels
if (!stackTotalGroup) {
axis.stackTotalGroup = stackTotalGroup =
renderer.g('stack-labels')
.attr({
visibility: 'visible',
zIndex: 6
})
.add();
}
// plotLeft/Top will change when y axis gets wider so we need to translate
// the stackTotalGroup at every render call. See bug #506 and #516
stackTotalGroup.translate(chart.plotLeft, chart.plotTop);
// Render each stack total
for (stackKey in stacks) {
oneStack = stacks[stackKey];
for (stackCategory in oneStack) {
oneStack[stackCategory].render(stackTotalGroup);
}
}
};
/**
* Set all the stacks to initial states and destroy unused ones.
*/
Axis.prototype.resetStacks = function() {
var stacks = this.stacks,
type,
i;
if (!this.isXAxis) {
for (type in stacks) {
for (i in stacks[type]) {
// Clean up memory after point deletion (#1044, #4320)
if (stacks[type][i].touched < this.stacksTouched) {
stacks[type][i].destroy();
delete stacks[type][i];
// Reset stacks
} else {
stacks[type][i].total = null;
stacks[type][i].cum = null;
}
}
}
}
};
Axis.prototype.cleanStacks = function() {
var stacks, type, i;
if (!this.isXAxis) {
if (this.oldStacks) {
stacks = this.stacks = this.oldStacks;
}
// reset stacks
for (type in stacks) {
for (i in stacks[type]) {
stacks[type][i].cum = stacks[type][i].total;
}
}
}
};
// Stacking methods defnied for Series prototype
/**
* Adds series' points value to corresponding stack
*/
Series.prototype.setStackedPoints = function() {
if (!this.options.stacking || (this.visible !== true &&
this.chart.options.chart.ignoreHiddenSeries !== false)) {
return;
}
var series = this,
xData = series.processedXData,
yData = series.processedYData,
stackedYData = [],
yDataLength = yData.length,
seriesOptions = series.options,
threshold = seriesOptions.threshold,
stackThreshold = seriesOptions.startFromThreshold ? threshold : 0,
stackOption = seriesOptions.stack,
stacking = seriesOptions.stacking,
stackKey = series.stackKey,
negKey = '-' + stackKey,
negStacks = series.negStacks,
yAxis = series.yAxis,
stacks = yAxis.stacks,
oldStacks = yAxis.oldStacks,
stackIndicator,
isNegative,
stack,
other,
key,
pointKey,
i,
x,
y;
yAxis.stacksTouched += 1;
// loop over the non-null y values and read them into a local array
for (i = 0; i < yDataLength; i++) {
x = xData[i];
y = yData[i];
stackIndicator = series.getStackIndicator(
stackIndicator,
x,
series.index
);
pointKey = stackIndicator.key;
// Read stacked values into a stack based on the x value,
// the sign of y and the stack key. Stacking is also handled for null
// values (#739)
isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
key = isNegative ? negKey : stackKey;
// Create empty object for this stack if it doesn't exist yet
if (!stacks[key]) {
stacks[key] = {};
}
// Initialize StackItem for this x
if (!stacks[key][x]) {
if (oldStacks[key] && oldStacks[key][x]) {
stacks[key][x] = oldStacks[key][x];
stacks[key][x].total = null;
} else {
stacks[key][x] = new StackItem(
yAxis,
yAxis.options.stackLabels,
isNegative,
x,
stackOption
);
}
}
// If the StackItem doesn't exist, create it first
stack = stacks[key][x];
if (y !== null) {
stack.points[pointKey] = stack.points[series.index] = [pick(stack.cum, stackThreshold)];
// Record the base of the stack
if (!defined(stack.cum)) {
stack.base = pointKey;
}
stack.touched = yAxis.stacksTouched;
// In area charts, if there are multiple points on the same X value,
// let the area fill the full span of those points
if (stackIndicator.index > 0 && series.singleStacks === false) {
stack.points[pointKey][0] =
stack.points[series.index + ',' + x + ',0'][0];
}
}
// Add value to the stack total
if (stacking === 'percent') {
// Percent stacked column, totals are the same for the positive and
// negative stacks
other = isNegative ? stackKey : negKey;
if (negStacks && stacks[other] && stacks[other][x]) {
other = stacks[other][x];
stack.total = other.total =
Math.max(other.total, stack.total) + Math.abs(y) || 0;
// Percent stacked areas
} else {
stack.total = correctFloat(stack.total + (Math.abs(y) || 0));
}
} else {
stack.total = correctFloat(stack.total + (y || 0));
}
stack.cum = pick(stack.cum, stackThreshold) + (y || 0);
if (y !== null) {
stack.points[pointKey].push(stack.cum);
stackedYData[i] = stack.cum;
}
}
if (stacking === 'percent') {
yAxis.usePercentage = true;
}
this.stackedYData = stackedYData; // To be used in getExtremes
// Reset old stacks
yAxis.oldStacks = {};
};
/**
* Iterate over all stacks and compute the absolute values to percent
*/
Series.prototype.setPercentStacks = function() {
var series = this,
stackKey = series.stackKey,
stacks = series.yAxis.stacks,
processedXData = series.processedXData,
stackIndicator;
each([stackKey, '-' + stackKey], function(key) {
var i = processedXData.length,
x,
stack,
pointExtremes,
totalFactor;
while (i--) {
x = processedXData[i];
stackIndicator = series.getStackIndicator(
stackIndicator,
x,
series.index,
key
);
stack = stacks[key] && stacks[key][x];
pointExtremes = stack && stack.points[stackIndicator.key];
if (pointExtremes) {
totalFactor = stack.total ? 100 / stack.total : 0;
// Y bottom value
pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor);
// Y value
pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor);
series.stackedYData[i] = pointExtremes[1];
}
}
});
};
/**
* Get stack indicator, according to it's x-value, to determine points with the
* same x-value
*/
Series.prototype.getStackIndicator = function(stackIndicator, x, index, key) {
// Update stack indicator, when:
// first point in a stack || x changed || stack type (negative vs positive)
// changed:
if (!defined(stackIndicator) || stackIndicator.x !== x ||
(key && stackIndicator.key !== key)) {
stackIndicator = {
x: x,
index: 0,
key: key
};
} else {
stackIndicator.index++;
}
stackIndicator.key = [index, x, stackIndicator.index].join(',');
return stackIndicator;
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
animate = H.animate,
Axis = H.Axis,
Chart = H.Chart,
createElement = H.createElement,
css = H.css,
defined = H.defined,
each = H.each,
erase = H.erase,
extend = H.extend,
fireEvent = H.fireEvent,
inArray = H.inArray,
isNumber = H.isNumber,
isObject = H.isObject,
merge = H.merge,
pick = H.pick,
Point = H.Point,
Series = H.Series,
seriesTypes = H.seriesTypes,
setAnimation = H.setAnimation,
splat = H.splat;
// Extend the Chart prototype for dynamic methods
extend(Chart.prototype, /** @lends Highcharts.Chart.prototype */ {
/**
* Add a series dynamically after time
*
* @param {Object} options The config options
* @param {Boolean} redraw Whether to redraw the chart after adding. Defaults to true.
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*
* @return {Object} series The newly created series object
*/
addSeries: function(options, redraw, animation) {
var series,
chart = this;
if (options) {
redraw = pick(redraw, true); // defaults to true
fireEvent(chart, 'addSeries', {
options: options
}, function() {
series = chart.initSeries(options);
chart.isDirtyLegend = true; // the series array is out of sync with the display
chart.linkSeries();
if (redraw) {
chart.redraw(animation);
}
});
}
return series;
},
/**
* Add an axis to the chart
* @param {Object} options The axis option
* @param {Boolean} isX Whether it is an X axis or a value axis
*/
addAxis: function(options, isX, redraw, animation) {
var key = isX ? 'xAxis' : 'yAxis',
chartOptions = this.options,
userOptions = merge(options, {
index: this[key].length,
isX: isX
});
new Axis(this, userOptions); // eslint-disable-line no-new
// Push the new axis options to the chart options
chartOptions[key] = splat(chartOptions[key] || {});
chartOptions[key].push(userOptions);
if (pick(redraw, true)) {
this.redraw(animation);
}
},
/**
* Dim the chart and show a loading text or symbol
* @param {String} str An optional text to show in the loading label instead of the default one
*/
showLoading: function(str) {
var chart = this,
options = chart.options,
loadingDiv = chart.loadingDiv,
loadingOptions = options.loading,
setLoadingSize = function() {
if (loadingDiv) {
css(loadingDiv, {
left: chart.plotLeft + 'px',
top: chart.plotTop + 'px',
width: chart.plotWidth + 'px',
height: chart.plotHeight + 'px'
});
}
};
// create the layer at the first call
if (!loadingDiv) {
chart.loadingDiv = loadingDiv = createElement('div', {
className: 'highcharts-loading highcharts-loading-hidden'
}, null, chart.container);
chart.loadingSpan = createElement(
'span', {
className: 'highcharts-loading-inner'
},
null,
loadingDiv
);
addEvent(chart, 'redraw', setLoadingSize); // #1080
}
loadingDiv.className = 'highcharts-loading';
// Update text
chart.loadingSpan.innerHTML = str || options.lang.loading;
// Update visuals
css(loadingDiv, extend(loadingOptions.style, {
zIndex: 10
}));
css(chart.loadingSpan, loadingOptions.labelStyle);
// Show it
if (!chart.loadingShown) {
css(loadingDiv, {
opacity: 0,
display: ''
});
animate(loadingDiv, {
opacity: loadingOptions.style.opacity || 0.5
}, {
duration: loadingOptions.showDuration || 0
});
}
chart.loadingShown = true;
setLoadingSize();
},
/**
* Hide the loading layer
*/
hideLoading: function() {
var options = this.options,
loadingDiv = this.loadingDiv;
if (loadingDiv) {
loadingDiv.className = 'highcharts-loading highcharts-loading-hidden';
animate(loadingDiv, {
opacity: 0
}, {
duration: options.loading.hideDuration || 100,
complete: function() {
css(loadingDiv, {
display: 'none'
});
}
});
}
this.loadingShown = false;
},
/**
* These properties cause isDirtyBox to be set to true when updating. Can be extended from plugins.
*/
propsRequireDirtyBox: ['backgroundColor', 'borderColor', 'borderWidth', 'margin', 'marginTop', 'marginRight',
'marginBottom', 'marginLeft', 'spacing', 'spacingTop', 'spacingRight', 'spacingBottom', 'spacingLeft',
'borderRadius', 'plotBackgroundColor', 'plotBackgroundImage', 'plotBorderColor', 'plotBorderWidth',
'plotShadow', 'shadow'
],
/**
* These properties cause all series to be updated when updating. Can be
* extended from plugins.
*/
propsRequireUpdateSeries: ['chart.inverted', 'chart.polar',
'chart.ignoreHiddenSeries', 'chart.type', 'colors', 'plotOptions'
],
/**
* Chart.update function that takes the whole options stucture.
*/
update: function(options, redraw) {
var key,
adders = {
credits: 'addCredits',
title: 'setTitle',
subtitle: 'setSubtitle'
},
optionsChart = options.chart,
updateAllAxes,
updateAllSeries,
newWidth,
newHeight;
// If the top-level chart option is present, some special updates are required
if (optionsChart) {
merge(true, this.options.chart, optionsChart);
// Setter function
if ('className' in optionsChart) {
this.setClassName(optionsChart.className);
}
if ('inverted' in optionsChart || 'polar' in optionsChart) {
// Parse options.chart.inverted and options.chart.polar together
// with the available series.
this.propFromSeries();
updateAllAxes = true;
}
if ('alignTicks' in optionsChart) { // #6452
updateAllAxes = true;
}
for (key in optionsChart) {
if (optionsChart.hasOwnProperty(key)) {
if (inArray('chart.' + key, this.propsRequireUpdateSeries) !== -1) {
updateAllSeries = true;
}
// Only dirty box
if (inArray(key, this.propsRequireDirtyBox) !== -1) {
this.isDirtyBox = true;
}
}
}
if ('style' in optionsChart) {
this.renderer.setStyle(optionsChart.style);
}
}
// Some option stuctures correspond one-to-one to chart objects that have
// update methods, for example
// options.credits => chart.credits
// options.legend => chart.legend
// options.title => chart.title
// options.tooltip => chart.tooltip
// options.subtitle => chart.subtitle
// options.mapNavigation => chart.mapNavigation
// options.navigator => chart.navigator
// options.scrollbar => chart.scrollbar
for (key in options) {
if (this[key] && typeof this[key].update === 'function') {
this[key].update(options[key], false);
// If a one-to-one object does not exist, look for an adder function
} else if (typeof this[adders[key]] === 'function') {
this[adders[key]](options[key]);
}
if (key !== 'chart' && inArray(key, this.propsRequireUpdateSeries) !== -1) {
updateAllSeries = true;
}
}
if (options.colors) {
this.options.colors = options.colors;
}
if (options.plotOptions) {
merge(true, this.options.plotOptions, options.plotOptions);
}
// Setters for collections. For axes and series, each item is referred
// by an id. If the id is not found, it defaults to the corresponding
// item in the collection, so setting one series without an id, will
// update the first series in the chart. Setting two series without
// an id will update the first and the second respectively (#6019)
// chart.update and responsive.
each(['xAxis', 'yAxis', 'series', 'colorAxis', 'pane'], function(coll) {
if (options[coll]) {
each(splat(options[coll]), function(newOptions, i) {
var item = (
defined(newOptions.id) &&
this.get(newOptions.id)
) || this[coll][i];
if (item && item.coll === coll) {
item.update(newOptions, false);
}
}, this);
}
}, this);
if (updateAllAxes) {
each(this.axes, function(axis) {
axis.update({}, false);
});
}
// Certain options require the whole series structure to be thrown away
// and rebuilt
if (updateAllSeries) {
each(this.series, function(series) {
series.update({}, false);
});
}
// For loading, just update the options, do not redraw
if (options.loading) {
merge(true, this.options.loading, options.loading);
}
// Update size. Redraw is forced.
newWidth = optionsChart && optionsChart.width;
newHeight = optionsChart && optionsChart.height;
if ((isNumber(newWidth) && newWidth !== this.chartWidth) ||
(isNumber(newHeight) && newHeight !== this.chartHeight)) {
this.setSize(newWidth, newHeight);
} else if (pick(redraw, true)) {
this.redraw();
}
},
/**
* Setter function to allow use from chart.update
*/
setSubtitle: function(options) {
this.setTitle(undefined, options);
}
});
// extend the Point prototype for dynamic methods
extend(Point.prototype, /** @lends Point.prototype */ {
/**
* Point.update with new options (typically x/y data) and optionally redraw the series.
*
* @param {Object} options Point options as defined in the series.data array
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
update: function(options, redraw, animation, runEvent) {
var point = this,
series = point.series,
graphic = point.graphic,
i,
chart = series.chart,
seriesOptions = series.options;
redraw = pick(redraw, true);
function update() {
point.applyOptions(options);
// Update visuals
if (point.y === null && graphic) { // #4146
point.graphic = graphic.destroy();
}
if (isObject(options, true)) {
// Destroy so we can get new elements
if (graphic && graphic.element) {
if (options && options.marker && options.marker.symbol) {
point.graphic = graphic.destroy();
}
}
if (options && options.dataLabels && point.dataLabel) { // #2468
point.dataLabel = point.dataLabel.destroy();
}
}
// record changes in the parallel arrays
i = point.index;
series.updateParallelArrays(point, i);
// Record the options to options.data. If the old or the new config
// is an object, use point options, otherwise use raw options
// (#4701, #4916).
seriesOptions.data[i] = (
isObject(seriesOptions.data[i], true) ||
isObject(options, true)
) ?
point.options :
options;
// redraw
series.isDirty = series.isDirtyData = true;
if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
chart.isDirtyBox = true;
}
if (seriesOptions.legendType === 'point') { // #1831, #1885
chart.isDirtyLegend = true;
}
if (redraw) {
chart.redraw(animation);
}
}
// Fire the event with a default handler of doing the update
if (runEvent === false) { // When called from setData
update();
} else {
point.firePointEvent('update', {
options: options
}, update);
}
},
/**
* Remove a point and optionally redraw the series and if necessary the axes
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
remove: function(redraw, animation) {
this.series.removePoint(inArray(this, this.series.data), redraw, animation);
}
});
// Extend the series prototype for dynamic methods
extend(Series.prototype, /** @lends Series.prototype */ {
/**
* Add a point dynamically after chart load time
* @param {Object} options Point options as given in series.data
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean} shift If shift is true, a point is shifted off the start
* of the series as one is appended to the end.
* @param {Boolean|AnimationOptions} animation Whether to apply animation, and optionally animation
* configuration
*/
addPoint: function(options, redraw, shift, animation) {
var series = this,
seriesOptions = series.options,
data = series.data,
chart = series.chart,
xAxis = series.xAxis,
names = xAxis && xAxis.hasNames && xAxis.names,
dataOptions = seriesOptions.data,
point,
isInTheMiddle,
xData = series.xData,
i,
x;
// Optional redraw, defaults to true
redraw = pick(redraw, true);
// Get options and push the point to xData, yData and series.options. In series.generatePoints
// the Point instance will be created on demand and pushed to the series.data array.
point = {
series: series
};
series.pointClass.prototype.applyOptions.apply(point, [options]);
x = point.x;
// Get the insertion point
i = xData.length;
if (series.requireSorting && x < xData[i - 1]) {
isInTheMiddle = true;
while (i && xData[i - 1] > x) {
i--;
}
}
series.updateParallelArrays(point, 'splice', i, 0, 0); // insert undefined item
series.updateParallelArrays(point, i); // update it
if (names && point.name) {
names[x] = point.name;
}
dataOptions.splice(i, 0, options);
if (isInTheMiddle) {
series.data.splice(i, 0, null);
series.processData();
}
// Generate points to be added to the legend (#1329)
if (seriesOptions.legendType === 'point') {
series.generatePoints();
}
// Shift the first point off the parallel arrays
if (shift) {
if (data[0] && data[0].remove) {
data[0].remove(false);
} else {
data.shift();
series.updateParallelArrays(point, 'shift');
dataOptions.shift();
}
}
// redraw
series.isDirty = true;
series.isDirtyData = true;
if (redraw) {
chart.redraw(animation); // Animation is set anyway on redraw, #5665
}
},
/**
* Remove a point (rendered or not), by index
*/
removePoint: function(i, redraw, animation) {
var series = this,
data = series.data,
point = data[i],
points = series.points,
chart = series.chart,
remove = function() {
if (points && points.length === data.length) { // #4935
points.splice(i, 1);
}
data.splice(i, 1);
series.options.data.splice(i, 1);
series.updateParallelArrays(point || {
series: series
}, 'splice', i, 1);
if (point) {
point.destroy();
}
// redraw
series.isDirty = true;
series.isDirtyData = true;
if (redraw) {
chart.redraw();
}
};
setAnimation(animation, chart);
redraw = pick(redraw, true);
// Fire the event with a default handler of removing the point
if (point) {
point.firePointEvent('remove', null, remove);
} else {
remove();
}
},
/**
* Remove a series and optionally redraw the chart
*
* @param {Boolean} redraw Whether to redraw the chart or wait for an explicit call
* @param {Boolean|Object} animation Whether to apply animation, and optionally animation
* configuration
*/
remove: function(redraw, animation, withEvent) {
var series = this,
chart = series.chart;
function remove() {
// Destroy elements
series.destroy();
// Redraw
chart.isDirtyLegend = chart.isDirtyBox = true;
chart.linkSeries();
if (pick(redraw, true)) {
chart.redraw(animation);
}
}
// Fire the event with a default handler of removing the point
if (withEvent !== false) {
fireEvent(series, 'remove', null, remove);
} else {
remove();
}
},
/**
* Series.update with a new set of options
*/
update: function(newOptions, redraw) {
var series = this,
chart = this.chart,
// must use user options when changing type because this.options is merged
// in with type specific plotOptions
oldOptions = this.userOptions,
oldType = this.oldType || this.type,
newType = newOptions.type || oldOptions.type || chart.options.chart.type,
proto = seriesTypes[oldType].prototype,
preserve = ['group', 'markerGroup', 'dataLabelsGroup'],
n;
// If we're changing type or zIndex, create new groups (#3380, #3404)
if ((newType && newType !== oldType) || newOptions.zIndex !== undefined) {
preserve.length = 0;
}
// Make sure groups are not destroyed (#3094)
each(preserve, function(prop) {
preserve[prop] = series[prop];
delete series[prop];
});
// Do the merge, with some forced options
newOptions = merge(oldOptions, {
animation: false,
index: this.index,
pointStart: this.xData[0] // when updating after addPoint
}, {
data: this.options.data
}, newOptions);
// Destroy the series and delete all properties. Reinsert all methods
// and properties from the new type prototype (#2270, #3719)
this.remove(false, null, false);
for (n in proto) {
this[n] = undefined;
}
extend(this, seriesTypes[newType || oldType].prototype);
// Re-register groups (#3094)
each(preserve, function(prop) {
series[prop] = preserve[prop];
});
this.init(chart, newOptions);
this.oldType = oldType;
chart.linkSeries(); // Links are lost in this.remove (#3028)
if (pick(redraw, true)) {
chart.redraw(false);
}
}
});
// Extend the Axis.prototype for dynamic methods
extend(Axis.prototype, /** @lends Axis.prototype */ {
/**
* Axis.update with a new options structure
*/
update: function(newOptions, redraw) {
var chart = this.chart;
newOptions = chart.options[this.coll][this.options.index] = merge(this.userOptions, newOptions);
this.destroy(true);
this.init(chart, extend(newOptions, {
events: undefined
}));
chart.isDirtyBox = true;
if (pick(redraw, true)) {
chart.redraw();
}
},
/**
* Remove the axis from the chart
*/
remove: function(redraw) {
var chart = this.chart,
key = this.coll, // xAxis or yAxis
axisSeries = this.series,
i = axisSeries.length;
// Remove associated series (#2687)
while (i--) {
if (axisSeries[i]) {
axisSeries[i].remove(false);
}
}
// Remove the axis
erase(chart.axes, this);
erase(chart[key], this);
chart.options[key].splice(this.options.index, 1);
each(chart[key], function(axis, i) { // Re-index, #1706
axis.options.index = i;
});
this.destroy();
chart.isDirtyBox = true;
if (pick(redraw, true)) {
chart.redraw();
}
},
/**
* Update the axis title by options
*/
setTitle: function(newTitleOptions, redraw) {
this.update({
title: newTitleOptions
}, redraw);
},
/**
* Set new axis categories and optionally redraw
* @param {Array} categories
* @param {Boolean} redraw
*/
setCategories: function(categories, redraw) {
this.update({
categories: categories
}, redraw);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var color = H.color,
each = H.each,
LegendSymbolMixin = H.LegendSymbolMixin,
map = H.map,
pick = H.pick,
Series = H.Series,
seriesType = H.seriesType;
/**
* Area series type.
* @constructor seriesTypes.area
* @extends {Series}
*/
seriesType('area', 'line', {
softThreshold: false,
threshold: 0
// trackByArea: false,
// lineColor: null, // overrides color, but lets fillColor be unaltered
// fillOpacity: 0.75,
// fillColor: null
}, /** @lends seriesTypes.area.prototype */ {
singleStacks: false,
/**
* Return an array of stacked points, where null and missing points are replaced by
* dummy points in order for gaps to be drawn correctly in stacks.
*/
getStackPoints: function() {
var series = this,
segment = [],
keys = [],
xAxis = this.xAxis,
yAxis = this.yAxis,
stack = yAxis.stacks[this.stackKey],
pointMap = {},
points = this.points,
seriesIndex = series.index,
yAxisSeries = yAxis.series,
seriesLength = yAxisSeries.length,
visibleSeries,
upOrDown = pick(yAxis.options.reversedStacks, true) ? 1 : -1,
i,
x;
if (this.options.stacking) {
// Create a map where we can quickly look up the points by their X value.
for (i = 0; i < points.length; i++) {
pointMap[points[i].x] = points[i];
}
// Sort the keys (#1651)
for (x in stack) {
if (stack[x].total !== null) { // nulled after switching between grouping and not (#1651, #2336)
keys.push(x);
}
}
keys.sort(function(a, b) {
return a - b;
});
visibleSeries = map(yAxisSeries, function() {
return this.visible;
});
each(keys, function(x, idx) {
var y = 0,
stackPoint,
stackedValues;
if (pointMap[x] && !pointMap[x].isNull) {
segment.push(pointMap[x]);
// Find left and right cliff. -1 goes left, 1 goes right.
each([-1, 1], function(direction) {
var nullName = direction === 1 ? 'rightNull' : 'leftNull',
cliffName = direction === 1 ? 'rightCliff' : 'leftCliff',
cliff = 0,
otherStack = stack[keys[idx + direction]];
// If there is a stack next to this one, to the left or to the right...
if (otherStack) {
i = seriesIndex;
while (i >= 0 && i < seriesLength) { // Can go either up or down, depending on reversedStacks
stackPoint = otherStack.points[i];
if (!stackPoint) {
// If the next point in this series is missing, mark the point
// with point.leftNull or point.rightNull = true.
if (i === seriesIndex) {
pointMap[x][nullName] = true;
// If there are missing points in the next stack in any of the
// series below this one, we need to substract the missing values
// and add a hiatus to the left or right.
} else if (visibleSeries[i]) {
stackedValues = stack[x].points[i];
if (stackedValues) {
cliff -= stackedValues[1] - stackedValues[0];
}
}
}
// When reversedStacks is true, loop up, else loop down
i += upOrDown;
}
}
pointMap[x][cliffName] = cliff;
});
// There is no point for this X value in this series, so we
// insert a dummy point in order for the areas to be drawn
// correctly.
} else {
// Loop down the stack to find the series below this one that has
// a value (#1991)
i = seriesIndex;
while (i >= 0 && i < seriesLength) {
stackPoint = stack[x].points[i];
if (stackPoint) {
y = stackPoint[1];
break;
}
// When reversedStacks is true, loop up, else loop down
i += upOrDown;
}
y = yAxis.translate(y, 0, 1, 0, 1); // #6272
segment.push({
isNull: true,
plotX: xAxis.translate(x, 0, 0, 0, 1), // #6272
x: x,
plotY: y,
yBottom: y
});
}
});
}
return segment;
},
getGraphPath: function(points) {
var getGraphPath = Series.prototype.getGraphPath,
graphPath,
options = this.options,
stacking = options.stacking,
yAxis = this.yAxis,
topPath,
//topPoints = [],
bottomPath,
bottomPoints = [],
graphPoints = [],
seriesIndex = this.index,
i,
areaPath,
plotX,
stacks = yAxis.stacks[this.stackKey],
threshold = options.threshold,
translatedThreshold = yAxis.getThreshold(options.threshold),
isNull,
yBottom,
connectNulls = options.connectNulls || stacking === 'percent',
/**
* To display null points in underlying stacked series, this series graph must be
* broken, and the area also fall down to fill the gap left by the null point. #2069
*/
addDummyPoints = function(i, otherI, side) {
var point = points[i],
stackedValues = stacking && stacks[point.x].points[seriesIndex],
nullVal = point[side + 'Null'] || 0,
cliffVal = point[side + 'Cliff'] || 0,
top,
bottom,
isNull = true;
if (cliffVal || nullVal) {
top = (nullVal ? stackedValues[0] : stackedValues[1]) + cliffVal;
bottom = stackedValues[0] + cliffVal;
isNull = !!nullVal;
} else if (!stacking && points[otherI] && points[otherI].isNull) {
top = bottom = threshold;
}
// Add to the top and bottom line of the area
if (top !== undefined) {
graphPoints.push({
plotX: plotX,
plotY: top === null ? translatedThreshold : yAxis.getThreshold(top),
isNull: isNull,
isCliff: true
});
bottomPoints.push({
plotX: plotX,
plotY: bottom === null ? translatedThreshold : yAxis.getThreshold(bottom),
doCurve: false // #1041, gaps in areaspline areas
});
}
};
// Find what points to use
points = points || this.points;
// Fill in missing points
if (stacking) {
points = this.getStackPoints();
}
for (i = 0; i < points.length; i++) {
isNull = points[i].isNull;
plotX = pick(points[i].rectPlotX, points[i].plotX);
yBottom = pick(points[i].yBottom, translatedThreshold);
if (!isNull || connectNulls) {
if (!connectNulls) {
addDummyPoints(i, i - 1, 'left');
}
if (!(isNull && !stacking && connectNulls)) { // Skip null point when stacking is false and connectNulls true
graphPoints.push(points[i]);
bottomPoints.push({
x: i,
plotX: plotX,
plotY: yBottom
});
}
if (!connectNulls) {
addDummyPoints(i, i + 1, 'right');
}
}
}
topPath = getGraphPath.call(this, graphPoints, true, true);
bottomPoints.reversed = true;
bottomPath = getGraphPath.call(this, bottomPoints, true, true);
if (bottomPath.length) {
bottomPath[0] = 'L';
}
areaPath = topPath.concat(bottomPath);
graphPath = getGraphPath.call(this, graphPoints, false, connectNulls); // TODO: don't set leftCliff and rightCliff when connectNulls?
areaPath.xMap = topPath.xMap;
this.areaPath = areaPath;
return graphPath;
},
/**
* Draw the graph and the underlying area. This method calls the Series base
* function and adds the area. The areaPath is calculated in the getSegmentPath
* method called from Series.prototype.drawGraph.
*/
drawGraph: function() {
// Define or reset areaPath
this.areaPath = [];
// Call the base method
Series.prototype.drawGraph.apply(this);
// Define local variables
var series = this,
areaPath = this.areaPath,
options = this.options,
zones = this.zones,
props = [
[
'area',
'highcharts-area',
this.color,
options.fillColor
]
]; // area name, main color, fill color
each(zones, function(zone, i) {
props.push([
'zone-area-' + i,
'highcharts-area highcharts-zone-area-' + i + ' ' + zone.className,
zone.color || series.color,
zone.fillColor || options.fillColor
]);
});
each(props, function(prop) {
var areaKey = prop[0],
area = series[areaKey];
// Create or update the area
if (area) { // update
area.endX = areaPath.xMap;
area.animate({
d: areaPath
});
} else { // create
area = series[areaKey] = series.chart.renderer.path(areaPath)
.addClass(prop[1])
.attr({
fill: pick(
prop[3],
color(prop[2]).setOpacity(pick(options.fillOpacity, 0.75)).get()
),
zIndex: 0 // #1069
}).add(series.group);
area.isArea = true;
}
area.startX = areaPath.xMap;
area.shiftUnit = options.step ? 2 : 1;
});
},
drawLegendSymbol: LegendSymbolMixin.drawRectangle
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var pick = H.pick,
seriesType = H.seriesType;
/**
* Spline series type.
* @constructor seriesTypes.spline
* @extends {Series}
*/
seriesType('spline', 'line', {}, /** @lends seriesTypes.spline.prototype */ {
/**
* Get the spline segment from a given point's previous neighbour to the given point
*/
getPointSpline: function(points, point, i) {
var smoothing = 1.5, // 1 means control points midway between points, 2 means 1/3 from the point, 3 is 1/4 etc
denom = smoothing + 1,
plotX = point.plotX,
plotY = point.plotY,
lastPoint = points[i - 1],
nextPoint = points[i + 1],
leftContX,
leftContY,
rightContX,
rightContY,
ret;
function doCurve(otherPoint) {
return otherPoint &&
!otherPoint.isNull &&
otherPoint.doCurve !== false &&
!point.isCliff; // #6387, area splines next to null
}
// Find control points
if (doCurve(lastPoint) && doCurve(nextPoint)) {
var lastX = lastPoint.plotX,
lastY = lastPoint.plotY,
nextX = nextPoint.plotX,
nextY = nextPoint.plotY,
correction = 0;
leftContX = (smoothing * plotX + lastX) / denom;
leftContY = (smoothing * plotY + lastY) / denom;
rightContX = (smoothing * plotX + nextX) / denom;
rightContY = (smoothing * plotY + nextY) / denom;
// Have the two control points make a straight line through main point
if (rightContX !== leftContX) { // #5016, division by zero
correction = ((rightContY - leftContY) * (rightContX - plotX)) /
(rightContX - leftContX) + plotY - rightContY;
}
leftContY += correction;
rightContY += correction;
// to prevent false extremes, check that control points are between
// neighbouring points' y values
if (leftContY > lastY && leftContY > plotY) {
leftContY = Math.max(lastY, plotY);
rightContY = 2 * plotY - leftContY; // mirror of left control point
} else if (leftContY < lastY && leftContY < plotY) {
leftContY = Math.min(lastY, plotY);
rightContY = 2 * plotY - leftContY;
}
if (rightContY > nextY && rightContY > plotY) {
rightContY = Math.max(nextY, plotY);
leftContY = 2 * plotY - rightContY;
} else if (rightContY < nextY && rightContY < plotY) {
rightContY = Math.min(nextY, plotY);
leftContY = 2 * plotY - rightContY;
}
// record for drawing in next point
point.rightContX = rightContX;
point.rightContY = rightContY;
}
// Visualize control points for debugging
/*
if (leftContX) {
this.chart.renderer.circle(leftContX + this.chart.plotLeft, leftContY + this.chart.plotTop, 2)
.attr({
stroke: 'red',
'stroke-width': 2,
fill: 'none',
zIndex: 9
})
.add();
this.chart.renderer.path(['M', leftContX + this.chart.plotLeft, leftContY + this.chart.plotTop,
'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
.attr({
stroke: 'red',
'stroke-width': 2,
zIndex: 9
})
.add();
}
if (rightContX) {
this.chart.renderer.circle(rightContX + this.chart.plotLeft, rightContY + this.chart.plotTop, 2)
.attr({
stroke: 'green',
'stroke-width': 2,
fill: 'none',
zIndex: 9
})
.add();
this.chart.renderer.path(['M', rightContX + this.chart.plotLeft, rightContY + this.chart.plotTop,
'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
.attr({
stroke: 'green',
'stroke-width': 2,
zIndex: 9
})
.add();
}
// */
ret = [
'C',
pick(lastPoint.rightContX, lastPoint.plotX),
pick(lastPoint.rightContY, lastPoint.plotY),
pick(leftContX, plotX),
pick(leftContY, plotY),
plotX,
plotY
];
lastPoint.rightContX = lastPoint.rightContY = null; // reset for updating series later
return ret;
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var areaProto = H.seriesTypes.area.prototype,
defaultPlotOptions = H.defaultPlotOptions,
LegendSymbolMixin = H.LegendSymbolMixin,
seriesType = H.seriesType;
/**
* AreaSplineSeries object
*/
seriesType('areaspline', 'spline', defaultPlotOptions.area, {
getStackPoints: areaProto.getStackPoints,
getGraphPath: areaProto.getGraphPath,
setStackCliffs: areaProto.setStackCliffs,
drawGraph: areaProto.drawGraph,
drawLegendSymbol: LegendSymbolMixin.drawRectangle
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var animObject = H.animObject,
color = H.color,
each = H.each,
extend = H.extend,
isNumber = H.isNumber,
LegendSymbolMixin = H.LegendSymbolMixin,
merge = H.merge,
noop = H.noop,
pick = H.pick,
Series = H.Series,
seriesType = H.seriesType,
svg = H.svg;
/**
* The column series type.
*
* @constructor seriesTypes.column
* @augments Series
*/
seriesType('column', 'line', {
borderRadius: 0,
//colorByPoint: undefined,
crisp: true,
groupPadding: 0.2,
//grouping: true,
marker: null, // point options are specified in the base options
pointPadding: 0.1,
//pointWidth: null,
minPointLength: 0,
cropThreshold: 50, // when there are more points, they will not animate out of the chart on xAxis.setExtremes
pointRange: null, // null means auto, meaning 1 in a categorized axis and least distance between points if not categories
states: {
hover: {
halo: false,
brightness: 0.1,
shadow: false
},
select: {
color: '#cccccc',
borderColor: '#000000',
shadow: false
}
},
dataLabels: {
align: null, // auto
verticalAlign: null, // auto
y: null
},
softThreshold: false,
startFromThreshold: true, // false doesn't work well: http://jsfiddle.net/highcharts/hz8fopan/14/
stickyTracking: false,
tooltip: {
distance: 6
},
threshold: 0,
borderColor: '#ffffff'
// borderWidth: 1
}, /** @lends seriesTypes.column.prototype */ {
cropShoulder: 0,
directTouch: true, // When tooltip is not shared, this series (and derivatives) requires direct touch/hover. KD-tree does not apply.
trackerGroups: ['group', 'dataLabelsGroup'],
negStacks: true, // use separate negative stacks, unlike area stacks where a negative
// point is substracted from previous (#1910)
/**
* Initialize the series. Extends the basic Series.init method by
* marking other series of the same type as dirty.
*
* @function #init
* @memberOf seriesTypes.column
* @returns {void}
*/
init: function() {
Series.prototype.init.apply(this, arguments);
var series = this,
chart = series.chart;
// if the series is added dynamically, force redraw of other
// series affected by a new column
if (chart.hasRendered) {
each(chart.series, function(otherSeries) {
if (otherSeries.type === series.type) {
otherSeries.isDirty = true;
}
});
}
},
/**
* Return the width and x offset of the columns adjusted for grouping, groupPadding, pointPadding,
* pointWidth etc.
*/
getColumnMetrics: function() {
var series = this,
options = series.options,
xAxis = series.xAxis,
yAxis = series.yAxis,
reversedXAxis = xAxis.reversed,
stackKey,
stackGroups = {},
columnCount = 0;
// Get the total number of column type series.
// This is called on every series. Consider moving this logic to a
// chart.orderStacks() function and call it on init, addSeries and removeSeries
if (options.grouping === false) {
columnCount = 1;
} else {
each(series.chart.series, function(otherSeries) {
var otherOptions = otherSeries.options,
otherYAxis = otherSeries.yAxis,
columnIndex;
if (otherSeries.type === series.type && otherSeries.visible &&
yAxis.len === otherYAxis.len && yAxis.pos === otherYAxis.pos) { // #642, #2086
if (otherOptions.stacking) {
stackKey = otherSeries.stackKey;
if (stackGroups[stackKey] === undefined) {
stackGroups[stackKey] = columnCount++;
}
columnIndex = stackGroups[stackKey];
} else if (otherOptions.grouping !== false) { // #1162
columnIndex = columnCount++;
}
otherSeries.columnIndex = columnIndex;
}
});
}
var categoryWidth = Math.min(
Math.abs(xAxis.transA) * (xAxis.ordinalSlope || options.pointRange || xAxis.closestPointRange || xAxis.tickInterval || 1), // #2610
xAxis.len // #1535
),
groupPadding = categoryWidth * options.groupPadding,
groupWidth = categoryWidth - 2 * groupPadding,
pointOffsetWidth = groupWidth / (columnCount || 1),
pointWidth = Math.min(
options.maxPointWidth || xAxis.len,
pick(options.pointWidth, pointOffsetWidth * (1 - 2 * options.pointPadding))
),
pointPadding = (pointOffsetWidth - pointWidth) / 2,
colIndex = (series.columnIndex || 0) + (reversedXAxis ? 1 : 0), // #1251, #3737
pointXOffset = pointPadding + (groupPadding + colIndex *
pointOffsetWidth - (categoryWidth / 2)) *
(reversedXAxis ? -1 : 1);
// Save it for reading in linked series (Error bars particularly)
series.columnMetrics = {
width: pointWidth,
offset: pointXOffset
};
return series.columnMetrics;
},
/**
* Make the columns crisp. The edges are rounded to the nearest full pixel.
*/
crispCol: function(x, y, w, h) {
var chart = this.chart,
borderWidth = this.borderWidth,
xCrisp = -(borderWidth % 2 ? 0.5 : 0),
yCrisp = borderWidth % 2 ? 0.5 : 1,
right,
bottom,
fromTop;
if (chart.inverted && chart.renderer.isVML) {
yCrisp += 1;
}
// Horizontal. We need to first compute the exact right edge, then round it
// and compute the width from there.
if (this.options.crisp) {
right = Math.round(x + w) + xCrisp;
x = Math.round(x) + xCrisp;
w = right - x;
}
// Vertical
bottom = Math.round(y + h) + yCrisp;
fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
y = Math.round(y) + yCrisp;
h = bottom - y;
// Top edges are exceptions
if (fromTop && h) { // #5146
y -= 1;
h += 1;
}
return {
x: x,
y: y,
width: w,
height: h
};
},
/**
* Translate each point to the plot area coordinate system and find shape positions
*/
translate: function() {
var series = this,
chart = series.chart,
options = series.options,
dense = series.dense = series.closestPointRange * series.xAxis.transA < 2,
borderWidth = series.borderWidth = pick(
options.borderWidth,
dense ? 0 : 1 // #3635
),
yAxis = series.yAxis,
threshold = options.threshold,
translatedThreshold = series.translatedThreshold = yAxis.getThreshold(threshold),
minPointLength = pick(options.minPointLength, 5),
metrics = series.getColumnMetrics(),
pointWidth = metrics.width,
seriesBarW = series.barW = Math.max(pointWidth, 1 + 2 * borderWidth), // postprocessed for border width
pointXOffset = series.pointXOffset = metrics.offset;
if (chart.inverted) {
translatedThreshold -= 0.5; // #3355
}
// When the pointPadding is 0, we want the columns to be packed tightly, so we allow individual
// columns to have individual sizes. When pointPadding is greater, we strive for equal-width
// columns (#2694).
if (options.pointPadding) {
seriesBarW = Math.ceil(seriesBarW);
}
Series.prototype.translate.apply(series);
// Record the new values
each(series.points, function(point) {
var yBottom = pick(point.yBottom, translatedThreshold),
safeDistance = 999 + Math.abs(yBottom),
plotY = Math.min(Math.max(-safeDistance, point.plotY), yAxis.len + safeDistance), // Don't draw too far outside plot area (#1303, #2241, #4264)
barX = point.plotX + pointXOffset,
barW = seriesBarW,
barY = Math.min(plotY, yBottom),
up,
barH = Math.max(plotY, yBottom) - barY;
// Handle options.minPointLength
if (Math.abs(barH) < minPointLength) {
if (minPointLength) {
barH = minPointLength;
up = (!yAxis.reversed && !point.negative) || (yAxis.reversed && point.negative);
barY = Math.abs(barY - translatedThreshold) > minPointLength ? // stacked
yBottom - minPointLength : // keep position
translatedThreshold - (up ? minPointLength : 0); // #1485, #4051
}
}
// Cache for access in polar
point.barX = barX;
point.pointWidth = pointWidth;
// Fix the tooltip on center of grouped columns (#1216, #424, #3648)
point.tooltipPos = chart.inverted ? [yAxis.len + yAxis.pos - chart.plotLeft - plotY, series.xAxis.len - barX - barW / 2, barH] : [barX + barW / 2, plotY + yAxis.pos - chart.plotTop, barH];
// Register shape type and arguments to be used in drawPoints
point.shapeType = 'rect';
point.shapeArgs = series.crispCol.apply(
series,
point.isNull ? [point.plotX, yAxis.len / 2, 0, 0] : // #3169, drilldown from null must have a position to work from
[barX, barY, barW, barH]
);
});
},
getSymbol: noop,
/**
* Use a solid rectangle like the area series types
*/
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
/**
* Columns have no graph
*/
drawGraph: function() {
this.group[this.dense ? 'addClass' : 'removeClass']('highcharts-dense-data');
},
/**
* Get presentational attributes
*/
pointAttribs: function(point, state) {
var options = this.options,
stateOptions,
ret,
p2o = this.pointAttrToOptions || {},
strokeOption = p2o.stroke || 'borderColor',
strokeWidthOption = p2o['stroke-width'] || 'borderWidth',
fill = (point && point.color) || this.color,
stroke = point[strokeOption] || options[strokeOption] ||
this.color || fill, // set to fill when borderColor null
strokeWidth = point[strokeWidthOption] ||
options[strokeWidthOption] || this[strokeWidthOption] || 0,
dashstyle = options.dashStyle,
zone,
brightness;
// Handle zone colors
if (point && this.zones.length) {
zone = point.getZone();
fill = (zone && zone.color) || point.options.color || this.color; // When zones are present, don't use point.color (#4267)
}
// Select or hover states
if (state) {
stateOptions = merge(
options.states[state],
point.options.states && point.options.states[state] || {} // #6401
);
brightness = stateOptions.brightness;
fill = stateOptions.color ||
(brightness !== undefined && color(fill).brighten(stateOptions.brightness).get()) ||
fill;
stroke = stateOptions[strokeOption] || stroke;
strokeWidth = stateOptions[strokeWidthOption] || strokeWidth;
dashstyle = stateOptions.dashStyle || dashstyle;
}
ret = {
'fill': fill,
'stroke': stroke,
'stroke-width': strokeWidth
};
if (options.borderRadius) {
ret.r = options.borderRadius;
}
if (dashstyle) {
ret.dashstyle = dashstyle;
}
return ret;
},
/**
* Draw the columns. For bars, the series.group is rotated, so the same coordinates
* apply for columns and bars. This method is inherited by scatter series.
*
*/
drawPoints: function() {
var series = this,
chart = this.chart,
options = series.options,
renderer = chart.renderer,
animationLimit = options.animationLimit || 250,
shapeArgs;
// draw the columns
each(series.points, function(point) {
var plotY = point.plotY,
graphic = point.graphic;
if (isNumber(plotY) && point.y !== null) {
shapeArgs = point.shapeArgs;
if (graphic) { // update
graphic[chart.pointCount < animationLimit ? 'animate' : 'attr'](
merge(shapeArgs)
);
} else {
point.graphic = graphic = renderer[point.shapeType](shapeArgs)
.add(point.group || series.group);
}
// Presentational
graphic
.attr(series.pointAttribs(point, point.selected && 'select'))
.shadow(options.shadow, null, options.stacking && !options.borderRadius);
graphic.addClass(point.getClassName(), true);
} else if (graphic) {
point.graphic = graphic.destroy(); // #1269
}
});
},
/**
* Animate the column heights one by one from zero
* @param {Boolean} init Whether to initialize the animation or run it
*/
animate: function(init) {
var series = this,
yAxis = this.yAxis,
options = series.options,
inverted = this.chart.inverted,
attr = {},
translatedThreshold;
if (svg) { // VML is too slow anyway
if (init) {
attr.scaleY = 0.001;
translatedThreshold = Math.min(yAxis.pos + yAxis.len, Math.max(yAxis.pos, yAxis.toPixels(options.threshold)));
if (inverted) {
attr.translateX = translatedThreshold - yAxis.len;
} else {
attr.translateY = translatedThreshold;
}
series.group.attr(attr);
} else { // run the animation
attr[inverted ? 'translateX' : 'translateY'] = yAxis.pos;
series.group.animate(attr, extend(animObject(series.options.animation), {
// Do the scale synchronously to ensure smooth updating (#5030)
step: function(val, fx) {
series.group.attr({
scaleY: Math.max(0.001, fx.pos) // #5250
});
}
}));
// delete this function to allow it only once
series.animate = null;
}
}
},
/**
* Remove this series from the chart
*/
remove: function() {
var series = this,
chart = series.chart;
// column and bar series affects other series of the same type
// as they are either stacked or grouped
if (chart.hasRendered) {
each(chart.series, function(otherSeries) {
if (otherSeries.type === series.type) {
otherSeries.isDirty = true;
}
});
}
Series.prototype.remove.apply(series, arguments);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var seriesType = H.seriesType;
/**
* The Bar series class
*/
seriesType('bar', 'column', null, {
inverted: true
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Series = H.Series,
seriesType = H.seriesType;
/**
* The scatter series type
*/
seriesType('scatter', 'line', {
lineWidth: 0,
findNearestPointBy: 'xy',
marker: {
enabled: true // Overrides auto-enabling in line series (#3647)
},
tooltip: {
headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
'<span style="font-size: 0.85em"> {series.name}</span><br/>',
pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
}
// Prototype members
}, {
sorted: false,
requireSorting: false,
noSharedTooltip: true,
trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
takeOrdinalPosition: false, // #2342
drawGraph: function() {
if (this.options.lineWidth) {
Series.prototype.drawGraph.call(this);
}
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var pick = H.pick,
relativeLength = H.relativeLength;
H.CenteredSeriesMixin = {
/**
* Get the center of the pie based on the size and center options relative to the
* plot area. Borrowed by the polar and gauge series types.
*/
getCenter: function() {
var options = this.options,
chart = this.chart,
slicingRoom = 2 * (options.slicedOffset || 0),
handleSlicingRoom,
plotWidth = chart.plotWidth - 2 * slicingRoom,
plotHeight = chart.plotHeight - 2 * slicingRoom,
centerOption = options.center,
positions = [pick(centerOption[0], '50%'), pick(centerOption[1], '50%'), options.size || '100%', options.innerSize || 0],
smallestSize = Math.min(plotWidth, plotHeight),
i,
value;
for (i = 0; i < 4; ++i) {
value = positions[i];
handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value));
// i == 0: centerX, relative to width
// i == 1: centerY, relative to height
// i == 2: size, relative to smallestSize
// i == 3: innerSize, relative to size
positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) +
(handleSlicingRoom ? slicingRoom : 0);
}
// innerSize cannot be larger than size (#3632)
if (positions[3] > positions[2]) {
positions[3] = positions[2];
}
return positions;
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
CenteredSeriesMixin = H.CenteredSeriesMixin,
defined = H.defined,
each = H.each,
extend = H.extend,
inArray = H.inArray,
LegendSymbolMixin = H.LegendSymbolMixin,
noop = H.noop,
pick = H.pick,
Point = H.Point,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes,
setAnimation = H.setAnimation;
/**
* The pie series type.
*
* @constructor seriesTypes.pie
* @augments Series
*/
seriesType('pie', 'line', {
center: [null, null],
clip: false,
colorByPoint: true, // always true for pies
dataLabels: {
// align: null,
// connectorWidth: 1,
// connectorColor: point.color,
// connectorPadding: 5,
distance: 30,
enabled: true,
formatter: function() { // #2945
return this.y === null ? undefined : this.point.name;
},
// softConnector: true,
x: 0
// y: 0
},
ignoreHiddenPoint: true,
//innerSize: 0,
legendType: 'point',
marker: null, // point options are specified in the base options
size: null,
showInLegend: false,
slicedOffset: 10,
stickyTracking: false,
tooltip: {
followPointer: true
},
borderColor: '#ffffff',
borderWidth: 1,
states: {
hover: {
brightness: 0.1,
shadow: false
}
}
}, /** @lends seriesTypes.pie.prototype */ {
isCartesian: false,
requireSorting: false,
directTouch: true,
noSharedTooltip: true,
trackerGroups: ['group', 'dataLabelsGroup'],
axisTypes: [],
pointAttribs: seriesTypes.column.prototype.pointAttribs,
/**
* Animate the pies in
*/
animate: function(init) {
var series = this,
points = series.points,
startAngleRad = series.startAngleRad;
if (!init) {
each(points, function(point) {
var graphic = point.graphic,
args = point.shapeArgs;
if (graphic) {
// start values
graphic.attr({
r: point.startR || (series.center[3] / 2), // animate from inner radius (#779)
start: startAngleRad,
end: startAngleRad
});
// animate
graphic.animate({
r: args.r,
start: args.start,
end: args.end
}, series.options.animation);
}
});
// delete this function to allow it only once
series.animate = null;
}
},
/**
* Recompute total chart sum and update percentages of points.
*/
updateTotals: function() {
var i,
total = 0,
points = this.points,
len = points.length,
point,
ignoreHiddenPoint = this.options.ignoreHiddenPoint;
// Get the total sum
for (i = 0; i < len; i++) {
point = points[i];
// Disallow negative values (#1530, #3623, #5322)
if (point.y < 0) {
point.y = null;
}
total += (ignoreHiddenPoint && !point.visible) ? 0 : point.y;
}
this.total = total;
// Set each point's properties
for (i = 0; i < len; i++) {
point = points[i];
point.percentage = (total > 0 && (point.visible || !ignoreHiddenPoint)) ? point.y / total * 100 : 0;
point.total = total;
}
},
/**
* Extend the generatePoints method by adding total and percentage properties to each point
*/
generatePoints: function() {
Series.prototype.generatePoints.call(this);
this.updateTotals();
},
/**
* Do translation for pie slices
*/
translate: function(positions) {
this.generatePoints();
var series = this,
cumulative = 0,
precision = 1000, // issue #172
options = series.options,
slicedOffset = options.slicedOffset,
connectorOffset = slicedOffset + (options.borderWidth || 0),
start,
end,
angle,
startAngle = options.startAngle || 0,
startAngleRad = series.startAngleRad = Math.PI / 180 * (startAngle - 90),
endAngleRad = series.endAngleRad = Math.PI / 180 * ((pick(options.endAngle, startAngle + 360)) - 90),
circ = endAngleRad - startAngleRad, //2 * Math.PI,
points = series.points,
radiusX, // the x component of the radius vector for a given point
radiusY,
labelDistance = options.dataLabels.distance,
ignoreHiddenPoint = options.ignoreHiddenPoint,
i,
len = points.length,
point;
// Get positions - either an integer or a percentage string must be given.
// If positions are passed as a parameter, we're in a recursive loop for adjusting
// space for data labels.
if (!positions) {
series.center = positions = series.getCenter();
}
// utility for getting the x value from a given y, used for anticollision logic in data labels
series.getX = function(y, left) {
angle = Math.asin(Math.min((y - positions[1]) / (positions[2] / 2 + labelDistance), 1));
return positions[0] +
(left ? -1 : 1) *
(Math.cos(angle) * (positions[2] / 2 + labelDistance));
};
// Calculate the geometry for each point
for (i = 0; i < len; i++) {
point = points[i];
// set start and end angle
start = startAngleRad + (cumulative * circ);
if (!ignoreHiddenPoint || point.visible) {
cumulative += point.percentage / 100;
}
end = startAngleRad + (cumulative * circ);
// set the shape
point.shapeType = 'arc';
point.shapeArgs = {
x: positions[0],
y: positions[1],
r: positions[2] / 2,
innerR: positions[3] / 2,
start: Math.round(start * precision) / precision,
end: Math.round(end * precision) / precision
};
// The angle must stay within -90 and 270 (#2645)
angle = (end + start) / 2;
if (angle > 1.5 * Math.PI) {
angle -= 2 * Math.PI;
} else if (angle < -Math.PI / 2) {
angle += 2 * Math.PI;
}
// Center for the sliced out slice
point.slicedTranslation = {
translateX: Math.round(Math.cos(angle) * slicedOffset),
translateY: Math.round(Math.sin(angle) * slicedOffset)
};
// set the anchor point for tooltips
radiusX = Math.cos(angle) * positions[2] / 2;
radiusY = Math.sin(angle) * positions[2] / 2;
point.tooltipPos = [
positions[0] + radiusX * 0.7,
positions[1] + radiusY * 0.7
];
point.half = angle < -Math.PI / 2 || angle > Math.PI / 2 ? 1 : 0;
point.angle = angle;
// set the anchor point for data labels
connectorOffset = Math.min(connectorOffset, labelDistance / 5); // #1678
point.labelPos = [
positions[0] + radiusX + Math.cos(angle) * labelDistance, // first break of connector
positions[1] + radiusY + Math.sin(angle) * labelDistance, // a/a
positions[0] + radiusX + Math.cos(angle) * connectorOffset, // second break, right outside pie
positions[1] + radiusY + Math.sin(angle) * connectorOffset, // a/a
positions[0] + radiusX, // landing point for connector
positions[1] + radiusY, // a/a
labelDistance < 0 ? // alignment
'center' :
point.half ? 'right' : 'left', // alignment
angle // center angle
];
}
},
drawGraph: null,
/**
* Draw the data points
*/
drawPoints: function() {
var series = this,
chart = series.chart,
renderer = chart.renderer,
groupTranslation,
//center,
graphic,
//group,
pointAttr,
shapeArgs;
var shadow = series.options.shadow;
if (shadow && !series.shadowGroup) {
series.shadowGroup = renderer.g('shadow')
.add(series.group);
}
// draw the slices
each(series.points, function(point) {
if (point.y !== null) {
graphic = point.graphic;
shapeArgs = point.shapeArgs;
// If the point is sliced, use special translation, else use
// plot area traslation
groupTranslation = point.getTranslate();
// Put the shadow behind all points
var shadowGroup = point.shadowGroup;
if (shadow && !shadowGroup) {
shadowGroup = point.shadowGroup = renderer.g('shadow')
.add(series.shadowGroup);
}
if (shadowGroup) {
shadowGroup.attr(groupTranslation);
}
pointAttr = series.pointAttribs(point, point.selected && 'select');
// Draw the slice
if (graphic) {
graphic
.setRadialReference(series.center)
.attr(pointAttr)
.animate(extend(shapeArgs, groupTranslation));
} else {
point.graphic = graphic = renderer[point.shapeType](shapeArgs)
.setRadialReference(series.center)
.attr(groupTranslation)
.add(series.group);
if (!point.visible) {
graphic.attr({
visibility: 'hidden'
});
}
graphic
.attr(pointAttr)
.attr({
'stroke-linejoin': 'round'
})
.shadow(shadow, shadowGroup);
}
graphic.addClass(point.getClassName());
}
});
},
searchPoint: noop,
/**
* Utility for sorting data labels
*/
sortByAngle: function(points, sign) {
points.sort(function(a, b) {
return a.angle !== undefined && (b.angle - a.angle) * sign;
});
},
/**
* Use a simple symbol from LegendSymbolMixin
*/
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
/**
* Use the getCenter method from drawLegendSymbol
*/
getCenter: CenteredSeriesMixin.getCenter,
/**
* Pies don't have point marker symbols
*/
getSymbol: noop
/**
* @constructor seriesTypes.pie.prototype.pointClass
* @extends {Point}
*/
}, /** @lends seriesTypes.pie.prototype.pointClass.prototype */ {
/**
* Initiate the pie slice
*/
init: function() {
Point.prototype.init.apply(this, arguments);
var point = this,
toggleSlice;
point.name = pick(point.name, 'Slice');
// add event listener for select
toggleSlice = function(e) {
point.slice(e.type === 'select');
};
addEvent(point, 'select', toggleSlice);
addEvent(point, 'unselect', toggleSlice);
return point;
},
/**
* Toggle the visibility of the pie slice
* @param {Boolean} vis Whether to show the slice or not. If undefined, the
* visibility is toggled
*/
setVisible: function(vis, redraw) {
var point = this,
series = point.series,
chart = series.chart,
ignoreHiddenPoint = series.options.ignoreHiddenPoint;
redraw = pick(redraw, ignoreHiddenPoint);
if (vis !== point.visible) {
// If called without an argument, toggle visibility
point.visible = point.options.visible = vis = vis === undefined ? !point.visible : vis;
series.options.data[inArray(point, series.data)] = point.options; // update userOptions.data
// Show and hide associated elements. This is performed regardless of redraw or not,
// because chart.redraw only handles full series.
each(['graphic', 'dataLabel', 'connector', 'shadowGroup'], function(key) {
if (point[key]) {
point[key][vis ? 'show' : 'hide'](true);
}
});
if (point.legendItem) {
chart.legend.colorizeItem(point, vis);
}
// #4170, hide halo after hiding point
if (!vis && point.state === 'hover') {
point.setState('');
}
// Handle ignore hidden slices
if (ignoreHiddenPoint) {
series.isDirty = true;
}
if (redraw) {
chart.redraw();
}
}
},
/**
* Set or toggle whether the slice is cut out from the pie
* @param {Boolean} sliced When undefined, the slice state is toggled
* @param {Boolean} redraw Whether to redraw the chart. True by default.
*/
slice: function(sliced, redraw, animation) {
var point = this,
series = point.series,
chart = series.chart;
setAnimation(animation, chart);
// redraw is true by default
redraw = pick(redraw, true);
// if called without an argument, toggle
point.sliced = point.options.sliced = sliced = defined(sliced) ? sliced : !point.sliced;
series.options.data[inArray(point, series.data)] = point.options; // update userOptions.data
point.graphic.animate(this.getTranslate());
if (point.shadowGroup) {
point.shadowGroup.animate(this.getTranslate());
}
},
getTranslate: function() {
return this.sliced ? this.slicedTranslation : {
translateX: 0,
translateY: 0
};
},
haloPath: function(size) {
var shapeArgs = this.shapeArgs;
return this.sliced || !this.visible ? [] :
this.series.chart.renderer.symbols.arc(
shapeArgs.x,
shapeArgs.y,
shapeArgs.r + size,
shapeArgs.r + size, {
innerR: this.shapeArgs.r,
start: shapeArgs.start,
end: shapeArgs.end
}
);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
arrayMax = H.arrayMax,
defined = H.defined,
each = H.each,
extend = H.extend,
format = H.format,
map = H.map,
merge = H.merge,
noop = H.noop,
pick = H.pick,
relativeLength = H.relativeLength,
Series = H.Series,
seriesTypes = H.seriesTypes,
stableSort = H.stableSort;
/**
* Generatl distribution algorithm for distributing labels of differing size along a
* confined length in two dimensions. The algorithm takes an array of objects containing
* a size, a target and a rank. It will place the labels as close as possible to their
* targets, skipping the lowest ranked labels if necessary.
*/
H.distribute = function(boxes, len) {
var i,
overlapping = true,
origBoxes = boxes, // Original array will be altered with added .pos
restBoxes = [], // The outranked overshoot
box,
target,
total = 0;
function sortByTarget(a, b) {
return a.target - b.target;
}
// If the total size exceeds the len, remove those boxes with the lowest rank
i = boxes.length;
while (i--) {
total += boxes[i].size;
}
// Sort by rank, then slice away overshoot
if (total > len) {
stableSort(boxes, function(a, b) {
return (b.rank || 0) - (a.rank || 0);
});
i = 0;
total = 0;
while (total <= len) {
total += boxes[i].size;
i++;
}
restBoxes = boxes.splice(i - 1, boxes.length);
}
// Order by target
stableSort(boxes, sortByTarget);
// So far we have been mutating the original array. Now
// create a copy with target arrays
boxes = map(boxes, function(box) {
return {
size: box.size,
targets: [box.target]
};
});
while (overlapping) {
// Initial positions: target centered in box
i = boxes.length;
while (i--) {
box = boxes[i];
// Composite box, average of targets
target = (Math.min.apply(0, box.targets) + Math.max.apply(0, box.targets)) / 2;
box.pos = Math.min(Math.max(0, target - box.size / 2), len - box.size);
}
// Detect overlap and join boxes
i = boxes.length;
overlapping = false;
while (i--) {
if (i > 0 && boxes[i - 1].pos + boxes[i - 1].size > boxes[i].pos) { // Overlap
boxes[i - 1].size += boxes[i].size; // Add this size to the previous box
boxes[i - 1].targets = boxes[i - 1].targets.concat(boxes[i].targets);
// Overlapping right, push left
if (boxes[i - 1].pos + boxes[i - 1].size > len) {
boxes[i - 1].pos = len - boxes[i - 1].size;
}
boxes.splice(i, 1); // Remove this item
overlapping = true;
}
}
}
// Now the composite boxes are placed, we need to put the original boxes within them
i = 0;
each(boxes, function(box) {
var posInCompositeBox = 0;
each(box.targets, function() {
origBoxes[i].pos = box.pos + posInCompositeBox;
posInCompositeBox += origBoxes[i].size;
i++;
});
});
// Add the rest (hidden) boxes and sort by target
origBoxes.push.apply(origBoxes, restBoxes);
stableSort(origBoxes, sortByTarget);
};
/**
* Draw the data labels
*/
Series.prototype.drawDataLabels = function() {
var series = this,
seriesOptions = series.options,
options = seriesOptions.dataLabels,
points = series.points,
pointOptions,
generalOptions,
hasRendered = series.hasRendered || 0,
str,
dataLabelsGroup,
defer = pick(options.defer, true),
renderer = series.chart.renderer;
if (options.enabled || series._hasPointLabels) {
// Process default alignment of data labels for columns
if (series.dlProcessOptions) {
series.dlProcessOptions(options);
}
// Create a separate group for the data labels to avoid rotation
dataLabelsGroup = series.plotGroup(
'dataLabelsGroup',
'data-labels',
defer && !hasRendered ? 'hidden' : 'visible', // #5133
options.zIndex || 6
);
if (defer) {
dataLabelsGroup.attr({
opacity: +hasRendered
}); // #3300
if (!hasRendered) {
addEvent(series, 'afterAnimate', function() {
if (series.visible) { // #2597, #3023, #3024
dataLabelsGroup.show(true);
}
dataLabelsGroup[seriesOptions.animation ? 'animate' : 'attr']({
opacity: 1
}, {
duration: 200
});
});
}
}
// Make the labels for each point
generalOptions = options;
each(points, function(point) {
var enabled,
dataLabel = point.dataLabel,
labelConfig,
attr,
name,
rotation,
connector = point.connector,
isNew = !dataLabel,
style;
// Determine if each data label is enabled
// @note dataLabelAttribs (like pointAttribs) would eradicate
// the need for dlOptions, and simplify the section below.
pointOptions = point.dlOptions || (point.options && point.options.dataLabels); // dlOptions is used in treemaps
enabled = pick(pointOptions && pointOptions.enabled, generalOptions.enabled) && point.y !== null; // #2282, #4641
if (enabled) {
// Create individual options structure that can be extended without
// affecting others
options = merge(generalOptions, pointOptions);
labelConfig = point.getLabelConfig();
str = options.format ?
format(options.format, labelConfig) :
options.formatter.call(labelConfig, options);
style = options.style;
rotation = options.rotation;
// Determine the color
style.color = pick(options.color, style.color, series.color, '#000000');
// Get automated contrast color
if (style.color === 'contrast') {
point.contrastColor = renderer.getContrast(point.color || series.color);
style.color = options.inside || options.distance < 0 || !!seriesOptions.stacking ?
point.contrastColor : '#000000';
}
if (seriesOptions.cursor) {
style.cursor = seriesOptions.cursor;
}
attr = {
//align: align,
fill: options.backgroundColor,
stroke: options.borderColor,
'stroke-width': options.borderWidth,
r: options.borderRadius || 0,
rotation: rotation,
padding: options.padding,
zIndex: 1
};
// Remove unused attributes (#947)
for (name in attr) {
if (attr[name] === undefined) {
delete attr[name];
}
}
}
// If the point is outside the plot area, destroy it. #678, #820
if (dataLabel && (!enabled || !defined(str))) {
point.dataLabel = dataLabel = dataLabel.destroy();
if (connector) {
point.connector = connector.destroy();
}
// Individual labels are disabled if the are explicitly disabled
// in the point options, or if they fall outside the plot area.
} else if (enabled && defined(str)) {
// create new label
if (!dataLabel) {
dataLabel = point.dataLabel = renderer[rotation ? 'text' : 'label']( // labels don't support rotation
str,
0, -9999,
options.shape,
null,
null,
options.useHTML,
null,
'data-label'
);
dataLabel.addClass(
'highcharts-data-label-color-' + point.colorIndex +
' ' + (options.className || '') +
(options.useHTML ? 'highcharts-tracker' : '') // #3398
);
} else {
attr.text = str;
}
dataLabel.attr(attr);
// Styles must be applied before add in order to read text bounding box
dataLabel.css(style).shadow(options.shadow);
if (!dataLabel.added) {
dataLabel.add(dataLabelsGroup);
}
// Now the data label is created and placed at 0,0, so we need to align it
series.alignDataLabel(point, dataLabel, options, null, isNew);
}
});
}
};
/**
* Align each individual data label
*/
Series.prototype.alignDataLabel = function(point, dataLabel, options, alignTo, isNew) {
var chart = this.chart,
inverted = chart.inverted,
plotX = pick(point.plotX, -9999),
plotY = pick(point.plotY, -9999),
bBox = dataLabel.getBBox(),
fontSize,
baseline,
rotation = options.rotation,
normRotation,
negRotation,
align = options.align,
rotCorr, // rotation correction
// Math.round for rounding errors (#2683), alignTo to allow column labels (#2700)
visible =
this.visible &&
(
point.series.forceDL ||
chart.isInsidePlot(plotX, Math.round(plotY), inverted) ||
(
alignTo && chart.isInsidePlot(
plotX,
inverted ? alignTo.x + 1 : alignTo.y + alignTo.height - 1,
inverted
)
)
),
alignAttr, // the final position;
justify = pick(options.overflow, 'justify') === 'justify';
if (visible) {
fontSize = options.style.fontSize;
baseline = chart.renderer.fontMetrics(fontSize, dataLabel).b;
// The alignment box is a singular point
alignTo = extend({
x: inverted ? chart.plotWidth - plotY : plotX,
y: Math.round(inverted ? chart.plotHeight - plotX : plotY),
width: 0,
height: 0
}, alignTo);
// Add the text size for alignment calculation
extend(options, {
width: bBox.width,
height: bBox.height
});
// Allow a hook for changing alignment in the last moment, then do the alignment
if (rotation) {
justify = false; // Not supported for rotated text
rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
alignAttr = {
x: alignTo.x + options.x + alignTo.width / 2 + rotCorr.x,
y: alignTo.y + options.y + {
top: 0,
middle: 0.5,
bottom: 1
}[options.verticalAlign] * alignTo.height
};
dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
.attr({ // #3003
align: align
});
// Compensate for the rotated label sticking out on the sides
normRotation = (rotation + 720) % 360;
negRotation = normRotation > 180 && normRotation < 360;
if (align === 'left') {
alignAttr.y -= negRotation ? bBox.height : 0;
} else if (align === 'center') {
alignAttr.x -= bBox.width / 2;
alignAttr.y -= bBox.height / 2;
} else if (align === 'right') {
alignAttr.x -= bBox.width;
alignAttr.y -= negRotation ? 0 : bBox.height;
}
} else {
dataLabel.align(options, null, alignTo);
alignAttr = dataLabel.alignAttr;
}
// Handle justify or crop
if (justify) {
point.isLabelJustified = this.justifyDataLabel(
dataLabel,
options,
alignAttr,
bBox,
alignTo,
isNew
);
// Now check that the data label is within the plot area
} else if (pick(options.crop, true)) {
visible = chart.isInsidePlot(alignAttr.x, alignAttr.y) && chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height);
}
// When we're using a shape, make it possible with a connector or an arrow pointing to thie point
if (options.shape && !rotation) {
dataLabel.attr({
anchorX: point.plotX,
anchorY: point.plotY
});
}
}
// Show or hide based on the final aligned position
if (!visible) {
dataLabel.attr({
y: -9999
});
dataLabel.placed = false; // don't animate back in
}
};
/**
* If data labels fall partly outside the plot area, align them back in, in a way that
* doesn't hide the point.
*/
Series.prototype.justifyDataLabel = function(dataLabel, options, alignAttr, bBox, alignTo, isNew) {
var chart = this.chart,
align = options.align,
verticalAlign = options.verticalAlign,
off,
justified,
padding = dataLabel.box ? 0 : (dataLabel.padding || 0);
// Off left
off = alignAttr.x + padding;
if (off < 0) {
if (align === 'right') {
options.align = 'left';
} else {
options.x = -off;
}
justified = true;
}
// Off right
off = alignAttr.x + bBox.width - padding;
if (off > chart.plotWidth) {
if (align === 'left') {
options.align = 'right';
} else {
options.x = chart.plotWidth - off;
}
justified = true;
}
// Off top
off = alignAttr.y + padding;
if (off < 0) {
if (verticalAlign === 'bottom') {
options.verticalAlign = 'top';
} else {
options.y = -off;
}
justified = true;
}
// Off bottom
off = alignAttr.y + bBox.height - padding;
if (off > chart.plotHeight) {
if (verticalAlign === 'top') {
options.verticalAlign = 'bottom';
} else {
options.y = chart.plotHeight - off;
}
justified = true;
}
if (justified) {
dataLabel.placed = !isNew;
dataLabel.align(options, null, alignTo);
}
return justified;
};
/**
* Override the base drawDataLabels method by pie specific functionality
*/
if (seriesTypes.pie) {
seriesTypes.pie.prototype.drawDataLabels = function() {
var series = this,
data = series.data,
point,
chart = series.chart,
options = series.options.dataLabels,
connectorPadding = pick(options.connectorPadding, 10),
connectorWidth = pick(options.connectorWidth, 1),
plotWidth = chart.plotWidth,
plotHeight = chart.plotHeight,
connector,
distanceOption = options.distance,
seriesCenter = series.center,
radius = seriesCenter[2] / 2,
centerY = seriesCenter[1],
outside = distanceOption > 0,
dataLabel,
dataLabelWidth,
labelPos,
labelHeight,
halves = [ // divide the points into right and left halves for anti collision
[], // right
[] // left
],
x,
y,
visibility,
j,
overflow = [0, 0, 0, 0]; // top, right, bottom, left
// get out if not enabled
if (!series.visible || (!options.enabled && !series._hasPointLabels)) {
return;
}
// Reset all labels that have been shortened
each(data, function(point) {
if (point.dataLabel && point.visible && point.dataLabel.shortened) {
point.dataLabel
.attr({
width: 'auto'
}).css({
width: 'auto',
textOverflow: 'clip'
});
point.dataLabel.shortened = false;
}
});
// run parent method
Series.prototype.drawDataLabels.apply(series);
each(data, function(point) {
if (point.dataLabel && point.visible) { // #407, #2510
// Arrange points for detection collision
halves[point.half].push(point);
// Reset positions (#4905)
point.dataLabel._pos = null;
}
});
/* Loop over the points in each half, starting from the top and bottom
* of the pie to detect overlapping labels.
*/
each(halves, function(points, i) {
var top,
bottom,
length = points.length,
positions,
naturalY,
sideOverflow,
size;
if (!length) {
return;
}
// Sort by angle
series.sortByAngle(points, i - 0.5);
// Only do anti-collision when we are outside the pie and have connectors (#856)
if (distanceOption > 0) {
top = Math.max(0, centerY - radius - distanceOption);
bottom = Math.min(centerY + radius + distanceOption, chart.plotHeight);
positions = map(points, function(point) {
if (point.dataLabel) {
size = point.dataLabel.getBBox().height || 21;
return {
target: point.labelPos[1] - top + size / 2,
size: size,
rank: point.y
};
}
});
H.distribute(positions, bottom + size - top);
}
// now the used slots are sorted, fill them up sequentially
for (j = 0; j < length; j++) {
point = points[j];
labelPos = point.labelPos;
dataLabel = point.dataLabel;
visibility = point.visible === false ? 'hidden' : 'inherit';
naturalY = labelPos[1];
if (positions) {
if (positions[j].pos === undefined) {
visibility = 'hidden';
} else {
labelHeight = positions[j].size;
y = top + positions[j].pos;
}
} else {
y = naturalY;
}
// get the x - use the natural x position for labels near the top and bottom, to prevent the top
// and botton slice connectors from touching each other on either side
if (options.justify) {
x = seriesCenter[0] + (i ? -1 : 1) * (radius + distanceOption);
} else {
x = series.getX(y < top + 2 || y > bottom - 2 ? naturalY : y, i);
}
// Record the placement and visibility
dataLabel._attr = {
visibility: visibility,
align: labelPos[6]
};
dataLabel._pos = {
x: x + options.x +
({
left: connectorPadding,
right: -connectorPadding
}[labelPos[6]] || 0),
y: y + options.y - 10 // 10 is for the baseline (label vs text)
};
labelPos.x = x;
labelPos.y = y;
// Detect overflowing data labels
if (series.options.size === null) {
dataLabelWidth = dataLabel.getBBox().width;
sideOverflow = null;
// Overflow left
if (x - dataLabelWidth < connectorPadding) {
sideOverflow = Math.round(
dataLabelWidth - x + connectorPadding
);
overflow[3] = Math.max(sideOverflow, overflow[3]);
// Overflow right
} else if (x + dataLabelWidth > plotWidth - connectorPadding) {
sideOverflow = Math.round(
x + dataLabelWidth - plotWidth + connectorPadding
);
overflow[1] = Math.max(sideOverflow, overflow[1]);
}
// Overflow top
if (y - labelHeight / 2 < 0) {
overflow[0] = Math.max(
Math.round(-y + labelHeight / 2),
overflow[0]
);
// Overflow left
} else if (y + labelHeight / 2 > plotHeight) {
overflow[2] = Math.max(
Math.round(y + labelHeight / 2 - plotHeight),
overflow[2]
);
}
dataLabel.sideOverflow = sideOverflow;
}
} // for each point
}); // for each half
// Do not apply the final placement and draw the connectors until we have verified
// that labels are not spilling over.
if (arrayMax(overflow) === 0 || this.verifyDataLabelOverflow(overflow)) {
// Place the labels in the final position
this.placeDataLabels();
// Draw the connectors
if (outside && connectorWidth) {
each(this.points, function(point) {
var isNew;
connector = point.connector;
dataLabel = point.dataLabel;
if (dataLabel && dataLabel._pos && point.visible) {
visibility = dataLabel._attr.visibility;
isNew = !connector;
if (isNew) {
point.connector = connector = chart.renderer.path()
.addClass('highcharts-data-label-connector highcharts-color-' + point.colorIndex)
.add(series.dataLabelsGroup);
connector.attr({
'stroke-width': connectorWidth,
'stroke': options.connectorColor || point.color || '#666666'
});
}
connector[isNew ? 'attr' : 'animate']({
d: series.connectorPath(point.labelPos)
});
connector.attr('visibility', visibility);
} else if (connector) {
point.connector = connector.destroy();
}
});
}
}
};
/**
* Extendable method for getting the path of the connector between the data label
* and the pie slice.
*/
seriesTypes.pie.prototype.connectorPath = function(labelPos) {
var x = labelPos.x,
y = labelPos.y;
return pick(this.options.dataLabels.softConnector, true) ? [
'M',
x + (labelPos[6] === 'left' ? 5 : -5), y, // end of the string at the label
'C',
x, y, // first break, next to the label
2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
labelPos[2], labelPos[3], // second break
'L',
labelPos[4], labelPos[5] // base
] : [
'M',
x + (labelPos[6] === 'left' ? 5 : -5), y, // end of the string at the label
'L',
labelPos[2], labelPos[3], // second break
'L',
labelPos[4], labelPos[5] // base
];
};
/**
* Perform the final placement of the data labels after we have verified that they
* fall within the plot area.
*/
seriesTypes.pie.prototype.placeDataLabels = function() {
each(this.points, function(point) {
var dataLabel = point.dataLabel,
_pos;
if (dataLabel && point.visible) {
_pos = dataLabel._pos;
if (_pos) {
// Shorten data labels with ellipsis if they still overflow
// after the pie has reached minSize (#223).
if (dataLabel.sideOverflow) {
dataLabel._attr.width =
dataLabel.getBBox().width - dataLabel.sideOverflow;
dataLabel.css({
width: dataLabel._attr.width + 'px',
textOverflow: 'ellipsis'
});
dataLabel.shortened = true;
}
dataLabel.attr(dataLabel._attr);
dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
dataLabel.moved = true;
} else if (dataLabel) {
dataLabel.attr({
y: -9999
});
}
}
}, this);
};
seriesTypes.pie.prototype.alignDataLabel = noop;
/**
* Verify whether the data labels are allowed to draw, or we should run more translation and data
* label positioning to keep them inside the plot area. Returns true when data labels are ready
* to draw.
*/
seriesTypes.pie.prototype.verifyDataLabelOverflow = function(overflow) {
var center = this.center,
options = this.options,
centerOption = options.center,
minSize = options.minSize || 80,
newSize = minSize,
ret;
// Handle horizontal size and center
if (centerOption[0] !== null) { // Fixed center
newSize = Math.max(center[2] - Math.max(overflow[1], overflow[3]), minSize);
} else { // Auto center
newSize = Math.max(
center[2] - overflow[1] - overflow[3], // horizontal overflow
minSize
);
center[0] += (overflow[3] - overflow[1]) / 2; // horizontal center
}
// Handle vertical size and center
if (centerOption[1] !== null) { // Fixed center
newSize = Math.max(Math.min(newSize, center[2] - Math.max(overflow[0], overflow[2])), minSize);
} else { // Auto center
newSize = Math.max(
Math.min(
newSize,
center[2] - overflow[0] - overflow[2] // vertical overflow
),
minSize
);
center[1] += (overflow[0] - overflow[2]) / 2; // vertical center
}
// If the size must be decreased, we need to run translate and drawDataLabels again
if (newSize < center[2]) {
center[2] = newSize;
center[3] = Math.min(relativeLength(options.innerSize || 0, newSize), newSize); // #3632
this.translate(center);
if (this.drawDataLabels) {
this.drawDataLabels();
}
// Else, return true to indicate that the pie and its labels is within the plot area
} else {
ret = true;
}
return ret;
};
}
if (seriesTypes.column) {
/**
* Override the basic data label alignment by adjusting for the position of the column
*/
seriesTypes.column.prototype.alignDataLabel = function(point, dataLabel, options, alignTo, isNew) {
var inverted = this.chart.inverted,
series = point.series,
dlBox = point.dlBox || point.shapeArgs, // data label box for alignment
below = pick(point.below, point.plotY > pick(this.translatedThreshold, series.yAxis.len)), // point.below is used in range series
inside = pick(options.inside, !!this.options.stacking), // draw it inside the box?
overshoot;
// Align to the column itself, or the top of it
if (dlBox) { // Area range uses this method but not alignTo
alignTo = merge(dlBox);
if (alignTo.y < 0) {
alignTo.height += alignTo.y;
alignTo.y = 0;
}
overshoot = alignTo.y + alignTo.height - series.yAxis.len;
if (overshoot > 0) {
alignTo.height -= overshoot;
}
if (inverted) {
alignTo = {
x: series.yAxis.len - alignTo.y - alignTo.height,
y: series.xAxis.len - alignTo.x - alignTo.width,
width: alignTo.height,
height: alignTo.width
};
}
// Compute the alignment box
if (!inside) {
if (inverted) {
alignTo.x += below ? 0 : alignTo.width;
alignTo.width = 0;
} else {
alignTo.y += below ? alignTo.height : 0;
alignTo.height = 0;
}
}
}
// When alignment is undefined (typically columns and bars), display the individual
// point below or above the point depending on the threshold
options.align = pick(
options.align, !inverted || inside ? 'center' : below ? 'right' : 'left'
);
options.verticalAlign = pick(
options.verticalAlign,
inverted || inside ? 'middle' : below ? 'top' : 'bottom'
);
// Call the parent method
Series.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
// If label was justified and we have contrast, set it:
if (point.isLabelJustified && point.contrastColor) {
point.dataLabel.css({
color: point.contrastColor
});
}
};
}
}(Highcharts));
(function(H) {
/**
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/**
* Highcharts module to hide overlapping data labels. This module is included in
* Highcharts.
*/
var Chart = H.Chart,
each = H.each,
pick = H.pick,
addEvent = H.addEvent;
// Collect potensial overlapping data labels. Stack labels probably don't need
// to be considered because they are usually accompanied by data labels that lie
// inside the columns.
Chart.prototype.callbacks.push(function(chart) {
function collectAndHide() {
var labels = [];
each(chart.series || [], function(series) {
var dlOptions = series.options.dataLabels,
// Range series have two collections
collections = series.dataLabelCollections || ['dataLabel'];
if (
(dlOptions.enabled || series._hasPointLabels) &&
!dlOptions.allowOverlap &&
series.visible
) { // #3866
each(collections, function(coll) {
each(series.points, function(point) {
if (point[coll]) {
point[coll].labelrank = pick(
point.labelrank,
point.shapeArgs && point.shapeArgs.height
); // #4118
labels.push(point[coll]);
}
});
});
}
});
chart.hideOverlappingLabels(labels);
}
// Do it now ...
collectAndHide();
// ... and after each chart redraw
addEvent(chart, 'redraw', collectAndHide);
});
/**
* Hide overlapping labels. Labels are moved and faded in and out on zoom to
* provide a smooth visual imression.
*/
Chart.prototype.hideOverlappingLabels = function(labels) {
var len = labels.length,
label,
i,
j,
label1,
label2,
isIntersecting,
pos1,
pos2,
parent1,
parent2,
padding,
intersectRect = function(x1, y1, w1, h1, x2, y2, w2, h2) {
return !(
x2 > x1 + w1 ||
x2 + w2 < x1 ||
y2 > y1 + h1 ||
y2 + h2 < y1
);
};
// Mark with initial opacity
for (i = 0; i < len; i++) {
label = labels[i];
if (label) {
label.oldOpacity = label.opacity;
label.newOpacity = 1;
}
}
// Prevent a situation in a gradually rising slope, that each label will
// hide the previous one because the previous one always has lower rank.
labels.sort(function(a, b) {
return (b.labelrank || 0) - (a.labelrank || 0);
});
// Detect overlapping labels
for (i = 0; i < len; i++) {
label1 = labels[i];
for (j = i + 1; j < len; ++j) {
label2 = labels[j];
if (
label1 && label2 &&
label1 !== label2 && // #6465, polar chart with connectEnds
label1.placed && label2.placed &&
label1.newOpacity !== 0 && label2.newOpacity !== 0
) {
pos1 = label1.alignAttr;
pos2 = label2.alignAttr;
// Different panes have different positions
parent1 = label1.parentGroup;
parent2 = label2.parentGroup;
// Substract the padding if no background or border (#4333)
padding = 2 * (label1.box ? 0 : label1.padding);
isIntersecting = intersectRect(
pos1.x + parent1.translateX,
pos1.y + parent1.translateY,
label1.width - padding,
label1.height - padding,
pos2.x + parent2.translateX,
pos2.y + parent2.translateY,
label2.width - padding,
label2.height - padding
);
if (isIntersecting) {
(label1.labelrank < label2.labelrank ? label1 : label2)
.newOpacity = 0;
}
}
}
}
// Hide or show
each(labels, function(label) {
var complete,
newOpacity;
if (label) {
newOpacity = label.newOpacity;
if (label.oldOpacity !== newOpacity && label.placed) {
// Make sure the label is completely hidden to avoid catching
// clicks (#4362)
if (newOpacity) {
label.show(true);
} else {
complete = function() {
label.hide();
};
}
// Animate or set the opacity
label.alignAttr.opacity = newOpacity;
label[label.isOld ? 'animate' : 'attr'](
label.alignAttr,
null,
complete
);
}
label.isOld = true;
}
});
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
Chart = H.Chart,
createElement = H.createElement,
css = H.css,
defaultOptions = H.defaultOptions,
defaultPlotOptions = H.defaultPlotOptions,
each = H.each,
extend = H.extend,
fireEvent = H.fireEvent,
hasTouch = H.hasTouch,
inArray = H.inArray,
isObject = H.isObject,
Legend = H.Legend,
merge = H.merge,
pick = H.pick,
Point = H.Point,
Series = H.Series,
seriesTypes = H.seriesTypes,
svg = H.svg,
TrackerMixin;
/**
* TrackerMixin for points and graphs.
*
* @mixin
*/
TrackerMixin = H.TrackerMixin = {
/**
* Draw the tracker for a point.
*/
drawTrackerPoint: function() {
var series = this,
chart = series.chart,
pointer = chart.pointer,
onMouseOver = function(e) {
var point = pointer.getPointFromEvent(e);
// undefined on graph in scatterchart
if (point !== undefined) {
point.onMouseOver(e);
}
};
// Add reference to the point
each(series.points, function(point) {
if (point.graphic) {
point.graphic.element.point = point;
}
if (point.dataLabel) {
if (point.dataLabel.div) {
point.dataLabel.div.point = point;
} else {
point.dataLabel.element.point = point;
}
}
});
// Add the event listeners, we need to do this only once
if (!series._hasTracking) {
each(series.trackerGroups, function(key) {
if (series[key]) { // we don't always have dataLabelsGroup
series[key]
.addClass('highcharts-tracker')
.on('mouseover', onMouseOver)
.on('mouseout', function(e) {
pointer.onTrackerMouseOut(e);
});
if (hasTouch) {
series[key].on('touchstart', onMouseOver);
}
if (series.options.cursor) {
series[key]
.css(css)
.css({
cursor: series.options.cursor
});
}
}
});
series._hasTracking = true;
}
},
/**
* Draw the tracker object that sits above all data labels and markers to
* track mouse events on the graph or points. For the line type charts
* the tracker uses the same graphPath, but with a greater stroke width
* for better control.
*/
drawTrackerGraph: function() {
var series = this,
options = series.options,
trackByArea = options.trackByArea,
trackerPath = [].concat(trackByArea ? series.areaPath : series.graphPath),
trackerPathLength = trackerPath.length,
chart = series.chart,
pointer = chart.pointer,
renderer = chart.renderer,
snap = chart.options.tooltip.snap,
tracker = series.tracker,
i,
onMouseOver = function() {
if (chart.hoverSeries !== series) {
series.onMouseOver();
}
},
/*
* Empirical lowest possible opacities for TRACKER_FILL for an element to stay invisible but clickable
* IE6: 0.002
* IE7: 0.002
* IE8: 0.002
* IE9: 0.00000000001 (unlimited)
* IE10: 0.0001 (exporting only)
* FF: 0.00000000001 (unlimited)
* Chrome: 0.000001
* Safari: 0.000001
* Opera: 0.00000000001 (unlimited)
*/
TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';
// Extend end points. A better way would be to use round linecaps,
// but those are not clickable in VML.
if (trackerPathLength && !trackByArea) {
i = trackerPathLength + 1;
while (i--) {
if (trackerPath[i] === 'M') { // extend left side
trackerPath.splice(i + 1, 0, trackerPath[i + 1] - snap, trackerPath[i + 2], 'L');
}
if ((i && trackerPath[i] === 'M') || i === trackerPathLength) { // extend right side
trackerPath.splice(i, 0, 'L', trackerPath[i - 2] + snap, trackerPath[i - 1]);
}
}
}
// handle single points
/*for (i = 0; i < singlePoints.length; i++) {
singlePoint = singlePoints[i];
trackerPath.push(M, singlePoint.plotX - snap, singlePoint.plotY,
L, singlePoint.plotX + snap, singlePoint.plotY);
}*/
// draw the tracker
if (tracker) {
tracker.attr({
d: trackerPath
});
} else if (series.graph) { // create
series.tracker = renderer.path(trackerPath)
.attr({
'stroke-linejoin': 'round', // #1225
visibility: series.visible ? 'visible' : 'hidden',
stroke: TRACKER_FILL,
fill: trackByArea ? TRACKER_FILL : 'none',
'stroke-width': series.graph.strokeWidth() + (trackByArea ? 0 : 2 * snap),
zIndex: 2
})
.add(series.group);
// The tracker is added to the series group, which is clipped, but is covered
// by the marker group. So the marker group also needs to capture events.
each([series.tracker, series.markerGroup], function(tracker) {
tracker.addClass('highcharts-tracker')
.on('mouseover', onMouseOver)
.on('mouseout', function(e) {
pointer.onTrackerMouseOut(e);
});
if (options.cursor) {
tracker.css({
cursor: options.cursor
});
}
if (hasTouch) {
tracker.on('touchstart', onMouseOver);
}
});
}
}
};
/* End TrackerMixin */
/**
* Add tracking event listener to the series group, so the point graphics
* themselves act as trackers
*/
if (seriesTypes.column) {
seriesTypes.column.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
}
if (seriesTypes.pie) {
seriesTypes.pie.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
}
if (seriesTypes.scatter) {
seriesTypes.scatter.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
}
/*
* Extend Legend for item events
*/
extend(Legend.prototype, {
setItemEvents: function(item, legendItem, useHTML) {
var legend = this,
boxWrapper = legend.chart.renderer.boxWrapper,
activeClass = 'highcharts-legend-' + (item.series ? 'point' : 'series') + '-active';
// Set the events on the item group, or in case of useHTML, the item itself (#1249)
(useHTML ? legendItem : item.legendGroup).on('mouseover', function() {
item.setState('hover');
// A CSS class to dim or hide other than the hovered series
boxWrapper.addClass(activeClass);
legendItem.css(legend.options.itemHoverStyle);
})
.on('mouseout', function() {
legendItem.css(item.visible ? legend.itemStyle : legend.itemHiddenStyle);
// A CSS class to dim or hide other than the hovered series
boxWrapper.removeClass(activeClass);
item.setState();
})
.on('click', function(event) {
var strLegendItemClick = 'legendItemClick',
fnLegendItemClick = function() {
if (item.setVisible) {
item.setVisible();
}
};
// Pass over the click/touch event. #4.
event = {
browserEvent: event
};
// click the name or symbol
if (item.firePointEvent) { // point
item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
} else {
fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
}
});
},
createCheckboxForItem: function(item) {
var legend = this;
item.checkbox = createElement('input', {
type: 'checkbox',
checked: item.selected,
defaultChecked: item.selected // required by IE7
}, legend.options.itemCheckboxStyle, legend.chart.container);
addEvent(item.checkbox, 'click', function(event) {
var target = event.target;
fireEvent(
item.series || item,
'checkboxClick', { // #3712
checked: target.checked,
item: item
},
function() {
item.select();
}
);
});
}
});
// Add pointer cursor to legend itemstyle in defaultOptions
defaultOptions.legend.itemStyle.cursor = 'pointer';
/*
* Extend the Chart object with interaction
*/
extend(Chart.prototype, /** @lends Chart.prototype */ {
/**
* Display the zoom button
*/
showResetZoom: function() {
var chart = this,
lang = defaultOptions.lang,
btnOptions = chart.options.chart.resetZoomButton,
theme = btnOptions.theme,
states = theme.states,
alignTo = btnOptions.relativeTo === 'chart' ? null : 'plotBox';
function zoomOut() {
chart.zoomOut();
}
this.resetZoomButton = chart.renderer.button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
.attr({
align: btnOptions.position.align,
title: lang.resetZoomTitle
})
.addClass('highcharts-reset-zoom')
.add()
.align(btnOptions.position, false, alignTo);
},
/**
* Zoom out to 1:1
*/
zoomOut: function() {
var chart = this;
fireEvent(chart, 'selection', {
resetSelection: true
}, function() {
chart.zoom();
});
},
/**
* Zoom into a given portion of the chart given by axis coordinates
* @param {Object} event
*/
zoom: function(event) {
var chart = this,
hasZoomed,
pointer = chart.pointer,
displayButton = false,
resetZoomButton;
// If zoom is called with no arguments, reset the axes
if (!event || event.resetSelection) {
each(chart.axes, function(axis) {
hasZoomed = axis.zoom();
});
} else { // else, zoom in on all axes
each(event.xAxis.concat(event.yAxis), function(axisData) {
var axis = axisData.axis,
isXAxis = axis.isXAxis;
// don't zoom more than minRange
if (pointer[isXAxis ? 'zoomX' : 'zoomY']) {
hasZoomed = axis.zoom(axisData.min, axisData.max);
if (axis.displayBtn) {
displayButton = true;
}
}
});
}
// Show or hide the Reset zoom button
resetZoomButton = chart.resetZoomButton;
if (displayButton && !resetZoomButton) {
chart.showResetZoom();
} else if (!displayButton && isObject(resetZoomButton)) {
chart.resetZoomButton = resetZoomButton.destroy();
}
// Redraw
if (hasZoomed) {
chart.redraw(
pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100) // animation
);
}
},
/**
* Pan the chart by dragging the mouse across the pane. This function is called
* on mouse move, and the distance to pan is computed from chartX compared to
* the first chartX position in the dragging operation.
*/
pan: function(e, panning) {
var chart = this,
hoverPoints = chart.hoverPoints,
doRedraw;
// remove active points for shared tooltip
if (hoverPoints) {
each(hoverPoints, function(point) {
point.setState();
});
}
each(panning === 'xy' ? [1, 0] : [1], function(isX) { // xy is used in maps
var axis = chart[isX ? 'xAxis' : 'yAxis'][0],
horiz = axis.horiz,
mousePos = e[horiz ? 'chartX' : 'chartY'],
mouseDown = horiz ? 'mouseDownX' : 'mouseDownY',
startPos = chart[mouseDown],
halfPointRange = (axis.pointRange || 0) / 2,
extremes = axis.getExtremes(),
panMin = axis.toValue(startPos - mousePos, true) +
halfPointRange,
panMax = axis.toValue(startPos + axis.len - mousePos, true) -
halfPointRange,
flipped = panMax < panMin,
newMin = flipped ? panMax : panMin,
newMax = flipped ? panMin : panMax,
paddedMin = axis.toValue(
axis.toPixels(extremes.min) - axis.minPixelPadding
),
paddedMax = axis.toValue(
axis.toPixels(extremes.max) + axis.minPixelPadding
),
distMin = Math.min(extremes.dataMin, paddedMin) - newMin,
distMax = newMax - Math.max(extremes.dataMax, paddedMax);
// Negative distMin and distMax means that we're still inside the
// data range.
if (axis.series.length && distMin < 0 && distMax < 0) {
axis.setExtremes(
newMin,
newMax,
false,
false, {
trigger: 'pan'
}
);
doRedraw = true;
}
chart[mouseDown] = mousePos; // set new reference for next run
});
if (doRedraw) {
chart.redraw(false);
}
css(chart.container, {
cursor: 'move'
});
}
});
/*
* Extend the Point object with interaction
*/
extend(Point.prototype, /** @lends Point.prototype */ {
/**
* Toggle the selection status of a point
* @param {Boolean} selected Whether to select or unselect the point.
* @param {Boolean} accumulate Whether to add to the previous selection. By default,
* this happens if the control key (Cmd on Mac) was pressed during clicking.
*/
select: function(selected, accumulate) {
var point = this,
series = point.series,
chart = series.chart;
selected = pick(selected, !point.selected);
// fire the event with the default handler
point.firePointEvent(selected ? 'select' : 'unselect', {
accumulate: accumulate
}, function() {
point.selected = point.options.selected = selected;
series.options.data[inArray(point, series.data)] = point.options;
point.setState(selected && 'select');
// unselect all other points unless Ctrl or Cmd + click
if (!accumulate) {
each(chart.getSelectedPoints(), function(loopPoint) {
if (loopPoint.selected && loopPoint !== point) {
loopPoint.selected = loopPoint.options.selected = false;
series.options.data[inArray(loopPoint, series.data)] = loopPoint.options;
loopPoint.setState('');
loopPoint.firePointEvent('unselect');
}
});
}
});
},
/**
* Runs on mouse over the point
*
* @param {Object} e The event arguments
*/
onMouseOver: function(e) {
var point = this,
series = point.series,
chart = series.chart,
pointer = chart.pointer;
point.firePointEvent('mouseOver');
pointer.runPointActions(e, point);
},
/**
* Runs on mouse out from the point
*/
onMouseOut: function() {
var point = this,
chart = point.series.chart;
point.firePointEvent('mouseOut');
each(chart.hoverPoints || [], function(p) {
p.setState();
});
chart.hoverPoints = chart.hoverPoint = null;
},
/**
* Import events from the series' and point's options. Only do it on
* demand, to save processing time on hovering.
*/
importEvents: function() {
if (!this.hasImportedEvents) {
var point = this,
options = merge(point.series.options.point, point.options),
events = options.events,
eventType;
point.events = events;
for (eventType in events) {
addEvent(point, eventType, events[eventType]);
}
this.hasImportedEvents = true;
}
},
/**
* Set the point's state
* @param {String} state
*/
setState: function(state, move) {
var point = this,
plotX = Math.floor(point.plotX), // #4586
plotY = point.plotY,
series = point.series,
stateOptions = series.options.states[state] || {},
markerOptions = defaultPlotOptions[series.type].marker &&
series.options.marker,
normalDisabled = markerOptions && markerOptions.enabled === false,
markerStateOptions = (markerOptions && markerOptions.states &&
markerOptions.states[state]) || {},
stateDisabled = markerStateOptions.enabled === false,
stateMarkerGraphic = series.stateMarkerGraphic,
pointMarker = point.marker || {},
chart = series.chart,
halo = series.halo,
haloOptions,
markerAttribs,
hasMarkers = markerOptions && series.markerAttribs,
newSymbol;
state = state || ''; // empty string
if (
// already has this state
(state === point.state && !move) ||
// selected points don't respond to hover
(point.selected && state !== 'select') ||
// series' state options is disabled
(stateOptions.enabled === false) ||
// general point marker's state options is disabled
(state && (stateDisabled || (normalDisabled && markerStateOptions.enabled === false))) ||
// individual point marker's state options is disabled
(state && pointMarker.states && pointMarker.states[state] && pointMarker.states[state].enabled === false) // #1610
) {
return;
}
if (hasMarkers) {
markerAttribs = series.markerAttribs(point, state);
}
// Apply hover styles to the existing point
if (point.graphic) {
if (point.state) {
point.graphic.removeClass('highcharts-point-' + point.state);
}
if (state) {
point.graphic.addClass('highcharts-point-' + state);
}
/*attribs = radius ? { // new symbol attributes (#507, #612)
x: plotX - radius,
y: plotY - radius,
width: 2 * radius,
height: 2 * radius
} : {};*/
//attribs = merge(series.pointAttribs(point, state), attribs);
point.graphic.attr(series.pointAttribs(point, state));
if (markerAttribs) {
point.graphic.animate(
markerAttribs,
pick(
chart.options.chart.animation, // Turn off globally
markerStateOptions.animation,
markerOptions.animation
)
);
}
// Zooming in from a range with no markers to a range with markers
if (stateMarkerGraphic) {
stateMarkerGraphic.hide();
}
} else {
// if a graphic is not applied to each point in the normal state, create a shared
// graphic for the hover state
if (state && markerStateOptions) {
newSymbol = pointMarker.symbol || series.symbol;
// If the point has another symbol than the previous one, throw away the
// state marker graphic and force a new one (#1459)
if (stateMarkerGraphic && stateMarkerGraphic.currentSymbol !== newSymbol) {
stateMarkerGraphic = stateMarkerGraphic.destroy();
}
// Add a new state marker graphic
if (!stateMarkerGraphic) {
if (newSymbol) {
series.stateMarkerGraphic = stateMarkerGraphic = chart.renderer.symbol(
newSymbol,
markerAttribs.x,
markerAttribs.y,
markerAttribs.width,
markerAttribs.height
)
.add(series.markerGroup);
stateMarkerGraphic.currentSymbol = newSymbol;
}
// Move the existing graphic
} else {
stateMarkerGraphic[move ? 'animate' : 'attr']({ // #1054
x: markerAttribs.x,
y: markerAttribs.y
});
}
if (stateMarkerGraphic) {
stateMarkerGraphic.attr(series.pointAttribs(point, state));
}
}
if (stateMarkerGraphic) {
stateMarkerGraphic[state && chart.isInsidePlot(plotX, plotY, chart.inverted) ? 'show' : 'hide'](); // #2450
stateMarkerGraphic.element.point = point; // #4310
}
}
// Show me your halo
haloOptions = stateOptions.halo;
if (haloOptions && haloOptions.size) {
if (!halo) {
series.halo = halo = chart.renderer.path()
// #5818, #5903
.add(hasMarkers ? series.markerGroup : series.group);
}
halo[move ? 'animate' : 'attr']({
d: point.haloPath(haloOptions.size)
});
halo.attr({
'class': 'highcharts-halo highcharts-color-' +
pick(point.colorIndex, series.colorIndex)
});
halo.point = point; // #6055
halo.attr(extend({
'fill': point.color || series.color,
'fill-opacity': haloOptions.opacity,
'zIndex': -1 // #4929, IE8 added halo above everything
}, haloOptions.attributes));
} else if (halo && halo.point && halo.point.haloPath) {
// Animate back to 0 on the current halo point (#6055)
halo.animate({
d: halo.point.haloPath(0)
});
}
point.state = state;
},
/**
* Get the circular path definition for the halo
* @param {Number} size The radius of the circular halo.
* @returns {Array} The path definition
*/
haloPath: function(size) {
var series = this.series,
chart = series.chart;
return chart.renderer.symbols.circle(
Math.floor(this.plotX) - size,
this.plotY - size,
size * 2,
size * 2
);
}
});
/*
* Extend the Series object with interaction
*/
extend(Series.prototype, /** @lends Series.prototype */ {
/**
* Series mouse over handler
*/
onMouseOver: function() {
var series = this,
chart = series.chart,
hoverSeries = chart.hoverSeries;
// set normal state to previous series
if (hoverSeries && hoverSeries !== series) {
hoverSeries.onMouseOut();
}
// trigger the event, but to save processing time,
// only if defined
if (series.options.events.mouseOver) {
fireEvent(series, 'mouseOver');
}
// hover this
series.setState('hover');
chart.hoverSeries = series;
},
/**
* Series mouse out handler
*/
onMouseOut: function() {
// trigger the event only if listeners exist
var series = this,
options = series.options,
chart = series.chart,
tooltip = chart.tooltip,
hoverPoint = chart.hoverPoint;
chart.hoverSeries = null; // #182, set to null before the mouseOut event fires
// trigger mouse out on the point, which must be in this series
if (hoverPoint) {
hoverPoint.onMouseOut();
}
// fire the mouse out event
if (series && options.events.mouseOut) {
fireEvent(series, 'mouseOut');
}
// hide the tooltip
if (tooltip && !series.stickyTracking && (!tooltip.shared || series.noSharedTooltip)) {
tooltip.hide();
}
// set normal state
series.setState();
},
/**
* Set the state of the graph
*/
setState: function(state) {
var series = this,
options = series.options,
graph = series.graph,
stateOptions = options.states,
lineWidth = options.lineWidth,
attribs,
i = 0;
state = state || '';
if (series.state !== state) {
// Toggle class names
each([
series.group,
series.markerGroup,
series.dataLabelsGroup
], function(group) {
if (group) {
// Old state
if (series.state) {
group.removeClass('highcharts-series-' + series.state);
}
// New state
if (state) {
group.addClass('highcharts-series-' + state);
}
}
});
series.state = state;
if (stateOptions[state] && stateOptions[state].enabled === false) {
return;
}
if (state) {
lineWidth = stateOptions[state].lineWidth || lineWidth + (stateOptions[state].lineWidthPlus || 0); // #4035
}
if (graph && !graph.dashstyle) { // hover is turned off for dashed lines in VML
attribs = {
'stroke-width': lineWidth
};
// Animate the graph stroke-width. By default a quick animation
// to hover, slower to un-hover.
graph.animate(
attribs,
pick(
series.chart.options.chart.animation,
stateOptions[state] && stateOptions[state].animation
)
);
while (series['zone-graph-' + i]) {
series['zone-graph-' + i].attr(attribs);
i = i + 1;
}
}
}
},
/**
* Set the visibility of the graph
*
* @param vis {Boolean} True to show the series, false to hide. If undefined,
* the visibility is toggled.
*/
setVisible: function(vis, redraw) {
var series = this,
chart = series.chart,
legendItem = series.legendItem,
showOrHide,
ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
oldVisibility = series.visible;
// if called without an argument, toggle visibility
series.visible = vis = series.options.visible = series.userOptions.visible = vis === undefined ? !oldVisibility : vis; // #5618
showOrHide = vis ? 'show' : 'hide';
// show or hide elements
each(['group', 'dataLabelsGroup', 'markerGroup', 'tracker', 'tt'], function(key) {
if (series[key]) {
series[key][showOrHide]();
}
});
// hide tooltip (#1361)
if (chart.hoverSeries === series || (chart.hoverPoint && chart.hoverPoint.series) === series) {
series.onMouseOut();
}
if (legendItem) {
chart.legend.colorizeItem(series, vis);
}
// rescale or adapt to resized chart
series.isDirty = true;
// in a stack, all other series are affected
if (series.options.stacking) {
each(chart.series, function(otherSeries) {
if (otherSeries.options.stacking && otherSeries.visible) {
otherSeries.isDirty = true;
}
});
}
// show or hide linked series
each(series.linkedSeries, function(otherSeries) {
otherSeries.setVisible(vis, false);
});
if (ignoreHiddenSeries) {
chart.isDirtyBox = true;
}
if (redraw !== false) {
chart.redraw();
}
fireEvent(series, showOrHide);
},
/**
* Show the graph
*/
show: function() {
this.setVisible(true);
},
/**
* Hide the graph
*/
hide: function() {
this.setVisible(false);
},
/**
* Set the selected state of the graph
*
* @param selected {Boolean} True to select the series, false to unselect. If
* undefined, the selection state is toggled.
*/
select: function(selected) {
var series = this;
// if called without an argument, toggle
series.selected = selected = (selected === undefined) ? !series.selected : selected;
if (series.checkbox) {
series.checkbox.checked = selected;
}
fireEvent(series, selected ? 'select' : 'unselect');
},
drawTracker: TrackerMixin.drawTrackerGraph
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Chart = H.Chart,
each = H.each,
inArray = H.inArray,
isArray = H.isArray,
isObject = H.isObject,
pick = H.pick,
splat = H.splat;
/**
* Update the chart based on the current chart/document size and options for
* responsiveness.
*/
Chart.prototype.setResponsive = function(redraw) {
var options = this.options.responsive,
ruleIds = [],
currentResponsive = this.currentResponsive,
currentRuleIds;
if (options && options.rules) {
each(options.rules, function(rule) {
if (rule._id === undefined) {
rule._id = H.uniqueKey();
}
this.matchResponsiveRule(rule, ruleIds, redraw);
}, this);
}
// Merge matching rules
var mergedOptions = H.merge.apply(0, H.map(ruleIds, function(ruleId) {
return H.find(options.rules, function(rule) {
return rule._id === ruleId;
}).chartOptions;
}));
// Stringified key for the rules that currently apply.
ruleIds = ruleIds.toString() || undefined;
currentRuleIds = currentResponsive && currentResponsive.ruleIds;
// Changes in what rules apply
if (ruleIds !== currentRuleIds) {
// Undo previous rules. Before we apply a new set of rules, we need to
// roll back completely to base options (#6291).
if (currentResponsive) {
this.update(currentResponsive.undoOptions, redraw);
}
if (ruleIds) {
// Get undo-options for matching rules
this.currentResponsive = {
ruleIds: ruleIds,
mergedOptions: mergedOptions,
undoOptions: this.currentOptions(mergedOptions)
};
this.update(mergedOptions, redraw);
} else {
this.currentResponsive = undefined;
}
}
};
/**
* Handle a single responsiveness rule
*/
Chart.prototype.matchResponsiveRule = function(rule, matches) {
var condition = rule.condition,
fn = condition.callback || function() {
return this.chartWidth <= pick(condition.maxWidth, Number.MAX_VALUE) &&
this.chartHeight <= pick(condition.maxHeight, Number.MAX_VALUE) &&
this.chartWidth >= pick(condition.minWidth, 0) &&
this.chartHeight >= pick(condition.minHeight, 0);
};
if (fn.call(this)) {
matches.push(rule._id);
}
};
/**
* Get the current values for a given set of options. Used before we update
* the chart with a new responsiveness rule.
* TODO: Restore axis options (by id?)
*/
Chart.prototype.currentOptions = function(options) {
var ret = {};
/**
* Recurse over a set of options and its current values,
* and store the current values in the ret object.
*/
function getCurrent(options, curr, ret, depth) {
var key, i;
for (key in options) {
if (!depth && inArray(key, ['series', 'xAxis', 'yAxis']) > -1) {
options[key] = splat(options[key]);
ret[key] = [];
// Iterate over collections like series, xAxis or yAxis and map
// the items by index.
for (i = 0; i < options[key].length; i++) {
if (curr[key][i]) { // Item exists in current data (#6347)
ret[key][i] = {};
getCurrent(
options[key][i],
curr[key][i],
ret[key][i],
depth + 1
);
}
}
} else if (isObject(options[key])) {
ret[key] = isArray(options[key]) ? [] : {};
getCurrent(
options[key],
curr[key] || {},
ret[key],
depth + 1
);
} else {
ret[key] = curr[key] || null;
}
}
}
getCurrent(options, this.options, ret, 0);
return ret;
};
}(Highcharts));
var Highcharts = (function(Highcharts) {
return Highcharts;
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
Axis = H.Axis,
Chart = H.Chart,
css = H.css,
dateFormat = H.dateFormat,
defined = H.defined,
each = H.each,
extend = H.extend,
noop = H.noop,
Series = H.Series,
timeUnits = H.timeUnits,
wrap = H.wrap;
/* ****************************************************************************
* Start ordinal axis logic *
*****************************************************************************/
wrap(Series.prototype, 'init', function(proceed) {
var series = this,
xAxis;
// call the original function
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
xAxis = series.xAxis;
// Destroy the extended ordinal index on updated data
if (xAxis && xAxis.options.ordinal) {
addEvent(series, 'updatedData', function() {
delete xAxis.ordinalIndex;
});
}
});
/**
* In an ordinal axis, there might be areas with dense consentrations of points, then large
* gaps between some. Creating equally distributed ticks over this entire range
* may lead to a huge number of ticks that will later be removed. So instead, break the
* positions up in segments, find the tick positions for each segment then concatenize them.
* This method is used from both data grouping logic and X axis tick position logic.
*/
wrap(Axis.prototype, 'getTimeTicks', function(proceed, normalizedInterval, min, max, startOfWeek, positions, closestDistance, findHigherRanks) {
var start = 0,
end,
segmentPositions,
higherRanks = {},
hasCrossedHigherRank,
info,
posLength,
outsideMax,
groupPositions = [],
lastGroupPosition = -Number.MAX_VALUE,
tickPixelIntervalOption = this.options.tickPixelInterval;
// The positions are not always defined, for example for ordinal positions when data
// has regular interval (#1557, #2090)
if ((!this.options.ordinal && !this.options.breaks) || !positions || positions.length < 3 || min === undefined) {
return proceed.call(this, normalizedInterval, min, max, startOfWeek);
}
// Analyze the positions array to split it into segments on gaps larger than 5 times
// the closest distance. The closest distance is already found at this point, so
// we reuse that instead of computing it again.
posLength = positions.length;
for (end = 0; end < posLength; end++) {
outsideMax = end && positions[end - 1] > max;
if (positions[end] < min) { // Set the last position before min
start = end;
}
if (end === posLength - 1 || positions[end + 1] - positions[end] > closestDistance * 5 || outsideMax) {
// For each segment, calculate the tick positions from the getTimeTicks utility
// function. The interval will be the same regardless of how long the segment is.
if (positions[end] > lastGroupPosition) { // #1475
segmentPositions = proceed.call(this, normalizedInterval, positions[start], positions[end], startOfWeek);
// Prevent duplicate groups, for example for multiple segments within one larger time frame (#1475)
while (segmentPositions.length && segmentPositions[0] <= lastGroupPosition) {
segmentPositions.shift();
}
if (segmentPositions.length) {
lastGroupPosition = segmentPositions[segmentPositions.length - 1];
}
groupPositions = groupPositions.concat(segmentPositions);
}
// Set start of next segment
start = end + 1;
}
if (outsideMax) {
break;
}
}
// Get the grouping info from the last of the segments. The info is the same for
// all segments.
info = segmentPositions.info;
// Optionally identify ticks with higher rank, for example when the ticks
// have crossed midnight.
if (findHigherRanks && info.unitRange <= timeUnits.hour) {
end = groupPositions.length - 1;
// Compare points two by two
for (start = 1; start < end; start++) {
if (dateFormat('%d', groupPositions[start]) !== dateFormat('%d', groupPositions[start - 1])) {
higherRanks[groupPositions[start]] = 'day';
hasCrossedHigherRank = true;
}
}
// If the complete array has crossed midnight, we want to mark the first
// positions also as higher rank
if (hasCrossedHigherRank) {
higherRanks[groupPositions[0]] = 'day';
}
info.higherRanks = higherRanks;
}
// Save the info
groupPositions.info = info;
// Don't show ticks within a gap in the ordinal axis, where the space between
// two points is greater than a portion of the tick pixel interval
if (findHigherRanks && defined(tickPixelIntervalOption)) { // check for squashed ticks
var length = groupPositions.length,
i = length,
itemToRemove,
translated,
translatedArr = [],
lastTranslated,
medianDistance,
distance,
distances = [];
// Find median pixel distance in order to keep a reasonably even distance between
// ticks (#748)
while (i--) {
translated = this.translate(groupPositions[i]);
if (lastTranslated) {
distances[i] = lastTranslated - translated;
}
translatedArr[i] = lastTranslated = translated;
}
distances.sort();
medianDistance = distances[Math.floor(distances.length / 2)];
if (medianDistance < tickPixelIntervalOption * 0.6) {
medianDistance = null;
}
// Now loop over again and remove ticks where needed
i = groupPositions[length - 1] > max ? length - 1 : length; // #817
lastTranslated = undefined;
while (i--) {
translated = translatedArr[i];
distance = Math.abs(lastTranslated - translated);
// #4175 - when axis is reversed, the distance, is negative but
// tickPixelIntervalOption positive, so we need to compare the same values
// Remove ticks that are closer than 0.6 times the pixel interval from the one to the right,
// but not if it is close to the median distance (#748).
if (lastTranslated && distance < tickPixelIntervalOption * 0.8 &&
(medianDistance === null || distance < medianDistance * 0.8)) {
// Is this a higher ranked position with a normal position to the right?
if (higherRanks[groupPositions[i]] && !higherRanks[groupPositions[i + 1]]) {
// Yes: remove the lower ranked neighbour to the right
itemToRemove = i + 1;
lastTranslated = translated; // #709
} else {
// No: remove this one
itemToRemove = i;
}
groupPositions.splice(itemToRemove, 1);
} else {
lastTranslated = translated;
}
}
}
return groupPositions;
});
// Extend the Axis prototype
extend(Axis.prototype, /** @lends Axis.prototype */ {
/**
* Calculate the ordinal positions before tick positions are calculated.
*/
beforeSetTickPositions: function() {
var axis = this,
len,
ordinalPositions = [],
useOrdinal = false,
dist,
extremes = axis.getExtremes(),
min = extremes.min,
max = extremes.max,
minIndex,
maxIndex,
slope,
hasBreaks = axis.isXAxis && !!axis.options.breaks,
isOrdinal = axis.options.ordinal,
ignoreHiddenSeries = axis.chart.options.chart.ignoreHiddenSeries,
i;
// apply the ordinal logic
if (isOrdinal || hasBreaks) { // #4167 YAxis is never ordinal ?
each(axis.series, function(series, i) {
if ((!ignoreHiddenSeries || series.visible !== false) && (series.takeOrdinalPosition !== false || hasBreaks)) {
// concatenate the processed X data into the existing positions, or the empty array
ordinalPositions = ordinalPositions.concat(series.processedXData);
len = ordinalPositions.length;
// remove duplicates (#1588)
ordinalPositions.sort(function(a, b) {
return a - b; // without a custom function it is sorted as strings
});
if (len) {
i = len - 1;
while (i--) {
if (ordinalPositions[i] === ordinalPositions[i + 1]) {
ordinalPositions.splice(i, 1);
}
}
}
}
});
// cache the length
len = ordinalPositions.length;
// Check if we really need the overhead of mapping axis data against the ordinal positions.
// If the series consist of evenly spaced data any way, we don't need any ordinal logic.
if (len > 2) { // two points have equal distance by default
dist = ordinalPositions[1] - ordinalPositions[0];
i = len - 1;
while (i-- && !useOrdinal) {
if (ordinalPositions[i + 1] - ordinalPositions[i] !== dist) {
useOrdinal = true;
}
}
// When zooming in on a week, prevent axis padding for weekends even though the data within
// the week is evenly spaced.
if (!axis.options.keepOrdinalPadding && (ordinalPositions[0] - min > dist || max - ordinalPositions[ordinalPositions.length - 1] > dist)) {
useOrdinal = true;
}
}
// Record the slope and offset to compute the linear values from the array index.
// Since the ordinal positions may exceed the current range, get the start and
// end positions within it (#719, #665b)
if (useOrdinal) {
// Register
axis.ordinalPositions = ordinalPositions;
// This relies on the ordinalPositions being set. Use Math.max
// and Math.min to prevent padding on either sides of the data.
minIndex = axis.ordinal2lin( // #5979
Math.max(
min,
ordinalPositions[0]
),
true
);
maxIndex = Math.max(axis.ordinal2lin(
Math.min(
max,
ordinalPositions[ordinalPositions.length - 1]
),
true
), 1); // #3339
// Set the slope and offset of the values compared to the indices in the ordinal positions
axis.ordinalSlope = slope = (max - min) / (maxIndex - minIndex);
axis.ordinalOffset = min - (minIndex * slope);
} else {
axis.ordinalPositions = axis.ordinalSlope = axis.ordinalOffset = undefined;
}
}
axis.isOrdinal = isOrdinal && useOrdinal; // #3818, #4196, #4926
axis.groupIntervalFactor = null; // reset for next run
},
/**
* Translate from a linear axis value to the corresponding ordinal axis position. If there
* are no gaps in the ordinal axis this will be the same. The translated value is the value
* that the point would have if the axis were linear, using the same min and max.
*
* @param Number val The axis value
* @param Boolean toIndex Whether to return the index in the ordinalPositions or the new value
*/
val2lin: function(val, toIndex) {
var axis = this,
ordinalPositions = axis.ordinalPositions,
ret;
if (!ordinalPositions) {
ret = val;
} else {
var ordinalLength = ordinalPositions.length,
i,
distance,
ordinalIndex;
// first look for an exact match in the ordinalpositions array
i = ordinalLength;
while (i--) {
if (ordinalPositions[i] === val) {
ordinalIndex = i;
break;
}
}
// if that failed, find the intermediate position between the two nearest values
i = ordinalLength - 1;
while (i--) {
if (val > ordinalPositions[i] || i === 0) { // interpolate
distance = (val - ordinalPositions[i]) / (ordinalPositions[i + 1] - ordinalPositions[i]); // something between 0 and 1
ordinalIndex = i + distance;
break;
}
}
ret = toIndex ?
ordinalIndex :
axis.ordinalSlope * (ordinalIndex || 0) + axis.ordinalOffset;
}
return ret;
},
/**
* Translate from linear (internal) to axis value
*
* @param Number val The linear abstracted value
* @param Boolean fromIndex Translate from an index in the ordinal positions rather than a value
*/
lin2val: function(val, fromIndex) {
var axis = this,
ordinalPositions = axis.ordinalPositions,
ret;
if (!ordinalPositions) { // the visible range contains only equally spaced values
ret = val;
} else {
var ordinalSlope = axis.ordinalSlope,
ordinalOffset = axis.ordinalOffset,
i = ordinalPositions.length - 1,
linearEquivalentLeft,
linearEquivalentRight,
distance;
// Handle the case where we translate from the index directly, used only
// when panning an ordinal axis
if (fromIndex) {
if (val < 0) { // out of range, in effect panning to the left
val = ordinalPositions[0];
} else if (val > i) { // out of range, panning to the right
val = ordinalPositions[i];
} else { // split it up
i = Math.floor(val);
distance = val - i; // the decimal
}
// Loop down along the ordinal positions. When the linear equivalent of i matches
// an ordinal position, interpolate between the left and right values.
} else {
while (i--) {
linearEquivalentLeft = (ordinalSlope * i) + ordinalOffset;
if (val >= linearEquivalentLeft) {
linearEquivalentRight = (ordinalSlope * (i + 1)) + ordinalOffset;
distance = (val - linearEquivalentLeft) / (linearEquivalentRight - linearEquivalentLeft); // something between 0 and 1
break;
}
}
}
// If the index is within the range of the ordinal positions, return the associated
// or interpolated value. If not, just return the value
return distance !== undefined && ordinalPositions[i] !== undefined ?
ordinalPositions[i] + (distance ? distance * (ordinalPositions[i + 1] - ordinalPositions[i]) : 0) :
val;
}
return ret;
},
/**
* Get the ordinal positions for the entire data set. This is necessary in chart panning
* because we need to find out what points or data groups are available outside the
* visible range. When a panning operation starts, if an index for the given grouping
* does not exists, it is created and cached. This index is deleted on updated data, so
* it will be regenerated the next time a panning operation starts.
*/
getExtendedPositions: function() {
var axis = this,
chart = axis.chart,
grouping = axis.series[0].currentDataGrouping,
ordinalIndex = axis.ordinalIndex,
key = grouping ? grouping.count + grouping.unitName : 'raw',
extremes = axis.getExtremes(),
fakeAxis,
fakeSeries;
// If this is the first time, or the ordinal index is deleted by updatedData,
// create it.
if (!ordinalIndex) {
ordinalIndex = axis.ordinalIndex = {};
}
if (!ordinalIndex[key]) {
// Create a fake axis object where the extended ordinal positions are emulated
fakeAxis = {
series: [],
chart: chart,
getExtremes: function() {
return {
min: extremes.dataMin,
max: extremes.dataMax
};
},
options: {
ordinal: true
},
val2lin: Axis.prototype.val2lin, // #2590
ordinal2lin: Axis.prototype.ordinal2lin // #6276
};
// Add the fake series to hold the full data, then apply processData to it
each(axis.series, function(series) {
fakeSeries = {
xAxis: fakeAxis,
xData: series.xData,
chart: chart,
destroyGroupedData: noop
};
fakeSeries.options = {
dataGrouping: grouping ? {
enabled: true,
forced: true,
approximation: 'open', // doesn't matter which, use the fastest
units: [
[grouping.unitName, [grouping.count]]
]
} : {
enabled: false
}
};
series.processData.apply(fakeSeries);
fakeAxis.series.push(fakeSeries);
});
// Run beforeSetTickPositions to compute the ordinalPositions
axis.beforeSetTickPositions.apply(fakeAxis);
// Cache it
ordinalIndex[key] = fakeAxis.ordinalPositions;
}
return ordinalIndex[key];
},
/**
* Find the factor to estimate how wide the plot area would have been if ordinal
* gaps were included. This value is used to compute an imagined plot width in order
* to establish the data grouping interval.
*
* A real world case is the intraday-candlestick
* example. Without this logic, it would show the correct data grouping when viewing
* a range within each day, but once moving the range to include the gap between two
* days, the interval would include the cut-away night hours and the data grouping
* would be wrong. So the below method tries to compensate by identifying the most
* common point interval, in this case days.
*
* An opposite case is presented in issue #718. We have a long array of daily data,
* then one point is appended one hour after the last point. We expect the data grouping
* not to change.
*
* In the future, if we find cases where this estimation doesn't work optimally, we
* might need to add a second pass to the data grouping logic, where we do another run
* with a greater interval if the number of data groups is more than a certain fraction
* of the desired group count.
*/
getGroupIntervalFactor: function(xMin, xMax, series) {
var i,
processedXData = series.processedXData,
len = processedXData.length,
distances = [],
median,
groupIntervalFactor = this.groupIntervalFactor;
// Only do this computation for the first series, let the other inherit it (#2416)
if (!groupIntervalFactor) {
// Register all the distances in an array
for (i = 0; i < len - 1; i++) {
distances[i] = processedXData[i + 1] - processedXData[i];
}
// Sort them and find the median
distances.sort(function(a, b) {
return a - b;
});
median = distances[Math.floor(len / 2)];
// Compensate for series that don't extend through the entire axis extent. #1675.
xMin = Math.max(xMin, processedXData[0]);
xMax = Math.min(xMax, processedXData[len - 1]);
this.groupIntervalFactor = groupIntervalFactor = (len * median) / (xMax - xMin);
}
// Return the factor needed for data grouping
return groupIntervalFactor;
},
/**
* Make the tick intervals closer because the ordinal gaps make the ticks spread out or cluster
*/
postProcessTickInterval: function(tickInterval) {
// Problem: http://jsfiddle.net/highcharts/FQm4E/1/
// This is a case where this algorithm doesn't work optimally. In this case, the
// tick labels are spread out per week, but all the gaps reside within weeks. So
// we have a situation where the labels are courser than the ordinal gaps, and
// thus the tick interval should not be altered
var ordinalSlope = this.ordinalSlope,
ret;
if (ordinalSlope) {
if (!this.options.breaks) {
ret = tickInterval / (ordinalSlope / this.closestPointRange);
} else {
ret = this.closestPointRange;
}
} else {
ret = tickInterval;
}
return ret;
}
});
// Record this to prevent overwriting by broken-axis module (#5979)
Axis.prototype.ordinal2lin = Axis.prototype.val2lin;
// Extending the Chart.pan method for ordinal axes
wrap(Chart.prototype, 'pan', function(proceed, e) {
var chart = this,
xAxis = chart.xAxis[0],
chartX = e.chartX,
runBase = false;
if (xAxis.options.ordinal && xAxis.series.length) {
var mouseDownX = chart.mouseDownX,
extremes = xAxis.getExtremes(),
dataMax = extremes.dataMax,
min = extremes.min,
max = extremes.max,
trimmedRange,
hoverPoints = chart.hoverPoints,
closestPointRange = xAxis.closestPointRange,
pointPixelWidth = xAxis.translationSlope * (xAxis.ordinalSlope || closestPointRange),
movedUnits = (mouseDownX - chartX) / pointPixelWidth, // how many ordinal units did we move?
extendedAxis = {
ordinalPositions: xAxis.getExtendedPositions()
}, // get index of all the chart's points
ordinalPositions,
searchAxisLeft,
lin2val = xAxis.lin2val,
val2lin = xAxis.val2lin,
searchAxisRight;
if (!extendedAxis.ordinalPositions) { // we have an ordinal axis, but the data is equally spaced
runBase = true;
} else if (Math.abs(movedUnits) > 1) {
// Remove active points for shared tooltip
if (hoverPoints) {
each(hoverPoints, function(point) {
point.setState();
});
}
if (movedUnits < 0) {
searchAxisLeft = extendedAxis;
searchAxisRight = xAxis.ordinalPositions ? xAxis : extendedAxis;
} else {
searchAxisLeft = xAxis.ordinalPositions ? xAxis : extendedAxis;
searchAxisRight = extendedAxis;
}
// In grouped data series, the last ordinal position represents the grouped data, which is
// to the left of the real data max. If we don't compensate for this, we will be allowed
// to pan grouped data series passed the right of the plot area.
ordinalPositions = searchAxisRight.ordinalPositions;
if (dataMax > ordinalPositions[ordinalPositions.length - 1]) {
ordinalPositions.push(dataMax);
}
// Get the new min and max values by getting the ordinal index for the current extreme,
// then add the moved units and translate back to values. This happens on the
// extended ordinal positions if the new position is out of range, else it happens
// on the current x axis which is smaller and faster.
chart.fixedRange = max - min;
trimmedRange = xAxis.toFixedRange(null, null,
lin2val.apply(searchAxisLeft, [
val2lin.apply(searchAxisLeft, [min, true]) + movedUnits, // the new index
true // translate from index
]),
lin2val.apply(searchAxisRight, [
val2lin.apply(searchAxisRight, [max, true]) + movedUnits, // the new index
true // translate from index
])
);
// Apply it if it is within the available data range
if (trimmedRange.min >= Math.min(extremes.dataMin, min) && trimmedRange.max <= Math.max(dataMax, max)) {
xAxis.setExtremes(trimmedRange.min, trimmedRange.max, true, false, {
trigger: 'pan'
});
}
chart.mouseDownX = chartX; // set new reference for next run
css(chart.container, {
cursor: 'move'
});
}
} else {
runBase = true;
}
// revert to the linear chart.pan version
if (runBase) {
// call the original function
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
}
});
/**
* Extend getGraphPath by identifying gaps in the ordinal data so that we can draw a gap in the
* line or area
*/
Series.prototype.gappedPath = function() {
var gapSize = this.options.gapSize,
points = this.points.slice(),
i = points.length - 1;
if (gapSize && i > 0) { // #5008
// extension for ordinal breaks
while (i--) {
if (points[i + 1].x - points[i].x > this.closestPointRange * gapSize) {
points.splice( // insert after this one
i + 1,
0, {
isNull: true
}
);
}
}
}
// Call base method
//return proceed.call(this, points, a, b);
return this.getGraphPath(points);
};
/* ****************************************************************************
* End ordinal axis logic *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var pick = H.pick,
wrap = H.wrap,
each = H.each,
extend = H.extend,
isArray = H.isArray,
fireEvent = H.fireEvent,
Axis = H.Axis,
Series = H.Series;
function stripArguments() {
return Array.prototype.slice.call(arguments, 1);
}
extend(Axis.prototype, {
isInBreak: function(brk, val) {
var ret,
repeat = brk.repeat || Infinity,
from = brk.from,
length = brk.to - brk.from,
test = (val >= from ? (val - from) % repeat : repeat - ((from - val) % repeat));
if (!brk.inclusive) {
ret = test < length && test !== 0;
} else {
ret = test <= length;
}
return ret;
},
isInAnyBreak: function(val, testKeep) {
var breaks = this.options.breaks,
i = breaks && breaks.length,
inbrk,
keep,
ret;
if (i) {
while (i--) {
if (this.isInBreak(breaks[i], val)) {
inbrk = true;
if (!keep) {
keep = pick(breaks[i].showPoints, this.isXAxis ? false : true);
}
}
}
if (inbrk && testKeep) {
ret = inbrk && !keep;
} else {
ret = inbrk;
}
}
return ret;
}
});
wrap(Axis.prototype, 'setTickPositions', function(proceed) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
if (this.options.breaks) {
var axis = this,
tickPositions = this.tickPositions,
info = this.tickPositions.info,
newPositions = [],
i;
for (i = 0; i < tickPositions.length; i++) {
if (!axis.isInAnyBreak(tickPositions[i])) {
newPositions.push(tickPositions[i]);
}
}
this.tickPositions = newPositions;
this.tickPositions.info = info;
}
});
wrap(Axis.prototype, 'init', function(proceed, chart, userOptions) {
var axis = this,
breaks;
// Force Axis to be not-ordinal when breaks are defined
if (userOptions.breaks && userOptions.breaks.length) {
userOptions.ordinal = false;
}
proceed.call(this, chart, userOptions);
breaks = this.options.breaks;
axis.isBroken = (isArray(breaks) && !!breaks.length);
if (axis.isBroken) {
axis.val2lin = function(val) {
var nval = val,
brk,
i;
for (i = 0; i < axis.breakArray.length; i++) {
brk = axis.breakArray[i];
if (brk.to <= val) {
nval -= brk.len;
} else if (brk.from >= val) {
break;
} else if (axis.isInBreak(brk, val)) {
nval -= (val - brk.from);
break;
}
}
return nval;
};
axis.lin2val = function(val) {
var nval = val,
brk,
i;
for (i = 0; i < axis.breakArray.length; i++) {
brk = axis.breakArray[i];
if (brk.from >= nval) {
break;
} else if (brk.to < nval) {
nval += brk.len;
} else if (axis.isInBreak(brk, nval)) {
nval += brk.len;
}
}
return nval;
};
axis.setExtremes = function(newMin, newMax, redraw, animation, eventArguments) {
// If trying to set extremes inside a break, extend it to before and after the break ( #3857 )
while (this.isInAnyBreak(newMin)) {
newMin -= this.closestPointRange;
}
while (this.isInAnyBreak(newMax)) {
newMax -= this.closestPointRange;
}
Axis.prototype.setExtremes.call(this, newMin, newMax, redraw, animation, eventArguments);
};
axis.setAxisTranslation = function(saveOld) {
Axis.prototype.setAxisTranslation.call(this, saveOld);
var breaks = axis.options.breaks,
breakArrayT = [], // Temporary one
breakArray = [],
length = 0,
inBrk,
repeat,
brk,
min = axis.userMin || axis.min,
max = axis.userMax || axis.max,
pointRangePadding = pick(axis.pointRangePadding, 0),
start,
i,
j;
// Min & max check (#4247)
for (i in breaks) {
brk = breaks[i];
repeat = brk.repeat || Infinity;
if (axis.isInBreak(brk, min)) {
min += (brk.to % repeat) - (min % repeat);
}
if (axis.isInBreak(brk, max)) {
max -= (max % repeat) - (brk.from % repeat);
}
}
// Construct an array holding all breaks in the axis
for (i in breaks) {
brk = breaks[i];
start = brk.from;
repeat = brk.repeat || Infinity;
while (start - repeat > min) {
start -= repeat;
}
while (start < min) {
start += repeat;
}
for (j = start; j < max; j += repeat) {
breakArrayT.push({
value: j,
move: 'in'
});
breakArrayT.push({
value: j + (brk.to - brk.from),
move: 'out',
size: brk.breakSize
});
}
}
breakArrayT.sort(function(a, b) {
var ret;
if (a.value === b.value) {
ret = (a.move === 'in' ? 0 : 1) - (b.move === 'in' ? 0 : 1);
} else {
ret = a.value - b.value;
}
return ret;
});
// Simplify the breaks
inBrk = 0;
start = min;
for (i in breakArrayT) {
brk = breakArrayT[i];
inBrk += (brk.move === 'in' ? 1 : -1);
if (inBrk === 1 && brk.move === 'in') {
start = brk.value;
}
if (inBrk === 0) {
breakArray.push({
from: start,
to: brk.value,
len: brk.value - start - (brk.size || 0)
});
length += brk.value - start - (brk.size || 0);
}
}
axis.breakArray = breakArray;
// Used with staticScale, and below, the actual axis length when
// breaks are substracted.
axis.unitLength = max - min - length + pointRangePadding;
fireEvent(axis, 'afterBreaks');
if (axis.options.staticScale) {
axis.transA = axis.options.staticScale;
} else {
axis.transA *= (max - axis.min + pointRangePadding) /
axis.unitLength;
}
if (pointRangePadding) {
axis.minPixelPadding = axis.transA * axis.minPointOffset;
}
axis.min = min;
axis.max = max;
};
}
});
wrap(Series.prototype, 'generatePoints', function(proceed) {
proceed.apply(this, stripArguments(arguments));
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis,
points = series.points,
point,
i = points.length,
connectNulls = series.options.connectNulls,
nullGap;
if (xAxis && yAxis && (xAxis.options.breaks || yAxis.options.breaks)) {
while (i--) {
point = points[i];
nullGap = point.y === null && connectNulls === false; // respect nulls inside the break (#4275)
if (!nullGap && (xAxis.isInAnyBreak(point.x, true) || yAxis.isInAnyBreak(point.y, true))) {
points.splice(i, 1);
if (this.data[i]) {
this.data[i].destroyElements(); // removes the graphics for this point if they exist
}
}
}
}
});
function drawPointsWrapped(proceed) {
proceed.apply(this);
this.drawBreaks(this.xAxis, ['x']);
this.drawBreaks(this.yAxis, pick(this.pointArrayMap, ['y']));
}
H.Series.prototype.drawBreaks = function(axis, keys) {
var series = this,
points = series.points,
breaks,
threshold,
eventName,
y;
if (!axis) {
return; // #5950
}
each(keys, function(key) {
breaks = axis.breakArray || [];
threshold = axis.isXAxis ? axis.min : pick(series.options.threshold, axis.min);
each(points, function(point) {
y = pick(point['stack' + key.toUpperCase()], point[key]);
each(breaks, function(brk) {
eventName = false;
if ((threshold < brk.from && y > brk.to) || (threshold > brk.from && y < brk.from)) {
eventName = 'pointBreak';
} else if ((threshold < brk.from && y > brk.from && y < brk.to) || (threshold > brk.from && y > brk.to && y < brk.from)) { // point falls inside the break
eventName = 'pointInBreak';
}
if (eventName) {
fireEvent(axis, eventName, {
point: point,
brk: brk
});
}
});
});
});
};
wrap(H.seriesTypes.column.prototype, 'drawPoints', drawPointsWrapped);
wrap(H.Series.prototype, 'drawPoints', drawPointsWrapped);
}(Highcharts));
(function() {
}());
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
Axis = H.Axis,
defaultPlotOptions = H.defaultPlotOptions,
defined = H.defined,
each = H.each,
extend = H.extend,
format = H.format,
isNumber = H.isNumber,
merge = H.merge,
pick = H.pick,
Point = H.Point,
Series = H.Series,
Tooltip = H.Tooltip,
wrap = H.wrap;
/* ****************************************************************************
* Start data grouping module *
******************************************************************************/
var seriesProto = Series.prototype,
baseProcessData = seriesProto.processData,
baseGeneratePoints = seriesProto.generatePoints,
baseDestroy = seriesProto.destroy,
commonOptions = {
approximation: 'average', // average, open, high, low, close, sum
//enabled: null, // (true for stock charts, false for basic),
//forced: undefined,
groupPixelWidth: 2,
// the first one is the point or start value, the second is the start value if we're dealing with range,
// the third one is the end value if dealing with a range
dateTimeLabelFormats: {
millisecond: ['%A, %b %e, %H:%M:%S.%L', '%A, %b %e, %H:%M:%S.%L', '-%H:%M:%S.%L'],
second: ['%A, %b %e, %H:%M:%S', '%A, %b %e, %H:%M:%S', '-%H:%M:%S'],
minute: ['%A, %b %e, %H:%M', '%A, %b %e, %H:%M', '-%H:%M'],
hour: ['%A, %b %e, %H:%M', '%A, %b %e, %H:%M', '-%H:%M'],
day: ['%A, %b %e, %Y', '%A, %b %e', '-%A, %b %e, %Y'],
week: ['Week from %A, %b %e, %Y', '%A, %b %e', '-%A, %b %e, %Y'],
month: ['%B %Y', '%B', '-%B %Y'],
year: ['%Y', '%Y', '-%Y']
}
// smoothed = false, // enable this for navigator series only
},
specificOptions = { // extends common options
line: {},
spline: {},
area: {},
areaspline: {},
column: {
approximation: 'sum',
groupPixelWidth: 10
},
arearange: {
approximation: 'range'
},
areasplinerange: {
approximation: 'range'
},
columnrange: {
approximation: 'range',
groupPixelWidth: 10
},
candlestick: {
approximation: 'ohlc',
groupPixelWidth: 10
},
ohlc: {
approximation: 'ohlc',
groupPixelWidth: 5
}
},
// units are defined in a separate array to allow complete overriding in case of a user option
defaultDataGroupingUnits = H.defaultDataGroupingUnits = [
[
'millisecond', // unit name
[1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
],
[
'second', [1, 2, 5, 10, 15, 30]
],
[
'minute', [1, 2, 5, 10, 15, 30]
],
[
'hour', [1, 2, 3, 4, 6, 8, 12]
],
[
'day', [1]
],
[
'week', [1]
],
[
'month', [1, 3, 6]
],
[
'year',
null
]
],
/**
* Define the available approximation types. The data grouping approximations takes an array
* or numbers as the first parameter. In case of ohlc, four arrays are sent in as four parameters.
* Each array consists only of numbers. In case null values belong to the group, the property
* .hasNulls will be set to true on the array.
*/
approximations = {
sum: function(arr) {
var len = arr.length,
ret;
// 1. it consists of nulls exclusively
if (!len && arr.hasNulls) {
ret = null;
// 2. it has a length and real values
} else if (len) {
ret = 0;
while (len--) {
ret += arr[len];
}
}
// 3. it has zero length, so just return undefined
// => doNothing()
return ret;
},
average: function(arr) {
var len = arr.length,
ret = approximations.sum(arr);
// If we have a number, return it divided by the length. If not, return
// null or undefined based on what the sum method finds.
if (isNumber(ret) && len) {
ret = ret / len;
}
return ret;
},
open: function(arr) {
return arr.length ? arr[0] : (arr.hasNulls ? null : undefined);
},
high: function(arr) {
return arr.length ? arrayMax(arr) : (arr.hasNulls ? null : undefined);
},
low: function(arr) {
return arr.length ? arrayMin(arr) : (arr.hasNulls ? null : undefined);
},
close: function(arr) {
return arr.length ? arr[arr.length - 1] : (arr.hasNulls ? null : undefined);
},
// ohlc and range are special cases where a multidimensional array is input and an array is output
ohlc: function(open, high, low, close) {
open = approximations.open(open);
high = approximations.high(high);
low = approximations.low(low);
close = approximations.close(close);
if (isNumber(open) || isNumber(high) || isNumber(low) || isNumber(close)) {
return [open, high, low, close];
}
// else, return is undefined
},
range: function(low, high) {
low = approximations.low(low);
high = approximations.high(high);
if (isNumber(low) || isNumber(high)) {
return [low, high];
}
// else, return is undefined
}
};
/**
* Takes parallel arrays of x and y data and groups the data into intervals defined by groupPositions, a collection
* of starting x values for each group.
*/
seriesProto.groupData = function(xData, yData, groupPositions, approximation) {
var series = this,
data = series.data,
dataOptions = series.options.data,
groupedXData = [],
groupedYData = [],
groupMap = [],
dataLength = xData.length,
pointX,
pointY,
groupedY,
handleYData = !!yData, // when grouping the fake extended axis for panning, we don't need to consider y
values = [
[],
[],
[],
[]
],
approximationFn = typeof approximation === 'function' ? approximation : approximations[approximation],
pointArrayMap = series.pointArrayMap,
pointArrayMapLength = pointArrayMap && pointArrayMap.length,
i,
pos = 0,
start = 0;
// Start with the first point within the X axis range (#2696)
for (i = 0; i <= dataLength; i++) {
if (xData[i] >= groupPositions[0]) {
break;
}
}
for (i; i <= dataLength; i++) {
// when a new group is entered, summarize and initiate the previous group
while ((groupPositions[pos + 1] !== undefined && xData[i] >= groupPositions[pos + 1]) ||
i === dataLength) { // get the last group
// get group x and y
pointX = groupPositions[pos];
series.dataGroupInfo = {
start: start,
length: values[0].length
};
groupedY = approximationFn.apply(series, values);
// push the grouped data
if (groupedY !== undefined) {
groupedXData.push(pointX);
groupedYData.push(groupedY);
groupMap.push(series.dataGroupInfo);
}
// reset the aggregate arrays
start = i;
values[0] = [];
values[1] = [];
values[2] = [];
values[3] = [];
// Advance on the group positions
pos += 1;
// don't loop beyond the last group
if (i === dataLength) {
break;
}
}
// break out
if (i === dataLength) {
break;
}
// for each raw data point, push it to an array that contains all values for this specific group
if (pointArrayMap) {
var index = series.cropStart + i,
point = (data && data[index]) || series.pointClass.prototype.applyOptions.apply({
series: series
}, [dataOptions[index]]),
j,
val;
for (j = 0; j < pointArrayMapLength; j++) {
val = point[pointArrayMap[j]];
if (isNumber(val)) {
values[j].push(val);
} else if (val === null) {
values[j].hasNulls = true;
}
}
} else {
pointY = handleYData ? yData[i] : null;
if (isNumber(pointY)) {
values[0].push(pointY);
} else if (pointY === null) {
values[0].hasNulls = true;
}
}
}
return [groupedXData, groupedYData, groupMap];
};
/**
* Extend the basic processData method, that crops the data to the current zoom
* range, with data grouping logic.
*/
seriesProto.processData = function() {
var series = this,
chart = series.chart,
options = series.options,
dataGroupingOptions = options.dataGrouping,
groupingEnabled = series.allowDG !== false && dataGroupingOptions &&
pick(dataGroupingOptions.enabled, chart.options.isStock),
visible = series.visible || !chart.options.chart.ignoreHiddenSeries,
hasGroupedData,
skip;
// run base method
series.forceCrop = groupingEnabled; // #334
series.groupPixelWidth = null; // #2110
series.hasProcessed = true; // #2692
// skip if processData returns false or if grouping is disabled (in that order)
skip = baseProcessData.apply(series, arguments) === false || !groupingEnabled;
if (!skip) {
series.destroyGroupedData();
var i,
processedXData = series.processedXData,
processedYData = series.processedYData,
plotSizeX = chart.plotSizeX,
xAxis = series.xAxis,
ordinal = xAxis.options.ordinal,
groupPixelWidth = series.groupPixelWidth = xAxis.getGroupPixelWidth && xAxis.getGroupPixelWidth();
// Execute grouping if the amount of points is greater than the limit defined in groupPixelWidth
if (groupPixelWidth) {
hasGroupedData = true;
series.isDirty = true; // force recreation of point instances in series.translate, #5699
var extremes = xAxis.getExtremes(),
xMin = extremes.min,
xMax = extremes.max,
groupIntervalFactor = (ordinal && xAxis.getGroupIntervalFactor(xMin, xMax, series)) || 1,
interval = (groupPixelWidth * (xMax - xMin) / plotSizeX) * groupIntervalFactor,
groupPositions = xAxis.getTimeTicks(
xAxis.normalizeTimeTickInterval(interval, dataGroupingOptions.units || defaultDataGroupingUnits),
Math.min(xMin, processedXData[0]), // Processed data may extend beyond axis (#4907)
Math.max(xMax, processedXData[processedXData.length - 1]),
xAxis.options.startOfWeek,
processedXData,
series.closestPointRange
),
groupedData = seriesProto.groupData.apply(series, [processedXData, processedYData, groupPositions, dataGroupingOptions.approximation]),
groupedXData = groupedData[0],
groupedYData = groupedData[1];
// prevent the smoothed data to spill out left and right, and make
// sure data is not shifted to the left
if (dataGroupingOptions.smoothed) {
i = groupedXData.length - 1;
groupedXData[i] = Math.min(groupedXData[i], xMax);
while (i-- && i > 0) {
groupedXData[i] += interval / 2;
}
groupedXData[0] = Math.max(groupedXData[0], xMin);
}
// record what data grouping values were used
series.currentDataGrouping = groupPositions.info;
series.closestPointRange = groupPositions.info.totalRange;
series.groupMap = groupedData[2];
// Make sure the X axis extends to show the first group (#2533)
// But only for visible series (#5493, #6393)
if (defined(groupedXData[0]) && groupedXData[0] < xAxis.dataMin && visible) {
if (xAxis.min === xAxis.dataMin) {
xAxis.min = groupedXData[0];
}
xAxis.dataMin = groupedXData[0];
}
// set series props
series.processedXData = groupedXData;
series.processedYData = groupedYData;
} else {
series.currentDataGrouping = series.groupMap = null;
}
series.hasGroupedData = hasGroupedData;
}
};
/**
* Destroy the grouped data points. #622, #740
*/
seriesProto.destroyGroupedData = function() {
var groupedData = this.groupedData;
// clear previous groups
each(groupedData || [], function(point, i) {
if (point) {
groupedData[i] = point.destroy ? point.destroy() : null;
}
});
this.groupedData = null;
};
/**
* Override the generatePoints method by adding a reference to grouped data
*/
seriesProto.generatePoints = function() {
baseGeneratePoints.apply(this);
// record grouped data in order to let it be destroyed the next time processData runs
this.destroyGroupedData(); // #622
this.groupedData = this.hasGroupedData ? this.points : null;
};
/**
* Override point prototype to throw a warning when trying to update grouped points
*/
wrap(Point.prototype, 'update', function(proceed) {
if (this.dataGroup) {
H.error(24);
} else {
proceed.apply(this, [].slice.call(arguments, 1));
}
});
/**
* Extend the original method, make the tooltip's header reflect the grouped range
*/
wrap(Tooltip.prototype, 'tooltipFooterHeaderFormatter', function(proceed, labelConfig, isFooter) {
var tooltip = this,
series = labelConfig.series,
options = series.options,
tooltipOptions = series.tooltipOptions,
dataGroupingOptions = options.dataGrouping,
xDateFormat = tooltipOptions.xDateFormat,
xDateFormatEnd,
xAxis = series.xAxis,
dateFormat = H.dateFormat,
currentDataGrouping,
dateTimeLabelFormats,
labelFormats,
formattedKey;
// apply only to grouped series
if (xAxis && xAxis.options.type === 'datetime' && dataGroupingOptions && isNumber(labelConfig.key)) {
// set variables
currentDataGrouping = series.currentDataGrouping;
dateTimeLabelFormats = dataGroupingOptions.dateTimeLabelFormats;
// if we have grouped data, use the grouping information to get the right format
if (currentDataGrouping) {
labelFormats = dateTimeLabelFormats[currentDataGrouping.unitName];
if (currentDataGrouping.count === 1) {
xDateFormat = labelFormats[0];
} else {
xDateFormat = labelFormats[1];
xDateFormatEnd = labelFormats[2];
}
// if not grouped, and we don't have set the xDateFormat option, get the best fit,
// so if the least distance between points is one minute, show it, but if the
// least distance is one day, skip hours and minutes etc.
} else if (!xDateFormat && dateTimeLabelFormats) {
xDateFormat = tooltip.getXDateFormat(labelConfig, tooltipOptions, xAxis);
}
// now format the key
formattedKey = dateFormat(xDateFormat, labelConfig.key);
if (xDateFormatEnd) {
formattedKey += dateFormat(xDateFormatEnd, labelConfig.key + currentDataGrouping.totalRange - 1);
}
// return the replaced format
return format(tooltipOptions[(isFooter ? 'footer' : 'header') + 'Format'], {
point: extend(labelConfig.point, {
key: formattedKey
}),
series: series
});
}
// else, fall back to the regular formatter
return proceed.call(tooltip, labelConfig, isFooter);
});
/**
* Extend the series destroyer
*/
seriesProto.destroy = function() {
var series = this,
groupedData = series.groupedData || [],
i = groupedData.length;
while (i--) {
if (groupedData[i]) {
groupedData[i].destroy();
}
}
baseDestroy.apply(series);
};
// Handle default options for data grouping. This must be set at runtime because some series types are
// defined after this.
wrap(seriesProto, 'setOptions', function(proceed, itemOptions) {
var options = proceed.call(this, itemOptions),
type = this.type,
plotOptions = this.chart.options.plotOptions,
defaultOptions = defaultPlotOptions[type].dataGrouping;
if (specificOptions[type]) { // #1284
if (!defaultOptions) {
defaultOptions = merge(commonOptions, specificOptions[type]);
}
options.dataGrouping = merge(
defaultOptions,
plotOptions.series && plotOptions.series.dataGrouping, // #1228
plotOptions[type].dataGrouping, // Set by the StockChart constructor
itemOptions.dataGrouping
);
}
if (this.chart.options.isStock) {
this.requireSorting = true;
}
return options;
});
/**
* When resetting the scale reset the hasProccessed flag to avoid taking previous data grouping
* of neighbour series into accound when determining group pixel width (#2692).
*/
wrap(Axis.prototype, 'setScale', function(proceed) {
proceed.call(this);
each(this.series, function(series) {
series.hasProcessed = false;
});
});
/**
* Get the data grouping pixel width based on the greatest defined individual width
* of the axis' series, and if whether one of the axes need grouping.
*/
Axis.prototype.getGroupPixelWidth = function() {
var series = this.series,
len = series.length,
i,
groupPixelWidth = 0,
doGrouping = false,
dataLength,
dgOptions;
// If multiple series are compared on the same x axis, give them the same
// group pixel width (#334)
i = len;
while (i--) {
dgOptions = series[i].options.dataGrouping;
if (dgOptions) {
groupPixelWidth = Math.max(groupPixelWidth, dgOptions.groupPixelWidth);
}
}
// If one of the series needs grouping, apply it to all (#1634)
i = len;
while (i--) {
dgOptions = series[i].options.dataGrouping;
if (dgOptions && series[i].hasProcessed) { // #2692
dataLength = (series[i].processedXData || series[i].data).length;
// Execute grouping if the amount of points is greater than the limit defined in groupPixelWidth
if (series[i].groupPixelWidth || dataLength > (this.chart.plotSizeX / groupPixelWidth) || (dataLength && dgOptions.forced)) {
doGrouping = true;
}
}
}
return doGrouping ? groupPixelWidth : 0;
};
/**
* Force data grouping on all the axis' series.
*/
Axis.prototype.setDataGrouping = function(dataGrouping, redraw) {
var i;
redraw = pick(redraw, true);
if (!dataGrouping) {
dataGrouping = {
forced: false,
units: null
};
}
// Axis is instantiated, update all series
if (this instanceof Axis) {
i = this.series.length;
while (i--) {
this.series[i].update({
dataGrouping: dataGrouping
}, false);
}
// Axis not yet instanciated, alter series options
} else {
each(this.chart.options.series, function(seriesOptions) {
seriesOptions.dataGrouping = dataGrouping;
}, false);
}
if (redraw) {
this.chart.redraw();
}
};
/* ****************************************************************************
* End data grouping module *
******************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var each = H.each,
Point = H.Point,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/**
* The ohlc series type.
*
* @constructor seriesTypes.ohlc
* @augments seriesTypes.column
*/
seriesType('ohlc', 'column', {
lineWidth: 1,
tooltip: {
pointFormat: '<span style="color:{point.color}">\u25CF</span> <b> {series.name}</b><br/>' +
'Open: {point.open}<br/>' +
'High: {point.high}<br/>' +
'Low: {point.low}<br/>' +
'Close: {point.close}<br/>'
},
threshold: null,
states: {
hover: {
lineWidth: 3
}
},
stickyTracking: true
//upColor: undefined
}, /** @lends seriesTypes.ohlc */ {
directTouch: false,
pointArrayMap: ['open', 'high', 'low', 'close'], // array point configs are mapped to this
toYData: function(point) { // return a plain array for speedy calculation
return [point.open, point.high, point.low, point.close];
},
pointValKey: 'high',
pointAttrToOptions: {
'stroke': 'color',
'stroke-width': 'lineWidth'
},
/**
* Postprocess mapping between options and SVG attributes
*/
pointAttribs: function(point, state) {
var attribs = seriesTypes.column.prototype.pointAttribs.call(
this,
point,
state
),
options = this.options;
delete attribs.fill;
if (!point.options.color &&
options.upColor &&
point.open < point.close
) {
attribs.stroke = options.upColor;
}
return attribs;
},
/**
* Translate data points from raw values x and y to plotX and plotY
*/
translate: function() {
var series = this,
yAxis = series.yAxis,
hasModifyValue = !!series.modifyValue,
translated = ['plotOpen', 'plotHigh', 'plotLow', 'plotClose', 'yBottom']; // translate OHLC for
seriesTypes.column.prototype.translate.apply(series);
// Do the translation
each(series.points, function(point) {
each([point.open, point.high, point.low, point.close, point.low], function(value, i) {
if (value !== null) {
if (hasModifyValue) {
value = series.modifyValue(value);
}
point[translated[i]] = yAxis.toPixels(value, true);
}
});
});
},
/**
* Draw the data points
*/
drawPoints: function() {
var series = this,
points = series.points,
chart = series.chart;
each(points, function(point) {
var plotOpen,
plotClose,
crispCorr,
halfWidth,
path,
graphic = point.graphic,
crispX,
isNew = !graphic;
if (point.plotY !== undefined) {
// Create and/or update the graphic
if (!graphic) {
point.graphic = graphic = chart.renderer.path()
.add(series.group);
}
graphic.attr(series.pointAttribs(point, point.selected && 'select')); // #3897
// crisp vector coordinates
crispCorr = (graphic.strokeWidth() % 2) / 2;
crispX = Math.round(point.plotX) - crispCorr; // #2596
halfWidth = Math.round(point.shapeArgs.width / 2);
// the vertical stem
path = [
'M',
crispX, Math.round(point.yBottom),
'L',
crispX, Math.round(point.plotY)
];
// open
if (point.open !== null) {
plotOpen = Math.round(point.plotOpen) + crispCorr;
path.push(
'M',
crispX,
plotOpen,
'L',
crispX - halfWidth,
plotOpen
);
}
// close
if (point.close !== null) {
plotClose = Math.round(point.plotClose) + crispCorr;
path.push(
'M',
crispX,
plotClose,
'L',
crispX + halfWidth,
plotClose
);
}
graphic[isNew ? 'attr' : 'animate']({
d: path
})
.addClass(point.getClassName(), true);
}
});
},
animate: null // Disable animation
/**
* @constructor seriesTypes.ohlc.prototype.pointClass
* @extends {Point}
*/
}, /** @lends seriesTypes.ohlc.prototype.pointClass.prototype */ {
/**
* Extend the parent method by adding up or down to the class name.
*/
getClassName: function() {
return Point.prototype.getClassName.call(this) +
(this.open < this.close ? ' highcharts-point-up' : ' highcharts-point-down');
}
});
/* ****************************************************************************
* End OHLC series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var defaultPlotOptions = H.defaultPlotOptions,
each = H.each,
merge = H.merge,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/**
* The candlestick series type.
*
* @constructor seriesTypes.candlestick
* @augments seriesTypes.ohlc
*/
seriesType('candlestick', 'ohlc', merge(defaultPlotOptions.column, {
states: {
hover: {
lineWidth: 2
}
},
tooltip: defaultPlotOptions.ohlc.tooltip,
threshold: null,
lineColor: '#000000',
lineWidth: 1,
upColor: '#ffffff',
stickyTracking: true
// upLineColor: null
}), /** @lends seriesTypes.candlestick */ {
/**
* Postprocess mapping between options and SVG attributes
*/
pointAttribs: function(point, state) {
var attribs = seriesTypes.column.prototype.pointAttribs.call(this, point, state),
options = this.options,
isUp = point.open < point.close,
stroke = options.lineColor || this.color,
stateOptions;
attribs['stroke-width'] = options.lineWidth;
attribs.fill = point.options.color || (isUp ? (options.upColor || this.color) : this.color);
attribs.stroke = point.lineColor || (isUp ? (options.upLineColor || stroke) : stroke);
// Select or hover states
if (state) {
stateOptions = options.states[state];
attribs.fill = stateOptions.color || attribs.fill;
attribs.stroke = stateOptions.lineColor || attribs.stroke;
attribs['stroke-width'] =
stateOptions.lineWidth || attribs['stroke-width'];
}
return attribs;
},
/**
* Draw the data points
*/
drawPoints: function() {
var series = this, //state = series.state,
points = series.points,
chart = series.chart;
each(points, function(point) {
var graphic = point.graphic,
plotOpen,
plotClose,
topBox,
bottomBox,
hasTopWhisker,
hasBottomWhisker,
crispCorr,
crispX,
path,
halfWidth,
isNew = !graphic;
if (point.plotY !== undefined) {
if (!graphic) {
point.graphic = graphic = chart.renderer.path()
.add(series.group);
}
graphic
.attr(series.pointAttribs(point, point.selected && 'select')) // #3897
.shadow(series.options.shadow);
// Crisp vector coordinates
crispCorr = (graphic.strokeWidth() % 2) / 2;
crispX = Math.round(point.plotX) - crispCorr; // #2596
plotOpen = point.plotOpen;
plotClose = point.plotClose;
topBox = Math.min(plotOpen, plotClose);
bottomBox = Math.max(plotOpen, plotClose);
halfWidth = Math.round(point.shapeArgs.width / 2);
hasTopWhisker = Math.round(topBox) !== Math.round(point.plotY);
hasBottomWhisker = bottomBox !== point.yBottom;
topBox = Math.round(topBox) + crispCorr;
bottomBox = Math.round(bottomBox) + crispCorr;
// Create the path. Due to a bug in Chrome 49, the path is first instanciated
// with no values, then the values pushed. For unknown reasons, instanciated
// the path array with all the values would lead to a crash when updating
// frequently (#5193).
path = [];
path.push(
'M',
crispX - halfWidth, bottomBox,
'L',
crispX - halfWidth, topBox,
'L',
crispX + halfWidth, topBox,
'L',
crispX + halfWidth, bottomBox,
'Z', // Use a close statement to ensure a nice rectangle #2602
'M',
crispX, topBox,
'L',
crispX, hasTopWhisker ? Math.round(point.plotY) : topBox, // #460, #2094
'M',
crispX, bottomBox,
'L',
crispX, hasBottomWhisker ? Math.round(point.yBottom) : bottomBox // #460, #2094
);
graphic[isNew ? 'attr' : 'animate']({
d: path
})
.addClass(point.getClassName(), true);
}
});
}
});
/* ****************************************************************************
* End Candlestick series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
each = H.each,
merge = H.merge,
noop = H.noop,
Renderer = H.Renderer,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes,
SVGRenderer = H.SVGRenderer,
TrackerMixin = H.TrackerMixin,
VMLRenderer = H.VMLRenderer,
symbols = SVGRenderer.prototype.symbols,
stableSort = H.stableSort;
/**
* The flags series type.
*
* @constructor seriesTypes.flags
* @augments seriesTypes.column
*/
seriesType('flags', 'column', {
pointRange: 0, // #673
//radius: 2,
shape: 'flag',
stackDistance: 12,
textAlign: 'center',
tooltip: {
pointFormat: '{point.text}<br/>'
},
threshold: null,
y: -30,
fillColor: '#ffffff',
// lineColor: color,
lineWidth: 1,
states: {
hover: {
lineColor: '#000000',
fillColor: '#ccd6eb'
}
},
style: {
fontSize: '11px',
fontWeight: 'bold'
}
}, /** @lends seriesTypes.flags.prototype */ {
sorted: false,
noSharedTooltip: true,
allowDG: false,
takeOrdinalPosition: false, // #1074
trackerGroups: ['markerGroup'],
forceCrop: true,
/**
* Inherit the initialization from base Series.
*/
init: Series.prototype.init,
/**
* Get presentational attributes
*/
pointAttribs: function(point, state) {
var options = this.options,
color = (point && point.color) || this.color,
lineColor = options.lineColor,
lineWidth = (point && point.lineWidth),
fill = (point && point.fillColor) || options.fillColor;
if (state) {
fill = options.states[state].fillColor;
lineColor = options.states[state].lineColor;
lineWidth = options.states[state].lineWidth;
}
return {
'fill': fill || color,
'stroke': lineColor || color,
'stroke-width': lineWidth || options.lineWidth || 0
};
},
/**
* Extend the translate method by placing the point on the related series
*/
translate: function() {
seriesTypes.column.prototype.translate.apply(this);
var series = this,
options = series.options,
chart = series.chart,
points = series.points,
cursor = points.length - 1,
point,
lastPoint,
optionsOnSeries = options.onSeries,
onSeries = optionsOnSeries && chart.get(optionsOnSeries),
onKey = options.onKey || 'y',
step = onSeries && onSeries.options.step,
onData = onSeries && onSeries.points,
i = onData && onData.length,
xAxis = series.xAxis,
yAxis = series.yAxis,
xAxisExt = xAxis.getExtremes(),
xOffset = 0,
leftPoint,
lastX,
rightPoint,
currentDataGrouping;
// relate to a master series
if (onSeries && onSeries.visible && i) {
xOffset = (onSeries.pointXOffset || 0) + (onSeries.barW || 0) / 2;
currentDataGrouping = onSeries.currentDataGrouping;
lastX = onData[i - 1].x + (currentDataGrouping ? currentDataGrouping.totalRange : 0); // #2374
// sort the data points
stableSort(points, function(a, b) {
return (a.x - b.x);
});
onKey = 'plot' + onKey[0].toUpperCase() + onKey.substr(1);
while (i-- && points[cursor]) {
point = points[cursor];
leftPoint = onData[i];
if (leftPoint.x <= point.x && leftPoint[onKey] !== undefined) {
if (point.x <= lastX) { // #803
point.plotY = leftPoint[onKey];
// interpolate between points, #666
if (leftPoint.x < point.x && !step) {
rightPoint = onData[i + 1];
if (rightPoint && rightPoint[onKey] !== undefined) {
point.plotY +=
((point.x - leftPoint.x) / (rightPoint.x - leftPoint.x)) * // the distance ratio, between 0 and 1
(rightPoint[onKey] - leftPoint[onKey]); // the y distance
}
}
}
cursor--;
i++; // check again for points in the same x position
if (cursor < 0) {
break;
}
}
}
}
// Add plotY position and handle stacking
each(points, function(point, i) {
var stackIndex;
// Undefined plotY means the point is either on axis, outside series
// range or hidden series. If the series is outside the range of the
// x axis it should fall through with an undefined plotY, but then
// we must remove the shapeArgs (#847).
if (point.plotY === undefined) {
if (point.x >= xAxisExt.min && point.x <= xAxisExt.max) {
// we're inside xAxis range
point.plotY = chart.chartHeight - xAxis.bottom -
(xAxis.opposite ? xAxis.height : 0) +
xAxis.offset - yAxis.top; // #3517
} else {
point.shapeArgs = {}; // 847
}
}
point.plotX += xOffset; // #2049
// if multiple flags appear at the same x, order them into a stack
lastPoint = points[i - 1];
if (lastPoint && lastPoint.plotX === point.plotX) {
if (lastPoint.stackIndex === undefined) {
lastPoint.stackIndex = 0;
}
stackIndex = lastPoint.stackIndex + 1;
}
point.stackIndex = stackIndex; // #3639
});
},
/**
* Draw the markers
*/
drawPoints: function() {
var series = this,
points = series.points,
chart = series.chart,
renderer = chart.renderer,
plotX,
plotY,
options = series.options,
optionsY = options.y,
shape,
i,
point,
graphic,
stackIndex,
anchorX,
anchorY,
outsideRight,
yAxis = series.yAxis;
i = points.length;
while (i--) {
point = points[i];
outsideRight = point.plotX > series.xAxis.len;
plotX = point.plotX;
stackIndex = point.stackIndex;
shape = point.options.shape || options.shape;
plotY = point.plotY;
if (plotY !== undefined) {
plotY = point.plotY + optionsY - (stackIndex !== undefined && stackIndex * options.stackDistance);
}
anchorX = stackIndex ? undefined : point.plotX; // skip connectors for higher level stacked points
anchorY = stackIndex ? undefined : point.plotY;
graphic = point.graphic;
// Only draw the point if y is defined and the flag is within the visible area
if (plotY !== undefined && plotX >= 0 && !outsideRight) {
// Create the flag
if (!graphic) {
graphic = point.graphic = renderer.label(
'',
null,
null,
shape,
null,
null,
options.useHTML
)
.attr(series.pointAttribs(point))
.css(merge(options.style, point.style))
.attr({
align: shape === 'flag' ? 'left' : 'center',
width: options.width,
height: options.height,
'text-align': options.textAlign
})
.addClass('highcharts-point')
.add(series.markerGroup);
// Add reference to the point for tracker (#6303)
if (point.graphic.div) {
point.graphic.div.point = point;
}
graphic.shadow(options.shadow);
}
if (plotX > 0) { // #3119
plotX -= graphic.strokeWidth() % 2; // #4285
}
// Plant the flag
graphic.attr({
text: point.options.title || options.title || 'A',
x: plotX,
y: plotY,
anchorX: anchorX,
anchorY: anchorY
});
// Set the tooltip anchor position
point.tooltipPos = chart.inverted ? [yAxis.len + yAxis.pos - chart.plotLeft - plotY, series.xAxis.len - plotX] : [plotX, plotY + yAxis.pos - chart.plotTop]; // #6327
} else if (graphic) {
point.graphic = graphic.destroy();
}
}
// Might be a mix of SVG and HTML and we need events for both (#6303)
if (options.useHTML) {
H.wrap(series.markerGroup, 'on', function(proceed) {
return H.SVGElement.prototype.on.apply(
proceed.apply(this, [].slice.call(arguments, 1)), // for HTML
[].slice.call(arguments, 1)); // and for SVG
});
}
},
/**
* Extend the column trackers with listeners to expand and contract stacks
*/
drawTracker: function() {
var series = this,
points = series.points;
TrackerMixin.drawTrackerPoint.apply(this);
// Bring each stacked flag up on mouse over, this allows readability of vertically
// stacked elements as well as tight points on the x axis. #1924.
each(points, function(point) {
var graphic = point.graphic;
if (graphic) {
addEvent(graphic.element, 'mouseover', function() {
// Raise this point
if (point.stackIndex > 0 && !point.raised) {
point._y = graphic.y;
graphic.attr({
y: point._y - 8
});
point.raised = true;
}
// Revert other raised points
each(points, function(otherPoint) {
if (otherPoint !== point && otherPoint.raised && otherPoint.graphic) {
otherPoint.graphic.attr({
y: otherPoint._y
});
otherPoint.raised = false;
}
});
});
}
});
},
animate: noop, // Disable animation
buildKDTree: noop,
setClip: noop
});
// create the flag icon with anchor
symbols.flag = function(x, y, w, h, options) {
var anchorX = (options && options.anchorX) || x,
anchorY = (options && options.anchorY) || y;
return [
'M', anchorX, anchorY,
'L', x, y + h,
x, y,
x + w, y,
x + w, y + h,
x, y + h,
'Z'
];
};
// create the circlepin and squarepin icons with anchor
each(['circle', 'square'], function(shape) {
symbols[shape + 'pin'] = function(x, y, w, h, options) {
var anchorX = options && options.anchorX,
anchorY = options && options.anchorY,
path,
labelTopOrBottomY;
// For single-letter flags, make sure circular flags are not taller than their width
if (shape === 'circle' && h > w) {
x -= Math.round((h - w) / 2);
w = h;
}
path = symbols[shape](x, y, w, h);
if (anchorX && anchorY) {
// if the label is below the anchor, draw the connecting line from the top edge of the label
// otherwise start drawing from the bottom edge
labelTopOrBottomY = (y > anchorY) ? y : y + h;
path.push('M', anchorX, labelTopOrBottomY, 'L', anchorX, anchorY);
}
return path;
};
});
// The symbol callbacks are generated on the SVGRenderer object in all browsers. Even
// VML browsers need this in order to generate shapes in export. Now share
// them with the VMLRenderer.
if (Renderer === VMLRenderer) {
each(['flag', 'circlepin', 'squarepin'], function(shape) {
VMLRenderer.prototype.symbols[shape] = symbols[shape];
});
}
/* ****************************************************************************
* End Flags series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
Axis = H.Axis,
correctFloat = H.correctFloat,
defaultOptions = H.defaultOptions,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
doc = H.doc,
each = H.each,
fireEvent = H.fireEvent,
hasTouch = H.hasTouch,
isTouchDevice = H.isTouchDevice,
merge = H.merge,
pick = H.pick,
removeEvent = H.removeEvent,
svg = H.svg,
wrap = H.wrap,
swapXY;
var defaultScrollbarOptions = {
//enabled: true
height: isTouchDevice ? 20 : 14,
// trackBorderRadius: 0
barBorderRadius: 0,
buttonBorderRadius: 0,
liveRedraw: svg && !isTouchDevice,
margin: 10,
minWidth: 6,
//showFull: true,
//size: null,
step: 0.2,
zIndex: 3,
barBackgroundColor: '#cccccc',
barBorderWidth: 1,
barBorderColor: '#cccccc',
buttonArrowColor: '#333333',
buttonBackgroundColor: '#e6e6e6',
buttonBorderColor: '#cccccc',
buttonBorderWidth: 1,
rifleColor: '#333333',
trackBackgroundColor: '#f2f2f2',
trackBorderColor: '#f2f2f2',
trackBorderWidth: 1
};
defaultOptions.scrollbar = merge(true, defaultScrollbarOptions, defaultOptions.scrollbar);
/**
* When we have vertical scrollbar, rifles and arrow in buttons should be rotated.
* The same method is used in Navigator's handles, to rotate them.
* @param {Array} path - path to be rotated
* @param {Boolean} vertical - if vertical scrollbar, swap x-y values
*/
H.swapXY = swapXY = function(path, vertical) {
var i,
len = path.length,
temp;
if (vertical) {
for (i = 0; i < len; i += 3) {
temp = path[i + 1];
path[i + 1] = path[i + 2];
path[i + 2] = temp;
}
}
return path;
};
/**
* A reusable scrollbar, internally used in Highstock's navigator and optionally
* on individual axes.
*
* @class
* @param {Object} renderer
* @param {Object} options
* @param {Object} chart
*/
function Scrollbar(renderer, options, chart) { // docs
this.init(renderer, options, chart);
}
Scrollbar.prototype = {
init: function(renderer, options, chart) {
this.scrollbarButtons = [];
this.renderer = renderer;
this.userOptions = options;
this.options = merge(defaultScrollbarOptions, options);
this.chart = chart;
this.size = pick(this.options.size, this.options.height); // backward compatibility
// Init
if (options.enabled) {
this.render();
this.initEvents();
this.addEvents();
}
},
/**
* Render scrollbar with all required items.
*/
render: function() {
var scroller = this,
renderer = scroller.renderer,
options = scroller.options,
size = scroller.size,
group;
// Draw the scrollbar group
scroller.group = group = renderer.g('scrollbar').attr({
zIndex: options.zIndex,
translateY: -99999
}).add();
// Draw the scrollbar track:
scroller.track = renderer.rect()
.addClass('highcharts-scrollbar-track')
.attr({
x: 0,
r: options.trackBorderRadius || 0,
height: size,
width: size
}).add(group);
scroller.track.attr({
fill: options.trackBackgroundColor,
stroke: options.trackBorderColor,
'stroke-width': options.trackBorderWidth
});
this.trackBorderWidth = scroller.track.strokeWidth();
scroller.track.attr({
y: -this.trackBorderWidth % 2 / 2
});
// Draw the scrollbar itself
scroller.scrollbarGroup = renderer.g().add(group);
scroller.scrollbar = renderer.rect()
.addClass('highcharts-scrollbar-thumb')
.attr({
height: size,
width: size,
r: options.barBorderRadius || 0
}).add(scroller.scrollbarGroup);
scroller.scrollbarRifles = renderer.path(
swapXY([
'M', -3, size / 4,
'L', -3, 2 * size / 3,
'M',
0, size / 4,
'L',
0, 2 * size / 3,
'M',
3, size / 4,
'L',
3, 2 * size / 3
], options.vertical))
.addClass('highcharts-scrollbar-rifles')
.add(scroller.scrollbarGroup);
scroller.scrollbar.attr({
fill: options.barBackgroundColor,
stroke: options.barBorderColor,
'stroke-width': options.barBorderWidth
});
scroller.scrollbarRifles.attr({
stroke: options.rifleColor,
'stroke-width': 1
});
scroller.scrollbarStrokeWidth = scroller.scrollbar.strokeWidth();
scroller.scrollbarGroup.translate(-scroller.scrollbarStrokeWidth % 2 / 2, -scroller.scrollbarStrokeWidth % 2 / 2);
// Draw the buttons:
scroller.drawScrollbarButton(0);
scroller.drawScrollbarButton(1);
},
/**
* Position the scrollbar, method called from a parent with defined dimensions
* @param {Number} x - x-position on the chart
* @param {Number} y - y-position on the chart
* @param {Number} width - width of the scrollbar
* @param {Number} height - height of the scorllbar
*/
position: function(x, y, width, height) {
var scroller = this,
options = scroller.options,
vertical = options.vertical,
xOffset = height,
yOffset = 0,
method = scroller.rendered ? 'animate' : 'attr';
scroller.x = x;
scroller.y = y + this.trackBorderWidth;
scroller.width = width; // width with buttons
scroller.height = height;
scroller.xOffset = xOffset;
scroller.yOffset = yOffset;
// If Scrollbar is a vertical type, swap options:
if (vertical) {
scroller.width = scroller.yOffset = width = yOffset = scroller.size;
scroller.xOffset = xOffset = 0;
scroller.barWidth = height - width * 2; // width without buttons
scroller.x = x = x + scroller.options.margin;
} else {
scroller.height = scroller.xOffset = height = xOffset = scroller.size;
scroller.barWidth = width - height * 2; // width without buttons
scroller.y = scroller.y + scroller.options.margin;
}
// Set general position for a group:
scroller.group[method]({
translateX: x,
translateY: scroller.y
});
// Resize background/track:
scroller.track[method]({
width: width,
height: height
});
// Move right/bottom button ot it's place:
scroller.scrollbarButtons[1][method]({
translateX: vertical ? 0 : width - xOffset,
translateY: vertical ? height - yOffset : 0
});
},
/**
* Draw the scrollbar buttons with arrows
* @param {Number} index 0 is left, 1 is right
*/
drawScrollbarButton: function(index) {
var scroller = this,
renderer = scroller.renderer,
scrollbarButtons = scroller.scrollbarButtons,
options = scroller.options,
size = scroller.size,
group,
tempElem;
group = renderer.g().add(scroller.group);
scrollbarButtons.push(group);
// Create a rectangle for the scrollbar button
tempElem = renderer.rect()
.addClass('highcharts-scrollbar-button')
.add(group);
// Presentational attributes
tempElem.attr({
stroke: options.buttonBorderColor,
'stroke-width': options.buttonBorderWidth,
fill: options.buttonBackgroundColor
});
// Place the rectangle based on the rendered stroke width
tempElem.attr(tempElem.crisp({
x: -0.5,
y: -0.5,
width: size + 1, // +1 to compensate for crispifying in rect method
height: size + 1,
r: options.buttonBorderRadius
}, tempElem.strokeWidth()));
// Button arrow
tempElem = renderer
.path(swapXY([
'M',
size / 2 + (index ? -1 : 1),
size / 2 - 3,
'L',
size / 2 + (index ? -1 : 1),
size / 2 + 3,
'L',
size / 2 + (index ? 2 : -2),
size / 2
], options.vertical))
.addClass('highcharts-scrollbar-arrow')
.add(scrollbarButtons[index]);
tempElem.attr({
fill: options.buttonArrowColor
});
},
/**
* Set scrollbar size, with a given scale.
* @param {Number} from - scale (0-1) where bar should start
* @param {Number} to - scale (0-1) where bar should end
*/
setRange: function(from, to) {
var scroller = this,
options = scroller.options,
vertical = options.vertical,
minWidth = options.minWidth,
fullWidth = scroller.barWidth,
fromPX,
toPX,
newPos,
newSize,
newRiflesPos,
method = this.rendered && !this.hasDragged ? 'animate' : 'attr';
if (!defined(fullWidth)) {
return;
}
from = Math.max(from, 0);
fromPX = Math.ceil(fullWidth * from);
toPX = fullWidth * Math.min(to, 1);
scroller.calculatedWidth = newSize = correctFloat(toPX - fromPX);
// We need to recalculate position, if minWidth is used
if (newSize < minWidth) {
fromPX = (fullWidth - minWidth + newSize) * from;
newSize = minWidth;
}
newPos = Math.floor(fromPX + scroller.xOffset + scroller.yOffset);
newRiflesPos = newSize / 2 - 0.5; // -0.5 -> rifle line width / 2
// Store current position:
scroller.from = from;
scroller.to = to;
if (!vertical) {
scroller.scrollbarGroup[method]({
translateX: newPos
});
scroller.scrollbar[method]({
width: newSize
});
scroller.scrollbarRifles[method]({
translateX: newRiflesPos
});
scroller.scrollbarLeft = newPos;
scroller.scrollbarTop = 0;
} else {
scroller.scrollbarGroup[method]({
translateY: newPos
});
scroller.scrollbar[method]({
height: newSize
});
scroller.scrollbarRifles[method]({
translateY: newRiflesPos
});
scroller.scrollbarTop = newPos;
scroller.scrollbarLeft = 0;
}
if (newSize <= 12) {
scroller.scrollbarRifles.hide();
} else {
scroller.scrollbarRifles.show(true);
}
// Show or hide the scrollbar based on the showFull setting
if (options.showFull === false) {
if (from <= 0 && to >= 1) {
scroller.group.hide();
} else {
scroller.group.show();
}
}
scroller.rendered = true;
},
/**
* Init events methods, so we have an access to the Scrollbar itself
*/
initEvents: function() {
var scroller = this;
/**
* Event handler for the mouse move event.
*/
scroller.mouseMoveHandler = function(e) {
var normalizedEvent = scroller.chart.pointer.normalize(e),
options = scroller.options,
direction = options.vertical ? 'chartY' : 'chartX',
initPositions = scroller.initPositions,
scrollPosition,
chartPosition,
change;
// In iOS, a mousemove event with e.pageX === 0 is fired when holding the finger
// down in the center of the scrollbar. This should be ignored.
if (scroller.grabbedCenter && (!e.touches || e.touches[0][direction] !== 0)) { // #4696, scrollbar failed on Android
chartPosition = scroller.cursorToScrollbarPosition(normalizedEvent)[direction];
scrollPosition = scroller[direction];
change = chartPosition - scrollPosition;
scroller.hasDragged = true;
scroller.updatePosition(initPositions[0] + change, initPositions[1] + change);
if (scroller.hasDragged) {
fireEvent(scroller, 'changed', {
from: scroller.from,
to: scroller.to,
trigger: 'scrollbar',
DOMType: e.type,
DOMEvent: e
});
}
}
};
/**
* Event handler for the mouse up event.
*/
scroller.mouseUpHandler = function(e) {
if (scroller.hasDragged) {
fireEvent(scroller, 'changed', {
from: scroller.from,
to: scroller.to,
trigger: 'scrollbar',
DOMType: e.type,
DOMEvent: e
});
}
scroller.grabbedCenter = scroller.hasDragged = scroller.chartX = scroller.chartY = null;
};
scroller.mouseDownHandler = function(e) {
var normalizedEvent = scroller.chart.pointer.normalize(e),
mousePosition = scroller.cursorToScrollbarPosition(normalizedEvent);
scroller.chartX = mousePosition.chartX;
scroller.chartY = mousePosition.chartY;
scroller.initPositions = [scroller.from, scroller.to];
scroller.grabbedCenter = true;
};
scroller.buttonToMinClick = function(e) {
var range = correctFloat(scroller.to - scroller.from) * scroller.options.step;
scroller.updatePosition(correctFloat(scroller.from - range), correctFloat(scroller.to - range));
fireEvent(scroller, 'changed', {
from: scroller.from,
to: scroller.to,
trigger: 'scrollbar',
DOMEvent: e
});
};
scroller.buttonToMaxClick = function(e) {
var range = (scroller.to - scroller.from) * scroller.options.step;
scroller.updatePosition(scroller.from + range, scroller.to + range);
fireEvent(scroller, 'changed', {
from: scroller.from,
to: scroller.to,
trigger: 'scrollbar',
DOMEvent: e
});
};
scroller.trackClick = function(e) {
var normalizedEvent = scroller.chart.pointer.normalize(e),
range = scroller.to - scroller.from,
top = scroller.y + scroller.scrollbarTop,
left = scroller.x + scroller.scrollbarLeft;
if ((scroller.options.vertical && normalizedEvent.chartY > top) ||
(!scroller.options.vertical && normalizedEvent.chartX > left)) {
// On the top or on the left side of the track:
scroller.updatePosition(scroller.from + range, scroller.to + range);
} else {
// On the bottom or the right side of the track:
scroller.updatePosition(scroller.from - range, scroller.to - range);
}
fireEvent(scroller, 'changed', {
from: scroller.from,
to: scroller.to,
trigger: 'scrollbar',
DOMEvent: e
});
};
},
/**
* Get normalized (0-1) cursor position over the scrollbar
* @param {Event} normalizedEvent - normalized event, with chartX and chartY values
* @return {Object} Local position {chartX, chartY}
*/
cursorToScrollbarPosition: function(normalizedEvent) {
var scroller = this,
options = scroller.options,
minWidthDifference = options.minWidth > scroller.calculatedWidth ? options.minWidth : 0; // minWidth distorts translation
return {
chartX: (normalizedEvent.chartX - scroller.x - scroller.xOffset) / (scroller.barWidth - minWidthDifference),
chartY: (normalizedEvent.chartY - scroller.y - scroller.yOffset) / (scroller.barWidth - minWidthDifference)
};
},
/**
* Update position option in the Scrollbar, with normalized 0-1 scale
*/
updatePosition: function(from, to) {
if (to > 1) {
from = correctFloat(1 - correctFloat(to - from));
to = 1;
}
if (from < 0) {
to = correctFloat(to - from);
from = 0;
}
this.from = from;
this.to = to;
},
/**
* Update the scrollbar with new options
*/
update: function(options) {
this.destroy();
this.init(this.chart.renderer, merge(true, this.options, options), this.chart);
},
/**
* Set up the mouse and touch events for the Scrollbar
*/
addEvents: function() {
var buttonsOrder = this.options.inverted ? [1, 0] : [0, 1],
buttons = this.scrollbarButtons,
bar = this.scrollbarGroup.element,
track = this.track.element,
mouseDownHandler = this.mouseDownHandler,
mouseMoveHandler = this.mouseMoveHandler,
mouseUpHandler = this.mouseUpHandler,
_events;
// Mouse events
_events = [
[buttons[buttonsOrder[0]].element, 'click', this.buttonToMinClick],
[buttons[buttonsOrder[1]].element, 'click', this.buttonToMaxClick],
[track, 'click', this.trackClick],
[bar, 'mousedown', mouseDownHandler],
[doc, 'mousemove', mouseMoveHandler],
[doc, 'mouseup', mouseUpHandler]
];
// Touch events
if (hasTouch) {
_events.push(
[bar, 'touchstart', mouseDownHandler], [doc, 'touchmove', mouseMoveHandler], [doc, 'touchend', mouseUpHandler]
);
}
// Add them all
each(_events, function(args) {
addEvent.apply(null, args);
});
this._events = _events;
},
/**
* Removes the event handlers attached previously with addEvents.
*/
removeEvents: function() {
each(this._events, function(args) {
removeEvent.apply(null, args);
});
this._events = undefined;
},
/**
* Destroys allocated elements.
*/
destroy: function() {
var scroller = this.chart.scroller;
// Disconnect events added in addEvents
this.removeEvents();
// Destroy properties
each(['track', 'scrollbarRifles', 'scrollbar', 'scrollbarGroup', 'group'], function(prop) {
if (this[prop] && this[prop].destroy) {
this[prop] = this[prop].destroy();
}
}, this);
if (scroller && this === scroller.scrollbar) { // #6421, chart may have more scrollbars
scroller.scrollbar = null;
// Destroy elements in collection
destroyObjectProperties(scroller.scrollbarButtons);
}
}
};
/**
* Wrap axis initialization and create scrollbar if enabled:
*/
wrap(Axis.prototype, 'init', function(proceed) {
var axis = this;
proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
if (axis.options.scrollbar && axis.options.scrollbar.enabled) {
// Predefined options:
axis.options.scrollbar.vertical = !axis.horiz;
axis.options.startOnTick = axis.options.endOnTick = false;
axis.scrollbar = new Scrollbar(axis.chart.renderer, axis.options.scrollbar, axis.chart);
addEvent(axis.scrollbar, 'changed', function(e) {
var unitedMin = Math.min(pick(axis.options.min, axis.min), axis.min, axis.dataMin),
unitedMax = Math.max(pick(axis.options.max, axis.max), axis.max, axis.dataMax),
range = unitedMax - unitedMin,
to,
from;
if ((axis.horiz && !axis.reversed) || (!axis.horiz && axis.reversed)) {
to = unitedMin + range * this.to;
from = unitedMin + range * this.from;
} else {
// y-values in browser are reversed, but this also applies for reversed horizontal axis:
to = unitedMin + range * (1 - this.from);
from = unitedMin + range * (1 - this.to);
}
axis.setExtremes(from, to, true, false, e);
});
}
});
/**
* Wrap rendering axis, and update scrollbar if one is created:
*/
wrap(Axis.prototype, 'render', function(proceed) {
var axis = this,
scrollMin = Math.min(pick(axis.options.min, axis.min), axis.min, axis.dataMin),
scrollMax = Math.max(pick(axis.options.max, axis.max), axis.max, axis.dataMax),
scrollbar = axis.scrollbar,
offsetsIndex,
from,
to;
proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
if (scrollbar) {
if (axis.horiz) {
scrollbar.position(
axis.left,
axis.top + axis.height + 2 + axis.chart.scrollbarsOffsets[1] +
(axis.opposite ? 0 : axis.axisTitleMargin + axis.offset),
axis.width,
axis.height
);
offsetsIndex = 1;
} else {
scrollbar.position(
axis.left + axis.width + 2 + axis.chart.scrollbarsOffsets[0] +
(axis.opposite ? axis.axisTitleMargin + axis.offset : 0),
axis.top,
axis.width,
axis.height
);
offsetsIndex = 0;
}
if ((!axis.opposite && !axis.horiz) || (axis.opposite && axis.horiz)) {
axis.chart.scrollbarsOffsets[offsetsIndex] +=
axis.scrollbar.size + axis.scrollbar.options.margin;
}
if (isNaN(scrollMin) || isNaN(scrollMax) || !defined(axis.min) || !defined(axis.max)) {
scrollbar.setRange(0, 0); // default action: when there is not extremes on the axis, but scrollbar exists, make it full size
} else {
from = (axis.min - scrollMin) / (scrollMax - scrollMin);
to = (axis.max - scrollMin) / (scrollMax - scrollMin);
if ((axis.horiz && !axis.reversed) || (!axis.horiz && axis.reversed)) {
scrollbar.setRange(from, to);
} else {
scrollbar.setRange(1 - to, 1 - from); // inverse vertical axis
}
}
}
});
/**
* Make space for a scrollbar
*/
wrap(Axis.prototype, 'getOffset', function(proceed) {
var axis = this,
index = axis.horiz ? 2 : 1,
scrollbar = axis.scrollbar;
proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
if (scrollbar) {
axis.chart.scrollbarsOffsets = [0, 0]; // reset scrollbars offsets
axis.chart.axisOffset[index] += scrollbar.size + scrollbar.options.margin;
}
});
/**
* Destroy scrollbar when connected to the specific axis
*/
wrap(Axis.prototype, 'destroy', function(proceed) {
if (this.scrollbar) {
this.scrollbar = this.scrollbar.destroy();
}
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
});
H.Scrollbar = Scrollbar;
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/* ****************************************************************************
* Start Navigator code *
*****************************************************************************/
var addEvent = H.addEvent,
Axis = H.Axis,
Chart = H.Chart,
color = H.color,
defaultDataGroupingUnits = H.defaultDataGroupingUnits,
defaultOptions = H.defaultOptions,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
doc = H.doc,
each = H.each,
erase = H.erase,
error = H.error,
extend = H.extend,
grep = H.grep,
hasTouch = H.hasTouch,
isNumber = H.isNumber,
isObject = H.isObject,
merge = H.merge,
pick = H.pick,
removeEvent = H.removeEvent,
Scrollbar = H.Scrollbar,
Series = H.Series,
seriesTypes = H.seriesTypes,
wrap = H.wrap,
swapXY = H.swapXY,
units = [].concat(defaultDataGroupingUnits), // copy
defaultSeriesType,
// Finding the min or max of a set of variables where we don't know if they are defined,
// is a pattern that is repeated several places in Highcharts. Consider making this
// a global utility method.
numExt = function(extreme) {
var numbers = grep(arguments, isNumber);
if (numbers.length) {
return Math[extreme].apply(0, numbers);
}
};
// add more resolution to units
units[4] = ['day', [1, 2, 3, 4]]; // allow more days
units[5] = ['week', [1, 2, 3]]; // allow more weeks
defaultSeriesType = seriesTypes.areaspline === undefined ? 'line' : 'areaspline';
extend(defaultOptions, {
navigator: {
//enabled: true,
height: 40,
margin: 25,
maskInside: true,
handles: {
backgroundColor: '#f2f2f2',
borderColor: '#999999'
},
maskFill: color('#6685c2').setOpacity(0.3).get(),
outlineColor: '#cccccc',
outlineWidth: 1,
series: {
type: defaultSeriesType,
color: '#335cad',
fillOpacity: 0.05,
lineWidth: 1,
compare: null,
dataGrouping: {
approximation: 'average',
enabled: true,
groupPixelWidth: 2,
smoothed: true,
units: units
},
dataLabels: {
enabled: false,
zIndex: 2 // #1839
},
id: 'highcharts-navigator-series',
className: 'highcharts-navigator-series',
lineColor: null, // Allow color setting while disallowing default candlestick setting (#4602)
marker: {
enabled: false
},
pointRange: 0,
shadow: false,
threshold: null
},
//top: undefined,
//opposite: undefined,
xAxis: {
className: 'highcharts-navigator-xaxis',
tickLength: 0,
lineWidth: 0,
gridLineColor: '#e6e6e6',
gridLineWidth: 1,
tickPixelInterval: 200,
labels: {
align: 'left',
style: {
color: '#999999'
},
x: 3,
y: -4
},
crosshair: false
},
yAxis: {
className: 'highcharts-navigator-yaxis',
gridLineWidth: 0,
startOnTick: false,
endOnTick: false,
minPadding: 0.1,
maxPadding: 0.1,
labels: {
enabled: false
},
crosshair: false,
title: {
text: null
},
tickLength: 0,
tickWidth: 0
}
}
});
/**
* The Navigator class
* @param {Object} chart - Chart object
* @class
*/
function Navigator(chart) {
this.init(chart);
}
Navigator.prototype = {
/**
* Draw one of the handles on the side of the zoomed range in the navigator
* @param {Number} x The x center for the handle
* @param {Number} index 0 for left and 1 for right
* @param {Boolean} inverted flag for chart.inverted
* @param {String} verb use 'animate' or 'attr'
*/
drawHandle: function(x, index, inverted, verb) {
var navigator = this;
// Place it
navigator.handles[index][verb](inverted ? {
translateX: Math.round(navigator.left + navigator.height / 2 - 8),
translateY: Math.round(navigator.top + parseInt(x, 10) + 0.5)
} : {
translateX: Math.round(navigator.left + parseInt(x, 10)),
translateY: Math.round(navigator.top + navigator.height / 2 - 8)
});
},
/**
* Draw one of the handles on the side of the zoomed range in the navigator
* @param {Boolean} inverted flag for chart.inverted
* @returns {Array} Path to be used in a handle
*/
getHandlePath: function(inverted) {
return swapXY([
'M', -4.5, 0.5,
'L',
3.5, 0.5,
'L',
3.5, 15.5,
'L', -4.5, 15.5,
'L', -4.5, 0.5,
'M', -1.5, 4,
'L', -1.5, 12,
'M',
0.5, 4,
'L',
0.5, 12
], inverted);
},
/**
* Render outline around the zoomed range
* @param {Number} zoomedMin in pixels position where zoomed range starts
* @param {Number} zoomedMax in pixels position where zoomed range ends
* @param {Boolean} inverted flag if chart is inverted
* @param {String} verb use 'animate' or 'attr'
*/
drawOutline: function(zoomedMin, zoomedMax, inverted, verb) {
var navigator = this,
maskInside = navigator.navigatorOptions.maskInside,
outlineWidth = navigator.outline.strokeWidth(),
halfOutline = outlineWidth / 2,
outlineCorrection = (outlineWidth % 2) / 2, // #5800
outlineHeight = navigator.outlineHeight,
scrollbarHeight = navigator.scrollbarHeight,
navigatorSize = navigator.size,
left = navigator.left - scrollbarHeight,
navigatorTop = navigator.top,
verticalMin,
path;
if (inverted) {
left -= halfOutline;
verticalMin = navigatorTop + zoomedMax + outlineCorrection;
zoomedMax = navigatorTop + zoomedMin + outlineCorrection;
path = [
'M',
left + outlineHeight,
navigatorTop - scrollbarHeight - outlineCorrection, // top edge
'L',
left + outlineHeight,
verticalMin, // top right of zoomed range
'L',
left,
verticalMin, // top left of z.r.
'L',
left,
zoomedMax, // bottom left of z.r.
'L',
left + outlineHeight,
zoomedMax, // bottom right of z.r.
'L',
left + outlineHeight,
navigatorTop + navigatorSize + scrollbarHeight // bottom edge
].concat(maskInside ? [
'M',
left + outlineHeight,
verticalMin - halfOutline, // upper left of zoomed range
'L',
left + outlineHeight,
zoomedMax + halfOutline // upper right of z.r.
] : []);
} else {
zoomedMin += left + scrollbarHeight - outlineCorrection;
zoomedMax += left + scrollbarHeight - outlineCorrection;
navigatorTop += halfOutline;
path = [
'M',
left,
navigatorTop, // left
'L',
zoomedMin,
navigatorTop, // upper left of zoomed range
'L',
zoomedMin,
navigatorTop + outlineHeight, // lower left of z.r.
'L',
zoomedMax,
navigatorTop + outlineHeight, // lower right of z.r.
'L',
zoomedMax,
navigatorTop, // upper right of z.r.
'L',
left + navigatorSize + scrollbarHeight * 2,
navigatorTop // right
].concat(maskInside ? [
'M',
zoomedMin - halfOutline,
navigatorTop, // upper left of zoomed range
'L',
zoomedMax + halfOutline,
navigatorTop // upper right of z.r.
] : []);
}
navigator.outline[verb]({
d: path
});
},
/**
* Render outline around the zoomed range
* @param {Number} zoomedMin in pixels position where zoomed range starts
* @param {Number} zoomedMax in pixels position where zoomed range ends
* @param {Boolean} inverted flag if chart is inverted
* @param {String} verb use 'animate' or 'attr'
*/
drawMasks: function(zoomedMin, zoomedMax, inverted, verb) {
var navigator = this,
left = navigator.left,
top = navigator.top,
navigatorHeight = navigator.height,
height,
width,
x,
y;
// Determine rectangle position & size
// According to (non)inverted position:
if (inverted) {
x = [left, left, left];
y = [top, top + zoomedMin, top + zoomedMax];
width = [navigatorHeight, navigatorHeight, navigatorHeight];
height = [
zoomedMin,
zoomedMax - zoomedMin,
navigator.size - zoomedMax
];
} else {
x = [left, left + zoomedMin, left + zoomedMax];
y = [top, top, top];
width = [
zoomedMin,
zoomedMax - zoomedMin,
navigator.size - zoomedMax
];
height = [navigatorHeight, navigatorHeight, navigatorHeight];
}
each(navigator.shades, function(shade, i) {
shade[verb]({
x: x[i],
y: y[i],
width: width[i],
height: height[i]
});
});
},
/**
* Generate DOM elements for a navigator:
* - main navigator group
* - all shades
* - outline
* - handles
*/
renderElements: function() {
var navigator = this,
navigatorOptions = navigator.navigatorOptions,
maskInside = navigatorOptions.maskInside,
chart = navigator.chart,
inverted = chart.inverted,
renderer = chart.renderer,
navigatorGroup;
// Create the main navigator group
navigator.navigatorGroup = navigatorGroup = renderer.g('navigator')
.attr({
zIndex: 8,
visibility: 'hidden'
})
.add();
var mouseCursor = {
cursor: inverted ? 'ns-resize' : 'ew-resize'
};
// Create masks, each mask will get events and fill:
each([!maskInside, maskInside, !maskInside], function(hasMask, index) {
navigator.shades[index] = renderer.rect()
.addClass('highcharts-navigator-mask' +
(index === 1 ? '-inside' : '-outside'))
.attr({
fill: hasMask ? navigatorOptions.maskFill : 'transparent'
})
.css(index === 1 && mouseCursor)
.add(navigatorGroup);
});
// Create the outline:
navigator.outline = renderer.path()
.addClass('highcharts-navigator-outline')
.attr({
'stroke-width': navigatorOptions.outlineWidth,
stroke: navigatorOptions.outlineColor
})
.add(navigatorGroup);
// Create the handlers:
each([0, 1], function(index) {
navigator.handles[index] = renderer
.path(navigator.getHandlePath(inverted))
// zIndex = 6 for right handle, 7 for left.
// Can't be 10, because of the tooltip in inverted chart #2908
.attr({
zIndex: 7 - index
})
.addClass(
'highcharts-navigator-handle highcharts-navigator-handle-' + ['left', 'right'][index]
).add(navigatorGroup);
var handlesOptions = navigatorOptions.handles;
navigator.handles[index]
.attr({
fill: handlesOptions.backgroundColor,
stroke: handlesOptions.borderColor,
'stroke-width': 1
})
.css(mouseCursor);
});
},
/**
* Update navigator
* @param {Object} options Options to merge in when updating navigator
*/
update: function(options) {
this.destroy();
var chartOptions = this.chart.options;
merge(true, chartOptions.navigator, this.options, options);
this.init(this.chart);
},
/**
* Render the navigator
* @param {Number} min X axis value minimum
* @param {Number} max X axis value maximum
* @param {Number} pxMin Pixel value minimum
* @param {Number} pxMax Pixel value maximum
*/
render: function(min, max, pxMin, pxMax) {
var navigator = this,
chart = navigator.chart,
navigatorWidth,
scrollbarLeft,
scrollbarTop,
scrollbarHeight = navigator.scrollbarHeight,
navigatorSize,
xAxis = navigator.xAxis,
navigatorEnabled = navigator.navigatorEnabled,
zoomedMin,
zoomedMax,
rendered = navigator.rendered,
inverted = chart.inverted,
verb,
newMin,
newMax,
minRange = chart.xAxis[0].minRange;
// Don't redraw while moving the handles (#4703).
if (this.hasDragged && !defined(pxMin)) {
return;
}
// Don't render the navigator until we have data (#486, #4202, #5172).
if (!isNumber(min) || !isNumber(max)) {
// However, if navigator was already rendered, we may need to resize
// it. For example hidden series, but visible navigator (#6022).
if (rendered) {
pxMin = 0;
pxMax = xAxis.width;
} else {
return;
}
}
navigator.left = pick(
xAxis.left,
// in case of scrollbar only, without navigator
chart.plotLeft + scrollbarHeight + (inverted ? chart.plotWidth : 0)
);
navigator.size = zoomedMax = navigatorSize = pick(
xAxis.len,
(inverted ? chart.plotHeight : chart.plotWidth) - 2 * scrollbarHeight
);
if (inverted) {
navigatorWidth = scrollbarHeight;
} else {
navigatorWidth = navigatorSize + 2 * scrollbarHeight;
}
// Get the pixel position of the handles
pxMin = pick(pxMin, xAxis.toPixels(min, true));
pxMax = pick(pxMax, xAxis.toPixels(max, true));
if (!isNumber(pxMin) || Math.abs(pxMin) === Infinity) { // Verify (#1851, #2238)
pxMin = 0;
pxMax = navigatorWidth;
}
// Are we below the minRange? (#2618, #6191)
newMin = xAxis.toValue(pxMin, true);
newMax = xAxis.toValue(pxMax, true);
if (Math.abs(newMax - newMin) < minRange) {
if (this.grabbedLeft) {
pxMin = xAxis.toPixels(newMax - minRange, true);
} else if (this.grabbedRight) {
pxMax = xAxis.toPixels(newMin + minRange, true);
} else {
return;
}
}
// Handles are allowed to cross, but never exceed the plot area
navigator.zoomedMax = Math.min(Math.max(pxMin, pxMax, 0), zoomedMax);
navigator.zoomedMin = Math.min(
Math.max(
navigator.fixedWidth ?
navigator.zoomedMax - navigator.fixedWidth :
Math.min(pxMin, pxMax),
0
),
zoomedMax
);
navigator.range = navigator.zoomedMax - navigator.zoomedMin;
zoomedMax = Math.round(navigator.zoomedMax);
zoomedMin = Math.round(navigator.zoomedMin);
if (navigatorEnabled) {
navigator.navigatorGroup.attr({
visibility: 'visible'
});
// Place elements
verb = rendered && !navigator.hasDragged ? 'animate' : 'attr';
navigator.drawMasks(zoomedMin, zoomedMax, inverted, verb);
navigator.drawOutline(zoomedMin, zoomedMax, inverted, verb);
navigator.drawHandle(zoomedMin, 0, inverted, verb);
navigator.drawHandle(zoomedMax, 1, inverted, verb);
}
if (navigator.scrollbar) {
if (inverted) {
scrollbarTop = navigator.top - scrollbarHeight;
scrollbarLeft = navigator.left - scrollbarHeight +
(navigatorEnabled ? 0 : navigator.height);
scrollbarHeight = navigatorSize + 2 * scrollbarHeight;
} else {
scrollbarTop = navigator.top +
(navigatorEnabled ? navigator.height : -scrollbarHeight);
scrollbarLeft = navigator.left - scrollbarHeight;
}
// Reposition scrollbar
navigator.scrollbar.position(
scrollbarLeft,
scrollbarTop,
navigatorWidth,
scrollbarHeight
);
// Keep scale 0-1
navigator.scrollbar.setRange(
// Use real value, not rounded because range can be very small (#1716)
navigator.zoomedMin / navigatorSize,
navigator.zoomedMax / navigatorSize
);
}
navigator.rendered = true;
},
/**
* Set up the mouse and touch events for the navigator
*/
addMouseEvents: function() {
var navigator = this,
chart = navigator.chart,
container = chart.container,
eventsToUnbind = [],
mouseMoveHandler,
mouseUpHandler;
/**
* Create mouse events' handlers.
* Make them as separate functions to enable wrapping them:
*/
navigator.mouseMoveHandler = mouseMoveHandler = function(e) {
navigator.onMouseMove(e);
};
navigator.mouseUpHandler = mouseUpHandler = function(e) {
navigator.onMouseUp(e);
};
// Add shades and handles mousedown events
eventsToUnbind = navigator.getPartsEvents('mousedown');
// Add mouse move and mouseup events. These are bind to doc/container,
// because Navigator.grabbedSomething flags are stored in mousedown events:
eventsToUnbind.push(
addEvent(container, 'mousemove', mouseMoveHandler),
addEvent(doc, 'mouseup', mouseUpHandler)
);
// Touch events
if (hasTouch) {
eventsToUnbind.push(
addEvent(container, 'touchmove', mouseMoveHandler),
addEvent(doc, 'touchend', mouseUpHandler)
);
eventsToUnbind.concat(navigator.getPartsEvents('touchstart'));
}
navigator.eventsToUnbind = eventsToUnbind;
// Data events
if (navigator.series && navigator.series[0]) {
eventsToUnbind.push(
addEvent(navigator.series[0].xAxis, 'foundExtremes', function() {
chart.navigator.modifyNavigatorAxisExtremes();
})
);
}
},
/**
* Generate events for handles and masks
* @param {String} eventName Event name handler, 'mousedown' or 'touchstart'
* @returns {Array} An array of arrays: [DOMElement, eventName, callback].
*/
getPartsEvents: function(eventName) {
var navigator = this,
events = [];
each(['shades', 'handles'], function(name) {
each(navigator[name], function(navigatorItem, index) {
events.push(
addEvent(
navigatorItem.element,
eventName,
function(e) {
navigator[name + 'Mousedown'](e, index);
}
)
);
});
});
return events;
},
/**
* Mousedown on a shaded mask, either:
* - will be stored for future drag&drop
* - will directly shift to a new range
*
* @param {Object} e Mouse event
* @param {Number} index Index of a mask in Navigator.shades array
*/
shadesMousedown: function(e, index) {
e = this.chart.pointer.normalize(e);
var navigator = this,
chart = navigator.chart,
xAxis = navigator.xAxis,
zoomedMin = navigator.zoomedMin,
navigatorPosition = navigator.left,
navigatorSize = navigator.size,
range = navigator.range,
chartX = e.chartX,
fixedMax,
ext,
left;
// For inverted chart, swap some options:
if (chart.inverted) {
chartX = e.chartY;
navigatorPosition = navigator.top;
}
if (index === 1) {
// Store information for drag&drop
navigator.grabbedCenter = chartX;
navigator.fixedWidth = range;
navigator.dragOffset = chartX - zoomedMin;
} else {
// Shift the range by clicking on shaded areas
left = chartX - navigatorPosition - range / 2;
if (index === 0) {
left = Math.max(0, left);
} else if (index === 2 && left + range >= navigatorSize) {
left = navigatorSize - range;
fixedMax = navigator.getUnionExtremes().dataMax; // #2293, #3543
}
if (left !== zoomedMin) { // it has actually moved
navigator.fixedWidth = range; // #1370
ext = xAxis.toFixedRange(left, left + range, null, fixedMax);
chart.xAxis[0].setExtremes(
Math.min(ext.min, ext.max),
Math.max(ext.min, ext.max),
true,
null, // auto animation
{
trigger: 'navigator'
}
);
}
}
},
/**
* Mousedown on a handle mask.
* Will store necessary information for drag&drop.
*
* @param {Object} e Mouse event
* @param {Number} index Index of a handle in Navigator.handles array
*/
handlesMousedown: function(e, index) {
e = this.chart.pointer.normalize(e);
var navigator = this,
chart = navigator.chart,
baseXAxis = chart.xAxis[0],
// For reversed axes, min and max are chagned,
// so the other extreme should be stored
reverse = (chart.inverted && !baseXAxis.reversed) ||
(!chart.inverted && baseXAxis.reversed);
if (index === 0) {
// Grab the left handle
navigator.grabbedLeft = true;
navigator.otherHandlePos = navigator.zoomedMax;
navigator.fixedExtreme = reverse ? baseXAxis.min : baseXAxis.max;
} else {
// Grab the right handle
navigator.grabbedRight = true;
navigator.otherHandlePos = navigator.zoomedMin;
navigator.fixedExtreme = reverse ? baseXAxis.max : baseXAxis.min;
}
chart.fixedRange = null;
},
/**
* Mouse move event based on x/y mouse position.
* @param {Object} e Mouse event
*/
onMouseMove: function(e) {
var navigator = this,
chart = navigator.chart,
left = navigator.left,
navigatorSize = navigator.navigatorSize,
range = navigator.range,
dragOffset = navigator.dragOffset,
inverted = chart.inverted,
chartX;
// In iOS, a mousemove event with e.pageX === 0 is fired when holding the finger
// down in the center of the scrollbar. This should be ignored.
if (!e.touches || e.touches[0].pageX !== 0) { // #4696, scrollbar failed on Android
e = chart.pointer.normalize(e);
chartX = e.chartX;
// Swap some options for inverted chart
if (inverted) {
left = navigator.top;
chartX = e.chartY;
}
// Drag left handle or top handle
if (navigator.grabbedLeft) {
navigator.hasDragged = true;
navigator.render(
0,
0,
chartX - left,
navigator.otherHandlePos
);
// Drag right handle or bottom handle
} else if (navigator.grabbedRight) {
navigator.hasDragged = true;
navigator.render(
0,
0,
navigator.otherHandlePos,
chartX - left
);
// Drag scrollbar or open area in navigator
} else if (navigator.grabbedCenter) {
navigator.hasDragged = true;
if (chartX < dragOffset) { // outside left
chartX = dragOffset;
} else if (chartX > navigatorSize + dragOffset - range) { // outside right
chartX = navigatorSize + dragOffset - range;
}
navigator.render(
0,
0,
chartX - dragOffset,
chartX - dragOffset + range
);
}
if (navigator.hasDragged && navigator.scrollbar && navigator.scrollbar.options.liveRedraw) {
e.DOMType = e.type; // DOMType is for IE8 because it can't read type async
setTimeout(function() {
navigator.onMouseUp(e);
}, 0);
}
}
},
/**
* Mouse up event based on x/y mouse position.
* @param {Object} e Mouse event
*/
onMouseUp: function(e) {
var navigator = this,
chart = navigator.chart,
xAxis = navigator.xAxis,
scrollbar = navigator.scrollbar,
fixedMin,
fixedMax,
ext,
DOMEvent = e.DOMEvent || e;
if (
// MouseUp is called for both, navigator and scrollbar (that order),
// which causes calling afterSetExtremes twice. Prevent first call
// by checking if scrollbar is going to set new extremes (#6334)
(navigator.hasDragged && (!scrollbar || !scrollbar.hasDragged)) ||
e.trigger === 'scrollbar'
) {
// When dragging one handle, make sure the other one doesn't change
if (navigator.zoomedMin === navigator.otherHandlePos) {
fixedMin = navigator.fixedExtreme;
} else if (navigator.zoomedMax === navigator.otherHandlePos) {
fixedMax = navigator.fixedExtreme;
}
// Snap to right edge (#4076)
if (navigator.zoomedMax === navigator.size) {
fixedMax = navigator.getUnionExtremes().dataMax;
}
ext = xAxis.toFixedRange(
navigator.zoomedMin,
navigator.zoomedMax,
fixedMin,
fixedMax
);
if (defined(ext.min)) {
chart.xAxis[0].setExtremes(
Math.min(ext.min, ext.max),
Math.max(ext.min, ext.max),
true,
navigator.hasDragged ? false : null, // Run animation when clicking buttons, scrollbar track etc, but not when dragging handles or scrollbar
{
trigger: 'navigator',
triggerOp: 'navigator-drag',
DOMEvent: DOMEvent // #1838
}
);
}
}
if (e.DOMType !== 'mousemove') {
navigator.grabbedLeft = navigator.grabbedRight =
navigator.grabbedCenter = navigator.fixedWidth =
navigator.fixedExtreme = navigator.otherHandlePos =
navigator.hasDragged = navigator.dragOffset = null;
}
},
/**
* Removes the event handlers attached previously with addEvents.
*/
removeEvents: function() {
if (this.eventsToUnbind) {
each(this.eventsToUnbind, function(unbind) {
unbind();
});
this.eventsToUnbind = undefined;
}
this.removeBaseSeriesEvents();
},
/**
* Remove data events.
*/
removeBaseSeriesEvents: function() {
var baseSeries = this.baseSeries || [];
if (this.navigatorEnabled && baseSeries[0] && this.navigatorOptions.adaptToUpdatedData !== false) {
each(baseSeries, function(series) {
removeEvent(series, 'updatedData', this.updatedDataHandler);
}, this);
// We only listen for extremes-events on the first baseSeries
if (baseSeries[0].xAxis) {
removeEvent(baseSeries[0].xAxis, 'foundExtremes', this.modifyBaseAxisExtremes);
}
}
},
/**
* Initiate the Navigator object
*/
init: function(chart) {
var chartOptions = chart.options,
navigatorOptions = chartOptions.navigator,
navigatorEnabled = navigatorOptions.enabled,
scrollbarOptions = chartOptions.scrollbar,
scrollbarEnabled = scrollbarOptions.enabled,
height = navigatorEnabled ? navigatorOptions.height : 0,
scrollbarHeight = scrollbarEnabled ? scrollbarOptions.height : 0;
this.handles = [];
this.shades = [];
this.chart = chart;
this.setBaseSeries();
this.height = height;
this.scrollbarHeight = scrollbarHeight;
this.scrollbarEnabled = scrollbarEnabled;
this.navigatorEnabled = navigatorEnabled;
this.navigatorOptions = navigatorOptions;
this.scrollbarOptions = scrollbarOptions;
this.outlineHeight = height + scrollbarHeight;
this.opposite = pick(navigatorOptions.opposite, !navigatorEnabled && chart.inverted); // #6262
var navigator = this,
baseSeries = navigator.baseSeries,
xAxisIndex = chart.xAxis.length,
yAxisIndex = chart.yAxis.length,
baseXaxis = baseSeries && baseSeries[0] && baseSeries[0].xAxis || chart.xAxis[0];
// Make room for the navigator, can be placed around the chart:
chart.extraMargin = {
type: navigator.opposite ? 'plotTop' : 'marginBottom',
value: (navigatorEnabled || !chart.inverted ? navigator.outlineHeight : 0) + navigatorOptions.margin
};
if (chart.inverted) {
chart.extraMargin.type = navigator.opposite ? 'marginRight' : 'plotLeft';
}
chart.isDirtyBox = true;
if (navigator.navigatorEnabled) {
// an x axis is required for scrollbar also
navigator.xAxis = new Axis(chart, merge({
// inherit base xAxis' break and ordinal options
breaks: baseXaxis.options.breaks,
ordinal: baseXaxis.options.ordinal
}, navigatorOptions.xAxis, {
id: 'navigator-x-axis',
yAxis: 'navigator-y-axis',
isX: true,
type: 'datetime',
index: xAxisIndex,
offset: 0,
keepOrdinalPadding: true, // #2436
startOnTick: false,
endOnTick: false,
minPadding: 0,
maxPadding: 0,
zoomEnabled: false
}, chart.inverted ? {
offsets: [scrollbarHeight, 0, -scrollbarHeight, 0],
width: height
} : {
offsets: [0, -scrollbarHeight, 0, scrollbarHeight],
height: height
}));
navigator.yAxis = new Axis(chart, merge(navigatorOptions.yAxis, {
id: 'navigator-y-axis',
alignTicks: false,
offset: 0,
index: yAxisIndex,
zoomEnabled: false
}, chart.inverted ? {
width: height
} : {
height: height
}));
// If we have a base series, initialize the navigator series
if (baseSeries || navigatorOptions.series.data) {
navigator.addBaseSeries();
// If not, set up an event to listen for added series
} else if (chart.series.length === 0) {
wrap(chart, 'redraw', function(proceed, animation) {
// We've got one, now add it as base and reset chart.redraw
if (chart.series.length > 0 && !navigator.series) {
navigator.setBaseSeries();
chart.redraw = proceed; // reset
}
proceed.call(chart, animation);
});
}
// Render items, so we can bind events to them:
navigator.renderElements();
// Add mouse events
navigator.addMouseEvents();
// in case of scrollbar only, fake an x axis to get translation
} else {
navigator.xAxis = {
translate: function(value, reverse) {
var axis = chart.xAxis[0],
ext = axis.getExtremes(),
scrollTrackWidth = axis.len - 2 * scrollbarHeight,
min = numExt('min', axis.options.min, ext.dataMin),
valueRange = numExt('max', axis.options.max, ext.dataMax) - min;
return reverse ?
// from pixel to value
(value * valueRange / scrollTrackWidth) + min :
// from value to pixel
scrollTrackWidth * (value - min) / valueRange;
},
toPixels: function(value) {
return this.translate(value);
},
toValue: function(value) {
return this.translate(value, true);
},
toFixedRange: Axis.prototype.toFixedRange,
fake: true
};
}
// Initialize the scrollbar
if (chart.options.scrollbar.enabled) {
chart.scrollbar = navigator.scrollbar = new Scrollbar(
chart.renderer,
merge(chart.options.scrollbar, {
margin: navigator.navigatorEnabled ? 0 : 10,
vertical: chart.inverted
}),
chart
);
addEvent(navigator.scrollbar, 'changed', function(e) {
var range = navigator.size,
to = range * this.to,
from = range * this.from;
navigator.hasDragged = navigator.scrollbar.hasDragged;
navigator.render(0, 0, from, to);
if (chart.options.scrollbar.liveRedraw || e.DOMType !== 'mousemove') {
setTimeout(function() {
navigator.onMouseUp(e);
});
}
});
}
// Add data events
navigator.addBaseSeriesEvents();
// Add redraw events
navigator.addChartEvents();
},
/**
* Get the union data extremes of the chart - the outer data extremes of the base
* X axis and the navigator axis.
* @param {boolean} returnFalseOnNoBaseSeries - as the param says.
*/
getUnionExtremes: function(returnFalseOnNoBaseSeries) {
var baseAxis = this.chart.xAxis[0],
navAxis = this.xAxis,
navAxisOptions = navAxis.options,
baseAxisOptions = baseAxis.options,
ret;
if (!returnFalseOnNoBaseSeries || baseAxis.dataMin !== null) {
ret = {
dataMin: pick( // #4053
navAxisOptions && navAxisOptions.min,
numExt(
'min',
baseAxisOptions.min,
baseAxis.dataMin,
navAxis.dataMin,
navAxis.min
)
),
dataMax: pick(
navAxisOptions && navAxisOptions.max,
numExt(
'max',
baseAxisOptions.max,
baseAxis.dataMax,
navAxis.dataMax,
navAxis.max
)
)
};
}
return ret;
},
/**
* Set the base series. With a bit of modification we should be able to make
* this an API method to be called from the outside
* @param {Object} baseSeriesOptions - series options for a navigator
*/
setBaseSeries: function(baseSeriesOptions) {
var chart = this.chart,
baseSeries;
baseSeriesOptions = baseSeriesOptions || chart.options && chart.options.navigator.baseSeries || 0;
// If we're resetting, remove the existing series
if (this.series) {
this.removeBaseSeriesEvents();
each(this.series, function(s) {
s.destroy();
});
}
baseSeries = this.baseSeries = [];
// Iterate through series and add the ones that should be shown in navigator
each(chart.series || [], function(series, i) {
if (series.options.showInNavigator || (i === baseSeriesOptions || series.options.id === baseSeriesOptions) &&
series.options.showInNavigator !== false) {
baseSeries.push(series);
}
});
// When run after render, this.xAxis already exists
if (this.xAxis && !this.xAxis.fake) {
this.addBaseSeries();
}
},
/*
* Add base series to the navigator.
*/
addBaseSeries: function() {
var navigator = this,
chart = navigator.chart,
navigatorSeries = navigator.series = [],
baseSeries = navigator.baseSeries,
baseOptions,
mergedNavSeriesOptions,
chartNavigatorOptions = navigator.navigatorOptions.series,
baseNavigatorOptions,
navSeriesMixin = {
enableMouseTracking: false,
index: null, // #6162
group: 'nav', // for columns
padXAxis: false,
xAxis: 'navigator-x-axis',
yAxis: 'navigator-y-axis',
showInLegend: false,
stacking: false, // #4823
isInternal: true,
visible: true
};
// Go through each base series and merge the options to create new series
if (baseSeries) {
each(baseSeries, function(base, i) {
navSeriesMixin.name = 'Navigator ' + (i + 1);
baseOptions = base.options || {};
baseNavigatorOptions = baseOptions.navigatorOptions || {};
mergedNavSeriesOptions = merge(baseOptions, navSeriesMixin, chartNavigatorOptions, baseNavigatorOptions);
// Merge data separately. Do a slice to avoid mutating the navigator options from base series (#4923).
var navigatorSeriesData = baseNavigatorOptions.data || chartNavigatorOptions.data;
navigator.hasNavigatorData = navigator.hasNavigatorData || !!navigatorSeriesData;
mergedNavSeriesOptions.data = navigatorSeriesData || baseOptions.data && baseOptions.data.slice(0);
// Add the series
base.navigatorSeries = chart.initSeries(mergedNavSeriesOptions);
navigatorSeries.push(base.navigatorSeries);
});
} else {
// No base series, build from mixin and chart wide options
mergedNavSeriesOptions = merge(chartNavigatorOptions, navSeriesMixin);
mergedNavSeriesOptions.data = chartNavigatorOptions.data;
navigator.hasNavigatorData = !!mergedNavSeriesOptions.data;
navigatorSeries.push(chart.initSeries(mergedNavSeriesOptions));
}
this.addBaseSeriesEvents();
},
/**
* Add data events.
* For example when main series is updated we need to recalculate extremes
*/
addBaseSeriesEvents: function() {
var navigator = this,
baseSeries = navigator.baseSeries || [];
// Bind modified extremes event to first base's xAxis only. In event of > 1 base-xAxes, the navigator will ignore those.
if (baseSeries[0] && baseSeries[0].xAxis) {
addEvent(baseSeries[0].xAxis, 'foundExtremes', this.modifyBaseAxisExtremes);
}
if (this.navigatorOptions.adaptToUpdatedData !== false) {
// Respond to updated data in the base series.
// Abort if lazy-loading data from the server.
each(baseSeries, function(base) {
if (base.xAxis) {
addEvent(base, 'updatedData', this.updatedDataHandler);
}
// Handle series removal
addEvent(base, 'remove', function() {
if (this.navigatorSeries) {
erase(navigator.series, this.navigatorSeries);
this.navigatorSeries.remove(false);
delete this.navigatorSeries;
}
});
}, this);
}
},
/**
* Set the navigator x axis extremes to reflect the total. The navigator extremes
* should always be the extremes of the union of all series in the chart as
* well as the navigator series.
*/
modifyNavigatorAxisExtremes: function() {
var xAxis = this.xAxis,
unionExtremes;
if (xAxis.getExtremes) {
unionExtremes = this.getUnionExtremes(true);
if (unionExtremes && (unionExtremes.dataMin !== xAxis.min || unionExtremes.dataMax !== xAxis.max)) {
xAxis.min = unionExtremes.dataMin;
xAxis.max = unionExtremes.dataMax;
}
}
},
/**
* Hook to modify the base axis extremes with information from the Navigator
*/
modifyBaseAxisExtremes: function() {
var baseXAxis = this,
navigator = baseXAxis.chart.navigator,
baseExtremes = baseXAxis.getExtremes(),
baseMin = baseExtremes.min,
baseMax = baseExtremes.max,
baseDataMin = baseExtremes.dataMin,
baseDataMax = baseExtremes.dataMax,
range = baseMax - baseMin,
stickToMin = navigator.stickToMin,
stickToMax = navigator.stickToMax,
newMax,
newMin,
navigatorSeries = navigator.series && navigator.series[0],
hasSetExtremes = !!baseXAxis.setExtremes,
// When the extremes have been set by range selector button, don't stick to min or max.
// The range selector buttons will handle the extremes. (#5489)
unmutable = baseXAxis.eventArgs && baseXAxis.eventArgs.trigger === 'rangeSelectorButton';
if (!unmutable) {
// If the zoomed range is already at the min, move it to the right as new data
// comes in
if (stickToMin) {
newMin = baseDataMin;
newMax = newMin + range;
}
// If the zoomed range is already at the max, move it to the right as new data
// comes in
if (stickToMax) {
newMax = baseDataMax;
if (!stickToMin) { // if stickToMin is true, the new min value is set above
newMin = Math.max(
newMax - range,
navigatorSeries && navigatorSeries.xData ?
navigatorSeries.xData[0] : -Number.MAX_VALUE
);
}
}
// Update the extremes
if (hasSetExtremes && (stickToMin || stickToMax)) {
if (isNumber(newMin)) {
baseXAxis.min = baseXAxis.userMin = newMin;
baseXAxis.max = baseXAxis.userMax = newMax;
}
}
}
// Reset
navigator.stickToMin = navigator.stickToMax = null;
},
/**
* Handler for updated data on the base series. When data is modified, the navigator series
* must reflect it. This is called from the Chart.redraw function before axis and series
* extremes are computed.
*/
updatedDataHandler: function() {
var navigator = this.chart.navigator,
baseSeries = this,
navigatorSeries = this.navigatorSeries;
// Detect whether the zoomed area should stick to the minimum or maximum. If the current
// axis minimum falls outside the new updated dataset, we must adjust.
navigator.stickToMin = isNumber(baseSeries.xAxis.min) && (baseSeries.xAxis.min <= baseSeries.xData[0]);
// If the scrollbar is scrolled all the way to the right, keep right as new data
// comes in.
navigator.stickToMax = Math.round(navigator.zoomedMax) >= Math.round(navigator.size);
// Set the navigator series data to the new data of the base series
if (navigatorSeries && !navigator.hasNavigatorData) {
navigatorSeries.options.pointStart = baseSeries.xData[0];
navigatorSeries.setData(baseSeries.options.data, false, null, false); // #5414
}
},
/**
* Add chart events, like redrawing navigator, when chart requires that.
*/
addChartEvents: function() {
addEvent(this.chart, 'redraw', function() {
// Move the scrollbar after redraw, like after data updata even if axes don't redraw
var navigator = this.navigator,
xAxis = navigator && (
navigator.baseSeries &&
navigator.baseSeries[0] &&
navigator.baseSeries[0].xAxis ||
navigator.scrollbar && this.xAxis[0]
); // #5709
if (xAxis) {
navigator.render(xAxis.min, xAxis.max);
}
});
},
/**
* Destroys allocated elements.
*/
destroy: function() {
// Disconnect events added in addEvents
this.removeEvents();
if (this.xAxis) {
erase(this.chart.xAxis, this.xAxis);
erase(this.chart.axes, this.xAxis);
}
if (this.yAxis) {
erase(this.chart.yAxis, this.yAxis);
erase(this.chart.axes, this.yAxis);
}
// Destroy series
each(this.series || [], function(s) {
if (s.destroy) {
s.destroy();
}
});
// Destroy properties
each([
'series', 'xAxis', 'yAxis', 'shades', 'outline', 'scrollbarTrack',
'scrollbarRifles', 'scrollbarGroup', 'scrollbar', 'navigatorGroup',
'rendered'
], function(prop) {
if (this[prop] && this[prop].destroy) {
this[prop].destroy();
}
this[prop] = null;
}, this);
// Destroy elements in collection
each([this.handles], function(coll) {
destroyObjectProperties(coll);
}, this);
}
};
H.Navigator = Navigator;
/**
* For Stock charts, override selection zooming with some special features because
* X axis zooming is already allowed by the Navigator and Range selector.
*/
wrap(Axis.prototype, 'zoom', function(proceed, newMin, newMax) {
var chart = this.chart,
chartOptions = chart.options,
zoomType = chartOptions.chart.zoomType,
previousZoom,
navigator = chartOptions.navigator,
rangeSelector = chartOptions.rangeSelector,
ret;
if (this.isXAxis && ((navigator && navigator.enabled) ||
(rangeSelector && rangeSelector.enabled))) {
// For x only zooming, fool the chart.zoom method not to create the zoom button
// because the property already exists
if (zoomType === 'x') {
chart.resetZoomButton = 'blocked';
// For y only zooming, ignore the X axis completely
} else if (zoomType === 'y') {
ret = false;
// For xy zooming, record the state of the zoom before zoom selection, then when
// the reset button is pressed, revert to this state
} else if (zoomType === 'xy') {
previousZoom = this.previousZoom;
if (defined(newMin)) {
this.previousZoom = [this.min, this.max];
} else if (previousZoom) {
newMin = previousZoom[0];
newMax = previousZoom[1];
delete this.previousZoom;
}
}
}
return ret !== undefined ? ret : proceed.call(this, newMin, newMax);
});
// Initialize navigator for stock charts
wrap(Chart.prototype, 'init', function(proceed, options, callback) {
addEvent(this, 'beforeRender', function() {
var options = this.options;
if (options.navigator.enabled || options.scrollbar.enabled) {
this.scroller = this.navigator = new Navigator(this);
}
});
proceed.call(this, options, callback);
});
/**
* For stock charts, extend the Chart.setChartSize method so that we can set the final top position
* of the navigator once the height of the chart, including the legend, is determined. #367.
* We can't use Chart.getMargins, because labels offsets are not calculated yet.
*/
wrap(Chart.prototype, 'setChartSize', function(proceed) {
var legend = this.legend,
navigator = this.navigator,
scrollbarHeight,
legendOptions,
xAxis,
yAxis;
proceed.apply(this, [].slice.call(arguments, 1));
if (navigator) {
legendOptions = legend.options;
xAxis = navigator.xAxis;
yAxis = navigator.yAxis;
scrollbarHeight = navigator.scrollbarHeight;
// Compute the top position
if (this.inverted) {
navigator.left = navigator.opposite ?
this.chartWidth - scrollbarHeight - navigator.height :
this.spacing[3] + scrollbarHeight;
navigator.top = this.plotTop + scrollbarHeight;
} else {
navigator.left = this.plotLeft + scrollbarHeight;
navigator.top = navigator.navigatorOptions.top ||
this.chartHeight - navigator.height - scrollbarHeight - this.spacing[2] -
(legendOptions.verticalAlign === 'bottom' && legendOptions.enabled && !legendOptions.floating ?
legend.legendHeight + pick(legendOptions.margin, 10) : 0);
}
if (xAxis && yAxis) { // false if navigator is disabled (#904)
if (this.inverted) {
xAxis.options.left = yAxis.options.left = navigator.left;
} else {
xAxis.options.top = yAxis.options.top = navigator.top;
}
xAxis.setAxisSize();
yAxis.setAxisSize();
}
}
});
// Pick up badly formatted point options to addPoint
wrap(Series.prototype, 'addPoint', function(proceed, options, redraw, shift, animation) {
var turboThreshold = this.options.turboThreshold;
if (turboThreshold && this.xData.length > turboThreshold && isObject(options, true) && this.chart.navigator) {
error(20, true);
}
proceed.call(this, options, redraw, shift, animation);
});
// Handle adding new series
wrap(Chart.prototype, 'addSeries', function(proceed, options, redraw, animation) {
var series = proceed.call(this, options, false, animation);
if (this.navigator) {
this.navigator.setBaseSeries(); // Recompute which series should be shown in navigator, and add them
}
if (pick(redraw, true)) {
this.redraw();
}
return series;
});
// Handle updating series
wrap(Series.prototype, 'update', function(proceed, newOptions, redraw) {
proceed.call(this, newOptions, false);
if (this.chart.navigator) {
this.chart.navigator.setBaseSeries();
}
if (pick(redraw, true)) {
this.chart.redraw();
}
});
Chart.prototype.callbacks.push(function(chart) {
var extremes,
navigator = chart.navigator;
// Initiate the navigator
if (navigator) {
extremes = chart.xAxis[0].getExtremes();
navigator.render(extremes.min, extremes.max);
}
});
/* ****************************************************************************
* End Navigator code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
Axis = H.Axis,
Chart = H.Chart,
css = H.css,
createElement = H.createElement,
dateFormat = H.dateFormat,
defaultOptions = H.defaultOptions,
useUTC = defaultOptions.global.useUTC,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
discardElement = H.discardElement,
each = H.each,
extend = H.extend,
fireEvent = H.fireEvent,
HCDate = H.Date,
isNumber = H.isNumber,
merge = H.merge,
pick = H.pick,
pInt = H.pInt,
splat = H.splat,
wrap = H.wrap;
/* ****************************************************************************
* Start Range Selector code *
*****************************************************************************/
extend(defaultOptions, {
rangeSelector: {
// allButtonsEnabled: false,
// enabled: true,
// buttons: {Object}
// buttonSpacing: 0,
buttonTheme: {
'stroke-width': 0,
width: 28,
height: 18,
padding: 2,
zIndex: 7 // #484, #852
},
height: 35, // reserved space for buttons and input
inputPosition: {
align: 'right'
},
// inputDateFormat: '%b %e, %Y',
// inputEditDateFormat: '%Y-%m-%d',
// inputEnabled: true,
// selected: undefined,
// inputStyle: {},
labelStyle: {
color: '#666666'
}
}
});
defaultOptions.lang = merge(defaultOptions.lang, {
rangeSelectorZoom: 'Zoom',
rangeSelectorFrom: 'From',
rangeSelectorTo: 'To'
});
/**
* The range selector.
* @class
* @param {Object} chart
*/
function RangeSelector(chart) {
// Run RangeSelector
this.init(chart);
}
RangeSelector.prototype = {
/**
* The method to run when one of the buttons in the range selectors is clicked
* @param {Number} i The index of the button
* @param {Object} rangeOptions
* @param {Boolean} redraw
*/
clickButton: function(i, redraw) {
var rangeSelector = this,
chart = rangeSelector.chart,
rangeOptions = rangeSelector.buttonOptions[i],
baseAxis = chart.xAxis[0],
unionExtremes = (chart.scroller && chart.scroller.getUnionExtremes()) || baseAxis || {},
dataMin = unionExtremes.dataMin,
dataMax = unionExtremes.dataMax,
newMin,
newMax = baseAxis && Math.round(Math.min(baseAxis.max, pick(dataMax, baseAxis.max))), // #1568
type = rangeOptions.type,
baseXAxisOptions,
range = rangeOptions._range,
rangeMin,
minSetting,
rangeSetting,
ctx,
ytdExtremes,
dataGrouping = rangeOptions.dataGrouping;
if (dataMin === null || dataMax === null) { // chart has no data, base series is removed
return;
}
// Set the fixed range before range is altered
chart.fixedRange = range;
// Apply dataGrouping associated to button
if (dataGrouping) {
this.forcedDataGrouping = true;
Axis.prototype.setDataGrouping.call(baseAxis || {
chart: this.chart
}, dataGrouping, false);
}
// Apply range
if (type === 'month' || type === 'year') {
if (!baseAxis) {
// This is set to the user options and picked up later when the axis is instantiated
// so that we know the min and max.
range = rangeOptions;
} else {
ctx = {
range: rangeOptions,
max: newMax,
dataMin: dataMin,
dataMax: dataMax
};
newMin = baseAxis.minFromRange.call(ctx);
if (isNumber(ctx.newMax)) {
newMax = ctx.newMax;
}
}
// Fixed times like minutes, hours, days
} else if (range) {
newMin = Math.max(newMax - range, dataMin);
newMax = Math.min(newMin + range, dataMax);
} else if (type === 'ytd') {
// On user clicks on the buttons, or a delayed action running from the beforeRender
// event (below), the baseAxis is defined.
if (baseAxis) {
// When "ytd" is the pre-selected button for the initial view, its calculation
// is delayed and rerun in the beforeRender event (below). When the series
// are initialized, but before the chart is rendered, we have access to the xData
// array (#942).
if (dataMax === undefined) {
dataMin = Number.MAX_VALUE;
dataMax = Number.MIN_VALUE;
each(chart.series, function(series) {
var xData = series.xData; // reassign it to the last item
dataMin = Math.min(xData[0], dataMin);
dataMax = Math.max(xData[xData.length - 1], dataMax);
});
redraw = false;
}
ytdExtremes = rangeSelector.getYTDExtremes(dataMax, dataMin, useUTC);
newMin = rangeMin = ytdExtremes.min;
newMax = ytdExtremes.max;
// "ytd" is pre-selected. We don't yet have access to processed point and extremes data
// (things like pointStart and pointInterval are missing), so we delay the process (#942)
} else {
addEvent(chart, 'beforeRender', function() {
rangeSelector.clickButton(i);
});
return;
}
} else if (type === 'all' && baseAxis) {
newMin = dataMin;
newMax = dataMax;
}
rangeSelector.setSelected(i);
// Update the chart
if (!baseAxis) {
// Axis not yet instanciated. Temporarily set min and range
// options and remove them on chart load (#4317).
baseXAxisOptions = splat(chart.options.xAxis)[0];
rangeSetting = baseXAxisOptions.range;
baseXAxisOptions.range = range;
minSetting = baseXAxisOptions.min;
baseXAxisOptions.min = rangeMin;
addEvent(chart, 'load', function resetMinAndRange() {
baseXAxisOptions.range = rangeSetting;
baseXAxisOptions.min = minSetting;
});
} else {
// Existing axis object. Set extremes after render time.
baseAxis.setExtremes(
newMin,
newMax,
pick(redraw, 1),
null, // auto animation
{
trigger: 'rangeSelectorButton',
rangeSelectorButton: rangeOptions
}
);
}
},
/**
* Set the selected option. This method only sets the internal flag, it doesn't
* update the buttons or the actual zoomed range.
*/
setSelected: function(selected) {
this.selected = this.options.selected = selected;
},
/**
* The default buttons for pre-selecting time frames
*/
defaultButtons: [{
type: 'month',
count: 1,
text: '1m'
}, {
type: 'month',
count: 3,
text: '3m'
}, {
type: 'month',
count: 6,
text: '6m'
}, {
type: 'ytd',
text: 'YTD'
}, {
type: 'year',
count: 1,
text: '1y'
}, {
type: 'all',
text: 'All'
}],
/**
* Initialize the range selector
*/
init: function(chart) {
var rangeSelector = this,
options = chart.options.rangeSelector,
buttonOptions = options.buttons || [].concat(rangeSelector.defaultButtons),
selectedOption = options.selected,
blurInputs = function() {
var minInput = rangeSelector.minInput,
maxInput = rangeSelector.maxInput;
if (minInput && minInput.blur) { //#3274 in some case blur is not defined
fireEvent(minInput, 'blur'); //#3274
}
if (maxInput && maxInput.blur) { //#3274 in some case blur is not defined
fireEvent(maxInput, 'blur'); //#3274
}
};
rangeSelector.chart = chart;
rangeSelector.options = options;
rangeSelector.buttons = [];
chart.extraTopMargin = options.height;
rangeSelector.buttonOptions = buttonOptions;
this.unMouseDown = addEvent(chart.container, 'mousedown', blurInputs);
this.unResize = addEvent(chart, 'resize', blurInputs);
// Extend the buttonOptions with actual range
each(buttonOptions, rangeSelector.computeButtonRange);
// zoomed range based on a pre-selected button index
if (selectedOption !== undefined && buttonOptions[selectedOption]) {
this.clickButton(selectedOption, false);
}
addEvent(chart, 'load', function() {
// If a data grouping is applied to the current button, release it when extremes change
addEvent(chart.xAxis[0], 'setExtremes', function(e) {
if (this.max - this.min !== chart.fixedRange && e.trigger !== 'rangeSelectorButton' &&
e.trigger !== 'updatedData' && rangeSelector.forcedDataGrouping) {
this.setDataGrouping(false, false);
}
});
});
},
/**
* Dynamically update the range selector buttons after a new range has been set
*/
updateButtonStates: function() {
var rangeSelector = this,
chart = this.chart,
baseAxis = chart.xAxis[0],
actualRange = Math.round(baseAxis.max - baseAxis.min),
hasNoData = !baseAxis.hasVisibleSeries,
day = 24 * 36e5, // A single day in milliseconds
unionExtremes = (chart.scroller && chart.scroller.getUnionExtremes()) || baseAxis,
dataMin = unionExtremes.dataMin,
dataMax = unionExtremes.dataMax,
ytdExtremes = rangeSelector.getYTDExtremes(dataMax, dataMin, useUTC),
ytdMin = ytdExtremes.min,
ytdMax = ytdExtremes.max,
selected = rangeSelector.selected,
selectedExists = isNumber(selected),
allButtonsEnabled = rangeSelector.options.allButtonsEnabled,
buttons = rangeSelector.buttons;
each(rangeSelector.buttonOptions, function(rangeOptions, i) {
var range = rangeOptions._range,
type = rangeOptions.type,
count = rangeOptions.count || 1,
button = buttons[i],
state = 0,
disable,
select,
isSelected = i === selected,
// Disable buttons where the range exceeds what is allowed in the current view
isTooGreatRange = range > dataMax - dataMin,
// Disable buttons where the range is smaller than the minimum range
isTooSmallRange = range < baseAxis.minRange,
// Do not select the YTD button if not explicitly told so
isYTDButNotSelected = false,
// Disable the All button if we're already showing all
isAllButAlreadyShowingAll = false,
isSameRange = range === actualRange;
// Months and years have a variable range so we check the extremes
if (
(type === 'month' || type === 'year') &&
(actualRange >= {
month: 28,
year: 365
}[type] * day * count) &&
(actualRange <= {
month: 31,
year: 366
}[type] * day * count)
) {
isSameRange = true;
} else if (type === 'ytd') {
isSameRange = (ytdMax - ytdMin) === actualRange;
isYTDButNotSelected = !isSelected;
} else if (type === 'all') {
isSameRange = baseAxis.max - baseAxis.min >= dataMax - dataMin;
isAllButAlreadyShowingAll = !isSelected && selectedExists && isSameRange;
}
// The new zoom area happens to match the range for a button - mark it selected.
// This happens when scrolling across an ordinal gap. It can be seen in the intraday
// demos when selecting 1h and scroll across the night gap.
disable = (!allButtonsEnabled &&
(
isTooGreatRange ||
isTooSmallRange ||
isAllButAlreadyShowingAll ||
hasNoData
)
);
select = (
(isSelected && isSameRange) ||
(isSameRange && !selectedExists && !isYTDButNotSelected)
);
if (disable) {
state = 3;
} else if (select) {
selectedExists = true; // Only one button can be selected
state = 2;
}
// If state has changed, update the button
if (button.state !== state) {
button.setState(state);
}
});
},
/**
* Compute and cache the range for an individual button
*/
computeButtonRange: function(rangeOptions) {
var type = rangeOptions.type,
count = rangeOptions.count || 1,
// these time intervals have a fixed number of milliseconds, as opposed
// to month, ytd and year
fixedTimes = {
millisecond: 1,
second: 1000,
minute: 60 * 1000,
hour: 3600 * 1000,
day: 24 * 3600 * 1000,
week: 7 * 24 * 3600 * 1000
};
// Store the range on the button object
if (fixedTimes[type]) {
rangeOptions._range = fixedTimes[type] * count;
} else if (type === 'month' || type === 'year') {
rangeOptions._range = {
month: 30,
year: 365
}[type] * 24 * 36e5 * count;
}
},
/**
* Set the internal and displayed value of a HTML input for the dates
* @param {String} name
* @param {Number} time
*/
setInputValue: function(name, time) {
var options = this.chart.options.rangeSelector,
input = this[name + 'Input'];
if (defined(time)) {
input.previousValue = input.HCTime;
input.HCTime = time;
}
input.value = dateFormat(
options.inputEditDateFormat || '%Y-%m-%d',
input.HCTime
);
this[name + 'DateBox'].attr({
text: dateFormat(options.inputDateFormat || '%b %e, %Y', input.HCTime)
});
},
showInput: function(name) {
var inputGroup = this.inputGroup,
dateBox = this[name + 'DateBox'];
css(this[name + 'Input'], {
left: (inputGroup.translateX + dateBox.x) + 'px',
top: inputGroup.translateY + 'px',
width: (dateBox.width - 2) + 'px',
height: (dateBox.height - 2) + 'px',
border: '2px solid silver'
});
},
hideInput: function(name) {
css(this[name + 'Input'], {
border: 0,
width: '1px',
height: '1px'
});
this.setInputValue(name);
},
/**
* Draw either the 'from' or the 'to' HTML input box of the range selector
* @param {Object} name
*/
drawInput: function(name) {
var rangeSelector = this,
chart = rangeSelector.chart,
chartStyle = chart.renderer.style || {},
renderer = chart.renderer,
options = chart.options.rangeSelector,
lang = defaultOptions.lang,
div = rangeSelector.div,
isMin = name === 'min',
input,
label,
dateBox,
inputGroup = this.inputGroup;
function updateExtremes() {
var inputValue = input.value,
value = (options.inputDateParser || Date.parse)(inputValue),
chartAxis = chart.xAxis[0],
dataAxis = chart.scroller && chart.scroller.xAxis ? chart.scroller.xAxis : chartAxis,
dataMin = dataAxis.dataMin,
dataMax = dataAxis.dataMax;
if (value !== input.previousValue) {
input.previousValue = value;
// If the value isn't parsed directly to a value by the browser's Date.parse method,
// like YYYY-MM-DD in IE, try parsing it a different way
if (!isNumber(value)) {
value = inputValue.split('-');
value = Date.UTC(pInt(value[0]), pInt(value[1]) - 1, pInt(value[2]));
}
if (isNumber(value)) {
// Correct for timezone offset (#433)
if (!useUTC) {
value = value + new Date().getTimezoneOffset() * 60 * 1000;
}
// Validate the extremes. If it goes beyound the data min or max, use the
// actual data extreme (#2438).
if (isMin) {
if (value > rangeSelector.maxInput.HCTime) {
value = undefined;
} else if (value < dataMin) {
value = dataMin;
}
} else {
if (value < rangeSelector.minInput.HCTime) {
value = undefined;
} else if (value > dataMax) {
value = dataMax;
}
}
// Set the extremes
if (value !== undefined) {
chartAxis.setExtremes(
isMin ? value : chartAxis.min,
isMin ? chartAxis.max : value,
undefined,
undefined, {
trigger: 'rangeSelectorInput'
}
);
}
}
}
}
// Create the text label
this[name + 'Label'] = label = renderer.label(lang[isMin ? 'rangeSelectorFrom' : 'rangeSelectorTo'], this.inputGroup.offset)
.addClass('highcharts-range-label')
.attr({
padding: 2
})
.add(inputGroup);
inputGroup.offset += label.width + 5;
// Create an SVG label that shows updated date ranges and and records click events that
// bring in the HTML input.
this[name + 'DateBox'] = dateBox = renderer.label('', inputGroup.offset)
.addClass('highcharts-range-input')
.attr({
padding: 2,
width: options.inputBoxWidth || 90,
height: options.inputBoxHeight || 17,
stroke: options.inputBoxBorderColor || '#cccccc',
'stroke-width': 1,
'text-align': 'center'
})
.on('click', function() {
rangeSelector.showInput(name); // If it is already focused, the onfocus event doesn't fire (#3713)
rangeSelector[name + 'Input'].focus();
})
.add(inputGroup);
inputGroup.offset += dateBox.width + (isMin ? 10 : 0);
// Create the HTML input element. This is rendered as 1x1 pixel then set to the right size
// when focused.
this[name + 'Input'] = input = createElement('input', {
name: name,
className: 'highcharts-range-selector',
type: 'text'
}, {
top: chart.plotTop + 'px' // prevent jump on focus in Firefox
}, div);
// Styles
label.css(merge(chartStyle, options.labelStyle));
dateBox.css(merge({
color: '#333333'
}, chartStyle, options.inputStyle));
css(input, extend({
position: 'absolute',
border: 0,
width: '1px', // Chrome needs a pixel to see it
height: '1px',
padding: 0,
textAlign: 'center',
fontSize: chartStyle.fontSize,
fontFamily: chartStyle.fontFamily,
left: '-9em' // #4798
}, options.inputStyle));
// Blow up the input box
input.onfocus = function() {
rangeSelector.showInput(name);
};
// Hide away the input box
input.onblur = function() {
rangeSelector.hideInput(name);
};
// handle changes in the input boxes
input.onchange = updateExtremes;
input.onkeypress = function(event) {
// IE does not fire onchange on enter
if (event.keyCode === 13) {
updateExtremes();
}
};
},
/**
* Get the position of the range selector buttons and inputs. This can be overridden from outside for custom positioning.
*/
getPosition: function() {
var chart = this.chart,
options = chart.options.rangeSelector,
buttonTop = pick((options.buttonPosition || {}).y, chart.plotTop - chart.axisOffset[0] - options.height);
return {
buttonTop: buttonTop,
inputTop: buttonTop - 10
};
},
/**
* Get the extremes of YTD.
* Will choose dataMax if its value is lower than the current timestamp.
* Will choose dataMin if its value is higher than the timestamp for
* the start of current year.
* @param {number} dataMax
* @param {number} dataMin
* @return {object} Returns min and max for the YTD
*/
getYTDExtremes: function(dataMax, dataMin, useUTC) {
var min,
now = new HCDate(dataMax),
year = now[HCDate.hcGetFullYear](),
startOfYear = useUTC ? HCDate.UTC(year, 0, 1) : +new HCDate(year, 0, 1); // eslint-disable-line new-cap
min = Math.max(dataMin || 0, startOfYear);
now = now.getTime();
return {
max: Math.min(dataMax || now, now),
min: min
};
},
/**
* Render the range selector including the buttons and the inputs. The first time render
* is called, the elements are created and positioned. On subsequent calls, they are
* moved and updated.
* @param {Number} min X axis minimum
* @param {Number} max X axis maximum
*/
render: function(min, max) {
var rangeSelector = this,
chart = rangeSelector.chart,
renderer = chart.renderer,
container = chart.container,
chartOptions = chart.options,
navButtonOptions = chartOptions.exporting && chartOptions.exporting.enabled !== false &&
chartOptions.navigation && chartOptions.navigation.buttonOptions,
options = chartOptions.rangeSelector,
buttons = rangeSelector.buttons,
lang = defaultOptions.lang,
div = rangeSelector.div,
inputGroup = rangeSelector.inputGroup,
buttonTheme = options.buttonTheme,
buttonPosition = options.buttonPosition || {},
inputEnabled = options.inputEnabled,
states = buttonTheme && buttonTheme.states,
plotLeft = chart.plotLeft,
buttonLeft,
pos = this.getPosition(),
buttonGroup = rangeSelector.group,
buttonBBox,
rendered = rangeSelector.rendered;
if (options.enabled === false) {
return;
}
// create the elements
if (!rendered) {
rangeSelector.group = buttonGroup = renderer.g('range-selector-buttons').add();
rangeSelector.zoomText = renderer.text(lang.rangeSelectorZoom, pick(buttonPosition.x, plotLeft), 15)
.css(options.labelStyle)
.add(buttonGroup);
// button starting position
buttonLeft = pick(buttonPosition.x, plotLeft) + rangeSelector.zoomText.getBBox().width + 5;
each(rangeSelector.buttonOptions, function(rangeOptions, i) {
buttons[i] = renderer.button(
rangeOptions.text,
buttonLeft,
0,
function() {
rangeSelector.clickButton(i);
rangeSelector.isActive = true;
},
buttonTheme,
states && states.hover,
states && states.select,
states && states.disabled
)
.attr({
'text-align': 'center'
})
.add(buttonGroup);
// increase button position for the next button
buttonLeft += buttons[i].width + pick(options.buttonSpacing, 5);
});
// first create a wrapper outside the container in order to make
// the inputs work and make export correct
if (inputEnabled !== false) {
rangeSelector.div = div = createElement('div', null, {
position: 'relative',
height: 0,
zIndex: 1 // above container
});
container.parentNode.insertBefore(div, container);
// Create the group to keep the inputs
rangeSelector.inputGroup = inputGroup = renderer.g('input-group')
.add();
inputGroup.offset = 0;
rangeSelector.drawInput('min');
rangeSelector.drawInput('max');
}
}
rangeSelector.updateButtonStates();
// Set or update the group position
buttonGroup[rendered ? 'animate' : 'attr']({
translateY: pos.buttonTop
});
if (inputEnabled !== false) {
// Update the alignment to the updated spacing box
inputGroup.align(extend({
y: pos.inputTop,
width: inputGroup.offset,
// Detect collision with the exporting buttons
x: navButtonOptions && (pos.inputTop < (navButtonOptions.y || 0) + navButtonOptions.height - chart.spacing[0]) ?
-40 : 0
}, options.inputPosition), true, chart.spacingBox);
// Hide if overlapping - inputEnabled is null or undefined
if (!defined(inputEnabled)) {
buttonBBox = buttonGroup.getBBox();
inputGroup[inputGroup.alignAttr.translateX < buttonBBox.x + buttonBBox.width + 10 ? 'hide' : 'show']();
}
// Set or reset the input values
rangeSelector.setInputValue('min', min);
rangeSelector.setInputValue('max', max);
}
rangeSelector.rendered = true;
},
/**
* Update the range selector with new options
*/
update: function(options) {
var chart = this.chart;
merge(true, chart.options.rangeSelector, options);
this.destroy();
this.init(chart);
},
/**
* Destroys allocated elements.
*/
destroy: function() {
var minInput = this.minInput,
maxInput = this.maxInput,
key;
this.unMouseDown();
this.unResize();
// Destroy elements in collections
destroyObjectProperties(this.buttons);
// Clear input element events
if (minInput) {
minInput.onfocus = minInput.onblur = minInput.onchange = null;
}
if (maxInput) {
maxInput.onfocus = maxInput.onblur = maxInput.onchange = null;
}
// Destroy HTML and SVG elements
for (key in this) {
if (this[key] && key !== 'chart') {
if (this[key].destroy) { // SVGElement
this[key].destroy();
} else if (this[key].nodeType) { // HTML element
discardElement(this[key]);
}
}
if (this[key] !== RangeSelector.prototype[key]) {
this[key] = null;
}
}
}
};
/**
* Add logic to normalize the zoomed range in order to preserve the pressed state of range selector buttons
*/
Axis.prototype.toFixedRange = function(pxMin, pxMax, fixedMin, fixedMax) {
var fixedRange = this.chart && this.chart.fixedRange,
newMin = pick(fixedMin, this.translate(pxMin, true, !this.horiz)),
newMax = pick(fixedMax, this.translate(pxMax, true, !this.horiz)),
changeRatio = fixedRange && (newMax - newMin) / fixedRange;
// If the difference between the fixed range and the actual requested range is
// too great, the user is dragging across an ordinal gap, and we need to release
// the range selector button.
if (changeRatio > 0.7 && changeRatio < 1.3) {
if (fixedMax) {
newMin = newMax - fixedRange;
} else {
newMax = newMin + fixedRange;
}
}
if (!isNumber(newMin)) { // #1195
newMin = newMax = undefined;
}
return {
min: newMin,
max: newMax
};
};
/**
* Get the axis min value based on the range option and the current max. For
* stock charts this is extended via the {@link RangeSelector} so that if the
* selected range is a multiple of months or years, it is compensated for
* various month lengths.
*
* @return {number} The new minimum value.
*/
Axis.prototype.minFromRange = function() {
var rangeOptions = this.range,
type = rangeOptions.type,
timeName = {
month: 'Month',
year: 'FullYear'
}[type],
min,
max = this.max,
dataMin,
range,
// Get the true range from a start date
getTrueRange = function(base, count) {
var date = new Date(base);
date['set' + timeName](date['get' + timeName]() + count);
return date.getTime() - base;
};
if (isNumber(rangeOptions)) {
min = max - rangeOptions;
range = rangeOptions;
} else {
min = max + getTrueRange(max, -rangeOptions.count);
// Let the fixedRange reflect initial settings (#5930)
if (this.chart) {
this.chart.fixedRange = max - min;
}
}
dataMin = pick(this.dataMin, Number.MIN_VALUE);
if (!isNumber(min)) {
min = dataMin;
}
if (min <= dataMin) {
min = dataMin;
if (range === undefined) { // #4501
range = getTrueRange(min, rangeOptions.count);
}
this.newMax = Math.min(min + range, this.dataMax);
}
if (!isNumber(max)) {
min = undefined;
}
return min;
};
// Initialize scroller for stock charts
wrap(Chart.prototype, 'init', function(proceed, options, callback) {
addEvent(this, 'init', function() {
if (this.options.rangeSelector.enabled) {
this.rangeSelector = new RangeSelector(this);
}
});
proceed.call(this, options, callback);
});
Chart.prototype.callbacks.push(function(chart) {
var extremes,
rangeSelector = chart.rangeSelector,
unbindRender,
unbindSetExtremes;
function renderRangeSelector() {
extremes = chart.xAxis[0].getExtremes();
if (isNumber(extremes.min)) {
rangeSelector.render(extremes.min, extremes.max);
}
}
if (rangeSelector) {
// redraw the scroller on setExtremes
unbindSetExtremes = addEvent(
chart.xAxis[0],
'afterSetExtremes',
function(e) {
rangeSelector.render(e.min, e.max);
}
);
// redraw the scroller chart resize
unbindRender = addEvent(chart, 'redraw', renderRangeSelector);
// do it now
renderRangeSelector();
}
// Remove resize/afterSetExtremes at chart destroy
addEvent(chart, 'destroy', function destroyEvents() {
if (rangeSelector) {
unbindRender();
unbindSetExtremes();
}
});
});
H.RangeSelector = RangeSelector;
/* ****************************************************************************
* End Range Selector code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
Axis = H.Axis,
Chart = H.Chart,
defined = H.defined,
each = H.each,
extend = H.extend,
format = H.format,
inArray = H.inArray,
isNumber = H.isNumber,
isString = H.isString,
map = H.map,
merge = H.merge,
pick = H.pick,
Point = H.Point,
Renderer = H.Renderer,
Series = H.Series,
splat = H.splat,
SVGRenderer = H.SVGRenderer,
VMLRenderer = H.VMLRenderer,
wrap = H.wrap,
seriesProto = Series.prototype,
seriesInit = seriesProto.init,
seriesProcessData = seriesProto.processData,
pointTooltipFormatter = Point.prototype.tooltipFormatter;
/**
* A wrapper for Chart with all the default values for a Stock chart
*/
H.StockChart = H.stockChart = function(a, b, c) {
var hasRenderToArg = isString(a) || a.nodeName,
options = arguments[hasRenderToArg ? 1 : 0],
seriesOptions = options.series, // to increase performance, don't merge the data
defaultOptions = H.getOptions(),
opposite,
// Always disable startOnTick:true on the main axis when the navigator
// is enabled (#1090)
navigatorEnabled = pick(
options.navigator && options.navigator.enabled,
defaultOptions.navigator.enabled,
true
),
disableStartOnTick = navigatorEnabled ? {
startOnTick: false,
endOnTick: false
} : null,
lineOptions = {
marker: {
enabled: false,
radius: 2
}
// gapSize: 0
},
columnOptions = {
shadow: false,
borderWidth: 0
};
// apply X axis options to both single and multi y axes
options.xAxis = map(splat(options.xAxis || {}), function(xAxisOptions) {
return merge({ // defaults
minPadding: 0,
maxPadding: 0,
ordinal: true,
title: {
text: null
},
labels: {
overflow: 'justify'
},
showLastLabel: true
},
defaultOptions.xAxis, // #3802
xAxisOptions, // user options
{ // forced options
type: 'datetime',
categories: null
},
disableStartOnTick
);
});
// apply Y axis options to both single and multi y axes
options.yAxis = map(splat(options.yAxis || {}), function(yAxisOptions) {
opposite = pick(yAxisOptions.opposite, true);
return merge({ // defaults
labels: {
y: -2
},
opposite: opposite,
showLastLabel: false,
title: {
text: null
}
},
defaultOptions.yAxis, // #3802
yAxisOptions // user options
);
});
options.series = null;
options = merge({
chart: {
panning: true,
pinchType: 'x'
},
navigator: {
enabled: navigatorEnabled
},
scrollbar: {
// #4988 - check if setOptions was called
enabled: pick(defaultOptions.scrollbar.enabled, true)
},
rangeSelector: {
// #4988 - check if setOptions was called
enabled: pick(defaultOptions.rangeSelector.enabled, true)
},
title: {
text: null
},
tooltip: {
shared: true,
crosshairs: true
},
legend: {
enabled: false
},
plotOptions: {
line: lineOptions,
spline: lineOptions,
area: lineOptions,
areaspline: lineOptions,
arearange: lineOptions,
areasplinerange: lineOptions,
column: columnOptions,
columnrange: columnOptions,
candlestick: columnOptions,
ohlc: columnOptions
}
},
options, // user's options
{ // forced options
isStock: true // internal flag
}
);
options.series = seriesOptions;
return hasRenderToArg ?
new Chart(a, options, c) :
new Chart(options, b);
};
// Override the automatic label alignment so that the first Y axis' labels
// are drawn on top of the grid line, and subsequent axes are drawn outside
wrap(Axis.prototype, 'autoLabelAlign', function(proceed) {
var chart = this.chart,
options = this.options,
panes = chart._labelPanes = chart._labelPanes || {},
key,
labelOptions = this.options.labels;
if (this.chart.options.isStock && this.coll === 'yAxis') {
key = options.top + ',' + options.height;
if (!panes[key] && labelOptions.enabled) { // do it only for the first Y axis of each pane
if (labelOptions.x === 15) { // default
labelOptions.x = 0;
}
if (labelOptions.align === undefined) {
labelOptions.align = 'right';
}
panes[key] = this;
return 'right';
}
}
return proceed.call(this, [].slice.call(arguments, 1));
});
// Clear axis from label panes (#6071)
wrap(Axis.prototype, 'destroy', function(proceed) {
var chart = this.chart,
key = this.options && (this.options.top + ',' + this.options.height);
if (key && chart._labelPanes && chart._labelPanes[key] === this) {
delete chart._labelPanes[key];
}
return proceed.call(this, Array.prototype.slice.call(arguments, 1));
});
// Override getPlotLinePath to allow for multipane charts
wrap(Axis.prototype, 'getPlotLinePath', function(proceed, value, lineWidth, old, force, translatedValue) {
var axis = this,
series = (this.isLinked && !this.series ? this.linkedParent.series : this.series),
chart = axis.chart,
renderer = chart.renderer,
axisLeft = axis.left,
axisTop = axis.top,
x1,
y1,
x2,
y2,
result = [],
axes = [], //#3416 need a default array
axes2,
uniqueAxes,
transVal;
/**
* Return the other axis based on either the axis option or on related series.
*/
function getAxis(coll) {
var otherColl = coll === 'xAxis' ? 'yAxis' : 'xAxis',
opt = axis.options[otherColl];
// Other axis indexed by number
if (isNumber(opt)) {
return [chart[otherColl][opt]];
}
// Other axis indexed by id (like navigator)
if (isString(opt)) {
return [chart.get(opt)];
}
// Auto detect based on existing series
return map(series, function(s) {
return s[otherColl];
});
}
// Ignore in case of color Axis. #3360, #3524
if (axis.coll === 'colorAxis') {
return proceed.apply(this, [].slice.call(arguments, 1));
}
// Get the related axes based on series
axes = getAxis(axis.coll);
// Get the related axes based options.*Axis setting #2810
axes2 = (axis.isXAxis ? chart.yAxis : chart.xAxis);
each(axes2, function(A) {
if (defined(A.options.id) ? A.options.id.indexOf('navigator') === -1 : true) {
var a = (A.isXAxis ? 'yAxis' : 'xAxis'),
rax = (defined(A.options[a]) ? chart[a][A.options[a]] : chart[a][0]);
if (axis === rax) {
axes.push(A);
}
}
});
// Remove duplicates in the axes array. If there are no axes in the axes array,
// we are adding an axis without data, so we need to populate this with grid
// lines (#2796).
uniqueAxes = axes.length ? [] : [axis.isXAxis ? chart.yAxis[0] : chart.xAxis[0]]; //#3742
each(axes, function(axis2) {
if (inArray(axis2, uniqueAxes) === -1) {
uniqueAxes.push(axis2);
}
});
transVal = pick(translatedValue, axis.translate(value, null, null, old));
if (isNumber(transVal)) {
if (axis.horiz) {
each(uniqueAxes, function(axis2) {
var skip;
y1 = axis2.pos;
y2 = y1 + axis2.len;
x1 = x2 = Math.round(transVal + axis.transB);
if (x1 < axisLeft || x1 > axisLeft + axis.width) { // outside plot area
if (force) {
x1 = x2 = Math.min(Math.max(axisLeft, x1), axisLeft + axis.width);
} else {
skip = true;
}
}
if (!skip) {
result.push('M', x1, y1, 'L', x2, y2);
}
});
} else {
each(uniqueAxes, function(axis2) {
var skip;
x1 = axis2.pos;
x2 = x1 + axis2.len;
y1 = y2 = Math.round(axisTop + axis.height - transVal);
if (y1 < axisTop || y1 > axisTop + axis.height) { // outside plot area
if (force) {
y1 = y2 = Math.min(Math.max(axisTop, y1), axis.top + axis.height);
} else {
skip = true;
}
}
if (!skip) {
result.push('M', x1, y1, 'L', x2, y2);
}
});
}
}
return result.length > 0 ?
renderer.crispPolyLine(result, lineWidth || 1) :
null; //#3557 getPlotLinePath in regular Highcharts also returns null
});
// Override getPlotBandPath to allow for multipane charts
Axis.prototype.getPlotBandPath = function(from, to) {
var toPath = this.getPlotLinePath(to, null, null, true),
path = this.getPlotLinePath(from, null, null, true),
result = [],
i;
if (path && toPath) {
if (path.toString() === toPath.toString()) {
// #6166
result = path;
result.flat = true;
} else {
// Go over each subpath
for (i = 0; i < path.length; i += 6) {
result.push(
'M', path[i + 1], path[i + 2],
'L', path[i + 4], path[i + 5],
toPath[i + 4], toPath[i + 5],
toPath[i + 1], toPath[i + 2],
'z'
);
}
}
} else { // outside the axis area
result = null;
}
return result;
};
// Function to crisp a line with multiple segments
SVGRenderer.prototype.crispPolyLine = function(points, width) {
// points format: ['M', 0, 0, 'L', 100, 0]
// normalize to a crisp line
var i;
for (i = 0; i < points.length; i = i + 6) {
if (points[i + 1] === points[i + 4]) {
// Substract due to #1129. Now bottom and left axis gridlines behave the same.
points[i + 1] = points[i + 4] = Math.round(points[i + 1]) - (width % 2 / 2);
}
if (points[i + 2] === points[i + 5]) {
points[i + 2] = points[i + 5] = Math.round(points[i + 2]) + (width % 2 / 2);
}
}
return points;
};
if (Renderer === VMLRenderer) {
VMLRenderer.prototype.crispPolyLine = SVGRenderer.prototype.crispPolyLine;
}
// Wrapper to hide the label
wrap(Axis.prototype, 'hideCrosshair', function(proceed, i) {
proceed.call(this, i);
if (this.crossLabel) {
this.crossLabel = this.crossLabel.hide();
}
});
// Wrapper to draw the label
wrap(Axis.prototype, 'drawCrosshair', function(proceed, e, point) {
// Draw the crosshair
proceed.call(this, e, point);
// Check if the label has to be drawn
if (!defined(this.crosshair.label) || !this.crosshair.label.enabled || !this.cross) {
return;
}
var chart = this.chart,
options = this.options.crosshair.label, // the label's options
horiz = this.horiz, // axis orientation
opposite = this.opposite, // axis position
left = this.left, // left position
top = this.top, // top position
crossLabel = this.crossLabel, // reference to the svgElement
posx,
posy,
crossBox,
formatOption = options.format,
formatFormat = '',
limit,
align,
tickInside = this.options.tickPosition === 'inside',
snap = this.crosshair.snap !== false,
value,
offset = 0;
// Use last available event (#5287)
if (!e) {
e = this.cross && this.cross.e;
}
align = (horiz ? 'center' : opposite ?
(this.labelAlign === 'right' ? 'right' : 'left') :
(this.labelAlign === 'left' ? 'left' : 'center'));
// If the label does not exist yet, create it.
if (!crossLabel) {
crossLabel = this.crossLabel = chart.renderer.label(null, null, null, options.shape || 'callout')
.addClass('highcharts-crosshair-label' +
(this.series[0] && ' highcharts-color-' + this.series[0].colorIndex))
.attr({
align: options.align || align,
padding: pick(options.padding, 8),
r: pick(options.borderRadius, 3),
zIndex: 2
})
.add(this.labelGroup);
// Presentational
crossLabel
.attr({
fill: options.backgroundColor ||
(this.series[0] && this.series[0].color) || '#666666',
stroke: options.borderColor || '',
'stroke-width': options.borderWidth || 0
})
.css(extend({
color: '#ffffff',
fontWeight: 'normal',
fontSize: '11px',
textAlign: 'center'
}, options.style));
}
if (horiz) {
posx = snap ? point.plotX + left : e.chartX;
posy = top + (opposite ? 0 : this.height);
} else {
posx = opposite ? this.width + left : 0;
posy = snap ? point.plotY + top : e.chartY;
}
if (!formatOption && !options.formatter) {
if (this.isDatetimeAxis) {
formatFormat = '%b %d, %Y';
}
formatOption = '{value' + (formatFormat ? ':' + formatFormat : '') + '}';
}
// Show the label
value = snap ? point[this.isXAxis ? 'x' : 'y'] : this.toValue(horiz ? e.chartX : e.chartY);
crossLabel.attr({
text: formatOption ? format(formatOption, {
value: value
}) : options.formatter.call(this, value),
x: posx,
y: posy,
visibility: 'visible'
});
crossBox = crossLabel.getBBox();
// now it is placed we can correct its position
if (horiz) {
if ((tickInside && !opposite) || (!tickInside && opposite)) {
posy = crossLabel.y - crossBox.height;
}
} else {
posy = crossLabel.y - (crossBox.height / 2);
}
// check the edges
if (horiz) {
limit = {
left: left - crossBox.x,
right: left + this.width - crossBox.x
};
} else {
limit = {
left: this.labelAlign === 'left' ? left : 0,
right: this.labelAlign === 'right' ? left + this.width : chart.chartWidth
};
}
// left edge
if (crossLabel.translateX < limit.left) {
offset = limit.left - crossLabel.translateX;
}
// right edge
if (crossLabel.translateX + crossBox.width >= limit.right) {
offset = -(crossLabel.translateX + crossBox.width - limit.right);
}
// show the crosslabel
crossLabel.attr({
x: posx + offset,
y: posy,
// First set x and y, then anchorX and anchorY, when box is actually calculated, #5702
anchorX: horiz ? posx : (this.opposite ? 0 : chart.chartWidth),
anchorY: horiz ? (this.opposite ? chart.chartHeight : 0) : posy + crossBox.height / 2
});
});
/* ****************************************************************************
* Start value compare logic *
*****************************************************************************/
/**
* Extend series.init by adding a method to modify the y value used for plotting
* on the y axis. This method is called both from the axis when finding dataMin
* and dataMax, and from the series.translate method.
*/
seriesProto.init = function() {
// Call base method
seriesInit.apply(this, arguments);
// Set comparison mode
this.setCompare(this.options.compare);
};
/**
* The setCompare method can be called also from the outside after render time
*/
seriesProto.setCompare = function(compare) {
// Set or unset the modifyValue method
this.modifyValue = (compare === 'value' || compare === 'percent') ? function(value, point) {
var compareValue = this.compareValue;
if (value !== undefined && compareValue !== undefined) { // #2601, #5814
// Get the modified value
if (compare === 'value') {
value -= compareValue;
// Compare percent
} else {
value = 100 * (value / compareValue) -
(this.options.compareBase === 100 ? 0 : 100);
}
// record for tooltip etc.
if (point) {
point.change = value;
}
return value;
}
} : null;
// Survive to export, #5485
this.userOptions.compare = compare;
// Mark dirty
if (this.chart.hasRendered) {
this.isDirty = true;
}
};
/**
* Extend series.processData by finding the first y value in the plot area,
* used for comparing the following values
*/
seriesProto.processData = function() {
var series = this,
i,
keyIndex = -1,
processedXData,
processedYData,
length,
compareValue;
// call base method
seriesProcessData.apply(this, arguments);
if (series.xAxis && series.processedYData) { // not pies
// local variables
processedXData = series.processedXData;
processedYData = series.processedYData;
length = processedYData.length;
// For series with more than one value (range, OHLC etc), compare against
// close or the pointValKey (#4922, #3112)
if (series.pointArrayMap) {
// Use close if present (#3112)
keyIndex = inArray('close', series.pointArrayMap);
if (keyIndex === -1) {
keyIndex = inArray(series.pointValKey || 'y', series.pointArrayMap);
}
}
// find the first value for comparison
for (i = 0; i < length - 1; i++) {
compareValue = keyIndex > -1 ?
processedYData[i][keyIndex] :
processedYData[i];
if (isNumber(compareValue) && processedXData[i + 1] >= series.xAxis.min && compareValue !== 0) {
series.compareValue = compareValue;
break;
}
}
}
};
/**
* Modify series extremes
*/
wrap(seriesProto, 'getExtremes', function(proceed) {
var extremes;
proceed.apply(this, [].slice.call(arguments, 1));
if (this.modifyValue) {
extremes = [this.modifyValue(this.dataMin), this.modifyValue(this.dataMax)];
this.dataMin = arrayMin(extremes);
this.dataMax = arrayMax(extremes);
}
});
/**
* Add a utility method, setCompare, to the Y axis
*/
Axis.prototype.setCompare = function(compare, redraw) {
if (!this.isXAxis) {
each(this.series, function(series) {
series.setCompare(compare);
});
if (pick(redraw, true)) {
this.chart.redraw();
}
}
};
/**
* Extend the tooltip formatter by adding support for the point.change variable
* as well as the changeDecimals option
*/
Point.prototype.tooltipFormatter = function(pointFormat) {
var point = this;
pointFormat = pointFormat.replace(
'{point.change}',
(point.change > 0 ? '+' : '') +
H.numberFormat(point.change, pick(point.series.tooltipOptions.changeDecimals, 2))
);
return pointTooltipFormatter.apply(this, [pointFormat]);
};
/* ****************************************************************************
* End value compare logic *
*****************************************************************************/
/**
* Extend the Series prototype to create a separate series clip box. This is
* related to using multiple panes, and a future pane logic should incorporate
* this feature (#2754).
*/
wrap(Series.prototype, 'render', function(proceed) {
// Only do this on not 3d (#2939, #5904) nor polar (#6057) charts, and only
// if the series type handles clipping in the animate method (#2975).
if (!(this.chart.is3d && this.chart.is3d()) &&
!this.chart.polar &&
this.xAxis &&
!this.xAxis.isRadial // Gauge, #6192
) {
// First render, initial clip box
if (!this.clipBox && this.animate) {
this.clipBox = merge(this.chart.clipBox);
this.clipBox.width = this.xAxis.len;
this.clipBox.height = this.yAxis.len;
// On redrawing, resizing etc, update the clip rectangle
} else if (this.chart[this.sharedClipKey]) {
this.chart[this.sharedClipKey].attr({
width: this.xAxis.len,
height: this.yAxis.len
});
// #3111
} else if (this.clipBox) {
this.clipBox.width = this.xAxis.len;
this.clipBox.height = this.yAxis.len;
}
}
proceed.call(this);
});
}(Highcharts));
(function() {
}());
return Highcharts
}));
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| standalone-framework.js | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (0 / 0) | |
| standalone-framework.src.js | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (0 / 0) | 100% | (0 / 0) |
| 1 2 3 |
| 1 2 3 |
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| canvg.js | 0.36% | (5 / 1386) | 0.62% | (6 / 974) | 0.38% | (1 / 262) | 2.5% | (3 / 120) | |
| canvg.src.js | 0.43% | (9 / 2081) | 0.59% | (6 / 1017) | 0.38% | (1 / 265) | 0.48% | (9 / 1863) | |
| jspdf.js | 1.12% | (9 / 805) | 1.71% | (8 / 468) | 0.93% | (1 / 108) | 10.64% | (5 / 47) | |
| jspdf.src.js | 1.01% | (11 / 1084) | 1.61% | (8 / 498) | 0.75% | (1 / 133) | 1.04% | (11 / 1058) | |
| rgbcolor.js | 8.33% | (4 / 48) | 18.6% | (8 / 43) | 11.11% | (1 / 9) | 50% | (3 / 6) | |
| rgbcolor.src.js | 8.57% | (6 / 70) | 18.6% | (8 / 43) | 11.11% | (1 / 9) | 8.96% | (6 / 67) | |
| svg2pdf.js | 7.78% | (52 / 668) | 2.49% | (23 / 925) | 12.5% | (16 / 128) | 100% | (2 / 2) | |
| svg2pdf.src.js | 8.86% | (137 / 1547) | 2.64% | (25 / 946) | 12.03% | (16 / 133) | 8.11% | (121 / 1492) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | 2 1 1 | /*
canvg.js - Javascript SVG parser and renderer on Canvas
MIT Licensed
Gabe Lerner (gabelerner@gmail.com)
http://code.google.com/p/canvg/
Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/
*/
(function(x,y){"undefined"!==typeof define&&define.amd?define("canvgModule",["rgbcolor","stackblur"],y):"undefined"!==typeof module&&module.exports&&(module.exports=y(require("rgbcolor"),require("stackblur")));x.canvg=y(x.RGBColor,x.stackBlur)})("undefined"!==typeof window?window:this,function(x,y){function A(h){var a=[0,0,0],l=function(c,b){var e=h.match(c);null!=e&&(a[b]+=e.length,h=h.replace(c," "))};h=h.replace(/:not\(([^\)]*)\)/g," $1 ");h=h.replace(/{[^]*/gm," ");l(B,1);l(C,0);l(D,1);l(E,
2);l(F,1);l(G,1);h=h.replace(/[\*\s\+>~]/g," ");h=h.replace(/[#\.]/g," ");l(H,2);return a.join("")}function I(h){var a={opts:h,FRAMERATE:30,MAX_VIRTUAL_PIXELS:3E4,log:function(a){}};1==a.opts.log&&"undefined"!=typeof console&&(a.log=function(a){console.log(a)});a.init=function(c){var b=0;a.UniqueId=function(){b++;return"canvg"+b};a.Definitions={};a.Styles={};a.StylesSpecificity={};a.Animations=[];a.Images=[];a.ctx=c;a.ViewPort=new function(){this.viewPorts=[];this.Clear=function(){this.viewPorts=
[]};this.SetCurrent=function(a,b){this.viewPorts.push({width:a,height:b})};this.RemoveCurrent=function(){this.viewPorts.pop()};this.Current=function(){return this.viewPorts[this.viewPorts.length-1]};this.width=function(){return this.Current().width};this.height=function(){return this.Current().height};this.ComputeSize=function(a){return null!=a&&"number"==typeof a?a:"x"==a?this.width():"y"==a?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}};a.init();a.ImagesLoaded=
function(){for(var c=0;c<a.Images.length;c++)if(!a.Images[c].loaded)return!1;return!0};a.trim=function(a){return a.replace(/^\s+|\s+$/g,"")};a.compressSpaces=function(a){return a.replace(/[\s\r\t\n]+/gm," ")};a.ajax=function(a){var b;b=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");b.open("GET",a,!1);b.send(null);return b.responseText};a.parseXml=function(a){if("undefined"!=typeof Windows&&"undefined"!=typeof Windows.Data&&"undefined"!=typeof Windows.Data.Xml){var b=
new Windows.Data.Xml.Dom.XmlDocument,e=new Windows.Data.Xml.Dom.XmlLoadSettings;e.prohibitDtd=!1;b.loadXml(a,e);return b}if(window.DOMParser)return(new DOMParser).parseFromString(a,"text/xml");a=a.replace(/<!DOCTYPE svg[^>]*>/,"");b=new ActiveXObject("Microsoft.XMLDOM");b.async="false";b.loadXML(a);return b};a.Property=function(a,b){this.name=a;this.value=b};a.Property.prototype.getValue=function(){return this.value};a.Property.prototype.hasValue=function(){return null!=this.value&&""!==this.value};
a.Property.prototype.numValue=function(){if(!this.hasValue())return 0;var a=parseFloat(this.value);(this.value+"").match(/%$/)&&(a/=100);return a};a.Property.prototype.valueOrDefault=function(a){return this.hasValue()?this.value:a};a.Property.prototype.numValueOrDefault=function(a){return this.hasValue()?this.numValue():a};a.Property.prototype.addOpacity=function(c){var b=this.value;if(null!=c.value&&""!=c.value&&"string"==typeof this.value){var e=new x(this.value);e.ok&&(b="rgba("+e.r+", "+e.g+", "+
e.b+", "+c.numValue()+")")}return new a.Property(this.name,b)};a.Property.prototype.getDefinition=function(){var c=this.value.match(/#([^\)'"]+)/);c&&(c=c[1]);c||(c=this.value);return a.Definitions[c]};a.Property.prototype.isUrlDefinition=function(){return 0==this.value.indexOf("url(")};a.Property.prototype.getFillStyleDefinition=function(c,b){var e=this.getDefinition();if(null!=e&&e.createGradient)return e.createGradient(a.ctx,c,b);if(null!=e&&e.createPattern){if(e.getHrefAttribute().hasValue()){var d=
e.attribute("patternTransform"),e=e.getHrefAttribute().getDefinition();d.hasValue()&&(e.attribute("patternTransform",!0).value=d.value)}return e.createPattern(a.ctx,c)}return null};a.Property.prototype.getDPI=function(a){return 96};a.Property.prototype.getEM=function(c){var b=12,e=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);e.hasValue()&&(b=e.toPixels(c));return b};a.Property.prototype.getUnits=function(){return(this.value+"").replace(/[0-9\.\-]/g,"")};a.Property.prototype.toPixels=
function(c,b){if(!this.hasValue())return 0;var e=this.value+"";if(e.match(/em$/))return this.numValue()*this.getEM(c);if(e.match(/ex$/))return this.numValue()*this.getEM(c)/2;if(e.match(/px$/))return this.numValue();if(e.match(/pt$/))return this.numValue()*this.getDPI(c)*(1/72);if(e.match(/pc$/))return 15*this.numValue();if(e.match(/cm$/))return this.numValue()*this.getDPI(c)/2.54;if(e.match(/mm$/))return this.numValue()*this.getDPI(c)/25.4;if(e.match(/in$/))return this.numValue()*this.getDPI(c);
if(e.match(/%$/))return this.numValue()*a.ViewPort.ComputeSize(c);e=this.numValue();return b&&1>e?e*a.ViewPort.ComputeSize(c):e};a.Property.prototype.toMilliseconds=function(){if(!this.hasValue())return 0;var a=this.value+"";if(a.match(/s$/))return 1E3*this.numValue();a.match(/ms$/);return this.numValue()};a.Property.prototype.toRadians=function(){if(!this.hasValue())return 0;var a=this.value+"";return a.match(/deg$/)?this.numValue()*(Math.PI/180):a.match(/grad$/)?this.numValue()*(Math.PI/200):a.match(/rad$/)?
this.numValue():this.numValue()*(Math.PI/180)};var l={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};a.Property.prototype.toTextBaseline=function(){return this.hasValue()?l[this.value]:null};a.Font=new function(){this.Styles="normal|italic|oblique|inherit";this.Variants="normal|small-caps|inherit";this.Weights=
"normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit";this.CreateFont=function(b,e,d,c,f,g){g=null!=g?this.Parse(g):this.CreateFont("","","","","",a.ctx.font);return{fontFamily:f||g.fontFamily,fontSize:c||g.fontSize,fontStyle:b||g.fontStyle,fontWeight:d||g.fontWeight,fontVariant:e||g.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var c=this;this.Parse=function(b){var e={};b=a.trim(a.compressSpaces(b||
"")).split(" ");for(var d=!1,k=!1,f=!1,g=!1,m="",n=0;n<b.length;n++)k||-1==c.Styles.indexOf(b[n])?g||-1==c.Variants.indexOf(b[n])?f||-1==c.Weights.indexOf(b[n])?d?"inherit"!=b[n]&&(m+=b[n]):("inherit"!=b[n]&&(e.fontSize=b[n].split("/")[0]),k=g=f=d=!0):("inherit"!=b[n]&&(e.fontWeight=b[n]),k=g=f=!0):("inherit"!=b[n]&&(e.fontVariant=b[n]),k=g=!0):("inherit"!=b[n]&&(e.fontStyle=b[n]),k=!0);""!=m&&(e.fontFamily=m);return e}};a.ToNumberArray=function(c){c=a.trim(a.compressSpaces((c||"").replace(/,/g," "))).split(" ");
for(var b=0;b<c.length;b++)c[b]=parseFloat(c[b]);return c};a.Point=function(a,b){this.x=a;this.y=b};a.Point.prototype.angleTo=function(a){return Math.atan2(a.y-this.y,a.x-this.x)};a.Point.prototype.applyTransform=function(a){var b=this.x*a[1]+this.y*a[3]+a[5];this.x=this.x*a[0]+this.y*a[2]+a[4];this.y=b};a.CreatePoint=function(c){c=a.ToNumberArray(c);return new a.Point(c[0],c[1])};a.CreatePath=function(c){c=a.ToNumberArray(c);for(var b=[],e=0;e<c.length;e+=2)b.push(new a.Point(c[e],c[e+1]));return b};
a.BoundingBox=function(a,b,e,d){this.y2=this.x2=this.y1=this.x1=Number.NaN;this.x=function(){return this.x1};this.y=function(){return this.y1};this.width=function(){return this.x2-this.x1};this.height=function(){return this.y2-this.y1};this.addPoint=function(a,b){if(null!=a){if(isNaN(this.x1)||isNaN(this.x2))this.x2=this.x1=a;a<this.x1&&(this.x1=a);a>this.x2&&(this.x2=a)}if(null!=b){if(isNaN(this.y1)||isNaN(this.y2))this.y2=this.y1=b;b<this.y1&&(this.y1=b);b>this.y2&&(this.y2=b)}};this.addX=function(a){this.addPoint(a,
null)};this.addY=function(a){this.addPoint(null,a)};this.addBoundingBox=function(a){this.addPoint(a.x1,a.y1);this.addPoint(a.x2,a.y2)};this.addQuadraticCurve=function(a,b,e,d,c,r){e=a+2/3*(e-a);d=b+2/3*(d-b);this.addBezierCurve(a,b,e,e+1/3*(c-a),d,d+1/3*(r-b),c,r)};this.addBezierCurve=function(a,b,e,d,c,r,u,p){var t=[a,b],h=[e,d],q=[c,r],l=[u,p];this.addPoint(t[0],t[1]);this.addPoint(l[0],l[1]);for(i=0;1>=i;i++)a=function(a){return Math.pow(1-a,3)*t[i]+3*Math.pow(1-a,2)*a*h[i]+3*(1-a)*Math.pow(a,
2)*q[i]+Math.pow(a,3)*l[i]},b=6*t[i]-12*h[i]+6*q[i],e=-3*t[i]+9*h[i]-9*q[i]+3*l[i],d=3*h[i]-3*t[i],0==e?0!=b&&(b=-d/b,0<b&&1>b&&(0==i&&this.addX(a(b)),1==i&&this.addY(a(b)))):(d=Math.pow(b,2)-4*d*e,0>d||(c=(-b+Math.sqrt(d))/(2*e),0<c&&1>c&&(0==i&&this.addX(a(c)),1==i&&this.addY(a(c))),b=(-b-Math.sqrt(d))/(2*e),0<b&&1>b&&(0==i&&this.addX(a(b)),1==i&&this.addY(a(b)))))};this.isPointInBox=function(a,b){return this.x1<=a&&a<=this.x2&&this.y1<=b&&b<=this.y2};this.addPoint(a,b);this.addPoint(e,d)};a.Transform=
function(c){var b=this;this.Type={};this.Type.translate=function(b){this.p=a.CreatePoint(b);this.apply=function(a){a.translate(this.p.x||0,this.p.y||0)};this.unapply=function(a){a.translate(-1*this.p.x||0,-1*this.p.y||0)};this.applyToPoint=function(a){a.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}};this.Type.rotate=function(b){b=a.ToNumberArray(b);this.angle=new a.Property("angle",b[0]);this.cx=b[1]||0;this.cy=b[2]||0;this.apply=function(a){a.translate(this.cx,this.cy);a.rotate(this.angle.toRadians());
a.translate(-this.cx,-this.cy)};this.unapply=function(a){a.translate(this.cx,this.cy);a.rotate(-1*this.angle.toRadians());a.translate(-this.cx,-this.cy)};this.applyToPoint=function(a){var b=this.angle.toRadians();a.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]);a.applyTransform([Math.cos(b),Math.sin(b),-Math.sin(b),Math.cos(b),0,0]);a.applyTransform([1,0,0,1,-this.p.x||0,-this.p.y||0])}};this.Type.scale=function(b){this.p=a.CreatePoint(b);this.apply=function(a){a.scale(this.p.x||1,this.p.y||this.p.x||
1)};this.unapply=function(a){a.scale(1/this.p.x||1,1/this.p.y||this.p.x||1)};this.applyToPoint=function(a){a.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}};this.Type.matrix=function(b){this.m=a.ToNumberArray(b);this.apply=function(a){a.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])};this.unapply=function(a){var b=this.m[0],e=this.m[2],d=this.m[4],c=this.m[1],f=this.m[3],k=this.m[5],h=1/(b*(1*f-0*k)-e*(1*c-0*k)+d*(0*c-0*f));a.transform(h*(1*f-0*k),h*(0*k-1*c),h*(0*d-1*
e),h*(1*b-0*d),h*(e*k-d*f),h*(d*c-b*k))};this.applyToPoint=function(a){a.applyTransform(this.m)}};this.Type.SkewBase=function(e){this.base=b.Type.matrix;this.base(e);this.angle=new a.Property("angle",e)};this.Type.SkewBase.prototype=new this.Type.matrix;this.Type.skewX=function(a){this.base=b.Type.SkewBase;this.base(a);this.m=[1,0,Math.tan(this.angle.toRadians()),1,0,0]};this.Type.skewX.prototype=new this.Type.SkewBase;this.Type.skewY=function(a){this.base=b.Type.SkewBase;this.base(a);this.m=[1,Math.tan(this.angle.toRadians()),
0,1,0,0]};this.Type.skewY.prototype=new this.Type.SkewBase;this.transforms=[];this.apply=function(a){for(var b=0;b<this.transforms.length;b++)this.transforms[b].apply(a)};this.unapply=function(a){for(var b=this.transforms.length-1;0<=b;b--)this.transforms[b].unapply(a)};this.applyToPoint=function(a){for(var b=0;b<this.transforms.length;b++)this.transforms[b].applyToPoint(a)};c=a.trim(a.compressSpaces(c)).replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/);for(var e=0;e<
c.length;e++){var d=a.trim(c[e].split("(")[0]),k=c[e].split("(")[1].replace(")",""),k=new this.Type[d](k);k.type=d;this.transforms.push(k)}};a.AspectRatio=function(c,b,e,d,k,f,g,m,n,r){b=a.compressSpaces(b);b=b.replace(/^defer\s/,"");var h=b.split(" ")[0]||"xMidYMid";b=b.split(" ")[1]||"meet";var p=e/d,t=k/f,l=Math.min(p,t),q=Math.max(p,t);"meet"==b&&(d*=l,f*=l);"slice"==b&&(d*=q,f*=q);n=new a.Property("refX",n);r=new a.Property("refY",r);n.hasValue()&&r.hasValue()?c.translate(-l*n.toPixels("x"),
-l*r.toPixels("y")):(h.match(/^xMid/)&&("meet"==b&&l==t||"slice"==b&&q==t)&&c.translate(e/2-d/2,0),h.match(/YMid$/)&&("meet"==b&&l==p||"slice"==b&&q==p)&&c.translate(0,k/2-f/2),h.match(/^xMax/)&&("meet"==b&&l==t||"slice"==b&&q==t)&&c.translate(e-d,0),h.match(/YMax$/)&&("meet"==b&&l==p||"slice"==b&&q==p)&&c.translate(0,k-f));"none"==h?c.scale(p,t):"meet"==b?c.scale(l,l):"slice"==b&&c.scale(q,q);c.translate(null==g?0:-g,null==m?0:-m)};a.Element={};a.EmptyProperty=new a.Property("EMPTY","");a.Element.ElementBase=
function(c){this.attributes={};this.styles={};this.stylesSpecificity={};this.children=[];this.attribute=function(b,e){var d=this.attributes[b];if(null!=d)return d;1==e&&(d=new a.Property(b,""),this.attributes[b]=d);return d||a.EmptyProperty};this.getHrefAttribute=function(){for(var b in this.attributes)if("href"==b||b.match(/:href$/))return this.attributes[b];return a.EmptyProperty};this.style=function(b,e,d){var c=this.styles[b];if(null!=c)return c;var k=this.attribute(b);if(null!=k&&k.hasValue())return this.styles[b]=
k;if(1!=d&&(d=this.parent,null!=d&&(d=d.style(b),null!=d&&d.hasValue())))return d;1==e&&(c=new a.Property(b,""),this.styles[b]=c);return c||a.EmptyProperty};this.render=function(a){if("none"!=this.style("display").value&&"hidden"!=this.style("visibility").value){a.save();if(this.style("mask").hasValue()){var b=this.style("mask").getDefinition();null!=b&&b.apply(a,this)}else this.style("filter").hasValue()?(b=this.style("filter").getDefinition(),null!=b&&b.apply(a,this)):(this.setContext(a),this.renderChildren(a),
this.clearContext(a));a.restore()}};this.setContext=function(a){};this.clearContext=function(a){};this.renderChildren=function(a){for(var b=0;b<this.children.length;b++)this.children[b].render(a)};this.addChild=function(b,e){var d=b;e&&(d=a.CreateElement(b));d.parent=this;"title"!=d.type&&this.children.push(d)};this.addStylesFromStyleDefinition=function(){for(var b in a.Styles)if("@"!=b[0]&&w(c,b)){var e=a.Styles[b],d=a.StylesSpecificity[b];if(null!=e)for(var k in e){var r=this.stylesSpecificity[k];
"undefined"==typeof r&&(r="000");d>r&&(this.styles[k]=e[k],this.stylesSpecificity[k]=d)}}};if(null!=c&&1==c.nodeType){for(var b=0;b<c.attributes.length;b++){var e=c.attributes[b];this.attributes[e.nodeName]=new a.Property(e.nodeName,e.value)}this.addStylesFromStyleDefinition();if(this.attribute("style").hasValue())for(e=this.attribute("style").value.split(";"),b=0;b<e.length;b++)if(""!=a.trim(e[b])){var d=e[b].split(":"),k=a.trim(d[0]),d=a.trim(d[1]);this.styles[k]=new a.Property(k,d)}this.attribute("id").hasValue()&&
null==a.Definitions[this.attribute("id").value]&&(a.Definitions[this.attribute("id").value]=this);for(b=0;b<c.childNodes.length;b++)e=c.childNodes[b],1==e.nodeType&&this.addChild(e,!0),!this.captureTextNodes||3!=e.nodeType&&4!=e.nodeType||""!=a.compressSpaces(e.value||e.text||e.textContent||"")&&this.addChild(new a.Element.tspan(e),!1)}};a.Element.RenderedElementBase=function(c){this.base=a.Element.ElementBase;this.base(c);this.setContext=function(b){if(this.style("fill").isUrlDefinition()){var e=
this.style("fill").getFillStyleDefinition(this,this.style("fill-opacity"));null!=e&&(b.fillStyle=e)}else this.style("fill").hasValue()&&(e=this.style("fill"),"currentColor"==e.value&&(e.value=this.style("color").value),"inherit"!=e.value&&(b.fillStyle="none"==e.value?"rgba(0,0,0,0)":e.value));this.style("fill-opacity").hasValue()&&(e=new a.Property("fill",b.fillStyle),e=e.addOpacity(this.style("fill-opacity")),b.fillStyle=e.value);this.style("stroke").isUrlDefinition()?(e=this.style("stroke").getFillStyleDefinition(this,
this.style("stroke-opacity")),null!=e&&(b.strokeStyle=e)):this.style("stroke").hasValue()&&(e=this.style("stroke"),"currentColor"==e.value&&(e.value=this.style("color").value),"inherit"!=e.value&&(b.strokeStyle="none"==e.value?"rgba(0,0,0,0)":e.value));this.style("stroke-opacity").hasValue()&&(e=new a.Property("stroke",b.strokeStyle),e=e.addOpacity(this.style("stroke-opacity")),b.strokeStyle=e.value);this.style("stroke-width").hasValue()&&(e=this.style("stroke-width").toPixels(),b.lineWidth=0==e?
.001:e);this.style("stroke-linecap").hasValue()&&(b.lineCap=this.style("stroke-linecap").value);this.style("stroke-linejoin").hasValue()&&(b.lineJoin=this.style("stroke-linejoin").value);this.style("stroke-miterlimit").hasValue()&&(b.miterLimit=this.style("stroke-miterlimit").value);this.style("stroke-dasharray").hasValue()&&"none"!=this.style("stroke-dasharray").value&&(e=a.ToNumberArray(this.style("stroke-dasharray").value),"undefined"!=typeof b.setLineDash?b.setLineDash(e):"undefined"!=typeof b.webkitLineDash?
b.webkitLineDash=e:"undefined"==typeof b.mozDash||1==e.length&&0==e[0]||(b.mozDash=e),e=this.style("stroke-dashoffset").numValueOrDefault(1),"undefined"!=typeof b.lineDashOffset?b.lineDashOffset=e:"undefined"!=typeof b.webkitLineDashOffset?b.webkitLineDashOffset=e:"undefined"!=typeof b.mozDashOffset&&(b.mozDashOffset=e));"undefined"!=typeof b.font&&(b.font=a.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,this.style("font-weight").value,this.style("font-size").hasValue()?
this.style("font-size").toPixels()+"px":"",this.style("font-family").value).toString());this.style("transform",!1,!0).hasValue()&&(new a.Transform(this.style("transform",!1,!0).value)).apply(b);this.style("clip-path",!1,!0).hasValue()&&(e=this.style("clip-path",!1,!0).getDefinition(),null!=e&&e.apply(b));this.style("opacity").hasValue()&&(b.globalAlpha=this.style("opacity").numValue())}};a.Element.RenderedElementBase.prototype=new a.Element.ElementBase;a.Element.PathElementBase=function(c){this.base=
a.Element.RenderedElementBase;this.base(c);this.path=function(b){null!=b&&b.beginPath();return new a.BoundingBox};this.renderChildren=function(b){this.path(b);a.Mouse.checkPath(this,b);""!=b.fillStyle&&("inherit"!=this.style("fill-rule").valueOrDefault("inherit")?b.fill(this.style("fill-rule").value):b.fill());""!=b.strokeStyle&&b.stroke();var e=this.getMarkers();if(null!=e){if(this.style("marker-start").isUrlDefinition()){var d=this.style("marker-start").getDefinition();d.render(b,e[0][0],e[0][1])}if(this.style("marker-mid").isUrlDefinition())for(var d=
this.style("marker-mid").getDefinition(),c=1;c<e.length-1;c++)d.render(b,e[c][0],e[c][1]);this.style("marker-end").isUrlDefinition()&&(d=this.style("marker-end").getDefinition(),d.render(b,e[e.length-1][0],e[e.length-1][1]))}};this.getBoundingBox=function(){return this.path()};this.getMarkers=function(){return null}};a.Element.PathElementBase.prototype=new a.Element.RenderedElementBase;a.Element.svg=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseClearContext=this.clearContext;
this.clearContext=function(b){this.baseClearContext(b);a.ViewPort.RemoveCurrent()};this.baseSetContext=this.setContext;this.setContext=function(b){b.strokeStyle="rgba(0,0,0,0)";b.lineCap="butt";b.lineJoin="miter";b.miterLimit=4;"undefined"!=typeof b.font&&"undefined"!=typeof window.getComputedStyle&&(b.font=window.getComputedStyle(b.canvas).getPropertyValue("font"));this.baseSetContext(b);this.attribute("x").hasValue()||(this.attribute("x",!0).value=0);this.attribute("y").hasValue()||(this.attribute("y",
!0).value=0);b.translate(this.attribute("x").toPixels("x"),this.attribute("y").toPixels("y"));var e=a.ViewPort.width(),d=a.ViewPort.height();this.attribute("width").hasValue()||(this.attribute("width",!0).value="100%");this.attribute("height").hasValue()||(this.attribute("height",!0).value="100%");if("undefined"==typeof this.root){var e=this.attribute("width").toPixels("x"),d=this.attribute("height").toPixels("y"),c=0,f=0;this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()&&(c=-this.attribute("refX").toPixels("x"),
f=-this.attribute("refY").toPixels("y"));"visible"!=this.attribute("overflow").valueOrDefault("hidden")&&(b.beginPath(),b.moveTo(c,f),b.lineTo(e,f),b.lineTo(e,d),b.lineTo(c,d),b.closePath(),b.clip())}a.ViewPort.SetCurrent(e,d);if(this.attribute("viewBox").hasValue()){var c=a.ToNumberArray(this.attribute("viewBox").value),f=c[0],g=c[1],e=c[2],d=c[3];a.AspectRatio(b,this.attribute("preserveAspectRatio").value,a.ViewPort.width(),e,a.ViewPort.height(),d,f,g,this.attribute("refX").value,this.attribute("refY").value);
a.ViewPort.RemoveCurrent();a.ViewPort.SetCurrent(c[2],c[3])}}};a.Element.svg.prototype=new a.Element.RenderedElementBase;a.Element.rect=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(b){var e=this.attribute("x").toPixels("x"),d=this.attribute("y").toPixels("y"),c=this.attribute("width").toPixels("x"),f=this.attribute("height").toPixels("y"),g=this.attribute("rx").toPixels("x"),m=this.attribute("ry").toPixels("y");this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&
(m=g);this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(g=m);g=Math.min(g,c/2);m=Math.min(m,f/2);null!=b&&(b.beginPath(),b.moveTo(e+g,d),b.lineTo(e+c-g,d),b.quadraticCurveTo(e+c,d,e+c,d+m),b.lineTo(e+c,d+f-m),b.quadraticCurveTo(e+c,d+f,e+c-g,d+f),b.lineTo(e+g,d+f),b.quadraticCurveTo(e,d+f,e,d+f-m),b.lineTo(e,d+m),b.quadraticCurveTo(e,d,e+g,d),b.closePath());return new a.BoundingBox(e,d,e+c,d+f)}};a.Element.rect.prototype=new a.Element.PathElementBase;a.Element.circle=function(c){this.base=
a.Element.PathElementBase;this.base(c);this.path=function(b){var e=this.attribute("cx").toPixels("x"),d=this.attribute("cy").toPixels("y"),c=this.attribute("r").toPixels();null!=b&&(b.beginPath(),b.arc(e,d,c,0,2*Math.PI,!0),b.closePath());return new a.BoundingBox(e-c,d-c,e+c,d+c)}};a.Element.circle.prototype=new a.Element.PathElementBase;a.Element.ellipse=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(b){var e=(Math.sqrt(2)-1)/3*4,d=this.attribute("rx").toPixels("x"),
c=this.attribute("ry").toPixels("y"),f=this.attribute("cx").toPixels("x"),g=this.attribute("cy").toPixels("y");null!=b&&(b.beginPath(),b.moveTo(f,g-c),b.bezierCurveTo(f+e*d,g-c,f+d,g-e*c,f+d,g),b.bezierCurveTo(f+d,g+e*c,f+e*d,g+c,f,g+c),b.bezierCurveTo(f-e*d,g+c,f-d,g+e*c,f-d,g),b.bezierCurveTo(f-d,g-e*c,f-e*d,g-c,f,g-c),b.closePath());return new a.BoundingBox(f-d,g-c,f+d,g+c)}};a.Element.ellipse.prototype=new a.Element.PathElementBase;a.Element.line=function(c){this.base=a.Element.PathElementBase;
this.base(c);this.getPoints=function(){return[new a.Point(this.attribute("x1").toPixels("x"),this.attribute("y1").toPixels("y")),new a.Point(this.attribute("x2").toPixels("x"),this.attribute("y2").toPixels("y"))]};this.path=function(b){var e=this.getPoints();null!=b&&(b.beginPath(),b.moveTo(e[0].x,e[0].y),b.lineTo(e[1].x,e[1].y));return new a.BoundingBox(e[0].x,e[0].y,e[1].x,e[1].y)};this.getMarkers=function(){var a=this.getPoints(),e=a[0].angleTo(a[1]);return[[a[0],e],[a[1],e]]}};a.Element.line.prototype=
new a.Element.PathElementBase;a.Element.polyline=function(c){this.base=a.Element.PathElementBase;this.base(c);this.points=a.CreatePath(this.attribute("points").value);this.path=function(b){var e=new a.BoundingBox(this.points[0].x,this.points[0].y);null!=b&&(b.beginPath(),b.moveTo(this.points[0].x,this.points[0].y));for(var d=1;d<this.points.length;d++)e.addPoint(this.points[d].x,this.points[d].y),null!=b&&b.lineTo(this.points[d].x,this.points[d].y);return e};this.getMarkers=function(){for(var a=[],
e=0;e<this.points.length-1;e++)a.push([this.points[e],this.points[e].angleTo(this.points[e+1])]);a.push([this.points[this.points.length-1],a[a.length-1][1]]);return a}};a.Element.polyline.prototype=new a.Element.PathElementBase;a.Element.polygon=function(c){this.base=a.Element.polyline;this.base(c);this.basePath=this.path;this.path=function(a){var e=this.basePath(a);null!=a&&(a.lineTo(this.points[0].x,this.points[0].y),a.closePath());return e}};a.Element.polygon.prototype=new a.Element.polyline;a.Element.path=
function(c){this.base=a.Element.PathElementBase;this.base(c);c=this.attribute("d").value;c=c.replace(/,/gm," ");for(var b=0;2>b;b++)c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2");c=c.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([0-9])([+\-])/gm,"$1 $2");for(b=0;2>b;b++)c=c.replace(/(\.[0-9]*)(\.)/gm,"$1 $2");c=c.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 ");c=a.compressSpaces(c);c=a.trim(c);this.PathParser=new function(b){this.tokens=b.split(" ");
this.reset=function(){this.i=-1;this.previousCommand=this.command="";this.start=new a.Point(0,0);this.control=new a.Point(0,0);this.current=new a.Point(0,0);this.points=[];this.angles=[]};this.isEnd=function(){return this.i>=this.tokens.length-1};this.isCommandOrEnd=function(){return this.isEnd()?!0:null!=this.tokens[this.i+1].match(/^[A-Za-z]$/)};this.isRelativeCommand=function(){switch(this.command){case "m":case "l":case "h":case "v":case "c":case "s":case "q":case "t":case "a":case "z":return!0}return!1};
this.getToken=function(){this.i++;return this.tokens[this.i]};this.getScalar=function(){return parseFloat(this.getToken())};this.nextCommand=function(){this.previousCommand=this.command;this.command=this.getToken()};this.getPoint=function(){var b=new a.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(b)};this.getAsControlPoint=function(){var a=this.getPoint();return this.control=a};this.getAsCurrentPoint=function(){var a=this.getPoint();return this.current=a};this.getReflectedControlPoint=
function(){return"c"!=this.previousCommand.toLowerCase()&&"s"!=this.previousCommand.toLowerCase()&&"q"!=this.previousCommand.toLowerCase()&&"t"!=this.previousCommand.toLowerCase()?this.current:new a.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)};this.makeAbsolute=function(a){this.isRelativeCommand()&&(a.x+=this.current.x,a.y+=this.current.y);return a};this.addMarker=function(a,b,e){null!=e&&0<this.angles.length&&null==this.angles[this.angles.length-1]&&(this.angles[this.angles.length-
1]=this.points[this.points.length-1].angleTo(e));this.addMarkerAngle(a,null==b?null:b.angleTo(a))};this.addMarkerAngle=function(a,b){this.points.push(a);this.angles.push(b)};this.getMarkerPoints=function(){return this.points};this.getMarkerAngles=function(){for(var a=0;a<this.angles.length;a++)if(null==this.angles[a])for(var b=a+1;b<this.angles.length;b++)if(null!=this.angles[b]){this.angles[a]=this.angles[b];break}return this.angles}}(c);this.path=function(b){var d=this.PathParser;d.reset();var c=
new a.BoundingBox;for(null!=b&&b.beginPath();!d.isEnd();)switch(d.nextCommand(),d.command){case "M":case "m":var f=d.getAsCurrentPoint();d.addMarker(f);c.addPoint(f.x,f.y);null!=b&&b.moveTo(f.x,f.y);for(d.start=d.current;!d.isCommandOrEnd();)f=d.getAsCurrentPoint(),d.addMarker(f,d.start),c.addPoint(f.x,f.y),null!=b&&b.lineTo(f.x,f.y);break;case "L":case "l":for(;!d.isCommandOrEnd();){var g=d.current,f=d.getAsCurrentPoint();d.addMarker(f,g);c.addPoint(f.x,f.y);null!=b&&b.lineTo(f.x,f.y)}break;case "H":case "h":for(;!d.isCommandOrEnd();)f=
new a.Point((d.isRelativeCommand()?d.current.x:0)+d.getScalar(),d.current.y),d.addMarker(f,d.current),d.current=f,c.addPoint(d.current.x,d.current.y),null!=b&&b.lineTo(d.current.x,d.current.y);break;case "V":case "v":for(;!d.isCommandOrEnd();)f=new a.Point(d.current.x,(d.isRelativeCommand()?d.current.y:0)+d.getScalar()),d.addMarker(f,d.current),d.current=f,c.addPoint(d.current.x,d.current.y),null!=b&&b.lineTo(d.current.x,d.current.y);break;case "C":case "c":for(;!d.isCommandOrEnd();){var m=d.current,
g=d.getPoint(),n=d.getAsControlPoint(),f=d.getAsCurrentPoint();d.addMarker(f,n,g);c.addBezierCurve(m.x,m.y,g.x,g.y,n.x,n.y,f.x,f.y);null!=b&&b.bezierCurveTo(g.x,g.y,n.x,n.y,f.x,f.y)}break;case "S":case "s":for(;!d.isCommandOrEnd();)m=d.current,g=d.getReflectedControlPoint(),n=d.getAsControlPoint(),f=d.getAsCurrentPoint(),d.addMarker(f,n,g),c.addBezierCurve(m.x,m.y,g.x,g.y,n.x,n.y,f.x,f.y),null!=b&&b.bezierCurveTo(g.x,g.y,n.x,n.y,f.x,f.y);break;case "Q":case "q":for(;!d.isCommandOrEnd();)m=d.current,
n=d.getAsControlPoint(),f=d.getAsCurrentPoint(),d.addMarker(f,n,n),c.addQuadraticCurve(m.x,m.y,n.x,n.y,f.x,f.y),null!=b&&b.quadraticCurveTo(n.x,n.y,f.x,f.y);break;case "T":case "t":for(;!d.isCommandOrEnd();)m=d.current,n=d.getReflectedControlPoint(),d.control=n,f=d.getAsCurrentPoint(),d.addMarker(f,n,n),c.addQuadraticCurve(m.x,m.y,n.x,n.y,f.x,f.y),null!=b&&b.quadraticCurveTo(n.x,n.y,f.x,f.y);break;case "A":case "a":for(;!d.isCommandOrEnd();){var m=d.current,r=d.getScalar(),h=d.getScalar(),g=d.getScalar()*
(Math.PI/180),p=d.getScalar(),n=d.getScalar(),f=d.getAsCurrentPoint(),l=new a.Point(Math.cos(g)*(m.x-f.x)/2+Math.sin(g)*(m.y-f.y)/2,-Math.sin(g)*(m.x-f.x)/2+Math.cos(g)*(m.y-f.y)/2),v=Math.pow(l.x,2)/Math.pow(r,2)+Math.pow(l.y,2)/Math.pow(h,2);1<v&&(r*=Math.sqrt(v),h*=Math.sqrt(v));p=(p==n?-1:1)*Math.sqrt((Math.pow(r,2)*Math.pow(h,2)-Math.pow(r,2)*Math.pow(l.y,2)-Math.pow(h,2)*Math.pow(l.x,2))/(Math.pow(r,2)*Math.pow(l.y,2)+Math.pow(h,2)*Math.pow(l.x,2)));isNaN(p)&&(p=0);var q=new a.Point(p*r*l.y/
h,p*-h*l.x/r),m=new a.Point((m.x+f.x)/2+Math.cos(g)*q.x-Math.sin(g)*q.y,(m.y+f.y)/2+Math.sin(g)*q.x+Math.cos(g)*q.y),w=function(a,b){return(a[0]*b[0]+a[1]*b[1])/(Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2))*Math.sqrt(Math.pow(b[0],2)+Math.pow(b[1],2)))},x=function(a,b){return(a[0]*b[1]<a[1]*b[0]?-1:1)*Math.acos(w(a,b))},p=x([1,0],[(l.x-q.x)/r,(l.y-q.y)/h]),v=[(l.x-q.x)/r,(l.y-q.y)/h],q=[(-l.x-q.x)/r,(-l.y-q.y)/h],l=x(v,q);-1>=w(v,q)&&(l=Math.PI);1<=w(v,q)&&(l=0);v=1-n?1:-1;q=p+l/2*v;x=new a.Point(m.x+
r*Math.cos(q),m.y+h*Math.sin(q));d.addMarkerAngle(x,q-v*Math.PI/2);d.addMarkerAngle(f,q-v*Math.PI);c.addPoint(f.x,f.y);null!=b&&(w=r>h?r:h,f=r>h?1:r/h,r=r>h?h/r:1,b.translate(m.x,m.y),b.rotate(g),b.scale(f,r),b.arc(0,0,w,p,p+l,1-n),b.scale(1/f,1/r),b.rotate(-g),b.translate(-m.x,-m.y))}break;case "Z":case "z":null!=b&&b.closePath(),d.current=d.start}return c};this.getMarkers=function(){for(var a=this.PathParser.getMarkerPoints(),b=this.PathParser.getMarkerAngles(),c=[],f=0;f<a.length;f++)c.push([a[f],
b[f]]);return c}};a.Element.path.prototype=new a.Element.PathElementBase;a.Element.pattern=function(c){this.base=a.Element.ElementBase;this.base(c);this.createPattern=function(b,e){var d=this.attribute("width").toPixels("x",!0),c=this.attribute("height").toPixels("y",!0),f=new a.Element.svg;f.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);f.attributes.width=new a.Property("width",d+"px");f.attributes.height=new a.Property("height",c+"px");f.attributes.transform=new a.Property("transform",
this.attribute("patternTransform").value);f.children=this.children;var g=document.createElement("canvas");g.width=d;g.height=c;d=g.getContext("2d");this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&d.translate(this.attribute("x").toPixels("x",!0),this.attribute("y").toPixels("y",!0));for(c=-1;1>=c;c++)for(var m=-1;1>=m;m++)d.save(),f.attributes.x=new a.Property("x",c*g.width),f.attributes.y=new a.Property("y",m*g.height),f.render(d),d.restore();return b.createPattern(g,"repeat")}};a.Element.pattern.prototype=
new a.Element.ElementBase;a.Element.marker=function(c){this.base=a.Element.ElementBase;this.base(c);this.baseRender=this.render;this.render=function(b,e,d){b.translate(e.x,e.y);"auto"==this.attribute("orient").valueOrDefault("auto")&&b.rotate(d);"strokeWidth"==this.attribute("markerUnits").valueOrDefault("strokeWidth")&&b.scale(b.lineWidth,b.lineWidth);b.save();var c=new a.Element.svg;c.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);c.attributes.refX=new a.Property("refX",
this.attribute("refX").value);c.attributes.refY=new a.Property("refY",this.attribute("refY").value);c.attributes.width=new a.Property("width",this.attribute("markerWidth").value);c.attributes.height=new a.Property("height",this.attribute("markerHeight").value);c.attributes.fill=new a.Property("fill",this.attribute("fill").valueOrDefault("black"));c.attributes.stroke=new a.Property("stroke",this.attribute("stroke").valueOrDefault("none"));c.children=this.children;c.render(b);b.restore();"strokeWidth"==
this.attribute("markerUnits").valueOrDefault("strokeWidth")&&b.scale(1/b.lineWidth,1/b.lineWidth);"auto"==this.attribute("orient").valueOrDefault("auto")&&b.rotate(-d);b.translate(-e.x,-e.y)}};a.Element.marker.prototype=new a.Element.ElementBase;a.Element.defs=function(c){this.base=a.Element.ElementBase;this.base(c);this.render=function(a){}};a.Element.defs.prototype=new a.Element.ElementBase;a.Element.GradientBase=function(c){this.base=a.Element.ElementBase;this.base(c);this.stops=[];for(c=0;c<this.children.length;c++){var b=
this.children[c];"stop"==b.type&&this.stops.push(b)}this.getGradient=function(){};this.gradientUnits=function(){return this.attribute("gradientUnits").valueOrDefault("objectBoundingBox")};this.attributesToInherit=["gradientUnits"];this.inheritStopContainer=function(a){for(var b=0;b<this.attributesToInherit.length;b++){var c=this.attributesToInherit[b];!this.attribute(c).hasValue()&&a.attribute(c).hasValue()&&(this.attribute(c,!0).value=a.attribute(c).value)}};this.createGradient=function(b,d,c){var f=
this;this.getHrefAttribute().hasValue()&&(f=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(f));var g=function(b){return c.hasValue()?(new a.Property("color",b)).addOpacity(c).value:b};b=this.getGradient(b,d);if(null==b)return g(f.stops[f.stops.length-1].color);for(d=0;d<f.stops.length;d++)b.addColorStop(f.stops[d].offset,g(f.stops[d].color));return this.attribute("gradientTransform").hasValue()?(f=a.ViewPort.viewPorts[0],g=new a.Element.rect,g.attributes.x=new a.Property("x",-a.MAX_VIRTUAL_PIXELS/
3),g.attributes.y=new a.Property("y",-a.MAX_VIRTUAL_PIXELS/3),g.attributes.width=new a.Property("width",a.MAX_VIRTUAL_PIXELS),g.attributes.height=new a.Property("height",a.MAX_VIRTUAL_PIXELS),d=new a.Element.g,d.attributes.transform=new a.Property("transform",this.attribute("gradientTransform").value),d.children=[g],g=new a.Element.svg,g.attributes.x=new a.Property("x",0),g.attributes.y=new a.Property("y",0),g.attributes.width=new a.Property("width",f.width),g.attributes.height=new a.Property("height",
f.height),g.children=[d],d=document.createElement("canvas"),d.width=f.width,d.height=f.height,f=d.getContext("2d"),f.fillStyle=b,g.render(f),f.createPattern(d,"no-repeat")):b}};a.Element.GradientBase.prototype=new a.Element.ElementBase;a.Element.linearGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.attributesToInherit.push("x1");this.attributesToInherit.push("y1");this.attributesToInherit.push("x2");this.attributesToInherit.push("y2");this.getGradient=function(a,e){var c="objectBoundingBox"==
this.gradientUnits()?e.getBoundingBox():null;this.attribute("x1").hasValue()||this.attribute("y1").hasValue()||this.attribute("x2").hasValue()||this.attribute("y2").hasValue()||(this.attribute("x1",!0).value=0,this.attribute("y1",!0).value=0,this.attribute("x2",!0).value=1,this.attribute("y2",!0).value=0);var k="objectBoundingBox"==this.gradientUnits()?c.x()+c.width()*this.attribute("x1").numValue():this.attribute("x1").toPixels("x"),f="objectBoundingBox"==this.gradientUnits()?c.y()+c.height()*this.attribute("y1").numValue():
this.attribute("y1").toPixels("y"),g="objectBoundingBox"==this.gradientUnits()?c.x()+c.width()*this.attribute("x2").numValue():this.attribute("x2").toPixels("x"),c="objectBoundingBox"==this.gradientUnits()?c.y()+c.height()*this.attribute("y2").numValue():this.attribute("y2").toPixels("y");return k==g&&f==c?null:a.createLinearGradient(k,f,g,c)}};a.Element.linearGradient.prototype=new a.Element.GradientBase;a.Element.radialGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.attributesToInherit.push("cx");
this.attributesToInherit.push("cy");this.attributesToInherit.push("r");this.attributesToInherit.push("fx");this.attributesToInherit.push("fy");this.getGradient=function(a,c){var d=c.getBoundingBox();this.attribute("cx").hasValue()||(this.attribute("cx",!0).value="50%");this.attribute("cy").hasValue()||(this.attribute("cy",!0).value="50%");this.attribute("r").hasValue()||(this.attribute("r",!0).value="50%");var k="objectBoundingBox"==this.gradientUnits()?d.x()+d.width()*this.attribute("cx").numValue():
this.attribute("cx").toPixels("x"),f="objectBoundingBox"==this.gradientUnits()?d.y()+d.height()*this.attribute("cy").numValue():this.attribute("cy").toPixels("y"),g=k,m=f;this.attribute("fx").hasValue()&&(g="objectBoundingBox"==this.gradientUnits()?d.x()+d.width()*this.attribute("fx").numValue():this.attribute("fx").toPixels("x"));this.attribute("fy").hasValue()&&(m="objectBoundingBox"==this.gradientUnits()?d.y()+d.height()*this.attribute("fy").numValue():this.attribute("fy").toPixels("y"));d="objectBoundingBox"==
this.gradientUnits()?(d.width()+d.height())/2*this.attribute("r").numValue():this.attribute("r").toPixels();return a.createRadialGradient(g,m,0,k,f,d)}};a.Element.radialGradient.prototype=new a.Element.GradientBase;a.Element.stop=function(c){this.base=a.Element.ElementBase;this.base(c);this.offset=this.attribute("offset").numValue();0>this.offset&&(this.offset=0);1<this.offset&&(this.offset=1);c=this.style("stop-color",!0);""===c.value&&(c.value="#000");this.style("stop-opacity").hasValue()&&(c=c.addOpacity(this.style("stop-opacity")));
this.color=c.value};a.Element.stop.prototype=new a.Element.ElementBase;a.Element.AnimateBase=function(c){this.base=a.Element.ElementBase;this.base(c);a.Animations.push(this);this.duration=0;this.begin=this.attribute("begin").toMilliseconds();this.maxDuration=this.begin+this.attribute("dur").toMilliseconds();this.getProperty=function(){var a=this.attribute("attributeType").value,c=this.attribute("attributeName").value;return"CSS"==a?this.parent.style(c,!0):this.parent.attribute(c,!0)};this.initialValue=
null;this.initialUnits="";this.removed=!1;this.calcValue=function(){return""};this.update=function(a){null==this.initialValue&&(this.initialValue=this.getProperty().value,this.initialUnits=this.getProperty().getUnits());if(this.duration>this.maxDuration){if("indefinite"==this.attribute("repeatCount").value||"indefinite"==this.attribute("repeatDur").value)this.duration=0;else if("freeze"==this.attribute("fill").valueOrDefault("remove")&&!this.frozen)this.frozen=!0,this.parent.animationFrozen=!0,this.parent.animationFrozenValue=
this.getProperty().value;else if("remove"==this.attribute("fill").valueOrDefault("remove")&&!this.removed)return this.removed=!0,this.getProperty().value=this.parent.animationFrozen?this.parent.animationFrozenValue:this.initialValue,!0;return!1}this.duration+=a;a=!1;this.begin<this.duration&&(a=this.calcValue(),this.attribute("type").hasValue()&&(a=this.attribute("type").value+"("+a+")"),this.getProperty().value=a,a=!0);return a};this.from=this.attribute("from");this.to=this.attribute("to");this.values=
this.attribute("values");this.values.hasValue()&&(this.values.value=this.values.value.split(";"));this.progress=function(){var b={progress:(this.duration-this.begin)/(this.maxDuration-this.begin)};if(this.values.hasValue()){var c=b.progress*(this.values.value.length-1),d=Math.floor(c),k=Math.ceil(c);b.from=new a.Property("from",parseFloat(this.values.value[d]));b.to=new a.Property("to",parseFloat(this.values.value[k]));b.progress=(c-d)/(k-d)}else b.from=this.from,b.to=this.to;return b}};a.Element.AnimateBase.prototype=
new a.Element.ElementBase;a.Element.animate=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=this.progress();return a.from.numValue()+(a.to.numValue()-a.from.numValue())*a.progress+this.initialUnits}};a.Element.animate.prototype=new a.Element.AnimateBase;a.Element.animateColor=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=this.progress(),c=new x(a.from.value),d=new x(a.to.value);if(c.ok&&d.ok){var k=c.g+(d.g-c.g)*a.progress,
f=c.b+(d.b-c.b)*a.progress;return"rgb("+parseInt(c.r+(d.r-c.r)*a.progress,10)+","+parseInt(k,10)+","+parseInt(f,10)+")"}return this.attribute("from").value}};a.Element.animateColor.prototype=new a.Element.AnimateBase;a.Element.animateTransform=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){for(var b=this.progress(),c=a.ToNumberArray(b.from.value),d=a.ToNumberArray(b.to.value),k="",f=0;f<c.length;f++)k+=c[f]+(d[f]-c[f])*b.progress+" ";return k}};a.Element.animateTransform.prototype=
new a.Element.animate;a.Element.font=function(c){this.base=a.Element.ElementBase;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.isArabic=this.isRTL=!1;this.missingGlyph=this.fontFace=null;this.glyphs=[];for(c=0;c<this.children.length;c++){var b=this.children[c];"font-face"==b.type?(this.fontFace=b,b.style("font-family").hasValue()&&(a.Definitions[b.style("font-family").value]=this)):"missing-glyph"==b.type?this.missingGlyph=b:"glyph"==b.type&&(""!=b.arabicForm?(this.isArabic=
this.isRTL=!0,"undefined"==typeof this.glyphs[b.unicode]&&(this.glyphs[b.unicode]=[]),this.glyphs[b.unicode][b.arabicForm]=b):this.glyphs[b.unicode]=b)}};a.Element.font.prototype=new a.Element.ElementBase;a.Element.fontface=function(c){this.base=a.Element.ElementBase;this.base(c);this.ascent=this.attribute("ascent").value;this.descent=this.attribute("descent").value;this.unitsPerEm=this.attribute("units-per-em").numValue()};a.Element.fontface.prototype=new a.Element.ElementBase;a.Element.missingglyph=
function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=0};a.Element.missingglyph.prototype=new a.Element.path;a.Element.glyph=function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.unicode=this.attribute("unicode").value;this.arabicForm=this.attribute("arabic-form").value};a.Element.glyph.prototype=new a.Element.path;a.Element.text=function(c){this.captureTextNodes=!0;this.base=a.Element.RenderedElementBase;this.base(c);this.baseSetContext=
this.setContext;this.setContext=function(a){this.baseSetContext(a);var c=this.style("dominant-baseline").toTextBaseline();null==c&&(c=this.style("alignment-baseline").toTextBaseline());null!=c&&(a.textBaseline=c)};this.getBoundingBox=function(){var b=this.attribute("x").toPixels("x"),c=this.attribute("y").toPixels("y"),d=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize);return new a.BoundingBox(b,c-d,b+Math.floor(2*d/3)*this.children[0].getText().length,c)};this.renderChildren=
function(a){this.x=this.attribute("x").toPixels("x");this.y=this.attribute("y").toPixels("y");this.attribute("dx").hasValue()&&(this.x+=this.attribute("dx").toPixels("x"));this.attribute("dy").hasValue()&&(this.y+=this.attribute("dy").toPixels("y"));this.x+=this.getAnchorDelta(a,this,0);for(var c=0;c<this.children.length;c++)this.renderChild(a,this,c)};this.getAnchorDelta=function(a,c,d){var k=this.style("text-anchor").valueOrDefault("start");if("start"!=k){for(var f=0,g=d;g<c.children.length;g++){var m=
c.children[g];if(g>d&&m.attribute("x").hasValue())break;f+=m.measureTextRecursive(a)}return-1*("end"==k?f:f/2)}return 0};this.renderChild=function(a,c,d){var k=c.children[d];k.attribute("x").hasValue()?(k.x=k.attribute("x").toPixels("x")+c.getAnchorDelta(a,c,d),k.attribute("dx").hasValue()&&(k.x+=k.attribute("dx").toPixels("x"))):(k.attribute("dx").hasValue()&&(c.x+=k.attribute("dx").toPixels("x")),k.x=c.x);c.x=k.x+k.measureText(a);k.attribute("y").hasValue()?(k.y=k.attribute("y").toPixels("y"),k.attribute("dy").hasValue()&&
(k.y+=k.attribute("dy").toPixels("y"))):(k.attribute("dy").hasValue()&&(c.y+=k.attribute("dy").toPixels("y")),k.y=c.y);c.y=k.y;k.render(a);for(d=0;d<k.children.length;d++)c.renderChild(a,k,d)}};a.Element.text.prototype=new a.Element.RenderedElementBase;a.Element.TextElementBase=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getGlyph=function(a,c,d){var k=c[d],f=null;if(a.isArabic){var g="isolated";(0==d||" "==c[d-1])&&d<c.length-2&&" "!=c[d+1]&&(g="terminal");0<d&&" "!=c[d-
1]&&d<c.length-2&&" "!=c[d+1]&&(g="medial");0<d&&" "!=c[d-1]&&(d==c.length-1||" "==c[d+1])&&(g="initial");"undefined"!=typeof a.glyphs[k]&&(f=a.glyphs[k][g],null==f&&"glyph"==a.glyphs[k].type&&(f=a.glyphs[k]))}else f=a.glyphs[k];null==f&&(f=a.missingGlyph);return f};this.renderChildren=function(b){var c=this.parent.style("font-family").getDefinition();if(null!=c){var d=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize),k=this.parent.style("font-style").valueOrDefault(a.Font.Parse(a.ctx.font).fontStyle),
f=this.getText();c.isRTL&&(f=f.split("").reverse().join(""));for(var g=a.ToNumberArray(this.parent.attribute("dx").value),m=0;m<f.length;m++){var n=this.getGlyph(c,f,m),h=d/c.fontFace.unitsPerEm;b.translate(this.x,this.y);b.scale(h,-h);var l=b.lineWidth;b.lineWidth=b.lineWidth*c.fontFace.unitsPerEm/d;"italic"==k&&b.transform(1,0,.4,1,0,0);n.render(b);"italic"==k&&b.transform(1,0,-.4,1,0,0);b.lineWidth=l;b.scale(1/h,-1/h);b.translate(-this.x,-this.y);this.x+=d*(n.horizAdvX||c.horizAdvX)/c.fontFace.unitsPerEm;
"undefined"==typeof g[m]||isNaN(g[m])||(this.x+=g[m])}}else""!=b.fillStyle&&b.fillText(a.compressSpaces(this.getText()),this.x,this.y),""!=b.strokeStyle&&b.strokeText(a.compressSpaces(this.getText()),this.x,this.y)};this.getText=function(){};this.measureTextRecursive=function(a){for(var c=this.measureText(a),d=0;d<this.children.length;d++)c+=this.children[d].measureTextRecursive(a);return c};this.measureText=function(b){var c=this.parent.style("font-family").getDefinition();if(null!=c){b=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize);
var d=0,k=this.getText();c.isRTL&&(k=k.split("").reverse().join(""));for(var f=a.ToNumberArray(this.parent.attribute("dx").value),g=0;g<k.length;g++){var m=this.getGlyph(c,k,g),d=d+(m.horizAdvX||c.horizAdvX)*b/c.fontFace.unitsPerEm;"undefined"==typeof f[g]||isNaN(f[g])||(d+=f[g])}return d}c=a.compressSpaces(this.getText());if(!b.measureText)return 10*c.length;b.save();this.setContext(b);c=b.measureText(c).width;b.restore();return c}};a.Element.TextElementBase.prototype=new a.Element.RenderedElementBase;
a.Element.tspan=function(c){this.captureTextNodes=!0;this.base=a.Element.TextElementBase;this.base(c);this.text=a.compressSpaces(c.value||c.text||c.textContent||"");this.getText=function(){return 0<this.children.length?"":this.text}};a.Element.tspan.prototype=new a.Element.TextElementBase;a.Element.tref=function(c){this.base=a.Element.TextElementBase;this.base(c);this.getText=function(){var a=this.getHrefAttribute().getDefinition();if(null!=a)return a.children[0].getText()}};a.Element.tref.prototype=
new a.Element.TextElementBase;a.Element.a=function(c){this.base=a.Element.TextElementBase;this.base(c);this.hasText=0<c.childNodes.length;for(var b=0;b<c.childNodes.length;b++)3!=c.childNodes[b].nodeType&&(this.hasText=!1);this.text=this.hasText?c.childNodes[0].value:"";this.getText=function(){return this.text};this.baseRenderChildren=this.renderChildren;this.renderChildren=function(b){if(this.hasText){this.baseRenderChildren(b);var c=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);a.Mouse.checkBoundingBox(this,
new a.BoundingBox(this.x,this.y-c.toPixels("y"),this.x+this.measureText(b),this.y))}else 0<this.children.length&&(c=new a.Element.g,c.children=this.children,c.parent=this,c.render(b))};this.onclick=function(){window.open(this.getHrefAttribute().value)};this.onmousemove=function(){a.ctx.canvas.style.cursor="pointer"}};a.Element.a.prototype=new a.Element.TextElementBase;a.Element.image=function(c){this.base=a.Element.RenderedElementBase;this.base(c);var b=this.getHrefAttribute().value;if(""!=b){var e=
b.match(/\.svg$/);a.Images.push(this);this.loaded=!1;if(e)this.img=a.ajax(b),this.loaded=!0;else{this.img=document.createElement("img");1==a.opts.useCORS&&(this.img.crossOrigin="Anonymous");var d=this;this.img.onload=function(){d.loaded=!0};this.img.onerror=function(){a.log('ERROR: image "'+b+'" not found');d.loaded=!0};this.img.src=b}this.renderChildren=function(b){var c=this.attribute("x").toPixels("x"),d=this.attribute("y").toPixels("y"),m=this.attribute("width").toPixels("x"),n=this.attribute("height").toPixels("y");
0!=m&&0!=n&&(b.save(),e?b.drawSvg(this.img,c,d,m,n):(b.translate(c,d),a.AspectRatio(b,this.attribute("preserveAspectRatio").value,m,this.img.width,n,this.img.height,0,0),b.drawImage(this.img,0,0)),b.restore())};this.getBoundingBox=function(){var b=this.attribute("x").toPixels("x"),c=this.attribute("y").toPixels("y"),d=this.attribute("width").toPixels("x"),e=this.attribute("height").toPixels("y");return new a.BoundingBox(b,c,b+d,c+e)}}};a.Element.image.prototype=new a.Element.RenderedElementBase;a.Element.g=
function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getBoundingBox=function(){for(var b=new a.BoundingBox,c=0;c<this.children.length;c++)b.addBoundingBox(this.children[c].getBoundingBox());return b}};a.Element.g.prototype=new a.Element.RenderedElementBase;a.Element.symbol=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.render=function(a){}};a.Element.symbol.prototype=new a.Element.RenderedElementBase;a.Element.style=function(c){this.base=a.Element.ElementBase;
this.base(c);for(var b="",e=0;e<c.childNodes.length;e++)b+=c.childNodes[e].data;b=b.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"");b=a.compressSpaces(b);c=b.split("}");for(e=0;e<c.length;e++)if(""!=a.trim(c[e]))for(var d=c[e].split("{"),b=d[0].split(","),d=d[1].split(";"),k=0;k<b.length;k++){var f=a.trim(b[k]);if(""!=f){for(var g=a.Styles[f]||{},m=0;m<d.length;m++){var n=d[m].indexOf(":"),h=d[m].substr(0,n),n=d[m].substr(n+1,d[m].length-n);null!=h&&null!=n&&(g[a.trim(h)]=
new a.Property(a.trim(h),a.trim(n)))}a.Styles[f]=g;a.StylesSpecificity[f]=A(f);if("@font-face"==f)for(f=g["font-family"].value.replace(/"/g,""),g=g.src.value.split(","),m=0;m<g.length;m++)if(0<g[m].indexOf('format("svg")'))for(h=g[m].indexOf("url"),n=g[m].indexOf(")",h),h=g[m].substr(h+5,n-h-6),h=a.parseXml(a.ajax(h)).getElementsByTagName("font"),n=0;n<h.length;n++){var l=a.CreateElement(h[n]);a.Definitions[f]=l}}}};a.Element.style.prototype=new a.Element.ElementBase;a.Element.use=function(c){this.base=
a.Element.RenderedElementBase;this.base(c);this.baseSetContext=this.setContext;this.setContext=function(a){this.baseSetContext(a);this.attribute("x").hasValue()&&a.translate(this.attribute("x").toPixels("x"),0);this.attribute("y").hasValue()&&a.translate(0,this.attribute("y").toPixels("y"))};var b=this.getHrefAttribute().getDefinition();this.path=function(a){null!=b&&b.path(a)};this.getBoundingBox=function(){if(null!=b)return b.getBoundingBox()};this.renderChildren=function(c){if(null!=b){var d=b;
"symbol"==b.type&&(d=new a.Element.svg,d.type="svg",d.attributes.viewBox=new a.Property("viewBox",b.attribute("viewBox").value),d.attributes.preserveAspectRatio=new a.Property("preserveAspectRatio",b.attribute("preserveAspectRatio").value),d.attributes.overflow=new a.Property("overflow",b.attribute("overflow").value),d.children=b.children);"svg"==d.type&&(this.attribute("width").hasValue()&&(d.attributes.width=new a.Property("width",this.attribute("width").value)),this.attribute("height").hasValue()&&
(d.attributes.height=new a.Property("height",this.attribute("height").value)));var k=d.parent;d.parent=null;d.render(c);d.parent=k}}};a.Element.use.prototype=new a.Element.RenderedElementBase;a.Element.mask=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(b,c){var d=this.attribute("x").toPixels("x"),k=this.attribute("y").toPixels("y"),f=this.attribute("width").toPixels("x"),g=this.attribute("height").toPixels("y");if(0==f&&0==g){g=new a.BoundingBox;for(d=0;d<this.children.length;d++)g.addBoundingBox(this.children[d].getBoundingBox());
d=Math.floor(g.x1);k=Math.floor(g.y1);f=Math.floor(g.width());g=Math.floor(g.height())}var m=c.attribute("mask").value;c.attribute("mask").value="";var n=document.createElement("canvas");n.width=d+f;n.height=k+g;var h=n.getContext("2d");this.renderChildren(h);var l=document.createElement("canvas");l.width=d+f;l.height=k+g;var p=l.getContext("2d");c.render(p);p.globalCompositeOperation="destination-in";p.fillStyle=h.createPattern(n,"no-repeat");p.fillRect(0,0,d+f,k+g);b.fillStyle=p.createPattern(l,
"no-repeat");b.fillRect(0,0,d+f,k+g);c.attribute("mask").value=m};this.render=function(a){}};a.Element.mask.prototype=new a.Element.ElementBase;a.Element.clipPath=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(b){var c=CanvasRenderingContext2D.prototype.beginPath;CanvasRenderingContext2D.prototype.beginPath=function(){};var d=CanvasRenderingContext2D.prototype.closePath;CanvasRenderingContext2D.prototype.closePath=function(){};c.call(b);for(var k=0;k<this.children.length;k++){var f=
this.children[k];if("undefined"!=typeof f.path){var g=null;f.style("transform",!1,!0).hasValue()&&(g=new a.Transform(f.style("transform",!1,!0).value),g.apply(b));f.path(b);CanvasRenderingContext2D.prototype.closePath=d;g&&g.unapply(b)}}d.call(b);b.clip();CanvasRenderingContext2D.prototype.beginPath=c;CanvasRenderingContext2D.prototype.closePath=d};this.render=function(a){}};a.Element.clipPath.prototype=new a.Element.ElementBase;a.Element.filter=function(c){this.base=a.Element.ElementBase;this.base(c);
this.apply=function(a,c){var d=c.getBoundingBox(),k=Math.floor(d.x1),f=Math.floor(d.y1),g=Math.floor(d.width()),d=Math.floor(d.height()),m=c.style("filter").value;c.style("filter").value="";for(var h=0,l=0,u=0;u<this.children.length;u++)var p=this.children[u].extraFilterDistance||0,h=Math.max(h,p),l=Math.max(l,p);p=document.createElement("canvas");p.width=g+2*h;p.height=d+2*l;var t=p.getContext("2d");t.translate(-k+h,-f+l);c.render(t);for(u=0;u<this.children.length;u++)"function"===typeof this.children[u].apply&&
this.children[u].apply(t,0,0,g+2*h,d+2*l);a.drawImage(p,0,0,g+2*h,d+2*l,k-h,f-l,g+2*h,d+2*l);c.style("filter",!0).value=m};this.render=function(a){}};a.Element.filter.prototype=new a.Element.ElementBase;a.Element.feMorphology=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,c,d,k,f){}};a.Element.feMorphology.prototype=new a.Element.ElementBase;a.Element.feComposite=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,c,d,k,f){}};a.Element.feComposite.prototype=
new a.Element.ElementBase;a.Element.feColorMatrix=function(c){function b(a,b){var c=e[a];return c*(0>c?b-255:b)}this.base=a.Element.ElementBase;this.base(c);var e=a.ToNumberArray(this.attribute("values").value);switch(this.attribute("type").valueOrDefault("matrix")){case "saturate":c=e[0];e=[.213+.787*c,.715-.715*c,.072-.072*c,0,0,.213-.213*c,.715+.285*c,.072-.072*c,0,0,.213-.213*c,.715-.715*c,.072+.928*c,0,0,0,0,0,1,0,0,0,0,0,1];break;case "hueRotate":var d=e[0]*Math.PI/180;c=function(a,b,c){return a+
Math.cos(d)*b+Math.sin(d)*c};e=[c(.213,.787,-.213),c(.715,-.715,-.715),c(.072,-.072,.928),0,0,c(.213,-.213,.143),c(.715,.285,.14),c(.072,-.072,-.283),0,0,c(.213,-.213,-.787),c(.715,-.715,.715),c(.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break;case "luminanceToAlpha":e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}this.apply=function(a,c,d,e,h){var l=a.getImageData(0,0,e,h);for(d=0;d<h;d++)for(c=0;c<e;c++){var u=l.data[d*e*4+4*c+0],p=l.data[d*e*4+4*c+1],t=l.data[d*e*4+4*c+2],v=l.data[d*
e*4+4*c+3],q=b(0,u)+b(1,p)+b(2,t)+b(3,v)+b(4,1);l.data[d*e*4+4*c+0]=q;q=b(5,u)+b(6,p)+b(7,t)+b(8,v)+b(9,1);l.data[d*e*4+4*c+1]=q;q=b(10,u)+b(11,p)+b(12,t)+b(13,v)+b(14,1);l.data[d*e*4+4*c+2]=q;u=b(15,u)+b(16,p)+b(17,t)+b(18,v)+b(19,1);l.data[d*e*4+4*c+3]=u}a.clearRect(0,0,e,h);a.putImageData(l,0,0)}};a.Element.feColorMatrix.prototype=new a.Element.ElementBase;a.Element.feGaussianBlur=function(c){this.base=a.Element.ElementBase;this.base(c);this.extraFilterDistance=this.blurRadius=Math.floor(this.attribute("stdDeviation").numValue());
this.apply=function(b,c,d,k,f){"undefined"==typeof y.canvasRGBA?a.log("ERROR: StackBlur.js must be included for blur to work"):(b.canvas.id=a.UniqueId(),b.canvas.style.display="none",document.body.appendChild(b.canvas),y.canvasRGBA(b.canvas.id,c,d,k,f,this.blurRadius),document.body.removeChild(b.canvas))}};a.Element.feGaussianBlur.prototype=new a.Element.ElementBase;a.Element.title=function(a){};a.Element.title.prototype=new a.Element.ElementBase;a.Element.desc=function(a){};a.Element.desc.prototype=
new a.Element.ElementBase;a.Element.MISSING=function(c){a.log("ERROR: Element '"+c.nodeName+"' not yet implemented.")};a.Element.MISSING.prototype=new a.Element.ElementBase;a.CreateElement=function(c){var b=c.nodeName.replace(/^[^:]+:/,""),b=b.replace(/\-/g,""),b="undefined"!=typeof a.Element[b]?new a.Element[b](c):new a.Element.MISSING(c);b.type=c.nodeName;return b};a.load=function(c,b){a.loadXml(c,a.ajax(b))};a.loadXml=function(c,b){a.loadXmlDoc(c,a.parseXml(b))};a.loadXmlDoc=function(c,b){a.init(c);
var e=function(a){for(var b=c.canvas;b;)a.x-=b.offsetLeft,a.y-=b.offsetTop,b=b.offsetParent;window.scrollX&&(a.x+=window.scrollX);window.scrollY&&(a.y+=window.scrollY);return a};1!=a.opts.ignoreMouse&&(c.canvas.onclick=function(b){b=e(new a.Point(null!=b?b.clientX:event.clientX,null!=b?b.clientY:event.clientY));a.Mouse.onclick(b.x,b.y)},c.canvas.onmousemove=function(b){b=e(new a.Point(null!=b?b.clientX:event.clientX,null!=b?b.clientY:event.clientY));a.Mouse.onmousemove(b.x,b.y)});var d=a.CreateElement(b.documentElement);
d.root=!0;d.addStylesFromStyleDefinition();var k=!0,f=function(){a.ViewPort.Clear();c.canvas.parentNode&&a.ViewPort.SetCurrent(c.canvas.parentNode.clientWidth,c.canvas.parentNode.clientHeight);1!=a.opts.ignoreDimensions&&(d.style("width").hasValue()&&(c.canvas.width=d.style("width").toPixels("x"),c.canvas.style.width=c.canvas.width+"px"),d.style("height").hasValue()&&(c.canvas.height=d.style("height").toPixels("y"),c.canvas.style.height=c.canvas.height+"px"));var e=c.canvas.clientWidth||c.canvas.width,
f=c.canvas.clientHeight||c.canvas.height;1==a.opts.ignoreDimensions&&d.style("width").hasValue()&&d.style("height").hasValue()&&(e=d.style("width").toPixels("x"),f=d.style("height").toPixels("y"));a.ViewPort.SetCurrent(e,f);null!=a.opts.offsetX&&(d.attribute("x",!0).value=a.opts.offsetX);null!=a.opts.offsetY&&(d.attribute("y",!0).value=a.opts.offsetY);if(null!=a.opts.scaleWidth||null!=a.opts.scaleHeight){var g=null,h=null,l=a.ToNumberArray(d.attribute("viewBox").value);null!=a.opts.scaleWidth&&(d.attribute("width").hasValue()?
g=d.attribute("width").toPixels("x")/a.opts.scaleWidth:isNaN(l[2])||(g=l[2]/a.opts.scaleWidth));null!=a.opts.scaleHeight&&(d.attribute("height").hasValue()?h=d.attribute("height").toPixels("y")/a.opts.scaleHeight:isNaN(l[3])||(h=l[3]/a.opts.scaleHeight));null==g&&(g=h);null==h&&(h=g);d.attribute("width",!0).value=a.opts.scaleWidth;d.attribute("height",!0).value=a.opts.scaleHeight;d.style("transform",!0,!0).value+=" scale("+1/g+","+1/h+")"}1!=a.opts.ignoreClear&&c.clearRect(0,0,e,f);d.render(c);k&&
(k=!1,"function"==typeof a.opts.renderCallback&&a.opts.renderCallback(b))},g=!0;a.ImagesLoaded()&&(g=!1,f());a.intervalID=setInterval(function(){var b=!1;g&&a.ImagesLoaded()&&(g=!1,b=!0);1!=a.opts.ignoreMouse&&(b|=a.Mouse.hasEvents());if(1!=a.opts.ignoreAnimation)for(var c=0;c<a.Animations.length;c++)b|=a.Animations[c].update(1E3/a.FRAMERATE);"function"==typeof a.opts.forceRedraw&&1==a.opts.forceRedraw()&&(b=!0);b&&(f(),a.Mouse.runEvents())},1E3/a.FRAMERATE)};a.stop=function(){a.intervalID&&clearInterval(a.intervalID)};
a.Mouse=new function(){this.events=[];this.hasEvents=function(){return 0!=this.events.length};this.onclick=function(a,b){this.events.push({type:"onclick",x:a,y:b,run:function(a){if(a.onclick)a.onclick()}})};this.onmousemove=function(a,b){this.events.push({type:"onmousemove",x:a,y:b,run:function(a){if(a.onmousemove)a.onmousemove()}})};this.eventElements=[];this.checkPath=function(a,b){for(var e=0;e<this.events.length;e++){var d=this.events[e];b.isPointInPath&&b.isPointInPath(d.x,d.y)&&(this.eventElements[e]=
a)}};this.checkBoundingBox=function(a,b){for(var e=0;e<this.events.length;e++){var d=this.events[e];b.isPointInBox(d.x,d.y)&&(this.eventElements[e]=a)}};this.runEvents=function(){a.ctx.canvas.style.cursor="";for(var c=0;c<this.events.length;c++)for(var b=this.events[c],e=this.eventElements[c];e;)b.run(e),e=e.parent;this.events=[];this.eventElements=[]}};return a}var z=function(h,a,l){if(null==h&&null==a&&null==l)for(a=document.querySelectorAll("svg"),h=0;h<a.length;h++){l=a[h];var c=document.createElement("canvas");
c.width=l.clientWidth;c.height=l.clientHeight;l.parentNode.insertBefore(c,l);l.parentNode.removeChild(l);var b=document.createElement("div");b.appendChild(l);z(c,b.innerHTML)}else{"string"==typeof h&&(h=document.getElementById(h));null!=h.svg&&h.svg.stop();l=I(l||{});if(1!=h.childNodes.length||"OBJECT"!=h.childNodes[0].nodeName)h.svg=l;h=h.getContext("2d");"undefined"!=typeof a.documentElement?l.loadXmlDoc(h,a):"<"==a.substr(0,1)?l.loadXml(h,a):l.load(h,a)}},w;if("undefined"!=typeof Element.prototype.matches)w=
function(h,a){return h.matches(a)};else if("undefined"!=typeof Element.prototype.webkitMatchesSelector)w=function(h,a){return h.webkitMatchesSelector(a)};else if("undefined"!=typeof Element.prototype.mozMatchesSelector)w=function(h,a){return h.mozMatchesSelector(a)};else if("undefined"!=typeof Element.prototype.msMatchesSelector)w=function(h,a){return h.msMatchesSelector(a)};else if("undefined"!=typeof Element.prototype.oMatchesSelector)w=function(h,a){return h.oMatchesSelector(a)};else{if("function"===
typeof jQuery||"function"===typeof Zepto)w=function(h,a){return $(h).is(a)};"undefined"===typeof w&&(w=Sizzle.matchesSelector)}var B=/(\[[^\]]+\])/g,C=/(#[^\s\+>~\.\[:]+)/g,D=/(\.[^\s\+>~\.\[:]+)/g,E=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,F=/(:[\w-]+\([^\)]*\))/gi,G=/(:[^\s\+>~\.\[:]+)/g,H=/([^\s\+>~\.\[:]+)/g;"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.drawSvg=function(h,a,l,c,b){z(this.canvas,h,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,
ignoreClear:!0,offsetX:a,offsetY:l,scaleWidth:c,scaleHeight:b})});return z});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 | 2 2 2 2 1 1 1 1 1 | /** @preserve
* canvg.js - Javascript SVG parser and renderer on Canvas
* MIT Licensed
* Gabe Lerner (gabelerner@gmail.com)
* http://code.google.com/p/canvg/
*
* Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/
*/
(function ( global, factory ) {
'use strict';
// export as AMD...
Iif ( typeof define !== 'undefined' && define.amd ) {
define('canvgModule', [ 'rgbcolor', 'stackblur' ], factory );
}
// ...or as browserify
else Eif ( typeof module !== 'undefined' && module.exports ) {
module.exports = factory( require( 'rgbcolor' ), require( 'stackblur' ) );
}
global.canvg = factory( global.RGBColor, global.stackBlur );
}( typeof window !== 'undefined' ? window : this, function ( RGBColor, stackBlur ) {
// canvg(target, s)
// empty parameters: replace all 'svg' elements on page with 'canvas' elements
// target: canvas element or the id of a canvas element
// s: svg string, url to svg file, or xml document
// opts: optional hash of options
// ignoreMouse: true => ignore mouse events
// ignoreAnimation: true => ignore animations
// ignoreDimensions: true => does not try to resize canvas
// ignoreClear: true => does not clear canvas
// offsetX: int => draws at a x offset
// offsetY: int => draws at a y offset
// scaleWidth: int => scales horizontally to width
// scaleHeight: int => scales vertically to height
// renderCallback: function => will call the function after the first render is completed
// forceRedraw: function => will call the function on every frame, if it returns true, will redraw
var canvg = function (target, s, opts) {
// no parameters
if (target == null && s == null && opts == null) {
var svgTags = document.querySelectorAll('svg');
for (var i=0; i<svgTags.length; i++) {
var svgTag = svgTags[i];
var c = document.createElement('canvas');
c.width = svgTag.clientWidth;
c.height = svgTag.clientHeight;
svgTag.parentNode.insertBefore(c, svgTag);
svgTag.parentNode.removeChild(svgTag);
var div = document.createElement('div');
div.appendChild(svgTag);
canvg(c, div.innerHTML);
}
return;
}
if (typeof target == 'string') {
target = document.getElementById(target);
}
// store class on canvas
if (target.svg != null) target.svg.stop();
var svg = build(opts || {});
// on i.e. 8 for flash canvas, we can't assign the property so check for it
if (!(target.childNodes.length == 1 && target.childNodes[0].nodeName == 'OBJECT')) target.svg = svg;
var ctx = target.getContext('2d');
if (typeof(s.documentElement) != 'undefined') {
// load from xml doc
svg.loadXmlDoc(ctx, s);
}
else if (s.substr(0,1) == '<') {
// load from xml string
svg.loadXml(ctx, s);
}
else {
// load from url
svg.load(ctx, s);
}
}
// see https://developer.mozilla.org/en-US/docs/Web/API/Element.matches
var matchesSelector;
if (typeof(Element.prototype.matches) != 'undefined') {
matchesSelector = function(node, selector) {
return node.matches(selector);
};
} else if (typeof(Element.prototype.webkitMatchesSelector) != 'undefined') {
matchesSelector = function(node, selector) {
return node.webkitMatchesSelector(selector);
};
} else if (typeof(Element.prototype.mozMatchesSelector) != 'undefined') {
matchesSelector = function(node, selector) {
return node.mozMatchesSelector(selector);
};
} else if (typeof(Element.prototype.msMatchesSelector) != 'undefined') {
matchesSelector = function(node, selector) {
return node.msMatchesSelector(selector);
};
} else if (typeof(Element.prototype.oMatchesSelector) != 'undefined') {
matchesSelector = function(node, selector) {
return node.oMatchesSelector(selector);
};
} else {
// requires Sizzle: https://github.com/jquery/sizzle/wiki/Sizzle-Documentation
// or jQuery: http://jquery.com/download/
// or Zepto: http://zeptojs.com/#
// without it, this is a ReferenceError
if (typeof jQuery === 'function' || typeof Zepto === 'function') {
matchesSelector = function (node, selector) {
return $(node).is(selector);
};
}
if (typeof matchesSelector === 'undefined') {
matchesSelector = Sizzle.matchesSelector;
}
}
// slightly modified version of https://github.com/keeganstreet/specificity/blob/master/specificity.js
var attributeRegex = /(\[[^\]]+\])/g;
var idRegex = /(#[^\s\+>~\.\[:]+)/g;
var classRegex = /(\.[^\s\+>~\.\[:]+)/g;
var pseudoElementRegex = /(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi;
var pseudoClassWithBracketsRegex = /(:[\w-]+\([^\)]*\))/gi;
var pseudoClassRegex = /(:[^\s\+>~\.\[:]+)/g;
var elementRegex = /([^\s\+>~\.\[:]+)/g;
function getSelectorSpecificity(selector) {
var typeCount = [0, 0, 0];
var findMatch = function(regex, type) {
var matches = selector.match(regex);
if (matches == null) {
return;
}
typeCount[type] += matches.length;
selector = selector.replace(regex, ' ');
};
selector = selector.replace(/:not\(([^\)]*)\)/g, ' $1 ');
selector = selector.replace(/{[^]*/gm, ' ');
findMatch(attributeRegex, 1);
findMatch(idRegex, 0);
findMatch(classRegex, 1);
findMatch(pseudoElementRegex, 2);
findMatch(pseudoClassWithBracketsRegex, 1);
findMatch(pseudoClassRegex, 1);
selector = selector.replace(/[\*\s\+>~]/g, ' ');
selector = selector.replace(/[#\.]/g, ' ');
findMatch(elementRegex, 2);
return typeCount.join('');
}
function build(opts) {
var svg = { opts: opts };
svg.FRAMERATE = 30;
svg.MAX_VIRTUAL_PIXELS = 30000;
svg.log = function(msg) {};
if (svg.opts['log'] == true && typeof(console) != 'undefined') {
svg.log = function(msg) { console.log(msg); };
};
// globals
svg.init = function(ctx) {
var uniqueId = 0;
svg.UniqueId = function () { uniqueId++; return 'canvg' + uniqueId; };
svg.Definitions = {};
svg.Styles = {};
svg.StylesSpecificity = {};
svg.Animations = [];
svg.Images = [];
svg.ctx = ctx;
svg.ViewPort = new (function () {
this.viewPorts = [];
this.Clear = function() { this.viewPorts = []; }
this.SetCurrent = function(width, height) { this.viewPorts.push({ width: width, height: height }); }
this.RemoveCurrent = function() { this.viewPorts.pop(); }
this.Current = function() { return this.viewPorts[this.viewPorts.length - 1]; }
this.width = function() { return this.Current().width; }
this.height = function() { return this.Current().height; }
this.ComputeSize = function(d) {
if (d != null && typeof(d) == 'number') return d;
if (d == 'x') return this.width();
if (d == 'y') return this.height();
return Math.sqrt(Math.pow(this.width(), 2) + Math.pow(this.height(), 2)) / Math.sqrt(2);
}
});
}
svg.init();
// images loaded
svg.ImagesLoaded = function() {
for (var i=0; i<svg.Images.length; i++) {
if (!svg.Images[i].loaded) return false;
}
return true;
}
// trim
svg.trim = function(s) { return s.replace(/^\s+|\s+$/g, ''); }
// compress spaces
svg.compressSpaces = function(s) { return s.replace(/[\s\r\t\n]+/gm,' '); }
// ajax
svg.ajax = function(url) {
var AJAX;
if(window.XMLHttpRequest){AJAX=new XMLHttpRequest();}
else{AJAX=new ActiveXObject('Microsoft.XMLHTTP');}
if(AJAX){
AJAX.open('GET',url,false);
AJAX.send(null);
return AJAX.responseText;
}
return null;
}
// parse xml
svg.parseXml = function(xml) {
if (typeof(Windows) != 'undefined' && typeof(Windows.Data) != 'undefined' && typeof(Windows.Data.Xml) != 'undefined') {
var xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
var settings = new Windows.Data.Xml.Dom.XmlLoadSettings();
settings.prohibitDtd = false;
xmlDoc.loadXml(xml, settings);
return xmlDoc;
}
else if (window.DOMParser)
{
var parser = new DOMParser();
return parser.parseFromString(xml, 'text/xml');
}
else
{
xml = xml.replace(/<!DOCTYPE svg[^>]*>/, '');
var xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async = 'false';
xmlDoc.loadXML(xml);
return xmlDoc;
}
}
svg.Property = function(name, value) {
this.name = name;
this.value = value;
}
svg.Property.prototype.getValue = function() {
return this.value;
}
svg.Property.prototype.hasValue = function() {
return (this.value != null && this.value !== '');
}
// return the numerical value of the property
svg.Property.prototype.numValue = function() {
if (!this.hasValue()) return 0;
var n = parseFloat(this.value);
if ((this.value + '').match(/%$/)) {
n = n / 100.0;
}
return n;
}
svg.Property.prototype.valueOrDefault = function(def) {
if (this.hasValue()) return this.value;
return def;
}
svg.Property.prototype.numValueOrDefault = function(def) {
if (this.hasValue()) return this.numValue();
return def;
}
// color extensions
// augment the current color value with the opacity
svg.Property.prototype.addOpacity = function(opacityProp) {
var newValue = this.value;
if (opacityProp.value != null && opacityProp.value != '' && typeof(this.value)=='string') { // can only add opacity to colors, not patterns
var color = new RGBColor(this.value);
if (color.ok) {
newValue = 'rgba(' + color.r + ', ' + color.g + ', ' + color.b + ', ' + opacityProp.numValue() + ')';
}
}
return new svg.Property(this.name, newValue);
}
// definition extensions
// get the definition from the definitions table
svg.Property.prototype.getDefinition = function() {
var name = this.value.match(/#([^\)'"]+)/);
if (name) { name = name[1]; }
if (!name) { name = this.value; }
return svg.Definitions[name];
}
svg.Property.prototype.isUrlDefinition = function() {
return this.value.indexOf('url(') == 0
}
svg.Property.prototype.getFillStyleDefinition = function(e, opacityProp) {
var def = this.getDefinition();
// gradient
if (def != null && def.createGradient) {
return def.createGradient(svg.ctx, e, opacityProp);
}
// pattern
if (def != null && def.createPattern) {
if (def.getHrefAttribute().hasValue()) {
var pt = def.attribute('patternTransform');
def = def.getHrefAttribute().getDefinition();
if (pt.hasValue()) { def.attribute('patternTransform', true).value = pt.value; }
}
return def.createPattern(svg.ctx, e);
}
return null;
}
// length extensions
svg.Property.prototype.getDPI = function(viewPort) {
return 96.0; // TODO: compute?
}
svg.Property.prototype.getEM = function(viewPort) {
var em = 12;
var fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize);
if (fontSize.hasValue()) em = fontSize.toPixels(viewPort);
return em;
}
svg.Property.prototype.getUnits = function() {
var s = this.value+'';
return s.replace(/[0-9\.\-]/g,'');
}
// get the length as pixels
svg.Property.prototype.toPixels = function(viewPort, processPercent) {
if (!this.hasValue()) return 0;
var s = this.value+'';
if (s.match(/em$/)) return this.numValue() * this.getEM(viewPort);
if (s.match(/ex$/)) return this.numValue() * this.getEM(viewPort) / 2.0;
if (s.match(/px$/)) return this.numValue();
if (s.match(/pt$/)) return this.numValue() * this.getDPI(viewPort) * (1.0 / 72.0);
if (s.match(/pc$/)) return this.numValue() * 15;
if (s.match(/cm$/)) return this.numValue() * this.getDPI(viewPort) / 2.54;
if (s.match(/mm$/)) return this.numValue() * this.getDPI(viewPort) / 25.4;
if (s.match(/in$/)) return this.numValue() * this.getDPI(viewPort);
if (s.match(/%$/)) return this.numValue() * svg.ViewPort.ComputeSize(viewPort);
var n = this.numValue();
if (processPercent && n < 1.0) return n * svg.ViewPort.ComputeSize(viewPort);
return n;
}
// time extensions
// get the time as milliseconds
svg.Property.prototype.toMilliseconds = function() {
if (!this.hasValue()) return 0;
var s = this.value+'';
if (s.match(/s$/)) return this.numValue() * 1000;
if (s.match(/ms$/)) return this.numValue();
return this.numValue();
}
// angle extensions
// get the angle as radians
svg.Property.prototype.toRadians = function() {
if (!this.hasValue()) return 0;
var s = this.value+'';
if (s.match(/deg$/)) return this.numValue() * (Math.PI / 180.0);
if (s.match(/grad$/)) return this.numValue() * (Math.PI / 200.0);
if (s.match(/rad$/)) return this.numValue();
return this.numValue() * (Math.PI / 180.0);
}
// text extensions
// get the text baseline
var textBaselineMapping = {
'baseline': 'alphabetic',
'before-edge': 'top',
'text-before-edge': 'top',
'middle': 'middle',
'central': 'middle',
'after-edge': 'bottom',
'text-after-edge': 'bottom',
'ideographic': 'ideographic',
'alphabetic': 'alphabetic',
'hanging': 'hanging',
'mathematical': 'alphabetic'
};
svg.Property.prototype.toTextBaseline = function () {
if (!this.hasValue()) return null;
return textBaselineMapping[this.value];
}
// fonts
svg.Font = new (function() {
this.Styles = 'normal|italic|oblique|inherit';
this.Variants = 'normal|small-caps|inherit';
this.Weights = 'normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit';
this.CreateFont = function(fontStyle, fontVariant, fontWeight, fontSize, fontFamily, inherit) {
var f = inherit != null ? this.Parse(inherit) : this.CreateFont('', '', '', '', '', svg.ctx.font);
return {
fontFamily: fontFamily || f.fontFamily,
fontSize: fontSize || f.fontSize,
fontStyle: fontStyle || f.fontStyle,
fontWeight: fontWeight || f.fontWeight,
fontVariant: fontVariant || f.fontVariant,
toString: function () { return [this.fontStyle, this.fontVariant, this.fontWeight, this.fontSize, this.fontFamily].join(' ') }
}
}
var that = this;
this.Parse = function(s) {
var f = {};
var d = svg.trim(svg.compressSpaces(s || '')).split(' ');
var set = { fontSize: false, fontStyle: false, fontWeight: false, fontVariant: false }
var ff = '';
for (var i=0; i<d.length; i++) {
if (!set.fontStyle && that.Styles.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontStyle = d[i]; set.fontStyle = true; }
else if (!set.fontVariant && that.Variants.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontVariant = d[i]; set.fontStyle = set.fontVariant = true; }
else if (!set.fontWeight && that.Weights.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontWeight = d[i]; set.fontStyle = set.fontVariant = set.fontWeight = true; }
else if (!set.fontSize) { if (d[i] != 'inherit') f.fontSize = d[i].split('/')[0]; set.fontStyle = set.fontVariant = set.fontWeight = set.fontSize = true; }
else { if (d[i] != 'inherit') ff += d[i]; }
} if (ff != '') f.fontFamily = ff;
return f;
}
});
// points and paths
svg.ToNumberArray = function(s) {
var a = svg.trim(svg.compressSpaces((s || '').replace(/,/g, ' '))).split(' ');
for (var i=0; i<a.length; i++) {
a[i] = parseFloat(a[i]);
}
return a;
}
svg.Point = function(x, y) {
this.x = x;
this.y = y;
}
svg.Point.prototype.angleTo = function(p) {
return Math.atan2(p.y - this.y, p.x - this.x);
}
svg.Point.prototype.applyTransform = function(v) {
var xp = this.x * v[0] + this.y * v[2] + v[4];
var yp = this.x * v[1] + this.y * v[3] + v[5];
this.x = xp;
this.y = yp;
}
svg.CreatePoint = function(s) {
var a = svg.ToNumberArray(s);
return new svg.Point(a[0], a[1]);
}
svg.CreatePath = function(s) {
var a = svg.ToNumberArray(s);
var path = [];
for (var i=0; i<a.length; i+=2) {
path.push(new svg.Point(a[i], a[i+1]));
}
return path;
}
// bounding box
svg.BoundingBox = function(x1, y1, x2, y2) { // pass in initial points if you want
this.x1 = Number.NaN;
this.y1 = Number.NaN;
this.x2 = Number.NaN;
this.y2 = Number.NaN;
this.x = function() { return this.x1; }
this.y = function() { return this.y1; }
this.width = function() { return this.x2 - this.x1; }
this.height = function() { return this.y2 - this.y1; }
this.addPoint = function(x, y) {
if (x != null) {
if (isNaN(this.x1) || isNaN(this.x2)) {
this.x1 = x;
this.x2 = x;
}
if (x < this.x1) this.x1 = x;
if (x > this.x2) this.x2 = x;
}
if (y != null) {
if (isNaN(this.y1) || isNaN(this.y2)) {
this.y1 = y;
this.y2 = y;
}
if (y < this.y1) this.y1 = y;
if (y > this.y2) this.y2 = y;
}
}
this.addX = function(x) { this.addPoint(x, null); }
this.addY = function(y) { this.addPoint(null, y); }
this.addBoundingBox = function(bb) {
this.addPoint(bb.x1, bb.y1);
this.addPoint(bb.x2, bb.y2);
}
this.addQuadraticCurve = function(p0x, p0y, p1x, p1y, p2x, p2y) {
var cp1x = p0x + 2/3 * (p1x - p0x); // CP1 = QP0 + 2/3 *(QP1-QP0)
var cp1y = p0y + 2/3 * (p1y - p0y); // CP1 = QP0 + 2/3 *(QP1-QP0)
var cp2x = cp1x + 1/3 * (p2x - p0x); // CP2 = CP1 + 1/3 *(QP2-QP0)
var cp2y = cp1y + 1/3 * (p2y - p0y); // CP2 = CP1 + 1/3 *(QP2-QP0)
this.addBezierCurve(p0x, p0y, cp1x, cp2x, cp1y, cp2y, p2x, p2y);
}
this.addBezierCurve = function(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) {
// from http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
var p0 = [p0x, p0y], p1 = [p1x, p1y], p2 = [p2x, p2y], p3 = [p3x, p3y];
this.addPoint(p0[0], p0[1]);
this.addPoint(p3[0], p3[1]);
for (i=0; i<=1; i++) {
var f = function(t) {
return Math.pow(1-t, 3) * p0[i]
+ 3 * Math.pow(1-t, 2) * t * p1[i]
+ 3 * (1-t) * Math.pow(t, 2) * p2[i]
+ Math.pow(t, 3) * p3[i];
}
var b = 6 * p0[i] - 12 * p1[i] + 6 * p2[i];
var a = -3 * p0[i] + 9 * p1[i] - 9 * p2[i] + 3 * p3[i];
var c = 3 * p1[i] - 3 * p0[i];
if (a == 0) {
if (b == 0) continue;
var t = -c / b;
if (0 < t && t < 1) {
if (i == 0) this.addX(f(t));
if (i == 1) this.addY(f(t));
}
continue;
}
var b2ac = Math.pow(b, 2) - 4 * c * a;
if (b2ac < 0) continue;
var t1 = (-b + Math.sqrt(b2ac)) / (2 * a);
if (0 < t1 && t1 < 1) {
if (i == 0) this.addX(f(t1));
if (i == 1) this.addY(f(t1));
}
var t2 = (-b - Math.sqrt(b2ac)) / (2 * a);
if (0 < t2 && t2 < 1) {
if (i == 0) this.addX(f(t2));
if (i == 1) this.addY(f(t2));
}
}
}
this.isPointInBox = function(x, y) {
return (this.x1 <= x && x <= this.x2 && this.y1 <= y && y <= this.y2);
}
this.addPoint(x1, y1);
this.addPoint(x2, y2);
}
// transforms
svg.Transform = function(v) {
var that = this;
this.Type = {}
// translate
this.Type.translate = function(s) {
this.p = svg.CreatePoint(s);
this.apply = function(ctx) {
ctx.translate(this.p.x || 0.0, this.p.y || 0.0);
}
this.unapply = function(ctx) {
ctx.translate(-1.0 * this.p.x || 0.0, -1.0 * this.p.y || 0.0);
}
this.applyToPoint = function(p) {
p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]);
}
}
// rotate
this.Type.rotate = function(s) {
var a = svg.ToNumberArray(s);
this.angle = new svg.Property('angle', a[0]);
this.cx = a[1] || 0;
this.cy = a[2] || 0;
this.apply = function(ctx) {
ctx.translate(this.cx, this.cy);
ctx.rotate(this.angle.toRadians());
ctx.translate(-this.cx, -this.cy);
}
this.unapply = function(ctx) {
ctx.translate(this.cx, this.cy);
ctx.rotate(-1.0 * this.angle.toRadians());
ctx.translate(-this.cx, -this.cy);
}
this.applyToPoint = function(p) {
var a = this.angle.toRadians();
p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]);
p.applyTransform([Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0]);
p.applyTransform([1, 0, 0, 1, -this.p.x || 0.0, -this.p.y || 0.0]);
}
}
this.Type.scale = function(s) {
this.p = svg.CreatePoint(s);
this.apply = function(ctx) {
ctx.scale(this.p.x || 1.0, this.p.y || this.p.x || 1.0);
}
this.unapply = function(ctx) {
ctx.scale(1.0 / this.p.x || 1.0, 1.0 / this.p.y || this.p.x || 1.0);
}
this.applyToPoint = function(p) {
p.applyTransform([this.p.x || 0.0, 0, 0, this.p.y || 0.0, 0, 0]);
}
}
this.Type.matrix = function(s) {
this.m = svg.ToNumberArray(s);
this.apply = function(ctx) {
ctx.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]);
}
this.unapply = function(ctx) {
var a = this.m[0];
var b = this.m[2];
var c = this.m[4];
var d = this.m[1];
var e = this.m[3];
var f = this.m[5];
var g = 0.0;
var h = 0.0;
var i = 1.0;
var det = 1 / (a*(e*i-f*h)-b*(d*i-f*g)+c*(d*h-e*g));
ctx.transform(
det*(e*i-f*h),
det*(f*g-d*i),
det*(c*h-b*i),
det*(a*i-c*g),
det*(b*f-c*e),
det*(c*d-a*f)
);
}
this.applyToPoint = function(p) {
p.applyTransform(this.m);
}
}
this.Type.SkewBase = function(s) {
this.base = that.Type.matrix;
this.base(s);
this.angle = new svg.Property('angle', s);
}
this.Type.SkewBase.prototype = new this.Type.matrix;
this.Type.skewX = function(s) {
this.base = that.Type.SkewBase;
this.base(s);
this.m = [1, 0, Math.tan(this.angle.toRadians()), 1, 0, 0];
}
this.Type.skewX.prototype = new this.Type.SkewBase;
this.Type.skewY = function(s) {
this.base = that.Type.SkewBase;
this.base(s);
this.m = [1, Math.tan(this.angle.toRadians()), 0, 1, 0, 0];
}
this.Type.skewY.prototype = new this.Type.SkewBase;
this.transforms = [];
this.apply = function(ctx) {
for (var i=0; i<this.transforms.length; i++) {
this.transforms[i].apply(ctx);
}
}
this.unapply = function(ctx) {
for (var i=this.transforms.length-1; i>=0; i--) {
this.transforms[i].unapply(ctx);
}
}
this.applyToPoint = function(p) {
for (var i=0; i<this.transforms.length; i++) {
this.transforms[i].applyToPoint(p);
}
}
var data = svg.trim(svg.compressSpaces(v)).replace(/\)([a-zA-Z])/g, ') $1').replace(/\)(\s?,\s?)/g,') ').split(/\s(?=[a-z])/);
for (var i=0; i<data.length; i++) {
var type = svg.trim(data[i].split('(')[0]);
var s = data[i].split('(')[1].replace(')','');
var transform = new this.Type[type](s);
transform.type = type;
this.transforms.push(transform);
}
}
// aspect ratio
svg.AspectRatio = function(ctx, aspectRatio, width, desiredWidth, height, desiredHeight, minX, minY, refX, refY) {
// aspect ratio - http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute
aspectRatio = svg.compressSpaces(aspectRatio);
aspectRatio = aspectRatio.replace(/^defer\s/,''); // ignore defer
var align = aspectRatio.split(' ')[0] || 'xMidYMid';
var meetOrSlice = aspectRatio.split(' ')[1] || 'meet';
// calculate scale
var scaleX = width / desiredWidth;
var scaleY = height / desiredHeight;
var scaleMin = Math.min(scaleX, scaleY);
var scaleMax = Math.max(scaleX, scaleY);
if (meetOrSlice == 'meet') { desiredWidth *= scaleMin; desiredHeight *= scaleMin; }
if (meetOrSlice == 'slice') { desiredWidth *= scaleMax; desiredHeight *= scaleMax; }
refX = new svg.Property('refX', refX);
refY = new svg.Property('refY', refY);
if (refX.hasValue() && refY.hasValue()) {
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
}
else {
// align
if (align.match(/^xMid/) && ((meetOrSlice == 'meet' && scaleMin == scaleY) || (meetOrSlice == 'slice' && scaleMax == scaleY))) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.match(/YMid$/) && ((meetOrSlice == 'meet' && scaleMin == scaleX) || (meetOrSlice == 'slice' && scaleMax == scaleX))) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.match(/^xMax/) && ((meetOrSlice == 'meet' && scaleMin == scaleY) || (meetOrSlice == 'slice' && scaleMax == scaleY))) ctx.translate(width - desiredWidth, 0);
if (align.match(/YMax$/) && ((meetOrSlice == 'meet' && scaleMin == scaleX) || (meetOrSlice == 'slice' && scaleMax == scaleX))) ctx.translate(0, height - desiredHeight);
}
// scale
if (align == 'none') ctx.scale(scaleX, scaleY);
else if (meetOrSlice == 'meet') ctx.scale(scaleMin, scaleMin);
else if (meetOrSlice == 'slice') ctx.scale(scaleMax, scaleMax);
// translate
ctx.translate(minX == null ? 0 : -minX, minY == null ? 0 : -minY);
}
// elements
svg.Element = {}
svg.EmptyProperty = new svg.Property('EMPTY', '');
svg.Element.ElementBase = function(node) {
this.attributes = {};
this.styles = {};
this.stylesSpecificity = {};
this.children = [];
// get or create attribute
this.attribute = function(name, createIfNotExists) {
var a = this.attributes[name];
if (a != null) return a;
if (createIfNotExists == true) { a = new svg.Property(name, ''); this.attributes[name] = a; }
return a || svg.EmptyProperty;
}
this.getHrefAttribute = function() {
for (var a in this.attributes) {
if (a == 'href' || a.match(/:href$/)) {
return this.attributes[a];
}
}
return svg.EmptyProperty;
}
// get or create style, crawls up node tree
this.style = function(name, createIfNotExists, skipAncestors) {
var s = this.styles[name];
if (s != null) return s;
var a = this.attribute(name);
if (a != null && a.hasValue()) {
this.styles[name] = a; // move up to me to cache
return a;
}
if (skipAncestors != true) {
var p = this.parent;
if (p != null) {
var ps = p.style(name);
if (ps != null && ps.hasValue()) {
return ps;
}
}
}
if (createIfNotExists == true) { s = new svg.Property(name, ''); this.styles[name] = s; }
return s || svg.EmptyProperty;
}
// base render
this.render = function(ctx) {
// don't render display=none
if (this.style('display').value == 'none') return;
// don't render visibility=hidden
if (this.style('visibility').value == 'hidden') return;
ctx.save();
if (this.style('mask').hasValue()) { // mask
var mask = this.style('mask').getDefinition();
if (mask != null) mask.apply(ctx, this);
}
else if (this.style('filter').hasValue()) { // filter
var filter = this.style('filter').getDefinition();
if (filter != null) filter.apply(ctx, this);
}
else {
this.setContext(ctx);
this.renderChildren(ctx);
this.clearContext(ctx);
}
ctx.restore();
}
// base set context
this.setContext = function(ctx) {
// OVERRIDE ME!
}
// base clear context
this.clearContext = function(ctx) {
// OVERRIDE ME!
}
// base render children
this.renderChildren = function(ctx) {
for (var i=0; i<this.children.length; i++) {
this.children[i].render(ctx);
}
}
this.addChild = function(childNode, create) {
var child = childNode;
if (create) child = svg.CreateElement(childNode);
child.parent = this;
if (child.type != 'title') { this.children.push(child); }
}
this.addStylesFromStyleDefinition = function () {
// add styles
for (var selector in svg.Styles) {
if (selector[0] != '@' && matchesSelector(node, selector)) {
var styles = svg.Styles[selector];
var specificity = svg.StylesSpecificity[selector];
if (styles != null) {
for (var name in styles) {
var existingSpecificity = this.stylesSpecificity[name];
if (typeof(existingSpecificity) == 'undefined') {
existingSpecificity = '000';
}
if (specificity > existingSpecificity) {
this.styles[name] = styles[name];
this.stylesSpecificity[name] = specificity;
}
}
}
}
}
};
if (node != null && node.nodeType == 1) { //ELEMENT_NODE
// add attributes
for (var i=0; i<node.attributes.length; i++) {
var attribute = node.attributes[i];
this.attributes[attribute.nodeName] = new svg.Property(attribute.nodeName, attribute.value);
}
this.addStylesFromStyleDefinition();
// add inline styles
if (this.attribute('style').hasValue()) {
var styles = this.attribute('style').value.split(';');
for (var i=0; i<styles.length; i++) {
if (svg.trim(styles[i]) != '') {
var style = styles[i].split(':');
var name = svg.trim(style[0]);
var value = svg.trim(style[1]);
this.styles[name] = new svg.Property(name, value);
}
}
}
// add id
if (this.attribute('id').hasValue()) {
if (svg.Definitions[this.attribute('id').value] == null) {
svg.Definitions[this.attribute('id').value] = this;
}
}
// add children
for (var i=0; i<node.childNodes.length; i++) {
var childNode = node.childNodes[i];
if (childNode.nodeType == 1) this.addChild(childNode, true); //ELEMENT_NODE
if (this.captureTextNodes && (childNode.nodeType == 3 || childNode.nodeType == 4)) {
var text = childNode.value || childNode.text || childNode.textContent || '';
if (svg.compressSpaces(text) != '') {
this.addChild(new svg.Element.tspan(childNode), false); // TEXT_NODE
}
}
}
}
}
svg.Element.RenderedElementBase = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.setContext = function(ctx) {
// fill
if (this.style('fill').isUrlDefinition()) {
var fs = this.style('fill').getFillStyleDefinition(this, this.style('fill-opacity'));
if (fs != null) ctx.fillStyle = fs;
}
else if (this.style('fill').hasValue()) {
var fillStyle = this.style('fill');
if (fillStyle.value == 'currentColor') fillStyle.value = this.style('color').value;
if (fillStyle.value != 'inherit') ctx.fillStyle = (fillStyle.value == 'none' ? 'rgba(0,0,0,0)' : fillStyle.value);
}
if (this.style('fill-opacity').hasValue()) {
var fillStyle = new svg.Property('fill', ctx.fillStyle);
fillStyle = fillStyle.addOpacity(this.style('fill-opacity'));
ctx.fillStyle = fillStyle.value;
}
// stroke
if (this.style('stroke').isUrlDefinition()) {
var fs = this.style('stroke').getFillStyleDefinition(this, this.style('stroke-opacity'));
if (fs != null) ctx.strokeStyle = fs;
}
else if (this.style('stroke').hasValue()) {
var strokeStyle = this.style('stroke');
if (strokeStyle.value == 'currentColor') strokeStyle.value = this.style('color').value;
if (strokeStyle.value != 'inherit') ctx.strokeStyle = (strokeStyle.value == 'none' ? 'rgba(0,0,0,0)' : strokeStyle.value);
}
if (this.style('stroke-opacity').hasValue()) {
var strokeStyle = new svg.Property('stroke', ctx.strokeStyle);
strokeStyle = strokeStyle.addOpacity(this.style('stroke-opacity'));
ctx.strokeStyle = strokeStyle.value;
}
if (this.style('stroke-width').hasValue()) {
var newLineWidth = this.style('stroke-width').toPixels();
ctx.lineWidth = newLineWidth == 0 ? 0.001 : newLineWidth; // browsers don't respect 0
}
if (this.style('stroke-linecap').hasValue()) ctx.lineCap = this.style('stroke-linecap').value;
if (this.style('stroke-linejoin').hasValue()) ctx.lineJoin = this.style('stroke-linejoin').value;
if (this.style('stroke-miterlimit').hasValue()) ctx.miterLimit = this.style('stroke-miterlimit').value;
if (this.style('stroke-dasharray').hasValue() && this.style('stroke-dasharray').value != 'none') {
var gaps = svg.ToNumberArray(this.style('stroke-dasharray').value);
if (typeof(ctx.setLineDash) != 'undefined') { ctx.setLineDash(gaps); }
else if (typeof(ctx.webkitLineDash) != 'undefined') { ctx.webkitLineDash = gaps; }
else if (typeof(ctx.mozDash) != 'undefined' && !(gaps.length==1 && gaps[0]==0)) { ctx.mozDash = gaps; }
var offset = this.style('stroke-dashoffset').numValueOrDefault(1);
if (typeof(ctx.lineDashOffset) != 'undefined') { ctx.lineDashOffset = offset; }
else if (typeof(ctx.webkitLineDashOffset) != 'undefined') { ctx.webkitLineDashOffset = offset; }
else if (typeof(ctx.mozDashOffset) != 'undefined') { ctx.mozDashOffset = offset; }
}
// font
if (typeof(ctx.font) != 'undefined') {
ctx.font = svg.Font.CreateFont(
this.style('font-style').value,
this.style('font-variant').value,
this.style('font-weight').value,
this.style('font-size').hasValue() ? this.style('font-size').toPixels() + 'px' : '',
this.style('font-family').value).toString();
}
// transform
if (this.style('transform', false, true).hasValue()) {
var transform = new svg.Transform(this.style('transform', false, true).value);
transform.apply(ctx);
}
// clip
if (this.style('clip-path', false, true).hasValue()) {
var clip = this.style('clip-path', false, true).getDefinition();
if (clip != null) clip.apply(ctx);
}
// opacity
if (this.style('opacity').hasValue()) {
ctx.globalAlpha = this.style('opacity').numValue();
}
}
}
svg.Element.RenderedElementBase.prototype = new svg.Element.ElementBase;
svg.Element.PathElementBase = function(node) {
this.base = svg.Element.RenderedElementBase;
this.base(node);
this.path = function(ctx) {
if (ctx != null) ctx.beginPath();
return new svg.BoundingBox();
}
this.renderChildren = function(ctx) {
this.path(ctx);
svg.Mouse.checkPath(this, ctx);
if (ctx.fillStyle != '') {
if (this.style('fill-rule').valueOrDefault('inherit') != 'inherit') { ctx.fill(this.style('fill-rule').value); }
else { ctx.fill(); }
}
if (ctx.strokeStyle != '') ctx.stroke();
var markers = this.getMarkers();
if (markers != null) {
if (this.style('marker-start').isUrlDefinition()) {
var marker = this.style('marker-start').getDefinition();
marker.render(ctx, markers[0][0], markers[0][1]);
}
if (this.style('marker-mid').isUrlDefinition()) {
var marker = this.style('marker-mid').getDefinition();
for (var i=1;i<markers.length-1;i++) {
marker.render(ctx, markers[i][0], markers[i][1]);
}
}
if (this.style('marker-end').isUrlDefinition()) {
var marker = this.style('marker-end').getDefinition();
marker.render(ctx, markers[markers.length-1][0], markers[markers.length-1][1]);
}
}
}
this.getBoundingBox = function() {
return this.path();
}
this.getMarkers = function() {
return null;
}
}
svg.Element.PathElementBase.prototype = new svg.Element.RenderedElementBase;
// svg element
svg.Element.svg = function(node) {
this.base = svg.Element.RenderedElementBase;
this.base(node);
this.baseClearContext = this.clearContext;
this.clearContext = function(ctx) {
this.baseClearContext(ctx);
svg.ViewPort.RemoveCurrent();
}
this.baseSetContext = this.setContext;
this.setContext = function(ctx) {
// initial values and defaults
ctx.strokeStyle = 'rgba(0,0,0,0)';
ctx.lineCap = 'butt';
ctx.lineJoin = 'miter';
ctx.miterLimit = 4;
if (typeof(ctx.font) != 'undefined' && typeof(window.getComputedStyle) != 'undefined') {
ctx.font = window.getComputedStyle(ctx.canvas).getPropertyValue('font');
}
this.baseSetContext(ctx);
// create new view port
if (!this.attribute('x').hasValue()) this.attribute('x', true).value = 0;
if (!this.attribute('y').hasValue()) this.attribute('y', true).value = 0;
ctx.translate(this.attribute('x').toPixels('x'), this.attribute('y').toPixels('y'));
var width = svg.ViewPort.width();
var height = svg.ViewPort.height();
if (!this.attribute('width').hasValue()) this.attribute('width', true).value = '100%';
if (!this.attribute('height').hasValue()) this.attribute('height', true).value = '100%';
if (typeof(this.root) == 'undefined') {
width = this.attribute('width').toPixels('x');
height = this.attribute('height').toPixels('y');
var x = 0;
var y = 0;
if (this.attribute('refX').hasValue() && this.attribute('refY').hasValue()) {
x = -this.attribute('refX').toPixels('x');
y = -this.attribute('refY').toPixels('y');
}
if (this.attribute('overflow').valueOrDefault('hidden') != 'visible') {
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(width, y);
ctx.lineTo(width, height);
ctx.lineTo(x, height);
ctx.closePath();
ctx.clip();
}
}
svg.ViewPort.SetCurrent(width, height);
// viewbox
if (this.attribute('viewBox').hasValue()) {
var viewBox = svg.ToNumberArray(this.attribute('viewBox').value);
var minX = viewBox[0];
var minY = viewBox[1];
width = viewBox[2];
height = viewBox[3];
svg.AspectRatio(ctx,
this.attribute('preserveAspectRatio').value,
svg.ViewPort.width(),
width,
svg.ViewPort.height(),
height,
minX,
minY,
this.attribute('refX').value,
this.attribute('refY').value);
svg.ViewPort.RemoveCurrent();
svg.ViewPort.SetCurrent(viewBox[2], viewBox[3]);
}
}
}
svg.Element.svg.prototype = new svg.Element.RenderedElementBase;
// rect element
svg.Element.rect = function(node) {
this.base = svg.Element.PathElementBase;
this.base(node);
this.path = function(ctx) {
var x = this.attribute('x').toPixels('x');
var y = this.attribute('y').toPixels('y');
var width = this.attribute('width').toPixels('x');
var height = this.attribute('height').toPixels('y');
var rx = this.attribute('rx').toPixels('x');
var ry = this.attribute('ry').toPixels('y');
if (this.attribute('rx').hasValue() && !this.attribute('ry').hasValue()) ry = rx;
if (this.attribute('ry').hasValue() && !this.attribute('rx').hasValue()) rx = ry;
rx = Math.min(rx, width / 2.0);
ry = Math.min(ry, height / 2.0);
if (ctx != null) {
ctx.beginPath();
ctx.moveTo(x + rx, y);
ctx.lineTo(x + width - rx, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + ry)
ctx.lineTo(x + width, y + height - ry);
ctx.quadraticCurveTo(x + width, y + height, x + width - rx, y + height)
ctx.lineTo(x + rx, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - ry)
ctx.lineTo(x, y + ry);
ctx.quadraticCurveTo(x, y, x + rx, y)
ctx.closePath();
}
return new svg.BoundingBox(x, y, x + width, y + height);
}
}
svg.Element.rect.prototype = new svg.Element.PathElementBase;
// circle element
svg.Element.circle = function(node) {
this.base = svg.Element.PathElementBase;
this.base(node);
this.path = function(ctx) {
var cx = this.attribute('cx').toPixels('x');
var cy = this.attribute('cy').toPixels('y');
var r = this.attribute('r').toPixels();
if (ctx != null) {
ctx.beginPath();
ctx.arc(cx, cy, r, 0, Math.PI * 2, true);
ctx.closePath();
}
return new svg.BoundingBox(cx - r, cy - r, cx + r, cy + r);
}
}
svg.Element.circle.prototype = new svg.Element.PathElementBase;
// ellipse element
svg.Element.ellipse = function(node) {
this.base = svg.Element.PathElementBase;
this.base(node);
this.path = function(ctx) {
var KAPPA = 4 * ((Math.sqrt(2) - 1) / 3);
var rx = this.attribute('rx').toPixels('x');
var ry = this.attribute('ry').toPixels('y');
var cx = this.attribute('cx').toPixels('x');
var cy = this.attribute('cy').toPixels('y');
if (ctx != null) {
ctx.beginPath();
ctx.moveTo(cx, cy - ry);
ctx.bezierCurveTo(cx + (KAPPA * rx), cy - ry, cx + rx, cy - (KAPPA * ry), cx + rx, cy);
ctx.bezierCurveTo(cx + rx, cy + (KAPPA * ry), cx + (KAPPA * rx), cy + ry, cx, cy + ry);
ctx.bezierCurveTo(cx - (KAPPA * rx), cy + ry, cx - rx, cy + (KAPPA * ry), cx - rx, cy);
ctx.bezierCurveTo(cx - rx, cy - (KAPPA * ry), cx - (KAPPA * rx), cy - ry, cx, cy - ry);
ctx.closePath();
}
return new svg.BoundingBox(cx - rx, cy - ry, cx + rx, cy + ry);
}
}
svg.Element.ellipse.prototype = new svg.Element.PathElementBase;
// line element
svg.Element.line = function(node) {
this.base = svg.Element.PathElementBase;
this.base(node);
this.getPoints = function() {
return [
new svg.Point(this.attribute('x1').toPixels('x'), this.attribute('y1').toPixels('y')),
new svg.Point(this.attribute('x2').toPixels('x'), this.attribute('y2').toPixels('y'))];
}
this.path = function(ctx) {
var points = this.getPoints();
if (ctx != null) {
ctx.beginPath();
ctx.moveTo(points[0].x, points[0].y);
ctx.lineTo(points[1].x, points[1].y);
}
return new svg.BoundingBox(points[0].x, points[0].y, points[1].x, points[1].y);
}
this.getMarkers = function() {
var points = this.getPoints();
var a = points[0].angleTo(points[1]);
return [[points[0], a], [points[1], a]];
}
}
svg.Element.line.prototype = new svg.Element.PathElementBase;
// polyline element
svg.Element.polyline = function(node) {
this.base = svg.Element.PathElementBase;
this.base(node);
this.points = svg.CreatePath(this.attribute('points').value);
this.path = function(ctx) {
var bb = new svg.BoundingBox(this.points[0].x, this.points[0].y);
if (ctx != null) {
ctx.beginPath();
ctx.moveTo(this.points[0].x, this.points[0].y);
}
for (var i=1; i<this.points.length; i++) {
bb.addPoint(this.points[i].x, this.points[i].y);
if (ctx != null) ctx.lineTo(this.points[i].x, this.points[i].y);
}
return bb;
}
this.getMarkers = function() {
var markers = [];
for (var i=0; i<this.points.length - 1; i++) {
markers.push([this.points[i], this.points[i].angleTo(this.points[i+1])]);
}
markers.push([this.points[this.points.length-1], markers[markers.length-1][1]]);
return markers;
}
}
svg.Element.polyline.prototype = new svg.Element.PathElementBase;
// polygon element
svg.Element.polygon = function(node) {
this.base = svg.Element.polyline;
this.base(node);
this.basePath = this.path;
this.path = function(ctx) {
var bb = this.basePath(ctx);
if (ctx != null) {
ctx.lineTo(this.points[0].x, this.points[0].y);
ctx.closePath();
}
return bb;
}
}
svg.Element.polygon.prototype = new svg.Element.polyline;
// path element
svg.Element.path = function(node) {
this.base = svg.Element.PathElementBase;
this.base(node);
var d = this.attribute('d').value;
// TODO: convert to real lexer based on http://www.w3.org/TR/SVG11/paths.html#PathDataBNF
d = d.replace(/,/gm,' '); // get rid of all commas
// As the end of a match can also be the start of the next match, we need to run this replace twice.
for(var i=0; i<2; i++)
d = d.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,'$1 $2'); // suffix commands with spaces
d = d.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,'$1 $2'); // prefix commands with spaces
d = d.replace(/([0-9])([+\-])/gm,'$1 $2'); // separate digits on +- signs
// Again, we need to run this twice to find all occurances
for(var i=0; i<2; i++)
d = d.replace(/(\.[0-9]*)(\.)/gm,'$1 $2'); // separate digits when they start with a comma
d = d.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,'$1 $3 $4 '); // shorthand elliptical arc path syntax
d = svg.compressSpaces(d); // compress multiple spaces
d = svg.trim(d);
this.PathParser = new (function(d) {
this.tokens = d.split(' ');
this.reset = function() {
this.i = -1;
this.command = '';
this.previousCommand = '';
this.start = new svg.Point(0, 0);
this.control = new svg.Point(0, 0);
this.current = new svg.Point(0, 0);
this.points = [];
this.angles = [];
}
this.isEnd = function() {
return this.i >= this.tokens.length - 1;
}
this.isCommandOrEnd = function() {
if (this.isEnd()) return true;
return this.tokens[this.i + 1].match(/^[A-Za-z]$/) != null;
}
this.isRelativeCommand = function() {
switch(this.command)
{
case 'm':
case 'l':
case 'h':
case 'v':
case 'c':
case 's':
case 'q':
case 't':
case 'a':
case 'z':
return true;
break;
}
return false;
}
this.getToken = function() {
this.i++;
return this.tokens[this.i];
}
this.getScalar = function() {
return parseFloat(this.getToken());
}
this.nextCommand = function() {
this.previousCommand = this.command;
this.command = this.getToken();
}
this.getPoint = function() {
var p = new svg.Point(this.getScalar(), this.getScalar());
return this.makeAbsolute(p);
}
this.getAsControlPoint = function() {
var p = this.getPoint();
this.control = p;
return p;
}
this.getAsCurrentPoint = function() {
var p = this.getPoint();
this.current = p;
return p;
}
this.getReflectedControlPoint = function() {
if (this.previousCommand.toLowerCase() != 'c' &&
this.previousCommand.toLowerCase() != 's' &&
this.previousCommand.toLowerCase() != 'q' &&
this.previousCommand.toLowerCase() != 't' ){
return this.current;
}
// reflect point
var p = new svg.Point(2 * this.current.x - this.control.x, 2 * this.current.y - this.control.y);
return p;
}
this.makeAbsolute = function(p) {
if (this.isRelativeCommand()) {
p.x += this.current.x;
p.y += this.current.y;
}
return p;
}
this.addMarker = function(p, from, priorTo) {
// if the last angle isn't filled in because we didn't have this point yet ...
if (priorTo != null && this.angles.length > 0 && this.angles[this.angles.length-1] == null) {
this.angles[this.angles.length-1] = this.points[this.points.length-1].angleTo(priorTo);
}
this.addMarkerAngle(p, from == null ? null : from.angleTo(p));
}
this.addMarkerAngle = function(p, a) {
this.points.push(p);
this.angles.push(a);
}
this.getMarkerPoints = function() { return this.points; }
this.getMarkerAngles = function() {
for (var i=0; i<this.angles.length; i++) {
if (this.angles[i] == null) {
for (var j=i+1; j<this.angles.length; j++) {
if (this.angles[j] != null) {
this.angles[i] = this.angles[j];
break;
}
}
}
}
return this.angles;
}
})(d);
this.path = function(ctx) {
var pp = this.PathParser;
pp.reset();
var bb = new svg.BoundingBox();
if (ctx != null) ctx.beginPath();
while (!pp.isEnd()) {
pp.nextCommand();
switch (pp.command) {
case 'M':
case 'm':
var p = pp.getAsCurrentPoint();
pp.addMarker(p);
bb.addPoint(p.x, p.y);
if (ctx != null) ctx.moveTo(p.x, p.y);
pp.start = pp.current;
while (!pp.isCommandOrEnd()) {
var p = pp.getAsCurrentPoint();
pp.addMarker(p, pp.start);
bb.addPoint(p.x, p.y);
if (ctx != null) ctx.lineTo(p.x, p.y);
}
break;
case 'L':
case 'l':
while (!pp.isCommandOrEnd()) {
var c = pp.current;
var p = pp.getAsCurrentPoint();
pp.addMarker(p, c);
bb.addPoint(p.x, p.y);
if (ctx != null) ctx.lineTo(p.x, p.y);
}
break;
case 'H':
case 'h':
while (!pp.isCommandOrEnd()) {
var newP = new svg.Point((pp.isRelativeCommand() ? pp.current.x : 0) + pp.getScalar(), pp.current.y);
pp.addMarker(newP, pp.current);
pp.current = newP;
bb.addPoint(pp.current.x, pp.current.y);
if (ctx != null) ctx.lineTo(pp.current.x, pp.current.y);
}
break;
case 'V':
case 'v':
while (!pp.isCommandOrEnd()) {
var newP = new svg.Point(pp.current.x, (pp.isRelativeCommand() ? pp.current.y : 0) + pp.getScalar());
pp.addMarker(newP, pp.current);
pp.current = newP;
bb.addPoint(pp.current.x, pp.current.y);
if (ctx != null) ctx.lineTo(pp.current.x, pp.current.y);
}
break;
case 'C':
case 'c':
while (!pp.isCommandOrEnd()) {
var curr = pp.current;
var p1 = pp.getPoint();
var cntrl = pp.getAsControlPoint();
var cp = pp.getAsCurrentPoint();
pp.addMarker(cp, cntrl, p1);
bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
if (ctx != null) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
}
break;
case 'S':
case 's':
while (!pp.isCommandOrEnd()) {
var curr = pp.current;
var p1 = pp.getReflectedControlPoint();
var cntrl = pp.getAsControlPoint();
var cp = pp.getAsCurrentPoint();
pp.addMarker(cp, cntrl, p1);
bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
if (ctx != null) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y);
}
break;
case 'Q':
case 'q':
while (!pp.isCommandOrEnd()) {
var curr = pp.current;
var cntrl = pp.getAsControlPoint();
var cp = pp.getAsCurrentPoint();
pp.addMarker(cp, cntrl, cntrl);
bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y);
if (ctx != null) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y);
}
break;
case 'T':
case 't':
while (!pp.isCommandOrEnd()) {
var curr = pp.current;
var cntrl = pp.getReflectedControlPoint();
pp.control = cntrl;
var cp = pp.getAsCurrentPoint();
pp.addMarker(cp, cntrl, cntrl);
bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y);
if (ctx != null) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y);
}
break;
case 'A':
case 'a':
while (!pp.isCommandOrEnd()) {
var curr = pp.current;
var rx = pp.getScalar();
var ry = pp.getScalar();
var xAxisRotation = pp.getScalar() * (Math.PI / 180.0);
var largeArcFlag = pp.getScalar();
var sweepFlag = pp.getScalar();
var cp = pp.getAsCurrentPoint();
// Conversion from endpoint to center parameterization
// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
// x1', y1'
var currp = new svg.Point(
Math.cos(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.sin(xAxisRotation) * (curr.y - cp.y) / 2.0,
-Math.sin(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.cos(xAxisRotation) * (curr.y - cp.y) / 2.0
);
// adjust radii
var l = Math.pow(currp.x,2)/Math.pow(rx,2)+Math.pow(currp.y,2)/Math.pow(ry,2);
if (l > 1) {
rx *= Math.sqrt(l);
ry *= Math.sqrt(l);
}
// cx', cy'
var s = (largeArcFlag == sweepFlag ? -1 : 1) * Math.sqrt(
((Math.pow(rx,2)*Math.pow(ry,2))-(Math.pow(rx,2)*Math.pow(currp.y,2))-(Math.pow(ry,2)*Math.pow(currp.x,2))) /
(Math.pow(rx,2)*Math.pow(currp.y,2)+Math.pow(ry,2)*Math.pow(currp.x,2))
);
if (isNaN(s)) s = 0;
var cpp = new svg.Point(s * rx * currp.y / ry, s * -ry * currp.x / rx);
// cx, cy
var centp = new svg.Point(
(curr.x + cp.x) / 2.0 + Math.cos(xAxisRotation) * cpp.x - Math.sin(xAxisRotation) * cpp.y,
(curr.y + cp.y) / 2.0 + Math.sin(xAxisRotation) * cpp.x + Math.cos(xAxisRotation) * cpp.y
);
// vector magnitude
var m = function(v) { return Math.sqrt(Math.pow(v[0],2) + Math.pow(v[1],2)); }
// ratio between two vectors
var r = function(u, v) { return (u[0]*v[0]+u[1]*v[1]) / (m(u)*m(v)) }
// angle between two vectors
var a = function(u, v) { return (u[0]*v[1] < u[1]*v[0] ? -1 : 1) * Math.acos(r(u,v)); }
// initial angle
var a1 = a([1,0], [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry]);
// angle delta
var u = [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry];
var v = [(-currp.x-cpp.x)/rx,(-currp.y-cpp.y)/ry];
var ad = a(u, v);
if (r(u,v) <= -1) ad = Math.PI;
if (r(u,v) >= 1) ad = 0;
// for markers
var dir = 1 - sweepFlag ? 1.0 : -1.0;
var ah = a1 + dir * (ad / 2.0);
var halfWay = new svg.Point(
centp.x + rx * Math.cos(ah),
centp.y + ry * Math.sin(ah)
);
pp.addMarkerAngle(halfWay, ah - dir * Math.PI / 2);
pp.addMarkerAngle(cp, ah - dir * Math.PI);
bb.addPoint(cp.x, cp.y); // TODO: this is too naive, make it better
if (ctx != null) {
var r = rx > ry ? rx : ry;
var sx = rx > ry ? 1 : rx / ry;
var sy = rx > ry ? ry / rx : 1;
ctx.translate(centp.x, centp.y);
ctx.rotate(xAxisRotation);
ctx.scale(sx, sy);
ctx.arc(0, 0, r, a1, a1 + ad, 1 - sweepFlag);
ctx.scale(1/sx, 1/sy);
ctx.rotate(-xAxisRotation);
ctx.translate(-centp.x, -centp.y);
}
}
break;
case 'Z':
case 'z':
if (ctx != null) ctx.closePath();
pp.current = pp.start;
}
}
return bb;
}
this.getMarkers = function() {
var points = this.PathParser.getMarkerPoints();
var angles = this.PathParser.getMarkerAngles();
var markers = [];
for (var i=0; i<points.length; i++) {
markers.push([points[i], angles[i]]);
}
return markers;
}
}
svg.Element.path.prototype = new svg.Element.PathElementBase;
// pattern element
svg.Element.pattern = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.createPattern = function(ctx, element) {
var width = this.attribute('width').toPixels('x', true);
var height = this.attribute('height').toPixels('y', true);
// render me using a temporary svg element
var tempSvg = new svg.Element.svg();
tempSvg.attributes['viewBox'] = new svg.Property('viewBox', this.attribute('viewBox').value);
tempSvg.attributes['width'] = new svg.Property('width', width + 'px');
tempSvg.attributes['height'] = new svg.Property('height', height + 'px');
tempSvg.attributes['transform'] = new svg.Property('transform', this.attribute('patternTransform').value);
tempSvg.children = this.children;
var c = document.createElement('canvas');
c.width = width;
c.height = height;
var cctx = c.getContext('2d');
if (this.attribute('x').hasValue() && this.attribute('y').hasValue()) {
cctx.translate(this.attribute('x').toPixels('x', true), this.attribute('y').toPixels('y', true));
}
// render 3x3 grid so when we transform there's no white space on edges
for (var x=-1; x<=1; x++) {
for (var y=-1; y<=1; y++) {
cctx.save();
tempSvg.attributes['x'] = new svg.Property('x', x * c.width);
tempSvg.attributes['y'] = new svg.Property('y', y * c.height);
tempSvg.render(cctx);
cctx.restore();
}
}
var pattern = ctx.createPattern(c, 'repeat');
return pattern;
}
}
svg.Element.pattern.prototype = new svg.Element.ElementBase;
// marker element
svg.Element.marker = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.baseRender = this.render;
this.render = function(ctx, point, angle) {
ctx.translate(point.x, point.y);
if (this.attribute('orient').valueOrDefault('auto') == 'auto') ctx.rotate(angle);
if (this.attribute('markerUnits').valueOrDefault('strokeWidth') == 'strokeWidth') ctx.scale(ctx.lineWidth, ctx.lineWidth);
ctx.save();
// render me using a temporary svg element
var tempSvg = new svg.Element.svg();
tempSvg.attributes['viewBox'] = new svg.Property('viewBox', this.attribute('viewBox').value);
tempSvg.attributes['refX'] = new svg.Property('refX', this.attribute('refX').value);
tempSvg.attributes['refY'] = new svg.Property('refY', this.attribute('refY').value);
tempSvg.attributes['width'] = new svg.Property('width', this.attribute('markerWidth').value);
tempSvg.attributes['height'] = new svg.Property('height', this.attribute('markerHeight').value);
tempSvg.attributes['fill'] = new svg.Property('fill', this.attribute('fill').valueOrDefault('black'));
tempSvg.attributes['stroke'] = new svg.Property('stroke', this.attribute('stroke').valueOrDefault('none'));
tempSvg.children = this.children;
tempSvg.render(ctx);
ctx.restore();
if (this.attribute('markerUnits').valueOrDefault('strokeWidth') == 'strokeWidth') ctx.scale(1/ctx.lineWidth, 1/ctx.lineWidth);
if (this.attribute('orient').valueOrDefault('auto') == 'auto') ctx.rotate(-angle);
ctx.translate(-point.x, -point.y);
}
}
svg.Element.marker.prototype = new svg.Element.ElementBase;
// definitions element
svg.Element.defs = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.render = function(ctx) {
// NOOP
}
}
svg.Element.defs.prototype = new svg.Element.ElementBase;
// base for gradients
svg.Element.GradientBase = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.stops = [];
for (var i=0; i<this.children.length; i++) {
var child = this.children[i];
if (child.type == 'stop') this.stops.push(child);
}
this.getGradient = function() {
// OVERRIDE ME!
}
this.gradientUnits = function () {
return this.attribute('gradientUnits').valueOrDefault('objectBoundingBox');
}
this.attributesToInherit = ['gradientUnits'];
this.inheritStopContainer = function (stopsContainer) {
for (var i=0; i<this.attributesToInherit.length; i++) {
var attributeToInherit = this.attributesToInherit[i];
if (!this.attribute(attributeToInherit).hasValue() && stopsContainer.attribute(attributeToInherit).hasValue()) {
this.attribute(attributeToInherit, true).value = stopsContainer.attribute(attributeToInherit).value;
}
}
}
this.createGradient = function(ctx, element, parentOpacityProp) {
var stopsContainer = this;
if (this.getHrefAttribute().hasValue()) {
stopsContainer = this.getHrefAttribute().getDefinition();
this.inheritStopContainer(stopsContainer);
}
var addParentOpacity = function (color) {
if (parentOpacityProp.hasValue()) {
var p = new svg.Property('color', color);
return p.addOpacity(parentOpacityProp).value;
}
return color;
};
var g = this.getGradient(ctx, element);
if (g == null) return addParentOpacity(stopsContainer.stops[stopsContainer.stops.length - 1].color);
for (var i=0; i<stopsContainer.stops.length; i++) {
g.addColorStop(stopsContainer.stops[i].offset, addParentOpacity(stopsContainer.stops[i].color));
}
if (this.attribute('gradientTransform').hasValue()) {
// render as transformed pattern on temporary canvas
var rootView = svg.ViewPort.viewPorts[0];
var rect = new svg.Element.rect();
rect.attributes['x'] = new svg.Property('x', -svg.MAX_VIRTUAL_PIXELS/3.0);
rect.attributes['y'] = new svg.Property('y', -svg.MAX_VIRTUAL_PIXELS/3.0);
rect.attributes['width'] = new svg.Property('width', svg.MAX_VIRTUAL_PIXELS);
rect.attributes['height'] = new svg.Property('height', svg.MAX_VIRTUAL_PIXELS);
var group = new svg.Element.g();
group.attributes['transform'] = new svg.Property('transform', this.attribute('gradientTransform').value);
group.children = [ rect ];
var tempSvg = new svg.Element.svg();
tempSvg.attributes['x'] = new svg.Property('x', 0);
tempSvg.attributes['y'] = new svg.Property('y', 0);
tempSvg.attributes['width'] = new svg.Property('width', rootView.width);
tempSvg.attributes['height'] = new svg.Property('height', rootView.height);
tempSvg.children = [ group ];
var c = document.createElement('canvas');
c.width = rootView.width;
c.height = rootView.height;
var tempCtx = c.getContext('2d');
tempCtx.fillStyle = g;
tempSvg.render(tempCtx);
return tempCtx.createPattern(c, 'no-repeat');
}
return g;
}
}
svg.Element.GradientBase.prototype = new svg.Element.ElementBase;
// linear gradient element
svg.Element.linearGradient = function(node) {
this.base = svg.Element.GradientBase;
this.base(node);
this.attributesToInherit.push('x1');
this.attributesToInherit.push('y1');
this.attributesToInherit.push('x2');
this.attributesToInherit.push('y2');
this.getGradient = function(ctx, element) {
var bb = this.gradientUnits() == 'objectBoundingBox' ? element.getBoundingBox() : null;
if (!this.attribute('x1').hasValue()
&& !this.attribute('y1').hasValue()
&& !this.attribute('x2').hasValue()
&& !this.attribute('y2').hasValue()) {
this.attribute('x1', true).value = 0;
this.attribute('y1', true).value = 0;
this.attribute('x2', true).value = 1;
this.attribute('y2', true).value = 0;
}
var x1 = (this.gradientUnits() == 'objectBoundingBox'
? bb.x() + bb.width() * this.attribute('x1').numValue()
: this.attribute('x1').toPixels('x'));
var y1 = (this.gradientUnits() == 'objectBoundingBox'
? bb.y() + bb.height() * this.attribute('y1').numValue()
: this.attribute('y1').toPixels('y'));
var x2 = (this.gradientUnits() == 'objectBoundingBox'
? bb.x() + bb.width() * this.attribute('x2').numValue()
: this.attribute('x2').toPixels('x'));
var y2 = (this.gradientUnits() == 'objectBoundingBox'
? bb.y() + bb.height() * this.attribute('y2').numValue()
: this.attribute('y2').toPixels('y'));
if (x1 == x2 && y1 == y2) return null;
return ctx.createLinearGradient(x1, y1, x2, y2);
}
}
svg.Element.linearGradient.prototype = new svg.Element.GradientBase;
// radial gradient element
svg.Element.radialGradient = function(node) {
this.base = svg.Element.GradientBase;
this.base(node);
this.attributesToInherit.push('cx');
this.attributesToInherit.push('cy');
this.attributesToInherit.push('r');
this.attributesToInherit.push('fx');
this.attributesToInherit.push('fy');
this.getGradient = function(ctx, element) {
var bb = element.getBoundingBox();
if (!this.attribute('cx').hasValue()) this.attribute('cx', true).value = '50%';
if (!this.attribute('cy').hasValue()) this.attribute('cy', true).value = '50%';
if (!this.attribute('r').hasValue()) this.attribute('r', true).value = '50%';
var cx = (this.gradientUnits() == 'objectBoundingBox'
? bb.x() + bb.width() * this.attribute('cx').numValue()
: this.attribute('cx').toPixels('x'));
var cy = (this.gradientUnits() == 'objectBoundingBox'
? bb.y() + bb.height() * this.attribute('cy').numValue()
: this.attribute('cy').toPixels('y'));
var fx = cx;
var fy = cy;
if (this.attribute('fx').hasValue()) {
fx = (this.gradientUnits() == 'objectBoundingBox'
? bb.x() + bb.width() * this.attribute('fx').numValue()
: this.attribute('fx').toPixels('x'));
}
if (this.attribute('fy').hasValue()) {
fy = (this.gradientUnits() == 'objectBoundingBox'
? bb.y() + bb.height() * this.attribute('fy').numValue()
: this.attribute('fy').toPixels('y'));
}
var r = (this.gradientUnits() == 'objectBoundingBox'
? (bb.width() + bb.height()) / 2.0 * this.attribute('r').numValue()
: this.attribute('r').toPixels());
return ctx.createRadialGradient(fx, fy, 0, cx, cy, r);
}
}
svg.Element.radialGradient.prototype = new svg.Element.GradientBase;
// gradient stop element
svg.Element.stop = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.offset = this.attribute('offset').numValue();
if (this.offset < 0) this.offset = 0;
if (this.offset > 1) this.offset = 1;
var stopColor = this.style('stop-color', true);
if (stopColor.value === '') stopColor.value = '#000';
if (this.style('stop-opacity').hasValue()) stopColor = stopColor.addOpacity(this.style('stop-opacity'));
this.color = stopColor.value;
}
svg.Element.stop.prototype = new svg.Element.ElementBase;
// animation base element
svg.Element.AnimateBase = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
svg.Animations.push(this);
this.duration = 0.0;
this.begin = this.attribute('begin').toMilliseconds();
this.maxDuration = this.begin + this.attribute('dur').toMilliseconds();
this.getProperty = function() {
var attributeType = this.attribute('attributeType').value;
var attributeName = this.attribute('attributeName').value;
if (attributeType == 'CSS') {
return this.parent.style(attributeName, true);
}
return this.parent.attribute(attributeName, true);
};
this.initialValue = null;
this.initialUnits = '';
this.removed = false;
this.calcValue = function() {
// OVERRIDE ME!
return '';
}
this.update = function(delta) {
// set initial value
if (this.initialValue == null) {
this.initialValue = this.getProperty().value;
this.initialUnits = this.getProperty().getUnits();
}
// if we're past the end time
if (this.duration > this.maxDuration) {
// loop for indefinitely repeating animations
if (this.attribute('repeatCount').value == 'indefinite'
|| this.attribute('repeatDur').value == 'indefinite') {
this.duration = 0.0
}
else if (this.attribute('fill').valueOrDefault('remove') == 'freeze' && !this.frozen) {
this.frozen = true;
this.parent.animationFrozen = true;
this.parent.animationFrozenValue = this.getProperty().value;
}
else if (this.attribute('fill').valueOrDefault('remove') == 'remove' && !this.removed) {
this.removed = true;
this.getProperty().value = this.parent.animationFrozen ? this.parent.animationFrozenValue : this.initialValue;
return true;
}
return false;
}
this.duration = this.duration + delta;
// if we're past the begin time
var updated = false;
if (this.begin < this.duration) {
var newValue = this.calcValue(); // tween
if (this.attribute('type').hasValue()) {
// for transform, etc.
var type = this.attribute('type').value;
newValue = type + '(' + newValue + ')';
}
this.getProperty().value = newValue;
updated = true;
}
return updated;
}
this.from = this.attribute('from');
this.to = this.attribute('to');
this.values = this.attribute('values');
if (this.values.hasValue()) this.values.value = this.values.value.split(';');
// fraction of duration we've covered
this.progress = function() {
var ret = { progress: (this.duration - this.begin) / (this.maxDuration - this.begin) };
if (this.values.hasValue()) {
var p = ret.progress * (this.values.value.length - 1);
var lb = Math.floor(p), ub = Math.ceil(p);
ret.from = new svg.Property('from', parseFloat(this.values.value[lb]));
ret.to = new svg.Property('to', parseFloat(this.values.value[ub]));
ret.progress = (p - lb) / (ub - lb);
}
else {
ret.from = this.from;
ret.to = this.to;
}
return ret;
}
}
svg.Element.AnimateBase.prototype = new svg.Element.ElementBase;
// animate element
svg.Element.animate = function(node) {
this.base = svg.Element.AnimateBase;
this.base(node);
this.calcValue = function() {
var p = this.progress();
// tween value linearly
var newValue = p.from.numValue() + (p.to.numValue() - p.from.numValue()) * p.progress;
return newValue + this.initialUnits;
};
}
svg.Element.animate.prototype = new svg.Element.AnimateBase;
// animate color element
svg.Element.animateColor = function(node) {
this.base = svg.Element.AnimateBase;
this.base(node);
this.calcValue = function() {
var p = this.progress();
var from = new RGBColor(p.from.value);
var to = new RGBColor(p.to.value);
if (from.ok && to.ok) {
// tween color linearly
var r = from.r + (to.r - from.r) * p.progress;
var g = from.g + (to.g - from.g) * p.progress;
var b = from.b + (to.b - from.b) * p.progress;
return 'rgb('+parseInt(r,10)+','+parseInt(g,10)+','+parseInt(b,10)+')';
}
return this.attribute('from').value;
};
}
svg.Element.animateColor.prototype = new svg.Element.AnimateBase;
// animate transform element
svg.Element.animateTransform = function(node) {
this.base = svg.Element.AnimateBase;
this.base(node);
this.calcValue = function() {
var p = this.progress();
// tween value linearly
var from = svg.ToNumberArray(p.from.value);
var to = svg.ToNumberArray(p.to.value);
var newValue = '';
for (var i=0; i<from.length; i++) {
newValue += from[i] + (to[i] - from[i]) * p.progress + ' ';
}
return newValue;
};
}
svg.Element.animateTransform.prototype = new svg.Element.animate;
// font element
svg.Element.font = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.horizAdvX = this.attribute('horiz-adv-x').numValue();
this.isRTL = false;
this.isArabic = false;
this.fontFace = null;
this.missingGlyph = null;
this.glyphs = [];
for (var i=0; i<this.children.length; i++) {
var child = this.children[i];
if (child.type == 'font-face') {
this.fontFace = child;
if (child.style('font-family').hasValue()) {
svg.Definitions[child.style('font-family').value] = this;
}
}
else if (child.type == 'missing-glyph') this.missingGlyph = child;
else if (child.type == 'glyph') {
if (child.arabicForm != '') {
this.isRTL = true;
this.isArabic = true;
if (typeof(this.glyphs[child.unicode]) == 'undefined') this.glyphs[child.unicode] = [];
this.glyphs[child.unicode][child.arabicForm] = child;
}
else {
this.glyphs[child.unicode] = child;
}
}
}
}
svg.Element.font.prototype = new svg.Element.ElementBase;
// font-face element
svg.Element.fontface = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.ascent = this.attribute('ascent').value;
this.descent = this.attribute('descent').value;
this.unitsPerEm = this.attribute('units-per-em').numValue();
}
svg.Element.fontface.prototype = new svg.Element.ElementBase;
// missing-glyph element
svg.Element.missingglyph = function(node) {
this.base = svg.Element.path;
this.base(node);
this.horizAdvX = 0;
}
svg.Element.missingglyph.prototype = new svg.Element.path;
// glyph element
svg.Element.glyph = function(node) {
this.base = svg.Element.path;
this.base(node);
this.horizAdvX = this.attribute('horiz-adv-x').numValue();
this.unicode = this.attribute('unicode').value;
this.arabicForm = this.attribute('arabic-form').value;
}
svg.Element.glyph.prototype = new svg.Element.path;
// text element
svg.Element.text = function(node) {
this.captureTextNodes = true;
this.base = svg.Element.RenderedElementBase;
this.base(node);
this.baseSetContext = this.setContext;
this.setContext = function(ctx) {
this.baseSetContext(ctx);
var textBaseline = this.style('dominant-baseline').toTextBaseline();
if (textBaseline == null) textBaseline = this.style('alignment-baseline').toTextBaseline();
if (textBaseline != null) ctx.textBaseline = textBaseline;
}
this.getBoundingBox = function () {
var x = this.attribute('x').toPixels('x');
var y = this.attribute('y').toPixels('y');
var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize);
return new svg.BoundingBox(x, y - fontSize, x + Math.floor(fontSize * 2.0 / 3.0) * this.children[0].getText().length, y);
}
this.renderChildren = function(ctx) {
this.x = this.attribute('x').toPixels('x');
this.y = this.attribute('y').toPixels('y');
if (this.attribute('dx').hasValue()) this.x += this.attribute('dx').toPixels('x');
if (this.attribute('dy').hasValue()) this.y += this.attribute('dy').toPixels('y');
this.x += this.getAnchorDelta(ctx, this, 0);
for (var i=0; i<this.children.length; i++) {
this.renderChild(ctx, this, i);
}
}
this.getAnchorDelta = function (ctx, parent, startI) {
var textAnchor = this.style('text-anchor').valueOrDefault('start');
if (textAnchor != 'start') {
var width = 0;
for (var i=startI; i<parent.children.length; i++) {
var child = parent.children[i];
if (i > startI && child.attribute('x').hasValue()) break; // new group
width += child.measureTextRecursive(ctx);
}
return -1 * (textAnchor == 'end' ? width : width / 2.0);
}
return 0;
}
this.renderChild = function(ctx, parent, i) {
var child = parent.children[i];
if (child.attribute('x').hasValue()) {
child.x = child.attribute('x').toPixels('x') + parent.getAnchorDelta(ctx, parent, i);
if (child.attribute('dx').hasValue()) child.x += child.attribute('dx').toPixels('x');
}
else {
if (child.attribute('dx').hasValue()) parent.x += child.attribute('dx').toPixels('x');
child.x = parent.x;
}
parent.x = child.x + child.measureText(ctx);
if (child.attribute('y').hasValue()) {
child.y = child.attribute('y').toPixels('y');
if (child.attribute('dy').hasValue()) child.y += child.attribute('dy').toPixels('y');
}
else {
if (child.attribute('dy').hasValue()) parent.y += child.attribute('dy').toPixels('y');
child.y = parent.y;
}
parent.y = child.y;
child.render(ctx);
for (var i=0; i<child.children.length; i++) {
parent.renderChild(ctx, child, i);
}
}
}
svg.Element.text.prototype = new svg.Element.RenderedElementBase;
// text base
svg.Element.TextElementBase = function(node) {
this.base = svg.Element.RenderedElementBase;
this.base(node);
this.getGlyph = function(font, text, i) {
var c = text[i];
var glyph = null;
if (font.isArabic) {
var arabicForm = 'isolated';
if ((i==0 || text[i-1]==' ') && i<text.length-2 && text[i+1]!=' ') arabicForm = 'terminal';
if (i>0 && text[i-1]!=' ' && i<text.length-2 && text[i+1]!=' ') arabicForm = 'medial';
if (i>0 && text[i-1]!=' ' && (i == text.length-1 || text[i+1]==' ')) arabicForm = 'initial';
if (typeof(font.glyphs[c]) != 'undefined') {
glyph = font.glyphs[c][arabicForm];
if (glyph == null && font.glyphs[c].type == 'glyph') glyph = font.glyphs[c];
}
}
else {
glyph = font.glyphs[c];
}
if (glyph == null) glyph = font.missingGlyph;
return glyph;
}
this.renderChildren = function(ctx) {
var customFont = this.parent.style('font-family').getDefinition();
if (customFont != null) {
var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize);
var fontStyle = this.parent.style('font-style').valueOrDefault(svg.Font.Parse(svg.ctx.font).fontStyle);
var text = this.getText();
if (customFont.isRTL) text = text.split("").reverse().join("");
var dx = svg.ToNumberArray(this.parent.attribute('dx').value);
for (var i=0; i<text.length; i++) {
var glyph = this.getGlyph(customFont, text, i);
var scale = fontSize / customFont.fontFace.unitsPerEm;
ctx.translate(this.x, this.y);
ctx.scale(scale, -scale);
var lw = ctx.lineWidth;
ctx.lineWidth = ctx.lineWidth * customFont.fontFace.unitsPerEm / fontSize;
if (fontStyle == 'italic') ctx.transform(1, 0, .4, 1, 0, 0);
glyph.render(ctx);
if (fontStyle == 'italic') ctx.transform(1, 0, -.4, 1, 0, 0);
ctx.lineWidth = lw;
ctx.scale(1/scale, -1/scale);
ctx.translate(-this.x, -this.y);
this.x += fontSize * (glyph.horizAdvX || customFont.horizAdvX) / customFont.fontFace.unitsPerEm;
if (typeof(dx[i]) != 'undefined' && !isNaN(dx[i])) {
this.x += dx[i];
}
}
return;
}
if (ctx.fillStyle != '') ctx.fillText(svg.compressSpaces(this.getText()), this.x, this.y);
if (ctx.strokeStyle != '') ctx.strokeText(svg.compressSpaces(this.getText()), this.x, this.y);
}
this.getText = function() {
// OVERRIDE ME
}
this.measureTextRecursive = function(ctx) {
var width = this.measureText(ctx);
for (var i=0; i<this.children.length; i++) {
width += this.children[i].measureTextRecursive(ctx);
}
return width;
}
this.measureText = function(ctx) {
var customFont = this.parent.style('font-family').getDefinition();
if (customFont != null) {
var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize);
var measure = 0;
var text = this.getText();
if (customFont.isRTL) text = text.split("").reverse().join("");
var dx = svg.ToNumberArray(this.parent.attribute('dx').value);
for (var i=0; i<text.length; i++) {
var glyph = this.getGlyph(customFont, text, i);
measure += (glyph.horizAdvX || customFont.horizAdvX) * fontSize / customFont.fontFace.unitsPerEm;
if (typeof(dx[i]) != 'undefined' && !isNaN(dx[i])) {
measure += dx[i];
}
}
return measure;
}
var textToMeasure = svg.compressSpaces(this.getText());
if (!ctx.measureText) return textToMeasure.length * 10;
ctx.save();
this.setContext(ctx);
var width = ctx.measureText(textToMeasure).width;
ctx.restore();
return width;
}
}
svg.Element.TextElementBase.prototype = new svg.Element.RenderedElementBase;
// tspan
svg.Element.tspan = function(node) {
this.captureTextNodes = true;
this.base = svg.Element.TextElementBase;
this.base(node);
this.text = svg.compressSpaces(node.value || node.text || node.textContent || '');
this.getText = function() {
// if this node has children, then they own the text
if (this.children.length > 0) { return ''; }
return this.text;
}
}
svg.Element.tspan.prototype = new svg.Element.TextElementBase;
// tref
svg.Element.tref = function(node) {
this.base = svg.Element.TextElementBase;
this.base(node);
this.getText = function() {
var element = this.getHrefAttribute().getDefinition();
if (element != null) return element.children[0].getText();
}
}
svg.Element.tref.prototype = new svg.Element.TextElementBase;
// a element
svg.Element.a = function(node) {
this.base = svg.Element.TextElementBase;
this.base(node);
this.hasText = node.childNodes.length > 0;
for (var i=0; i<node.childNodes.length; i++) {
if (node.childNodes[i].nodeType != 3) this.hasText = false;
}
// this might contain text
this.text = this.hasText ? node.childNodes[0].value : '';
this.getText = function() {
return this.text;
}
this.baseRenderChildren = this.renderChildren;
this.renderChildren = function(ctx) {
if (this.hasText) {
// render as text element
this.baseRenderChildren(ctx);
var fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize);
svg.Mouse.checkBoundingBox(this, new svg.BoundingBox(this.x, this.y - fontSize.toPixels('y'), this.x + this.measureText(ctx), this.y));
}
else if (this.children.length > 0) {
// render as temporary group
var g = new svg.Element.g();
g.children = this.children;
g.parent = this;
g.render(ctx);
}
}
this.onclick = function() {
window.open(this.getHrefAttribute().value);
}
this.onmousemove = function() {
svg.ctx.canvas.style.cursor = 'pointer';
}
}
svg.Element.a.prototype = new svg.Element.TextElementBase;
// image element
svg.Element.image = function(node) {
this.base = svg.Element.RenderedElementBase;
this.base(node);
var href = this.getHrefAttribute().value;
if (href == '') { return; }
var isSvg = href.match(/\.svg$/)
svg.Images.push(this);
this.loaded = false;
if (!isSvg) {
this.img = document.createElement('img');
if (svg.opts['useCORS'] == true) { this.img.crossOrigin = 'Anonymous'; }
var self = this;
this.img.onload = function() { self.loaded = true; }
this.img.onerror = function() { svg.log('ERROR: image "' + href + '" not found'); self.loaded = true; }
this.img.src = href;
}
else {
this.img = svg.ajax(href);
this.loaded = true;
}
this.renderChildren = function(ctx) {
var x = this.attribute('x').toPixels('x');
var y = this.attribute('y').toPixels('y');
var width = this.attribute('width').toPixels('x');
var height = this.attribute('height').toPixels('y');
if (width == 0 || height == 0) return;
ctx.save();
if (isSvg) {
ctx.drawSvg(this.img, x, y, width, height);
}
else {
ctx.translate(x, y);
svg.AspectRatio(ctx,
this.attribute('preserveAspectRatio').value,
width,
this.img.width,
height,
this.img.height,
0,
0);
ctx.drawImage(this.img, 0, 0);
}
ctx.restore();
}
this.getBoundingBox = function() {
var x = this.attribute('x').toPixels('x');
var y = this.attribute('y').toPixels('y');
var width = this.attribute('width').toPixels('x');
var height = this.attribute('height').toPixels('y');
return new svg.BoundingBox(x, y, x + width, y + height);
}
}
svg.Element.image.prototype = new svg.Element.RenderedElementBase;
// group element
svg.Element.g = function(node) {
this.base = svg.Element.RenderedElementBase;
this.base(node);
this.getBoundingBox = function() {
var bb = new svg.BoundingBox();
for (var i=0; i<this.children.length; i++) {
bb.addBoundingBox(this.children[i].getBoundingBox());
}
return bb;
};
}
svg.Element.g.prototype = new svg.Element.RenderedElementBase;
// symbol element
svg.Element.symbol = function(node) {
this.base = svg.Element.RenderedElementBase;
this.base(node);
this.render = function(ctx) {
// NO RENDER
};
}
svg.Element.symbol.prototype = new svg.Element.RenderedElementBase;
// style element
svg.Element.style = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
// text, or spaces then CDATA
var css = ''
for (var i=0; i<node.childNodes.length; i++) {
css += node.childNodes[i].data;
}
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments
css = svg.compressSpaces(css); // replace whitespace
var cssDefs = css.split('}');
for (var i=0; i<cssDefs.length; i++) {
if (svg.trim(cssDefs[i]) != '') {
var cssDef = cssDefs[i].split('{');
var cssClasses = cssDef[0].split(',');
var cssProps = cssDef[1].split(';');
for (var j=0; j<cssClasses.length; j++) {
var cssClass = svg.trim(cssClasses[j]);
if (cssClass != '') {
var props = svg.Styles[cssClass] || {};
for (var k=0; k<cssProps.length; k++) {
var prop = cssProps[k].indexOf(':');
var name = cssProps[k].substr(0, prop);
var value = cssProps[k].substr(prop + 1, cssProps[k].length - prop);
if (name != null && value != null) {
props[svg.trim(name)] = new svg.Property(svg.trim(name), svg.trim(value));
}
}
svg.Styles[cssClass] = props;
svg.StylesSpecificity[cssClass] = getSelectorSpecificity(cssClass);
if (cssClass == '@font-face') {
var fontFamily = props['font-family'].value.replace(/"/g,'');
var srcs = props['src'].value.split(',');
for (var s=0; s<srcs.length; s++) {
if (srcs[s].indexOf('format("svg")') > 0) {
var urlStart = srcs[s].indexOf('url');
var urlEnd = srcs[s].indexOf(')', urlStart);
var url = srcs[s].substr(urlStart + 5, urlEnd - urlStart - 6);
var doc = svg.parseXml(svg.ajax(url));
var fonts = doc.getElementsByTagName('font');
for (var f=0; f<fonts.length; f++) {
var font = svg.CreateElement(fonts[f]);
svg.Definitions[fontFamily] = font;
}
}
}
}
}
}
}
}
}
svg.Element.style.prototype = new svg.Element.ElementBase;
// use element
svg.Element.use = function(node) {
this.base = svg.Element.RenderedElementBase;
this.base(node);
this.baseSetContext = this.setContext;
this.setContext = function(ctx) {
this.baseSetContext(ctx);
if (this.attribute('x').hasValue()) ctx.translate(this.attribute('x').toPixels('x'), 0);
if (this.attribute('y').hasValue()) ctx.translate(0, this.attribute('y').toPixels('y'));
}
var element = this.getHrefAttribute().getDefinition();
this.path = function(ctx) {
if (element != null) element.path(ctx);
}
this.getBoundingBox = function() {
if (element != null) return element.getBoundingBox();
}
this.renderChildren = function(ctx) {
if (element != null) {
var tempSvg = element;
if (element.type == 'symbol') {
// render me using a temporary svg element in symbol cases (http://www.w3.org/TR/SVG/struct.html#UseElement)
tempSvg = new svg.Element.svg();
tempSvg.type = 'svg';
tempSvg.attributes['viewBox'] = new svg.Property('viewBox', element.attribute('viewBox').value);
tempSvg.attributes['preserveAspectRatio'] = new svg.Property('preserveAspectRatio', element.attribute('preserveAspectRatio').value);
tempSvg.attributes['overflow'] = new svg.Property('overflow', element.attribute('overflow').value);
tempSvg.children = element.children;
}
if (tempSvg.type == 'svg') {
// if symbol or svg, inherit width/height from me
if (this.attribute('width').hasValue()) tempSvg.attributes['width'] = new svg.Property('width', this.attribute('width').value);
if (this.attribute('height').hasValue()) tempSvg.attributes['height'] = new svg.Property('height', this.attribute('height').value);
}
var oldParent = tempSvg.parent;
tempSvg.parent = null;
tempSvg.render(ctx);
tempSvg.parent = oldParent;
}
}
}
svg.Element.use.prototype = new svg.Element.RenderedElementBase;
// mask element
svg.Element.mask = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.apply = function(ctx, element) {
// render as temp svg
var x = this.attribute('x').toPixels('x');
var y = this.attribute('y').toPixels('y');
var width = this.attribute('width').toPixels('x');
var height = this.attribute('height').toPixels('y');
if (width == 0 && height == 0) {
var bb = new svg.BoundingBox();
for (var i=0; i<this.children.length; i++) {
bb.addBoundingBox(this.children[i].getBoundingBox());
}
var x = Math.floor(bb.x1);
var y = Math.floor(bb.y1);
var width = Math.floor(bb.width());
var height = Math.floor(bb.height());
}
// temporarily remove mask to avoid recursion
var mask = element.attribute('mask').value;
element.attribute('mask').value = '';
var cMask = document.createElement('canvas');
cMask.width = x + width;
cMask.height = y + height;
var maskCtx = cMask.getContext('2d');
this.renderChildren(maskCtx);
var c = document.createElement('canvas');
c.width = x + width;
c.height = y + height;
var tempCtx = c.getContext('2d');
element.render(tempCtx);
tempCtx.globalCompositeOperation = 'destination-in';
tempCtx.fillStyle = maskCtx.createPattern(cMask, 'no-repeat');
tempCtx.fillRect(0, 0, x + width, y + height);
ctx.fillStyle = tempCtx.createPattern(c, 'no-repeat');
ctx.fillRect(0, 0, x + width, y + height);
// reassign mask
element.attribute('mask').value = mask;
}
this.render = function(ctx) {
// NO RENDER
}
}
svg.Element.mask.prototype = new svg.Element.ElementBase;
// clip element
svg.Element.clipPath = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.apply = function(ctx) {
var oldBeginPath = CanvasRenderingContext2D.prototype.beginPath;
CanvasRenderingContext2D.prototype.beginPath = function () { };
var oldClosePath = CanvasRenderingContext2D.prototype.closePath;
CanvasRenderingContext2D.prototype.closePath = function () { };
oldBeginPath.call(ctx);
for (var i=0; i<this.children.length; i++) {
var child = this.children[i];
if (typeof(child.path) != 'undefined') {
var transform = null;
if (child.style('transform', false, true).hasValue()) {
transform = new svg.Transform(child.style('transform', false, true).value);
transform.apply(ctx);
}
child.path(ctx);
CanvasRenderingContext2D.prototype.closePath = oldClosePath;
if (transform) { transform.unapply(ctx); }
}
}
oldClosePath.call(ctx);
ctx.clip();
CanvasRenderingContext2D.prototype.beginPath = oldBeginPath;
CanvasRenderingContext2D.prototype.closePath = oldClosePath;
}
this.render = function(ctx) {
// NO RENDER
}
}
svg.Element.clipPath.prototype = new svg.Element.ElementBase;
// filters
svg.Element.filter = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.apply = function(ctx, element) {
// render as temp svg
var bb = element.getBoundingBox();
var x = Math.floor(bb.x1);
var y = Math.floor(bb.y1);
var width = Math.floor(bb.width());
var height = Math.floor(bb.height());
// temporarily remove filter to avoid recursion
var filter = element.style('filter').value;
element.style('filter').value = '';
var px = 0, py = 0;
for (var i=0; i<this.children.length; i++) {
var efd = this.children[i].extraFilterDistance || 0;
px = Math.max(px, efd);
py = Math.max(py, efd);
}
var c = document.createElement('canvas');
c.width = width + 2*px;
c.height = height + 2*py;
var tempCtx = c.getContext('2d');
tempCtx.translate(-x + px, -y + py);
element.render(tempCtx);
// apply filters
for (var i=0; i<this.children.length; i++) {
if (typeof(this.children[i].apply) === 'function') {
this.children[i].apply(tempCtx, 0, 0, width + 2*px, height + 2*py);
}
}
// render on me
ctx.drawImage(c, 0, 0, width + 2*px, height + 2*py, x - px, y - py, width + 2*px, height + 2*py);
// reassign filter
element.style('filter', true).value = filter;
}
this.render = function(ctx) {
// NO RENDER
}
}
svg.Element.filter.prototype = new svg.Element.ElementBase;
svg.Element.feMorphology = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.apply = function(ctx, x, y, width, height) {
// TODO: implement
}
}
svg.Element.feMorphology.prototype = new svg.Element.ElementBase;
svg.Element.feComposite = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.apply = function(ctx, x, y, width, height) {
// TODO: implement
}
}
svg.Element.feComposite.prototype = new svg.Element.ElementBase;
svg.Element.feColorMatrix = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
var matrix = svg.ToNumberArray(this.attribute('values').value);
switch (this.attribute('type').valueOrDefault('matrix')) { // http://www.w3.org/TR/SVG/filters.html#feColorMatrixElement
case 'saturate':
var s = matrix[0];
matrix = [0.213+0.787*s,0.715-0.715*s,0.072-0.072*s,0,0,
0.213-0.213*s,0.715+0.285*s,0.072-0.072*s,0,0,
0.213-0.213*s,0.715-0.715*s,0.072+0.928*s,0,0,
0,0,0,1,0,
0,0,0,0,1];
break;
case 'hueRotate':
var a = matrix[0] * Math.PI / 180.0;
var c = function (m1,m2,m3) { return m1 + Math.cos(a)*m2 + Math.sin(a)*m3; };
matrix = [c(0.213,0.787,-0.213),c(0.715,-0.715,-0.715),c(0.072,-0.072,0.928),0,0,
c(0.213,-0.213,0.143),c(0.715,0.285,0.140),c(0.072,-0.072,-0.283),0,0,
c(0.213,-0.213,-0.787),c(0.715,-0.715,0.715),c(0.072,0.928,0.072),0,0,
0,0,0,1,0,
0,0,0,0,1];
break;
case 'luminanceToAlpha':
matrix = [0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0.2125,0.7154,0.0721,0,0,
0,0,0,0,1];
break;
}
function imGet(img, x, y, width, height, rgba) {
return img[y*width*4 + x*4 + rgba];
}
function imSet(img, x, y, width, height, rgba, val) {
img[y*width*4 + x*4 + rgba] = val;
}
function m(i, v) {
var mi = matrix[i];
return mi * (mi < 0 ? v - 255 : v);
}
this.apply = function(ctx, x, y, width, height) {
// assuming x==0 && y==0 for now
var srcData = ctx.getImageData(0, 0, width, height);
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
var r = imGet(srcData.data, x, y, width, height, 0);
var g = imGet(srcData.data, x, y, width, height, 1);
var b = imGet(srcData.data, x, y, width, height, 2);
var a = imGet(srcData.data, x, y, width, height, 3);
imSet(srcData.data, x, y, width, height, 0, m(0,r)+m(1,g)+m(2,b)+m(3,a)+m(4,1));
imSet(srcData.data, x, y, width, height, 1, m(5,r)+m(6,g)+m(7,b)+m(8,a)+m(9,1));
imSet(srcData.data, x, y, width, height, 2, m(10,r)+m(11,g)+m(12,b)+m(13,a)+m(14,1));
imSet(srcData.data, x, y, width, height, 3, m(15,r)+m(16,g)+m(17,b)+m(18,a)+m(19,1));
}
}
ctx.clearRect(0, 0, width, height);
ctx.putImageData(srcData, 0, 0);
}
}
svg.Element.feColorMatrix.prototype = new svg.Element.ElementBase;
svg.Element.feGaussianBlur = function(node) {
this.base = svg.Element.ElementBase;
this.base(node);
this.blurRadius = Math.floor(this.attribute('stdDeviation').numValue());
this.extraFilterDistance = this.blurRadius;
this.apply = function(ctx, x, y, width, height) {
if (typeof(stackBlur.canvasRGBA) == 'undefined') {
svg.log('ERROR: StackBlur.js must be included for blur to work');
return;
}
// StackBlur requires canvas be on document
ctx.canvas.id = svg.UniqueId();
ctx.canvas.style.display = 'none';
document.body.appendChild(ctx.canvas);
stackBlur.canvasRGBA(ctx.canvas.id, x, y, width, height, this.blurRadius);
document.body.removeChild(ctx.canvas);
}
}
svg.Element.feGaussianBlur.prototype = new svg.Element.ElementBase;
// title element, do nothing
svg.Element.title = function(node) {
}
svg.Element.title.prototype = new svg.Element.ElementBase;
// desc element, do nothing
svg.Element.desc = function(node) {
}
svg.Element.desc.prototype = new svg.Element.ElementBase;
svg.Element.MISSING = function(node) {
svg.log('ERROR: Element \'' + node.nodeName + '\' not yet implemented.');
}
svg.Element.MISSING.prototype = new svg.Element.ElementBase;
// element factory
svg.CreateElement = function(node) {
var className = node.nodeName.replace(/^[^:]+:/,''); // remove namespace
className = className.replace(/\-/g,''); // remove dashes
var e = null;
if (typeof(svg.Element[className]) != 'undefined') {
e = new svg.Element[className](node);
}
else {
e = new svg.Element.MISSING(node);
}
e.type = node.nodeName;
return e;
}
// load from url
svg.load = function(ctx, url) {
svg.loadXml(ctx, svg.ajax(url));
}
// load from xml
svg.loadXml = function(ctx, xml) {
svg.loadXmlDoc(ctx, svg.parseXml(xml));
}
svg.loadXmlDoc = function(ctx, dom) {
svg.init(ctx);
var mapXY = function(p) {
var e = ctx.canvas;
while (e) {
p.x -= e.offsetLeft;
p.y -= e.offsetTop;
e = e.offsetParent;
}
if (window.scrollX) p.x += window.scrollX;
if (window.scrollY) p.y += window.scrollY;
return p;
}
// bind mouse
if (svg.opts['ignoreMouse'] != true) {
ctx.canvas.onclick = function(e) {
var p = mapXY(new svg.Point(e != null ? e.clientX : event.clientX, e != null ? e.clientY : event.clientY));
svg.Mouse.onclick(p.x, p.y);
};
ctx.canvas.onmousemove = function(e) {
var p = mapXY(new svg.Point(e != null ? e.clientX : event.clientX, e != null ? e.clientY : event.clientY));
svg.Mouse.onmousemove(p.x, p.y);
};
}
var e = svg.CreateElement(dom.documentElement);
e.root = true;
e.addStylesFromStyleDefinition();
// render loop
var isFirstRender = true;
var draw = function() {
svg.ViewPort.Clear();
if (ctx.canvas.parentNode) svg.ViewPort.SetCurrent(ctx.canvas.parentNode.clientWidth, ctx.canvas.parentNode.clientHeight);
if (svg.opts['ignoreDimensions'] != true) {
// set canvas size
if (e.style('width').hasValue()) {
ctx.canvas.width = e.style('width').toPixels('x');
ctx.canvas.style.width = ctx.canvas.width + 'px';
}
if (e.style('height').hasValue()) {
ctx.canvas.height = e.style('height').toPixels('y');
ctx.canvas.style.height = ctx.canvas.height + 'px';
}
}
var cWidth = ctx.canvas.clientWidth || ctx.canvas.width;
var cHeight = ctx.canvas.clientHeight || ctx.canvas.height;
if (svg.opts['ignoreDimensions'] == true && e.style('width').hasValue() && e.style('height').hasValue()) {
cWidth = e.style('width').toPixels('x');
cHeight = e.style('height').toPixels('y');
}
svg.ViewPort.SetCurrent(cWidth, cHeight);
if (svg.opts['offsetX'] != null) e.attribute('x', true).value = svg.opts['offsetX'];
if (svg.opts['offsetY'] != null) e.attribute('y', true).value = svg.opts['offsetY'];
if (svg.opts['scaleWidth'] != null || svg.opts['scaleHeight'] != null) {
var xRatio = null, yRatio = null, viewBox = svg.ToNumberArray(e.attribute('viewBox').value);
if (svg.opts['scaleWidth'] != null) {
if (e.attribute('width').hasValue()) xRatio = e.attribute('width').toPixels('x') / svg.opts['scaleWidth'];
else if (!isNaN(viewBox[2])) xRatio = viewBox[2] / svg.opts['scaleWidth'];
}
if (svg.opts['scaleHeight'] != null) {
if (e.attribute('height').hasValue()) yRatio = e.attribute('height').toPixels('y') / svg.opts['scaleHeight'];
else if (!isNaN(viewBox[3])) yRatio = viewBox[3] / svg.opts['scaleHeight'];
}
if (xRatio == null) { xRatio = yRatio; }
if (yRatio == null) { yRatio = xRatio; }
e.attribute('width', true).value = svg.opts['scaleWidth'];
e.attribute('height', true).value = svg.opts['scaleHeight'];
e.style('transform', true, true).value += ' scale('+(1.0/xRatio)+','+(1.0/yRatio)+')';
}
// clear and render
if (svg.opts['ignoreClear'] != true) {
ctx.clearRect(0, 0, cWidth, cHeight);
}
e.render(ctx);
if (isFirstRender) {
isFirstRender = false;
if (typeof(svg.opts['renderCallback']) == 'function') svg.opts['renderCallback'](dom);
}
}
var waitingForImages = true;
if (svg.ImagesLoaded()) {
waitingForImages = false;
draw();
}
svg.intervalID = setInterval(function() {
var needUpdate = false;
if (waitingForImages && svg.ImagesLoaded()) {
waitingForImages = false;
needUpdate = true;
}
// need update from mouse events?
if (svg.opts['ignoreMouse'] != true) {
needUpdate = needUpdate | svg.Mouse.hasEvents();
}
// need update from animations?
if (svg.opts['ignoreAnimation'] != true) {
for (var i=0; i<svg.Animations.length; i++) {
needUpdate = needUpdate | svg.Animations[i].update(1000 / svg.FRAMERATE);
}
}
// need update from redraw?
if (typeof(svg.opts['forceRedraw']) == 'function') {
if (svg.opts['forceRedraw']() == true) needUpdate = true;
}
// render if needed
if (needUpdate) {
draw();
svg.Mouse.runEvents(); // run and clear our events
}
}, 1000 / svg.FRAMERATE);
}
svg.stop = function() {
if (svg.intervalID) {
clearInterval(svg.intervalID);
}
}
svg.Mouse = new (function() {
this.events = [];
this.hasEvents = function() { return this.events.length != 0; }
this.onclick = function(x, y) {
this.events.push({ type: 'onclick', x: x, y: y,
run: function(e) { if (e.onclick) e.onclick(); }
});
}
this.onmousemove = function(x, y) {
this.events.push({ type: 'onmousemove', x: x, y: y,
run: function(e) { if (e.onmousemove) e.onmousemove(); }
});
}
this.eventElements = [];
this.checkPath = function(element, ctx) {
for (var i=0; i<this.events.length; i++) {
var e = this.events[i];
if (ctx.isPointInPath && ctx.isPointInPath(e.x, e.y)) this.eventElements[i] = element;
}
}
this.checkBoundingBox = function(element, bb) {
for (var i=0; i<this.events.length; i++) {
var e = this.events[i];
if (bb.isPointInBox(e.x, e.y)) this.eventElements[i] = element;
}
}
this.runEvents = function() {
svg.ctx.canvas.style.cursor = '';
for (var i=0; i<this.events.length; i++) {
var e = this.events[i];
var element = this.eventElements[i];
while (element) {
e.run(element);
element = element.parent;
}
}
// done running, clear
this.events = [];
this.eventElements = [];
}
});
return svg;
};
if (typeof(CanvasRenderingContext2D) != 'undefined') {
CanvasRenderingContext2D.prototype.drawSvg = function(s, dx, dy, dw, dh) {
canvg(this.canvas, s, {
ignoreMouse: true,
ignoreAnimation: true,
ignoreDimensions: true,
ignoreClear: true,
offsetX: dx,
offsetY: dy,
scaleWidth: dw,
scaleHeight: dh
});
}
}
return canvg;
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 1 1 1 1 1 | /*
jsPDF - PDF Document creation from JavaScript
Version ${versionID}
CommitID ${commitID}
Copyright (c) 2010-2014 James Hall <james@parall.ax>, https://github.com/MrRio/jsPDF
2010 Aaron Spike, https://github.com/acspike
2012 Willow Systems Corporation, willow-systems.com
2012 Pablo Hess, https://github.com/pablohess
2012 Florian Jenett, https://github.com/fjenett
2013 Warren Weckesser, https://github.com/warrenweckesser
2013 Youssef Beddad, https://github.com/lifof
2013 Lee Driscoll, https://github.com/lsdriscoll
2013 Stefan Slonevskiy, https://github.com/stefslon
2013 Jeremy Morel, https://github.com/jmorel
2013 Christoph Hartmann, https://github.com/chris-rock
2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
2014 James Makes, https://github.com/dollaruw
2014 Diego Casorran, https://github.com/diegocr
2014 Steven Spungin, https://github.com/Flamenco
2014 Kenneth Glassey, https://github.com/Gavvers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Contributor(s):
siefkenj, ahwolf, rickygu, Midnith, saintclair, eaparango,
kim3er, mfo, alnorth, Flamenco
*/
var jsPDF=function(t){function Pa(q){var A={};this.subscribe=function(F,q,w){if("function"!==typeof q)return!1;A.hasOwnProperty(F)||(A[F]={});var t=Math.random().toString(35);A[F][t]=[q,!!w];return t};this.unsubscribe=function(q){for(var t in A)if(A[t][q])return delete A[t][q],!0;return!1};this.publish=function(F){if(A.hasOwnProperty(F)){var Z=Array.prototype.slice.call(arguments,1),w=[],S;for(S in A[F]){var aa=A[F][S];try{aa[0].apply(q,Z)}catch(ca){t.console&&console.error("jsPDF PubSub Error",ca.message,
ca)}aa[1]&&w.push(S)}w.length&&w.forEach(this.unsubscribe)}}}function q(V,A,F,Z){var w={};"object"===typeof V&&(w=V,V=w.orientation,A=w.unit||A,F=w.format||F,Z=w.compress||w.compressPdf||Z);A=A||"mm";F=F||"a4";V=(""+(V||"P")).toLowerCase();(""+F).toLowerCase();var S=!!Z&&"function"===typeof Uint8Array,aa=w.textColor||"0 g",ca=w.drawColor||"0 G",L=w.fontSize||16,oa=w.lineHeight||1.15,Qa=w.lineWidth||.200025,C=2,da=!1,N=[],r={},G={},D,Fa=[],u={},pa={},H={},qa={},Ga=null,E,z=0,I,m=[],J=[],B=[],ra=[],
W=[],sa=0,ta=0,P=0,M={},ea={},fa=[],ga,ha,ia,X,Q,ua,O,ja,T={title:"",subject:"",author:"",keywords:"",creator:""},f={},v=new Pa(f),h=function(a){return a.toFixed(2)},k=function(a){return a.toFixed(3)},U=function(a){return("0"+parseInt(a)).slice(-2)},va=function(a){a="00"+a;return a.substr(a.length-2)},c=function(a){da?m[I].push(a):(P+=a.length+1,ra.push(a))},K=function(){C++;N[C]=P;c(C+" 0 obj");return C},ba=function(a){c("stream");c(a);c("endstream")},Ha=function(){c("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]");
c("/Font <<");for(var a in r)r.hasOwnProperty(a)&&c("/"+a+" "+r[a].objectNumber+" 0 R");c(">>");c("/Shading <<");for(var b in u)u.hasOwnProperty(b)&&u[b]instanceof f.ShadingPattern&&0<=u[b].objectNumber&&c("/"+b+" "+u[b].objectNumber+" 0 R");v.publish("putShadingPatternDict");c(">>");c("/Pattern <<");for(var g in u)u.hasOwnProperty(g)&&u[g]instanceof f.TilingPattern&&0<=u[g].objectNumber&&c("/"+g+" "+u[g].objectNumber+" 0 R");v.publish("putTilingPatternDict");c(">>");c("/ExtGState <<");for(var d in H)H.hasOwnProperty(d)&&
0<=H[d].objectNumber&&c("/"+d+" "+H[d].objectNumber+" 0 R");v.publish("putGStateDict");c(">>");c("/XObject <<");for(var e in M)M.hasOwnProperty(e)&&0<=M[e].objectNumber&&c("/"+e+" "+M[e].objectNumber+" 0 R");v.publish("putXobjectDict");c(">>")},Ia=function(a,b,g,c){var e="F"+(Object.keys(r).length+1).toString(10);a=r[e]={id:e,PostScriptName:a,fontName:b,fontStyle:g,encoding:c,metadata:{}};G.hasOwnProperty(b)||(G[b]={});G[b][g]=e;v.publish("addFont",a);return e},wa=function(a,b){return new R(a.a*b.a+
a.b*b.c,a.a*b.b+a.b*b.d,a.c*b.a+a.d*b.c,a.c*b.b+a.d*b.d,a.e*b.a+a.f*b.c+b.e,a.e*b.b+a.f*b.d+b.f)},R=function(a,b,g,c,e,l){this.a=a;this.b=b;this.c=g;this.d=c;this.e=e;this.f=l};R.prototype={toString:function(){return[k(this.a),k(this.b),k(this.c),k(this.d),k(this.e),k(this.f)].join(" ")}};var ka=new R(1,0,0,1,0,0),la=function(){this.page=z;this.currentPage=I;this.pages=m.slice(0);this.pagedim=B.slice(0);this.pagesContext=J.slice(0);this.x=ga;this.y=ha;this.matrix=ia;this.width=X;this.height=Q;this.id=
"";this.objectNumber=-1};la.prototype={restore:function(){z=this.page;I=this.currentPage;J=this.pagesContext;B=this.pagedim;m=this.pages;ga=this.x;ha=this.y;ia=this.matrix;X=this.width;Q=this.height}};var xa=function(a,b){if(!pa[a]){var g=(b instanceof f.ShadingPattern?"Sh":"P")+(Object.keys(u).length+1).toString(10);b.id=g;pa[a]=g;u[g]=b;v.publish("addPattern",b)}},Ja=function(a,b){if(!a||!qa[a]){var g=!1,c;for(c in H)if(H.hasOwnProperty(c)&&H[c].equals(b)){g=!0;break}g?b=H[c]:(g="GS"+(Object.keys(H).length+
1).toString(10),H[g]=b,b.id=g);a&&(qa[a]=b.id);v.publish("addGState",b);return b}},ya=function(a,b){var g,c,e,l,f,h;b=b||{};g=b.sourceEncoding||"Unicode";e=b.outputEncoding;if((b.autoencode||e)&&r[D].metadata&&r[D].metadata[g]&&r[D].metadata[g].encoding&&(g=r[D].metadata[g].encoding,!e&&r[D].encoding&&(e=r[D].encoding),!e&&g.codePages&&(e=g.codePages[0]),"string"===typeof e&&(e=g[e]),e)){f=!1;l=[];g=0;for(c=a.length;g<c;g++)(h=e[a.charCodeAt(g)])?l.push(String.fromCharCode(h)):l.push(a[g]),l[g].charCodeAt(0)>>
8&&(f=!0);a=l.join("")}for(g=a.length;void 0===f&&0!==g;)a.charCodeAt(g-1)>>8&&(f=!0),g--;if(f){l=b.noBOM?[]:[254,255];g=0;for(c=a.length;g<c;g++){h=a.charCodeAt(g);f=h>>8;if(f>>8)throw Error("Character at position "+g+" of string '"+a+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");l.push(f);l.push(h-(f<<8))}a=String.fromCharCode.apply(void 0,l)}return a.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},Aa=function(a,b){"string"===typeof b&&b.toLowerCase();if("string"===typeof a){var c=
a.toLowerCase();za.hasOwnProperty(c)&&(a=za[c][0]/E,b=za[c][1]/E)}Array.isArray(a)&&(b=a[1],a=a[0]);da=!0;m[++z]=[];B[z]={width:Number(a)||X,height:Number(b)||Q};J[z]={};Ka(z)},La=function(){Aa.apply(this,arguments);c(h(Qa)+" w");c(ca);0!==sa&&c(sa+" J");0!==ta&&c(ta+" j");v.publish("addPage",{pageNumber:z})},Ra=function(a){0<a&&a<=z&&(m.splice(a,1),B.splice(a,1),z--,I>z&&(I=z),this.setPage(I))},Ka=function(a){0<a&&a<=z&&(I=a,X=B[a].width,Q=B[a].height)},Ba=function(a,b){var c;a=void 0!==a?a:r[D].fontName;
b=void 0!==b?b:r[D].fontStyle;void 0!==a&&(a=a.toLowerCase());switch(a){case "sans-serif":case "verdana":case "arial":case "helvetica":a="helvetica";break;case "fixed":case "monospace":case "terminal":case "courier":a="courier";break;default:a="times"}try{c=G[a][b]}catch(d){}c||(c=G.times[b],null==c&&(c=G.times.normal));return c},Da=function(){da=!1;C=2;ra=[];N=[];W=[];c("%PDF-1.3");var a,b,g,d,e;e=t.adler32cs||q.adler32cs;S&&"undefined"===typeof e&&(S=!1);for(a=1;a<=z;a++){K();g=(X=B[a].width)*E;
b=(Q=B[a].height)*E;c("<</Type /Page");c("/Parent 1 0 R");c("/Resources 2 0 R");c("/MediaBox [0 0 "+h(g)+" "+h(b)+"]");v.publish("putPage",{pageNumber:a,page:m[a]});c("/Contents "+(C+1)+" 0 R");c(">>");c("endobj");b=m[a].join("\n");b=(new R(E,0,0,-E,0,Q)).toString()+" cm\n"+b;K();if(S){g=[];for(d=b.length;d--;)g[d]=b.charCodeAt(d);d=e.from(b);b=new Deflater(6);b.append(new Uint8Array(g));b=b.flush();g=new Uint8Array(b.length+6);g.set(new Uint8Array([120,156]));g.set(b,2);g.set(new Uint8Array([d&255,
d>>8&255,d>>16&255,d>>24&255]),b.length+2);b=String.fromCharCode.apply(null,g);c("<</Length "+b.length+" /Filter [/FlateDecode]>>")}else c("<</Length "+b.length+">>");ba(b);c("endobj")}N[1]=P;c("1 0 obj");c("<</Type /Pages");a="/Kids [";for(d=0;d<z;d++)a+=3+2*d+" 0 R ";c(a+"]");c("/Count "+z);c(">>");c("endobj");v.publish("postPutPages");v.publish("putAdditionalObjects");for(a=0;a<W.length;a++)e=W[a],N[e.objId]=P,c(e.objId+" 0 obj"),c(e.content),c("endobj");C+=W.length;v.publish("postPutAdditionalObjects");
for(var l in r)r.hasOwnProperty(l)&&(a=r[l],a.objectNumber=K(),c("<</BaseFont/"+a.PostScriptName+"/Type/Font"),"string"===typeof a.encoding&&c("/Encoding/"+a.encoding),c("/Subtype/Type1>>"),c("endobj"));for(var y in H)if(H.hasOwnProperty(y)){l=H[y];l.objectNumber=K();c("<<");a=void 0;for(a in l)switch(a){case "opacity":c("/ca "+h(l[a]))}c(">>");c("endobj")}for(var p in M)M.hasOwnProperty(p)&&(y=M[p],y.objectNumber=K(),c("<<"),c("/Type /XObject"),c("/Subtype /Form"),c("/BBox ["+[h(y.x),h(y.y),h(y.x+
y.width),h(y.y+y.height)].join(" ")+"]"),c("/Matrix ["+y.matrix.toString()+"]"),y=y.pages[1].join("\n"),c("/Length "+y.length),c(">>"),ba(y),c("endobj"));for(var n in u)if(u.hasOwnProperty(n))if(u[n]instanceof f.ShadingPattern){p=u[n];y=K();l=p.colors;a=[];for(d=0;1>d;d+=.05)a.push(d);a.push(1);0!=l[0].offset&&l.unshift({offset:0,color:l[0].color});1!=l[l.length-1].offset&&l.push({offset:1,color:l[l.length-1].color});e="";for(b=g=0;b<a.length;b++){for(d=a[b];d>l[g+1].offset;)g++;var Y=l[g].offset;
d=(d-Y)/(l[g+1].offset-Y);var Y=l[g].color,Ca=l[g+1].color;e+=va(Math.round((1-d)*Y[0]+d*Ca[0]).toString(16))+va(Math.round((1-d)*Y[1]+d*Ca[1]).toString(16))+va(Math.round((1-d)*Y[2]+d*Ca[2]).toString(16))}l=e.trim();c("<< /FunctionType 0");c("/Domain [0.0 1.0]");c("/Size [21]");c("/BitsPerSample 8");c("/Range [0.0 1.0 0.0 1.0 0.0 1.0]");c("/Decode [0.0 1.0 0.0 1.0 0.0 1.0]");c("/Length "+l.length);c("/Filter /ASCIIHexDecode");c(">>");ba(l);c("endobj");p.objectNumber=K();c("<< /ShadingType "+p.type);
c("/ColorSpace /DeviceRGB");l="/Coords ["+k(parseFloat(p.coords[0]))+" "+k(parseFloat(p.coords[1]))+" ";l=2===p.type?l+(k(parseFloat(p.coords[2]))+" "+k(parseFloat(p.coords[3]))):l+(k(parseFloat(p.coords[2]))+" "+k(parseFloat(p.coords[3]))+" "+k(parseFloat(p.coords[4]))+" "+k(parseFloat(p.coords[5])));c(l+"]");p.matrix&&c("/Matrix ["+p.matrix.toString()+"]");c("/Function "+y+" 0 R");c("/Extend [true true]");c(">>");c("endobj")}else u[n]instanceof f.TilingPattern&&(p=u[n],y=K(),c("<<"),Ha(),c(">>"),
c("endobj"),p.objectNumber=K(),c("<< /Type /Pattern"),c("/PatternType 1"),c("/PaintType 1"),c("/TilingType 1"),c("/BBox ["+p.boundingBox.map(k).join(" ")+"]"),c("/XStep "+k(p.xStep)),c("/YStep "+k(p.yStep)),c("/Length "+p.stream.length),c("/Resources "+y+" 0 R"),p.matrix&&c("/Matrix ["+p.matrix.toString()+"]"),c(">>"),ba(p.stream),c("endobj"));v.publish("putResources");N[2]=P;c("2 0 obj");c("<<");Ha();c(">>");c("endobj");v.publish("postPutResources");K();c("<<");c("/Producer (jsPDF "+q.version+")");
for(var x in T)T.hasOwnProperty(x)&&T[x]&&c("/"+x.substr(0,1).toUpperCase()+x.substr(1)+" ("+ya(T[x])+")");n=new Date;x=n.getTimezoneOffset();p=Math.abs(x%60);x=[0>x?"+":"-",U(Math.floor(Math.abs(x/60))),"'",U(p),"'"].join("");c(["/CreationDate (D:",n.getFullYear(),U(n.getMonth()+1),U(n.getDate()),U(n.getHours()),U(n.getMinutes()),U(n.getSeconds()),x,")"].join(""));c(">>");c("endobj");K();c("<<");c("/Type /Catalog");c("/Pages 1 0 R");O||(O="fullwidth");switch(O){case "fullwidth":c("/OpenAction [3 0 R /FitH null]");
break;case "fullheight":c("/OpenAction [3 0 R /FitV null]");break;case "fullpage":c("/OpenAction [3 0 R /Fit]");break;case "original":c("/OpenAction [3 0 R /XYZ null null 1]");break;default:n=""+O,"%"===n.substr(n.length-1)&&(O=parseInt(O)/100),"number"===typeof O&&c("/OpenAction [3 0 R /XYZ null null "+h(O)+"]")}ja||(ja="continuous");switch(ja){case "continuous":c("/PageLayout /OneColumn");break;case "single":c("/PageLayout /SinglePage");break;case "two":case "twoleft":c("/PageLayout /TwoColumnLeft");
break;case "tworight":c("/PageLayout /TwoColumnRight")}ua&&c("/PageMode /"+ua);v.publish("putCatalog");c(">>");c("endobj");n=P;c("xref");c("0 "+(C+1));c("0000000000 65535 f ");for(x=1;x<=C;x++)"function"===typeof N[x]?c(("0000000000"+N[x]()).slice(-10)+" 00000 n "):c(("0000000000"+N[x]).slice(-10)+" 00000 n ");c("trailer");c("<<");c("/Size "+(C+1));c("/Root "+C+" 0 R");c("/Info "+(C-1)+" 0 R");c(">>");c("startxref");c(n);c("%%EOF");da=!0;return ra.join("\n")},Ma=function(a){var b="n";if("D"===a)b=
"S";else if("F"===a)b="f";else if("FD"===a||"DF"===a)b="B";else if("f"===a||"f*"===a||"B"===a||"B*"===a)b=a;return b},ma=function(a,b,g){a=Ma(a);if(b){g||(g=ka);var d=pa[b],e=u[d];if(e instanceof f.ShadingPattern)c("q"),c("W "+a),e.gState&&f.setGState(e.gState),c(g.toString()+" cm"),c("/"+d+" sh"),c("Q");else if(e instanceof f.TilingPattern){var l=new R(1,0,0,-1,0,Q);g.matrix&&(l=wa(g.matrix||ka,l),d=e.createClone(b,g.boundingBox,g.xStep,g.yStep,l).id);c("q");c("/Pattern cs");c("/"+d+" scn");e.gState&&
f.setGState(e.gState);c(a);c("Q")}}else c(a)},Na=function(){for(var a=Da(),b=a.length,c=new ArrayBuffer(b),d=new Uint8Array(c);b--;)d[b]=a.charCodeAt(b);return c},Ea=function(){return new Blob([Na()],{type:"application/pdf"})},Oa=function(a){a.foo=function(){try{return a.apply(this,arguments)}catch(c){var b=c.stack||"";~b.indexOf(" at ")&&(b=b.split(" at ")[1]);b="Error in function "+b.split("\n")[0].split("<")[0]+": "+c.message;if(t.console)t.console.error(b,c),t.alert&&alert(b);else throw Error(b);
}};a.foo.bar=a;return a.foo}(function(a,b){var c="dataur"===(""+a).substr(0,6)?"data:application/pdf;base64,"+btoa(Da()):0;switch(a){case void 0:return Da();case "save":if(navigator.getUserMedia&&(void 0===t.URL||void 0===t.URL.createObjectURL))return f.output("dataurlnewwindow");saveAs(Ea(),b);"function"===typeof saveAs.unload&&t.setTimeout&&setTimeout(saveAs.unload,911);break;case "arraybuffer":return Na();case "blob":return Ea();case "bloburi":case "bloburl":return t.URL&&t.URL.createObjectURL(Ea())||
void 0;case "datauristring":case "dataurlstring":return c;case "dataurlnewwindow":if((a=t.open(c))||"undefined"===typeof safari)return a;case "datauri":case "dataurl":return t.document.location.href=c;default:throw Error('Output type "'+a+'" is not supported.');}});switch(A){case "pt":E=1;break;case "mm":E=72/25.4000508;break;case "cm":E=72/2.54000508;break;case "in":E=72;break;case "px":E=96/72;break;case "pc":E=12;break;case "em":E=12;break;case "ex":E=6;break;default:throw"Invalid unit: "+A;}f.internal=
{pdfEscape:ya,getStyle:Ma,getFont:function(){return r[Ba.apply(f,arguments)]},getFontSize:function(){return L},getLineHeight:function(){return L*oa},write:function(a){c(1===arguments.length?a:Array.prototype.join.call(arguments," "))},getCoordinateString:function(a){return h(a)},getVerticalCoordinateString:function(a){return h(a)},collections:{},newObject:K,newAdditionalObject:function(){var a=2*m.length+1,a=a+W.length,a={objId:a,content:""};W.push(a);return a},newObjectDeferred:function(){C++;N[C]=
function(){return P};return C},newObjectDeferredBegin:function(a){N[a]=P},putStream:ba,events:v,scaleFactor:E,pageSize:{get width(){return X},get height(){return Q}},output:function(a,b){return Oa(a,b)},getNumberOfPages:function(){return m.length-1},pages:m,out:c,f2:h,getPageInfo:function(a){return{objId:2*(a-1)+3,pageNumber:a,pageContext:J[a]}},getCurrentPageInfo:function(){return{objId:2*(I-1)+3,pageNumber:I,pageContext:J[I]}},getPDFVersion:function(){return"1.3"}};f.GState=function(a){for(var b in a)a.hasOwnProperty(b)&&
0<="opacity".indexOf(b)&&(this[b]=a[b]);this.id="";this.objectNumber=-1;this.equals=function(a){if(!a||typeof a!==typeof this)return!1;var b=0,c;for(c in this)if(!(0<="id,objectNumber,equals".indexOf(c))){if(this.hasOwnProperty(c)&&!a.hasOwnProperty(c)||this[c]!==a[c])return!1;b++}for(c in a)a.hasOwnProperty(c)&&0>"id,objectNumber,equals".indexOf(c)&&b--;return 0===b}};f.addGState=function(a,b){Ja(a,b);return this};f.addPage=function(){La.apply(this,arguments);return this};f.setPage=function(){Ka.apply(this,
arguments);return this};f.insertPage=function(a){this.addPage();this.movePage(I,a);return this};f.movePage=function(a,b){var c,d,e;if(a>b){e=m[a];d=B[a];for(c=J[a];a>b;a--)m[a]=m[a-1],B[a]=B[a-1],J[a]=J[a-1];m[b]=e;B[b]=d;J[b]=c;this.setPage(b)}else if(a<b){e=m[a];d=B[a];for(c=J[a];a<b;a++)m[a]=m[a+1],B[a]=B[a+1],J[a]=J[a+1];m[b]=e;B[b]=d;J[b]=c;this.setPage(b)}return this};f.deletePage=function(){Ra.apply(this,arguments);return this};f.setDisplayMode=function(a,b,c){O=a;ja=b;ua=c;return this};f.saveGraphicsState=
function(){c("q");Fa.push({key:D,size:L});return this};f.restoreGraphicsState=function(){c("Q");var a=Fa.pop();D=a.key;L=a.size;return this};f.setCurrentTransformationMatrix=function(a){c(a.toString()+" cm");return this};f.beginFormObject=function(a,b,c,d,e){fa.push(new la);z=I=0;m=[];ga=a;ha=b;ia=e;Aa(c,d);return this};f.endFormObject=function(a){if(!ea[a]){var b=new la,c="Xo"+(Object.keys(M).length+1).toString(10);b.id=c;ea[a]=c;M[c]=b;v.publish("addFormObject",b);fa.pop().restore()}return this};
f.doFormObject=function(a,b){a=M[ea[a]];c("q");c(b.toString()+" cm");c("/"+a.id+" Do");c("Q");return this};f.getFormObject=function(a){a=M[ea[a]];return{x:a.x,y:a.y,width:a.width,height:a.height,matrix:a.matrix}};f.Matrix=R;f.matrixMult=wa;f.unitMatrix=ka;f.ShadingPattern=function(a,b,c,d,e){this.type="axial"===a?2:3;this.coords=b;this.colors=c;this.gState=d;this.matrix=e;this.id="";this.objectNumber=-1};f.TilingPattern=function(a,b,c,d,e){this.boundingBox=a;this.xStep=b;this.yStep=c;this.stream=
"";this.cloneIndex=0;this.gState=d;this.matrix=e;this.id="";this.objectNumber=-1};f.TilingPattern.prototype={createClone:function(a,b,c,d,e){b=new f.TilingPattern(b||this.boundingBox,c||this.xStep,d||this.yStep,this.gState,e||this.matrix);b.stream=this.stream;a=a+"$$"+this.cloneIndex++ +"$$";xa(a,b);return b}};f.addShadingPattern=function(a,b){xa(a,b);return this};f.beginTilingPattern=function(a){var b=a.boundingBox[0],c=a.boundingBox[1],d=a.boundingBox[2]-a.boundingBox[0],e=a.boundingBox[3]-a.boundingBox[1];
a=a.matrix;fa.push(new la);z=I=0;m=[];ga=b;ha=c;ia=a;Aa(d,e)};f.endTilingPattern=function(a,b){b.stream=m[I].join("\n");xa(a,b);v.publish("endTilingPattern",b);fa.pop().restore()};f.text=function(a,b,g,d,e,l){function f(a){a=a.split("\t").join(Array(w.TabLen||9).join(" "));return ya(a,d)}if("number"===typeof a){var p=g;g=b;b=a;a=p}"string"===typeof a&&(a=a.match(/[\n\r]/)?a.split(/\r\n|\r|\n/g):[a]);"string"===typeof e&&(l=e,e=null);"string"===typeof d&&(l=d,d=null);"number"===typeof d&&(e=d,d=null);
e&&"number"===typeof e?(e*=Math.PI/180,p=Math.cos(e),e=Math.sin(e),e=new R(p,e,-e,p,0,0)):e||(e=ka);d=d||{};"noBOM"in d||(d.noBOM=!0);"autoencode"in d||(d.autoencode=!0);var p="",n=this.internal.getCurrentPageInfo().pageContext;!0===d.stroke?!0!==n.lastTextWasStroke&&(p="1 Tr\n",n.lastTextWasStroke=!0):(n.lastTextWasStroke&&(p="0 Tr\n"),n.lastTextWasStroke=!1);"undefined"===typeof this._runningPageHeight&&(this._runningPageHeight=0);if("string"===typeof a)a=f(a);else if("[object Array]"===Object.prototype.toString.call(a)){for(var k=
a.concat(),n=[],q=k.length;q--;)n.push(f(k.shift()));if(l){var x,m,v=L*oa,t=a.map(function(a){return this.getStringUnitWidth(a)*L},this);m=Math.max.apply(Math,t);if("center"===l)k=b-m/2,b-=t[0]/2;else if("right"===l)k=b-m,b-=t[0];else throw Error('Unrecognized alignment option, use "center" or "right".');x=b;a=n[0]+") Tj\n";i=1;for(q=n.length;i<q;i++){var u=m-t[i];"center"===l&&(u/=2);a+=k-x+u+" -"+v+" Td ("+n[i];x=k+u;i<q-1&&(a+=") Tj\n")}}else a=n.join(") Tj\nT* (")}else throw Error('Type of text must be string or Array. "'+
a+'" is not recognized.');g=h(g);b=new R(1,0,0,-1,b,g);e=wa(b,e);c("BT\n"+L*oa+" TL\n"+p+(e.toString()+" Tm")+"\n("+a+") Tj\nET");return this};f.lstext=function(a,b,c,d){for(var e=0,l=a.length;e<l;e++,b+=d)this.text(a[e],b,c)};f.line=function(a,b,c,d){return this.lines([[c-a,d-b]],a,b,[1,1],"D")};f.clip=function(){c("W");c("S")};f.lines=function(a,b,g,d,e,l,f,h){var n,q,m,t,u,v,w,r;"number"===typeof a&&(n=g,g=b,b=a,a=n);d=d||[1,1];c(k(b)+" "+k(g)+" m ");n=d[0];d=d[1];q=a.length;r=g;for(g=0;g<q;g++)m=
a[g],2===m.length?(b=m[0]*n+b,r=m[1]*d+r,c(k(b)+" "+k(r)+" l")):(t=m[0]*n+b,u=m[1]*d+r,v=m[2]*n+b,w=m[3]*d+r,b=m[4]*n+b,r=m[5]*d+r,c(k(t)+" "+k(u)+" "+k(v)+" "+k(w)+" "+k(b)+" "+k(r)+" c"));l&&c("h");ma(e,f,h);return this};f.path=function(a,b,g,d){for(var e=0;e<a.length;e++){var f=a[e],h=f.c;switch(f.op){case "m":c(k(h[0])+" "+k(h[1])+" m");break;case "l":c(k(h[0])+" "+k(h[1])+" l");break;case "c":c([k(h[0]),k(h[1]),k(h[2]),k(h[3]),k(h[4]),k(h[5]),"c"].join(" "));break;case "h":c("h")}}ma(b,g,d);
return this};f.rect=function(a,b,g,d,e,f,k){c([h(a),h(b),h(g),h(-d),"re"].join(" "));ma(e,f,k);return this};f.triangle=function(a,b,c,d,e,f,h,k,n){this.lines([[c-a,d-b],[e-c,f-d],[a-e,b-f]],a,b,[1,1],h,!0,k,n);return this};f.roundedRect=function(a,b,c,d,e,f,h,k,n){var m=4/3*(Math.SQRT2-1);e=Math.min(e,.5*c);f=Math.min(f,.5*d);this.lines([[c-2*e,0],[e*m,0,e,f-f*m,e,f],[0,d-2*f],[0,f*m,-(e*m),f,-e,f],[-c+2*e,0],[-(e*m),0,-e,-(f*m),-e,-f],[0,-d+2*f],[0,-(f*m),e*m,-f,e,-f]],a+e,b,[1,1],h,!0,k,n);return this};
f.ellipse=function(a,b,g,d,e,f,k){var m=4/3*(Math.SQRT2-1)*g,n=4/3*(Math.SQRT2-1)*d;c([h(a+g),h(b),"m",h(a+g),h(b-n),h(a+m),h(b-d),h(a),h(b-d),"c"].join(" "));c([h(a-m),h(b-d),h(a-g),h(b-n),h(a-g),h(b),"c"].join(" "));c([h(a-g),h(b+n),h(a-m),h(b+d),h(a),h(b+d),"c"].join(" "));c([h(a+m),h(b+d),h(a+g),h(b+n),h(a+g),h(b),"c"].join(" "));ma(e,f,k);return this};f.circle=function(a,b,c,d,e,f){return this.ellipse(a,b,c,c,d,e,f)};f.setProperties=function(a){for(var b in T)T.hasOwnProperty(b)&&a[b]&&(T[b]=
a[b]);return this};f.setFontSize=function(a){L=a;c("/"+D+" "+L+" Tf");return this};f.getFontSize=function(){return L};f.setFont=function(a,b){D=Ba(a,b);c("/"+D+" "+L+" Tf");return this};f.setFontStyle=f.setFontType=function(a){D=Ba(void 0,a);return this};f.getFontList=function(){var a={},b,c,d;for(b in G)if(G.hasOwnProperty(b))for(c in a[b]=d=[],G[b])G[b].hasOwnProperty(c)&&d.push(c);return a};f.addFont=function(a,b,c){Ia(a,b,c,"StandardEncoding")};f.setLineWidth=function(a){c(a.toFixed(2)+" w");
return this};f.setDrawColor=function(a,b,g,d){a=void 0===b||void 0===d&&a===b===g?"string"===typeof a?a+" G":h(a/255)+" G":void 0===d?"string"===typeof a?[a,b,g,"RG"].join(" "):[h(a/255),h(b/255),h(g/255),"RG"].join(" "):"string"===typeof a?[a,b,g,d,"K"].join(" "):[h(a),h(b),h(g),h(d),"K"].join(" ");c(a);return this};f.setFillColor=function(a,b,g,d){void 0===b||void 0===d&&a===b===g?a="string"===typeof a?a+" g":h(a/255)+" g":void 0===d||"object"===typeof d?(a="string"===typeof a?[a,b,g,"rg"].join(" "):
[h(a/255),h(b/255),h(g/255),"rg"].join(" "),d&&0===d.a&&(a="255 255 255 rg")):a="string"===typeof a?[a,b,g,d,"k"].join(" "):[h(a),h(b),h(g),h(d),"k"].join(" ");c(a);return this};f.setTextColor=function(a,b,g){"string"===typeof a&&/^#[0-9A-Fa-f]{6}$/.test(a)&&(g=parseInt(a.substr(1),16),a=g>>16&255,b=g>>8&255,g&=255);aa=0===a&&0===b&&0===g||"undefined"===typeof b?k(a/255)+" g":[k(a/255),k(b/255),k(g/255),"rg"].join(" ");c(aa);return this};f.setGState=function(a){a="string"===typeof a?H[qa[a]]:Ja(null,
a);a.equals(Ga)||(c("/"+a.id+" gs"),Ga=a)};f.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2};f.setLineCap=function(a){var b=this.CapJoinStyles[a];if(void 0===b)throw Error("Line cap style of '"+a+"' is not recognized. See or extend .CapJoinStyles property for valid styles");sa=b;c(b+" J");return this};f.setLineJoin=function(a){var b=this.CapJoinStyles[a];if(void 0===b)throw Error("Line join style of '"+a+"' is not recognized. See or extend .CapJoinStyles property for valid styles");
ta=b;c(b+" j");return this};f.setLineMiterLimit=function(a){c(h(a)+" M");return this};f.setLineDashPattern=function(a,b){c(["["+(void 0!==a[0]?a[0]:""),(void 0!==a[1]?a[1]:"")+"]",b,"d"].join(" "));return this};f.output=Oa;f.save=function(a){f.output("save",a)};for(var na in q.API)q.API.hasOwnProperty(na)&&("events"===na&&q.API.events.length?function(a,b){var c,d,e;for(e=b.length-1;-1!==e;e--)c=b[e][0],d=b[e][1],a.subscribe.apply(a,[c].concat("function"===typeof d?[d]:d))}(v,q.API.events):f[na]=q.API[na]);
(function(){for(var a=[["Helvetica","helvetica","normal"],["Helvetica-Bold","helvetica","bold"],["Helvetica-Oblique","helvetica","italic"],["Helvetica-BoldOblique","helvetica","bolditalic"],["Courier","courier","normal"],["Courier-Bold","courier","bold"],["Courier-Oblique","courier","italic"],["Courier-BoldOblique","courier","bolditalic"],["Times-Roman","times","normal"],["Times-Bold","times","bold"],["Times-Italic","times","italic"],["Times-BoldItalic","times","bolditalic"],["ZapfDingbats","zapfdingbats"]],
b=0,c=a.length;b<c;b++){var d=Ia(a[b][0],a[b][1],a[b][2],"StandardEncoding"),e=a[b][0].split("-"),f=e[0],e=e[1]||"";G.hasOwnProperty(f)||(G[f]={});G[f][e]=d}v.publish("addFonts",{fonts:r,dictionary:G})})();D="F1";La(F,V);v.publish("initialized");return f}var za={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,
2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,
360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};q.API={events:[]};q.version="1.0.0-trunk";"function"===typeof define&&define.amd?define("jsPDF",function(){return q}):"undefined"!==typeof module&&module.exports?module.exports=q:t.jsPDF=q;return q}("undefined"!==typeof self&&self||"undefined"!==typeof window&&window||this);
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 | 1 1 1 1 1 1 1 1 1 1 1 | /** @preserve
* jsPDF - PDF Document creation from JavaScript
* Version ${versionID}
* CommitID ${commitID}
*
* Copyright (c) 2010-2014 James Hall <james@parall.ax>, https://github.com/MrRio/jsPDF
* 2010 Aaron Spike, https://github.com/acspike
* 2012 Willow Systems Corporation, willow-systems.com
* 2012 Pablo Hess, https://github.com/pablohess
* 2012 Florian Jenett, https://github.com/fjenett
* 2013 Warren Weckesser, https://github.com/warrenweckesser
* 2013 Youssef Beddad, https://github.com/lifof
* 2013 Lee Driscoll, https://github.com/lsdriscoll
* 2013 Stefan Slonevskiy, https://github.com/stefslon
* 2013 Jeremy Morel, https://github.com/jmorel
* 2013 Christoph Hartmann, https://github.com/chris-rock
* 2014 Juan Pablo Gaviria, https://github.com/juanpgaviria
* 2014 James Makes, https://github.com/dollaruw
* 2014 Diego Casorran, https://github.com/diegocr
* 2014 Steven Spungin, https://github.com/Flamenco
* 2014 Kenneth Glassey, https://github.com/Gavvers
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Contributor(s):
* siefkenj, ahwolf, rickygu, Midnith, saintclair, eaparango,
* kim3er, mfo, alnorth, Flamenco
*/
/**
* Creates new jsPDF document object instance.
*
* @class
* @param orientation One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
* @param unit Measurement unit to be used when coordinates are specified.
* One of "pt" (points), "mm" (Default), "cm", "in"
* @param format One of 'pageFormats' as shown below, default: a4
* @returns {jsPDF}
* @name jsPDF
*/
var jsPDF = (function(global) {
'use strict';
var pdfVersion = '1.3',
pageFormats = { // Size in pt of various paper formats
'a0' : [2383.94, 3370.39], 'a1' : [1683.78, 2383.94],
'a2' : [1190.55, 1683.78], 'a3' : [ 841.89, 1190.55],
'a4' : [ 595.28, 841.89], 'a5' : [ 419.53, 595.28],
'a6' : [ 297.64, 419.53], 'a7' : [ 209.76, 297.64],
'a8' : [ 147.40, 209.76], 'a9' : [ 104.88, 147.40],
'a10' : [ 73.70, 104.88], 'b0' : [2834.65, 4008.19],
'b1' : [2004.09, 2834.65], 'b2' : [1417.32, 2004.09],
'b3' : [1000.63, 1417.32], 'b4' : [ 708.66, 1000.63],
'b5' : [ 498.90, 708.66], 'b6' : [ 354.33, 498.90],
'b7' : [ 249.45, 354.33], 'b8' : [ 175.75, 249.45],
'b9' : [ 124.72, 175.75], 'b10' : [ 87.87, 124.72],
'c0' : [2599.37, 3676.54], 'c1' : [1836.85, 2599.37],
'c2' : [1298.27, 1836.85], 'c3' : [ 918.43, 1298.27],
'c4' : [ 649.13, 918.43], 'c5' : [ 459.21, 649.13],
'c6' : [ 323.15, 459.21], 'c7' : [ 229.61, 323.15],
'c8' : [ 161.57, 229.61], 'c9' : [ 113.39, 161.57],
'c10' : [ 79.37, 113.39], 'dl' : [ 311.81, 623.62],
'letter' : [612, 792],
'government-letter' : [576, 756],
'legal' : [612, 1008],
'junior-legal' : [576, 360],
'ledger' : [1224, 792],
'tabloid' : [792, 1224],
'credit-card' : [153, 243]
};
/**
* jsPDF's Internal PubSub Implementation.
* See mrrio.github.io/jsPDF/doc/symbols/PubSub.html
* Backward compatible rewritten on 2014 by
* Diego Casorran, https://github.com/diegocr
*
* @class
* @name PubSub
*/
function PubSub(context) {
var topics = {};
this.subscribe = function(topic, callback, once) {
if(typeof callback !== 'function') {
return false;
}
if(!topics.hasOwnProperty(topic)) {
topics[topic] = {};
}
var id = Math.random().toString(35);
topics[topic][id] = [callback,!!once];
return id;
};
this.unsubscribe = function(token) {
for(var topic in topics) {
if(topics[topic][token]) {
delete topics[topic][token];
return true;
}
}
return false;
};
this.publish = function(topic) {
if(topics.hasOwnProperty(topic)) {
var args = Array.prototype.slice.call(arguments, 1), idr = [];
for(var id in topics[topic]) {
var sub = topics[topic][id];
try {
sub[0].apply(context, args);
} catch(ex) {
if(global.console) {
console.error('jsPDF PubSub Error', ex.message, ex);
}
}
if(sub[1]) idr.push(id);
}
if(idr.length) idr.forEach(this.unsubscribe);
}
};
}
/**
* @constructor
* @private
*/
function jsPDF(orientation, unit, format, compressPdf) {
var options = {};
if (typeof orientation === 'object') {
options = orientation;
orientation = options.orientation;
unit = options.unit || unit;
format = options.format || format;
compressPdf = options.compress || options.compressPdf || compressPdf;
}
// Default options
unit = unit || 'mm';
format = format || 'a4';
orientation = ('' + (orientation || 'P')).toLowerCase();
var format_as_string = ('' + format).toLowerCase(),
compress = !!compressPdf && typeof Uint8Array === 'function',
textColor = options.textColor || '0 g',
drawColor = options.drawColor || '0 G',
activeFontSize = options.fontSize || 16,
lineHeightProportion = options.lineHeight || 1.15,
lineWidth = options.lineWidth || 0.200025, // 2mm
objectNumber = 2, // 'n' Current object number
outToPages = !1, // switches where out() prints. outToPages true = push to pages obj. outToPages false = doc builder content
offsets = [], // List of offsets. Activated and reset by buildDocument(). Pupulated by various calls buildDocument makes.
fonts = {}, // collection of font objects, where key is fontKey - a dynamically created label for a given font.
fontmap = {}, // mapping structure fontName > fontStyle > font key - performance layer. See addFont()
activeFontKey, // will be string representing the KEY of the font as combination of fontName + fontStyle
fontStateStack = [], //
patterns = {}, // collection of pattern objects
patternMap = {}, // see fonts
gStates = {}, // collection of graphic state objects
gStatesMap = {}, // see fonts
activeGState = null,
k, // Scale factor
tmp,
page = 0,
currentPage,
pages = [],
pagesContext = [], // same index as pages and pagedim
pagedim = [],
content = [],
additionalObjects = [],
lineCapID = 0,
lineJoinID = 0,
content_length = 0,
renderTargets = {},
renderTargetMap = {},
renderTargetStack = [],
pageX, pageY, pageMatrix, // only used for FormObjects
pageWidth,
pageHeight,
pageMode,
zoomMode,
layoutMode,
documentProperties = {
'title' : '',
'subject' : '',
'author' : '',
'keywords' : '',
'creator' : ''
},
API = {},
events = new PubSub(API),
/////////////////////
// Private functions
/////////////////////
f2 = function(number) {
return number.toFixed(2); // Ie, %.2f
},
f3 = function(number) {
return number.toFixed(3); // Ie, %.3f
},
padd2 = function(number) {
return ('0' + parseInt(number)).slice(-2);
},
padd2Hex = function (hexString) {
var s = "00" + hexString;
return s.substr(s.length - 2);
},
out = function(string) {
if (outToPages) {
/* set by beginPage */
pages[currentPage].push(string);
} else {
// +1 for '\n' that will be used to join 'content'
content_length += string.length + 1;
content.push(string);
}
},
newObject = function() {
// Begin a new object
objectNumber++;
offsets[objectNumber] = content_length;
out(objectNumber + ' 0 obj');
return objectNumber;
},
// Does not output the object until after the pages have been output.
// Returns an object containing the objectId and content.
// All pages have been added so the object ID can be estimated to start right after.
// This does not modify the current objectNumber; It must be updated after the newObjects are output.
newAdditionalObject = function() {
var objId = pages.length * 2 + 1;
objId += additionalObjects.length;
var obj = {objId:objId, content:''};
additionalObjects.push(obj);
return obj;
},
// Does not output the object. The caller must call newObjectDeferredBegin(oid) before outputing any data
newObjectDeferred = function() {
objectNumber++;
offsets[objectNumber] = function(){
return content_length;
};
return objectNumber;
},
newObjectDeferredBegin = function(oid) {
offsets[oid] = content_length;
},
putStream = function(str) {
out('stream');
out(str);
out('endstream');
},
putPages = function() {
var n,p,arr,i,deflater,adler32,adler32cs,wPt,hPt;
adler32cs = global.adler32cs || jsPDF.adler32cs;
if (compress && typeof adler32cs === 'undefined') {
compress = false;
}
// outToPages = false as set in endDocument(). out() writes to content.
for (n = 1; n <= page; n++) {
newObject();
wPt = (pageWidth = pagedim[n].width) * k;
hPt = (pageHeight = pagedim[n].height) * k;
out('<</Type /Page');
out('/Parent 1 0 R');
out('/Resources 2 0 R');
out('/MediaBox [0 0 ' + f2(wPt) + ' ' + f2(hPt) + ']');
// Added for annotation plugin
events.publish('putPage', {pageNumber: n, page: pages[n]});
out('/Contents ' + (objectNumber + 1) + ' 0 R');
out('>>');
out('endobj');
// Page content
p = pages[n].join('\n');
// prepend global change of basis matrix
// (Now, instead of converting every coordinate to the pdf coordinate system, we apply a matrix
// that does this job for us (however, texts, images and similar objects must be drawn bottom up))
p = new Matrix(k, 0, 0, -k, 0, pageHeight).toString() + " cm\n" + p;
newObject();
if (compress) {
arr = [];
i = p.length;
while(i--) {
arr[i] = p.charCodeAt(i);
}
adler32 = adler32cs.from(p);
deflater = new Deflater(6);
deflater.append(new Uint8Array(arr));
p = deflater.flush();
arr = new Uint8Array(p.length + 6);
arr.set(new Uint8Array([120, 156]));
arr.set(p, 2);
arr.set(new Uint8Array([adler32 & 0xFF, (adler32 >> 8) & 0xFF, (adler32 >> 16) & 0xFF, (adler32 >> 24) & 0xFF]), p.length+2);
p = String.fromCharCode.apply(null, arr);
out('<</Length ' + p.length + ' /Filter [/FlateDecode]>>');
} else {
out('<</Length ' + p.length + '>>');
}
putStream(p);
out('endobj');
}
offsets[1] = content_length;
out('1 0 obj');
out('<</Type /Pages');
var kids = '/Kids [';
for (i = 0; i < page; i++) {
kids += (3 + 2 * i) + ' 0 R ';
}
out(kids + ']');
out('/Count ' + page);
out('>>');
out('endobj');
events.publish('postPutPages');
},
putFont = function(font) {
font.objectNumber = newObject();
out('<</BaseFont/' + font.PostScriptName + '/Type/Font');
if (typeof font.encoding === 'string') {
out('/Encoding/' + font.encoding);
}
out('/Subtype/Type1>>');
out('endobj');
},
putFonts = function() {
for (var fontKey in fonts) {
if (fonts.hasOwnProperty(fontKey)) {
putFont(fonts[fontKey]);
}
}
},
putXObject = function (xObject) {
xObject.objectNumber = newObject();
out("<<");
out("/Type /XObject");
out("/Subtype /Form");
out("/BBox [" + [
f2(xObject.x),
f2(xObject.y),
f2(xObject.x + xObject.width),
f2(xObject.y + xObject.height)
].join(" ") + "]");
out("/Matrix [" + xObject.matrix.toString() + "]");
// TODO: /Resources
var p = xObject.pages[1].join("\n");
out("/Length " + p.length);
out(">>");
putStream(p);
out("endobj");
},
putXObjects = function () {
for (var xObjectKey in renderTargets) {
if (renderTargets.hasOwnProperty(xObjectKey)) {
putXObject(renderTargets[xObjectKey]);
}
}
},
interpolateAndEncodeRGBStream = function (colors, numberSamples) {
var tValues = [];
var t;
var dT = 1.0 / (numberSamples - 1);
for (t = 0.0; t < 1.0; t += dT) {
tValues.push(t);
}
tValues.push(1.0);
// add first and last control point if not present
if (colors[0].offset != 0.0) {
var c0 = {
offset: 0.0,
color: colors[0].color
};
colors.unshift(c0)
}
if (colors[colors.length - 1].offset != 1.0) {
var c1 = {
offset: 1.0,
color: colors[colors.length - 1].color
};
colors.push(c1);
}
var out = "";
var index = 0;
for (var i = 0; i < tValues.length; i++) {
t = tValues[i];
while (t > colors[index + 1].offset)
index++;
var a = colors[index].offset;
var b = colors[index + 1].offset;
var d = (t - a) / (b - a);
var aColor = colors[index].color;
var bColor = colors[index + 1].color;
out += padd2Hex((Math.round((1 - d) * aColor[0] + d * bColor[0])).toString(16))
+ padd2Hex((Math.round((1 - d) * aColor[1] + d * bColor[1])).toString(16))
+ padd2Hex((Math.round((1 - d) * aColor[2] + d * bColor[2])).toString(16));
}
return out.trim();
},
putShadingPattern = function (pattern, numberSamples) {
/*
Axial patterns shade between the two points specified in coords, radial patterns between the inner
and outer circle.
The user can specify an array (colors) that maps t-Values in [0, 1] to RGB colors. These are now
interpolated to equidistant samples and written to pdf as a sample (type 0) function.
*/
// The number of color samples that should be used to describe the shading.
// The higher, the more accurate the gradient will be.
numberSamples || (numberSamples = 21);
var funcObjectNumber = newObject();
var stream = interpolateAndEncodeRGBStream(pattern.colors, numberSamples);
out("<< /FunctionType 0");
out("/Domain [0.0 1.0]");
out("/Size [" + numberSamples + "]");
out("/BitsPerSample 8");
out("/Range [0.0 1.0 0.0 1.0 0.0 1.0]");
out("/Decode [0.0 1.0 0.0 1.0 0.0 1.0]");
out("/Length " + stream.length);
// The stream is Hex encoded
out("/Filter /ASCIIHexDecode");
out(">>");
putStream(stream);
out("endobj");
pattern.objectNumber = newObject();
out("<< /ShadingType " + pattern.type);
out("/ColorSpace /DeviceRGB");
var coords = "/Coords ["
+ f3(parseFloat(pattern.coords[0])) + " "// x1
+ f3(parseFloat(pattern.coords[1])) + " "; // y1
if (pattern.type === 2) {
// axial
coords += f3(parseFloat(pattern.coords[2])) + " " // x2
+ f3(parseFloat(pattern.coords[3])); // y2
} else {
// radial
coords += f3(parseFloat(pattern.coords[2])) + " "// r1
+ f3(parseFloat(pattern.coords[3])) + " " // x2
+ f3(parseFloat(pattern.coords[4])) + " " // y2
+ f3(parseFloat(pattern.coords[5])); // r2
}
coords += "]";
out(coords);
if (pattern.matrix) {
out("/Matrix [" + pattern.matrix.toString() + "]");
}
out("/Function " + funcObjectNumber + " 0 R");
out("/Extend [true true]");
out(">>");
out("endobj");
},
putTilingPattern = function (pattern) {
var resourcesObjectNumber = newObject();
out("<<");
putResourceDictionary();
out(">>");
out("endobj");
pattern.objectNumber = newObject();
out("<< /Type /Pattern");
out("/PatternType 1"); // tiling pattern
out("/PaintType 1"); // colored tiling pattern
out("/TilingType 1"); // constant spacing
out("/BBox [" + pattern.boundingBox.map(f3).join(" ") + "]");
out("/XStep " + f3(pattern.xStep));
out("/YStep " + f3(pattern.yStep));
out("/Length " + pattern.stream.length);
out("/Resources " + resourcesObjectNumber + " 0 R"); // TODO: resources
pattern.matrix && out("/Matrix [" + pattern.matrix.toString() + "]");
out(">>");
putStream(pattern.stream);
out("endobj");
},
putPatterns = function () {
var patternKey;
for (patternKey in patterns) {
if (patterns.hasOwnProperty(patternKey)) {
if (patterns[patternKey] instanceof API.ShadingPattern) {
putShadingPattern(patterns[patternKey]);
} else if (patterns[patternKey] instanceof API.TilingPattern) {
putTilingPattern(patterns[patternKey]);
}
}
}
},
putGState = function (gState) {
gState.objectNumber = newObject();
out("<<");
for (var p in gState) {
switch (p) {
case "opacity":
out("/ca " + f2(gState[p]));
break;
}
}
out(">>");
out("endobj");
},
putGStates = function () {
var gStateKey;
for (gStateKey in gStates) {
if (gStates.hasOwnProperty(gStateKey)) {
putGState(gStates[gStateKey]);
}
}
},
putXobjectDict = function () {
for (var xObjectKey in renderTargets) {
if (renderTargets.hasOwnProperty(xObjectKey) && renderTargets[xObjectKey].objectNumber >= 0) {
out("/" + xObjectKey + " " + renderTargets[xObjectKey].objectNumber + " 0 R");
}
}
events.publish('putXobjectDict');
},
putShadingPatternDict = function () {
for (var patternKey in patterns) {
if (patterns.hasOwnProperty(patternKey) && patterns[patternKey] instanceof API.ShadingPattern && patterns[patternKey].objectNumber >= 0) {
out("/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R");
}
}
events.publish("putShadingPatternDict");
},
putTilingPatternDict = function () {
for (var patternKey in patterns) {
if (patterns.hasOwnProperty(patternKey) && patterns[patternKey] instanceof API.TilingPattern && patterns[patternKey].objectNumber >= 0) {
out("/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R");
}
}
events.publish("putTilingPatternDict");
},
putGStatesDict = function () {
var gStateKey;
for (gStateKey in gStates) {
if (gStates.hasOwnProperty(gStateKey) && gStates[gStateKey].objectNumber >= 0) {
out("/" + gStateKey + " " + gStates[gStateKey].objectNumber + " 0 R");
}
}
events.publish("putGStateDict");
},
putResourceDictionary = function() {
out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
out('/Font <<');
// Do this for each font, the '1' bit is the index of the font
for (var fontKey in fonts) {
if (fonts.hasOwnProperty(fontKey)) {
out('/' + fontKey + ' ' + fonts[fontKey].objectNumber + ' 0 R');
}
}
out('>>');
out("/Shading <<");
putShadingPatternDict();
out(">>");
out("/Pattern <<");
putTilingPatternDict();
out(">>");
out("/ExtGState <<");
putGStatesDict();
out('>>');
out('/XObject <<');
putXobjectDict();
out('>>');
},
putResources = function() {
putFonts();
putGStates();
putXObjects();
putPatterns();
events.publish('putResources');
// Resource dictionary
offsets[2] = content_length;
out('2 0 obj');
out('<<');
putResourceDictionary();
out('>>');
out('endobj');
events.publish('postPutResources');
},
putAdditionalObjects = function() {
events.publish('putAdditionalObjects');
for (var i=0; i<additionalObjects.length; i++){
var obj = additionalObjects[i];
offsets[obj.objId] = content_length;
out( obj.objId + ' 0 obj');
out(obj.content);
out('endobj');
}
objectNumber += additionalObjects.length;
events.publish('postPutAdditionalObjects');
},
addToFontDictionary = function(fontKey, fontName, fontStyle) {
// this is mapping structure for quick font key lookup.
// returns the KEY of the font (ex: "F1") for a given
// pair of font name and type (ex: "Arial". "Italic")
if (!fontmap.hasOwnProperty(fontName)) {
fontmap[fontName] = {};
}
fontmap[fontName][fontStyle] = fontKey;
},
/**
* FontObject describes a particular font as member of an instnace of jsPDF
*
* It's a collection of properties like 'id' (to be used in PDF stream),
* 'fontName' (font's family name), 'fontStyle' (font's style variant label)
*
* @public
* @property id {String} PDF-document-instance-specific label assinged to the font.
* @property PostScriptName {String} PDF specification full name for the font
* @property encoding {Object} Encoding_name-to-Font_metrics_object mapping.
* @name FontObject
*/
addFont = function(PostScriptName, fontName, fontStyle, encoding) {
var fontKey = 'F' + (Object.keys(fonts).length + 1).toString(10),
// This is FontObject
font = fonts[fontKey] = {
'id' : fontKey,
'PostScriptName' : PostScriptName,
'fontName' : fontName,
'fontStyle' : fontStyle,
'encoding' : encoding,
'metadata' : {}
};
addToFontDictionary(fontKey, fontName, fontStyle);
events.publish('addFont', font);
return fontKey;
},
addFonts = function() {
var HELVETICA = "helvetica",
TIMES = "times",
COURIER = "courier",
NORMAL = "normal",
BOLD = "bold",
ITALIC = "italic",
BOLD_ITALIC = "bolditalic",
encoding = 'StandardEncoding',
ZAPF = "zapfdingbats",
standardFonts = [
['Helvetica', HELVETICA, NORMAL],
['Helvetica-Bold', HELVETICA, BOLD],
['Helvetica-Oblique', HELVETICA, ITALIC],
['Helvetica-BoldOblique', HELVETICA, BOLD_ITALIC],
['Courier', COURIER, NORMAL],
['Courier-Bold', COURIER, BOLD],
['Courier-Oblique', COURIER, ITALIC],
['Courier-BoldOblique', COURIER, BOLD_ITALIC],
['Times-Roman', TIMES, NORMAL],
['Times-Bold', TIMES, BOLD],
['Times-Italic', TIMES, ITALIC],
['Times-BoldItalic', TIMES, BOLD_ITALIC],
['ZapfDingbats',ZAPF ]
];
for (var i = 0, l = standardFonts.length; i < l; i++) {
var fontKey = addFont(
standardFonts[i][0],
standardFonts[i][1],
standardFonts[i][2],
encoding);
// adding aliases for standard fonts, this time matching the capitalization
var parts = standardFonts[i][0].split('-');
addToFontDictionary(fontKey, parts[0], parts[1] || '');
}
events.publish('addFonts', { fonts : fonts, dictionary : fontmap });
},
matrixMult = function (m1, m2) {
return new Matrix(
m1.a * m2.a + m1.b * m2.c,
m1.a * m2.b + m1.b * m2.d,
m1.c * m2.a + m1.d * m2.c,
m1.c * m2.b + m1.d * m2.d,
m1.e * m2.a + m1.f * m2.c + m2.e,
m1.e * m2.b + m1.f * m2.d + m2.f
);
},
Matrix = function (a, b, c, d, e, f) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.e = e;
this.f = f;
};
Matrix.prototype = {
toString: function () {
return [
f3(this.a),
f3(this.b),
f3(this.c),
f3(this.d),
f3(this.e),
f3(this.f)
].join(" ");
}
};
var unitMatrix = new Matrix(1, 0, 0, 1, 0, 0),
// Used (1) to save the current stream state to the XObjects stack and (2) to save completed form
// objects in the xObjects map.
RenderTarget = function () {
this.page = page;
this.currentPage = currentPage;
this.pages = pages.slice(0);
this.pagedim = pagedim.slice(0);
this.pagesContext = pagesContext.slice(0);
this.x = pageX;
this.y = pageY;
this.matrix = pageMatrix;
this.width = pageWidth;
this.height = pageHeight;
this.id = ""; // set by endFormObject()
this.objectNumber = -1; // will be set by putXObject()
};
RenderTarget.prototype = {
restore: function () {
page = this.page;
currentPage = this.currentPage;
pagesContext = this.pagesContext;
pagedim = this.pagedim;
pages = this.pages;
pageX = this.x;
pageY = this.y;
pageMatrix = this.matrix;
pageWidth = this.width;
pageHeight = this.height;
}
};
var beginNewRenderTarget = function (x, y, width, height, matrix) {
// save current state
renderTargetStack.push(new RenderTarget());
// clear pages
page = currentPage = 0;
pages = [];
pageX = x;
pageY = y;
pageMatrix = matrix;
beginPage(width, height);
},
endFormObject = function (key) {
// only add it if it is not already present (the keys provided by the user must be unique!)
if (renderTargetMap[key])
return;
// save the created xObject
var newXObject = new RenderTarget();
var xObjectId = 'Xo' + (Object.keys(renderTargets).length + 1).toString(10);
newXObject.id = xObjectId;
renderTargetMap[key] = xObjectId;
renderTargets[xObjectId] = newXObject;
events.publish('addFormObject', newXObject);
// restore state from stack
renderTargetStack.pop().restore();
},
/**
* Adds a new pattern for later use.
* @param {String} key The key by it can be referenced later. The keys must be unique!
* @param {API.Pattern} pattern The pattern
*/
addPattern = function (key, pattern) {
// only add it if it is not already present (the keys provided by the user must be unique!)
if (patternMap[key])
return;
var prefix = pattern instanceof API.ShadingPattern ? "Sh" : "P";
var patternKey = prefix + (Object.keys(patterns).length + 1).toString(10);
pattern.id = patternKey;
patternMap[key] = patternKey;
patterns[patternKey] = pattern;
events.publish('addPattern', pattern);
},
/**
* Adds a new Graphics State. Duplicates are automatically eliminated.
* @param {String} key Might also be null, if no later reference to this gState is needed
* @param {Object} gState The gState object
*/
addGState = function (key, gState) {
// only add it if it is not already present (the keys provided by the user must be unique!)
if (key && gStatesMap[key])
return;
var duplicate = false;
for (var s in gStates) {
if (gStates.hasOwnProperty(s)) {
if (gStates[s].equals(gState)) {
duplicate = true;
break;
}
}
}
if (duplicate) {
gState = gStates[s];
} else {
var gStateKey = 'GS' + (Object.keys(gStates).length + 1).toString(10);
gStates[gStateKey] = gState;
gState.id = gStateKey;
}
// several user keys may point to the same GState object
key && (gStatesMap[key] = gState.id);
events.publish('addGState', gState);
return gState;
},
SAFE = function __safeCall(fn) {
fn.foo = function __safeCallWrapper() {
try {
return fn.apply(this, arguments);
} catch (e) {
var stack = e.stack || '';
if(~stack.indexOf(' at ')) stack = stack.split(" at ")[1];
var m = "Error in function " + stack.split("\n")[0].split('<')[0] + ": " + e.message;
if(global.console) {
global.console.error(m, e);
if(global.alert) alert(m);
} else {
throw new Error(m);
}
}
};
fn.foo.bar = fn;
return fn.foo;
},
to8bitStream = function(text, flags) {
/**
* PDF 1.3 spec:
* "For text strings encoded in Unicode, the first two bytes must be 254 followed by
* 255, representing the Unicode byte order marker, U+FEFF. (This sequence conflicts
* with the PDFDocEncoding character sequence thorn ydieresis, which is unlikely
* to be a meaningful beginning of a word or phrase.) The remainder of the
* string consists of Unicode character codes, according to the UTF-16 encoding
* specified in the Unicode standard, version 2.0. Commonly used Unicode values
* are represented as 2 bytes per character, with the high-order byte appearing first
* in the string."
*
* In other words, if there are chars in a string with char code above 255, we
* recode the string to UCS2 BE - string doubles in length and BOM is prepended.
*
* HOWEVER!
* Actual *content* (body) text (as opposed to strings used in document properties etc)
* does NOT expect BOM. There, it is treated as a literal GID (Glyph ID)
*
* Because of Adobe's focus on "you subset your fonts!" you are not supposed to have
* a font that maps directly Unicode (UCS2 / UTF16BE) code to font GID, but you could
* fudge it with "Identity-H" encoding and custom CIDtoGID map that mimics Unicode
* code page. There, however, all characters in the stream are treated as GIDs,
* including BOM, which is the reason we need to skip BOM in content text (i.e. that
* that is tied to a font).
*
* To signal this "special" PDFEscape / to8bitStream handling mode,
* API.text() function sets (unless you overwrite it with manual values
* given to API.text(.., flags) )
* flags.autoencode = true
* flags.noBOM = true
*
* ===================================================================================
* `flags` properties relied upon:
* .sourceEncoding = string with encoding label.
* "Unicode" by default. = encoding of the incoming text.
* pass some non-existing encoding name
* (ex: 'Do not touch my strings! I know what I am doing.')
* to make encoding code skip the encoding step.
* .outputEncoding = Either valid PDF encoding name
* (must be supported by jsPDF font metrics, otherwise no encoding)
* or a JS object, where key = sourceCharCode, value = outputCharCode
* missing keys will be treated as: sourceCharCode === outputCharCode
* .noBOM
* See comment higher above for explanation for why this is important
* .autoencode
* See comment higher above for explanation for why this is important
*/
var i,l,sourceEncoding,encodingBlock,outputEncoding,newtext,isUnicode,ch,bch;
flags = flags || {};
sourceEncoding = flags.sourceEncoding || 'Unicode';
outputEncoding = flags.outputEncoding;
// This 'encoding' section relies on font metrics format
// attached to font objects by, among others,
// "Willow Systems' standard_font_metrics plugin"
// see jspdf.plugin.standard_font_metrics.js for format
// of the font.metadata.encoding Object.
// It should be something like
// .encoding = {'codePages':['WinANSI....'], 'WinANSI...':{code:code, ...}}
// .widths = {0:width, code:width, ..., 'fof':divisor}
// .kerning = {code:{previous_char_code:shift, ..., 'fof':-divisor},...}
if ((flags.autoencode || outputEncoding) &&
fonts[activeFontKey].metadata &&
fonts[activeFontKey].metadata[sourceEncoding] &&
fonts[activeFontKey].metadata[sourceEncoding].encoding) {
encodingBlock = fonts[activeFontKey].metadata[sourceEncoding].encoding;
// each font has default encoding. Some have it clearly defined.
if (!outputEncoding && fonts[activeFontKey].encoding) {
outputEncoding = fonts[activeFontKey].encoding;
}
// Hmmm, the above did not work? Let's try again, in different place.
if (!outputEncoding && encodingBlock.codePages) {
outputEncoding = encodingBlock.codePages[0]; // let's say, first one is the default
}
if (typeof outputEncoding === 'string') {
outputEncoding = encodingBlock[outputEncoding];
}
// we want output encoding to be a JS Object, where
// key = sourceEncoding's character code and
// value = outputEncoding's character code.
if (outputEncoding) {
isUnicode = false;
newtext = [];
for (i = 0, l = text.length; i < l; i++) {
ch = outputEncoding[text.charCodeAt(i)];
if (ch) {
newtext.push(
String.fromCharCode(ch));
} else {
newtext.push(
text[i]);
}
// since we are looping over chars anyway, might as well
// check for residual unicodeness
if (newtext[i].charCodeAt(0) >> 8) {
/* more than 255 */
isUnicode = true;
}
}
text = newtext.join('');
}
}
i = text.length;
// isUnicode may be set to false above. Hence the triple-equal to undefined
while (isUnicode === undefined && i !== 0) {
if (text.charCodeAt(i - 1) >> 8) {
/* more than 255 */
isUnicode = true;
}
i--;
}
if (!isUnicode) {
return text;
}
newtext = flags.noBOM ? [] : [254, 255];
for (i = 0, l = text.length; i < l; i++) {
ch = text.charCodeAt(i);
bch = ch >> 8; // divide by 256
if (bch >> 8) {
/* something left after dividing by 256 second time */
throw new Error("Character at position " + i + " of string '"
+ text + "' exceeds 16bits. Cannot be encoded into UCS-2 BE");
}
newtext.push(bch);
newtext.push(ch - (bch << 8));
}
return String.fromCharCode.apply(undefined, newtext);
},
pdfEscape = function(text, flags) {
/**
* Replace '/', '(', and ')' with pdf-safe versions
*
* Doing to8bitStream does NOT make this PDF display unicode text. For that
* we also need to reference a unicode font and embed it - royal pain in the rear.
*
* There is still a benefit to to8bitStream - PDF simply cannot handle 16bit chars,
* which JavaScript Strings are happy to provide. So, while we still cannot display
* 2-byte characters property, at least CONDITIONALLY converting (entire string containing)
* 16bit chars to (USC-2-BE) 2-bytes per char + BOM streams we ensure that entire PDF
* is still parseable.
* This will allow immediate support for unicode in document properties strings.
*/
return to8bitStream(text, flags).replace(/\\/g, '\\\\').replace(/\(/g, '\\(').replace(/\)/g, '\\)');
},
putInfo = function() {
out('/Producer (jsPDF ' + jsPDF.version + ')');
for(var key in documentProperties) {
if(documentProperties.hasOwnProperty(key) && documentProperties[key]) {
out('/'+key.substr(0,1).toUpperCase() + key.substr(1)
+' (' + pdfEscape(documentProperties[key]) + ')');
}
}
var created = new Date(),
tzoffset = created.getTimezoneOffset(),
tzsign = tzoffset < 0 ? '+' : '-',
tzhour = Math.floor(Math.abs(tzoffset / 60)),
tzmin = Math.abs(tzoffset % 60),
tzstr = [tzsign, padd2(tzhour), "'", padd2(tzmin), "'"].join('');
out(['/CreationDate (D:',
created.getFullYear(),
padd2(created.getMonth() + 1),
padd2(created.getDate()),
padd2(created.getHours()),
padd2(created.getMinutes()),
padd2(created.getSeconds()), tzstr, ')'].join(''));
},
putCatalog = function() {
out('/Type /Catalog');
out('/Pages 1 0 R');
// PDF13ref Section 7.2.1
if (!zoomMode) zoomMode = 'fullwidth';
switch(zoomMode) {
case 'fullwidth' : out('/OpenAction [3 0 R /FitH null]'); break;
case 'fullheight' : out('/OpenAction [3 0 R /FitV null]'); break;
case 'fullpage' : out('/OpenAction [3 0 R /Fit]'); break;
case 'original' : out('/OpenAction [3 0 R /XYZ null null 1]'); break;
default:
var pcn = '' + zoomMode;
if (pcn.substr(pcn.length-1) === '%')
zoomMode = parseInt(zoomMode) / 100;
if (typeof zoomMode === 'number') {
out('/OpenAction [3 0 R /XYZ null null '+f2(zoomMode)+']');
}
}
if (!layoutMode) layoutMode = 'continuous';
switch(layoutMode) {
case 'continuous' : out('/PageLayout /OneColumn'); break;
case 'single' : out('/PageLayout /SinglePage'); break;
case 'two':
case 'twoleft' : out('/PageLayout /TwoColumnLeft'); break;
case 'tworight' : out('/PageLayout /TwoColumnRight'); break;
}
if (pageMode) {
/**
* A name object specifying how the document should be displayed when opened:
* UseNone : Neither document outline nor thumbnail images visible -- DEFAULT
* UseOutlines : Document outline visible
* UseThumbs : Thumbnail images visible
* FullScreen : Full-screen mode, with no menu bar, window controls, or any other window visible
*/
out('/PageMode /' + pageMode);
}
events.publish('putCatalog');
},
putTrailer = function() {
out('/Size ' + (objectNumber + 1));
out('/Root ' + objectNumber + ' 0 R');
out('/Info ' + (objectNumber - 1) + ' 0 R');
},
beginPage = function(width,height) {
// Dimensions are stored as user units and converted to points on output
var orientation = typeof height === 'string' && height.toLowerCase();
if (typeof width === 'string') {
var format = width.toLowerCase();
if (pageFormats.hasOwnProperty(format)) {
width = pageFormats[format][0] / k;
height = pageFormats[format][1] / k;
}
}
if (Array.isArray(width)) {
height = width[1];
width = width[0];
}
//if (orientation) {
// switch(orientation.substr(0,1)) {
// case 'l': if (height > width ) orientation = 's'; break;
// case 'p': if (width > height ) orientation = 's'; break;
// }
// TODO: What is the reason for this (for me it only seems to raise bugs)?
// if (orientation === 's') { tmp = width; width = height; height = tmp; }
//}
outToPages = true;
pages[++page] = [];
pagedim[page] = {
width : Number(width) || pageWidth,
height : Number(height) || pageHeight
};
pagesContext[page] = {};
_setPage(page);
},
_addPage = function() {
beginPage.apply(this, arguments);
// Set line width
out(f2(lineWidth) + ' w');
// Set draw color
out(drawColor);
// resurrecting non-default line caps, joins
if (lineCapID !== 0) {
out(lineCapID + ' J');
}
if (lineJoinID !== 0) {
out(lineJoinID + ' j');
}
events.publish('addPage', { pageNumber : page });
},
_deletePage = function( n ) {
if (n > 0 && n <= page) {
pages.splice(n, 1);
pagedim.splice(n, 1);
page--;
if (currentPage > page){
currentPage = page;
}
this.setPage(currentPage);
}
},
_setPage = function(n) {
if (n > 0 && n <= page) {
currentPage = n;
pageWidth = pagedim[n].width;
pageHeight = pagedim[n].height;
}
},
/**
* Returns a document-specific font key - a label assigned to a
* font name + font type combination at the time the font was added
* to the font inventory.
*
* Font key is used as label for the desired font for a block of text
* to be added to the PDF document stream.
* @private
* @function
* @param {String} fontName can be undefined on "falthy" to indicate "use current"
* @param {String} fontStyle can be undefined on "falthy" to indicate "use current"
* @returns {String} Font key.
*/
getFont = function(fontName, fontStyle) {
var key;
fontName = fontName !== undefined ? fontName : fonts[activeFontKey].fontName;
fontStyle = fontStyle !== undefined ? fontStyle : fonts[activeFontKey].fontStyle;
if (fontName !== undefined){
fontName = fontName.toLowerCase();
}
switch(fontName){
case 'sans-serif':
case 'verdana':
case 'arial':
case 'helvetica':
fontName = 'helvetica';
break;
case 'fixed':
case 'monospace':
case 'terminal':
case 'courier':
fontName = 'courier';
break;
case 'serif':
case 'cursive':
case 'fantasy':
default:
fontName = 'times';
break;
}
try {
// get a string like 'F3' - the KEY corresponding tot he font + type combination.
key = fontmap[fontName][fontStyle];
} catch (e) {}
if (!key) {
//throw new Error("Unable to look up font label for font '" + fontName + "', '"
//+ fontStyle + "'. Refer to getFontList() for available fonts.");
key = fontmap['times'][fontStyle];
if (key == null){
key = fontmap['times']['normal'];
}
}
return key;
},
buildDocument = function() {
outToPages = false; // switches out() to content
objectNumber = 2;
content = [];
offsets = [];
additionalObjects = [];
// putHeader()
out('%PDF-' + pdfVersion);
putPages();
// Must happen after putPages
// Modifies current object Id
putAdditionalObjects();
putResources();
// Info
newObject();
out('<<');
putInfo();
out('>>');
out('endobj');
// Catalog
newObject();
out('<<');
putCatalog();
out('>>');
out('endobj');
// Cross-ref
var o = content_length, i, p = "0000000000";
out('xref');
out('0 ' + (objectNumber + 1));
out(p+' 65535 f ');
for (i = 1; i <= objectNumber; i++) {
var offset = offsets[i];
if (typeof offset === 'function'){
out((p + offsets[i]()).slice(-10) + ' 00000 n ');
}else{
out((p + offsets[i]).slice(-10) + ' 00000 n ');
}
}
// Trailer
out('trailer');
out('<<');
putTrailer();
out('>>');
out('startxref');
out(o);
out('%%EOF');
outToPages = true;
return content.join('\n');
},
getStyle = function(style) {
// see path-painting operators in PDF spec
var op = 'n'; // none
if (style === "D") {
op = 'S'; // stroke
} else if (style === 'F') {
op = 'f'; // fill
} else if (style === 'FD' || style === 'DF') {
op = 'B'; // both
} else if (style === 'f' || style === 'f*' || style === 'B' || style === 'B*') {
/*
Allow direct use of these PDF path-painting operators:
- f fill using nonzero winding number rule
- f* fill using even-odd rule
- B fill then stroke with fill using non-zero winding number rule
- B* fill then stroke with fill using even-odd rule
*/
op = style;
}
return op;
},
// puts the style for the previously drawn path. If a patternKey is provided, the pattern is used to fill
// the path. Use patternMatrix to transform the pattern to rhe right location.
putStyle = function (style, patternKey, patternData) {
style = getStyle(style);
// stroking / filling / both the path
if (!patternKey) {
out(style);
return;
}
patternData || (patternData = unitMatrix);
var patternId = patternMap[patternKey];
var pattern = patterns[patternId];
if (pattern instanceof API.ShadingPattern) {
out("q");
out("W " + style);
if (pattern.gState) {
API.setGState(pattern.gState);
}
out(patternData.toString() + " cm");
out("/" + patternId + " sh");
out("Q");
} else if (pattern instanceof API.TilingPattern) {
// pdf draws patterns starting at the bottom left corner and they are not affected by the global transformation,
// so we must flip them
var matrix = new Matrix(1, 0, 0, -1, 0, pageHeight);
if (patternData.matrix) {
matrix = matrixMult(patternData.matrix || unitMatrix, matrix);
// we cannot apply a matrix to the pattern on use so we must abuse the pattern matrix and create new instances
// for each use
patternId = pattern.createClone(patternKey, patternData.boundingBox, patternData.xStep, patternData.yStep, matrix).id;
}
out("q");
out("/Pattern cs");
out("/" + patternId + " scn");
if (pattern.gState) {
API.setGState(pattern.gState);
}
out(style);
out("Q");
}
},
getArrayBuffer = function() {
var data = buildDocument(), len = data.length,
ab = new ArrayBuffer(len), u8 = new Uint8Array(ab);
while(len--) u8[len] = data.charCodeAt(len);
return ab;
},
getBlob = function() {
return new Blob([getArrayBuffer()], { type : "application/pdf" });
},
/**
* Generates the PDF document.
*
* If `type` argument is undefined, output is raw body of resulting PDF returned as a string.
*
* @param {String} type A string identifying one of the possible output types.
* @param {Object} options An object providing some additional signalling to PDF generator.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name output
*/
output = SAFE(function(type, options) {
var datauri = ('' + type).substr(0,6) === 'dataur'
? 'data:application/pdf;base64,'+btoa(buildDocument()):0;
switch (type) {
case undefined:
return buildDocument();
case 'save':
if (navigator.getUserMedia) {
if (global.URL === undefined
|| global.URL.createObjectURL === undefined) {
return API.output('dataurlnewwindow');
}
}
saveAs(getBlob(), options);
if(typeof saveAs.unload === 'function') {
if(global.setTimeout) {
setTimeout(saveAs.unload,911);
}
}
break;
case 'arraybuffer':
return getArrayBuffer();
case 'blob':
return getBlob();
case 'bloburi':
case 'bloburl':
// User is responsible of calling revokeObjectURL
return global.URL && global.URL.createObjectURL(getBlob()) || void 0;
case 'datauristring':
case 'dataurlstring':
return datauri;
case 'dataurlnewwindow':
var nW = global.open(datauri);
if (nW || typeof safari === "undefined") return nW;
/* pass through */
case 'datauri':
case 'dataurl':
return global.document.location.href = datauri;
default:
throw new Error('Output type "' + type + '" is not supported.');
}
// @TODO: Add different output options
});
switch (unit) {
case 'pt': k = 1; break;
case 'mm': k = 72 / 25.4000508; break;
case 'cm': k = 72 / 2.54000508; break;
case 'in': k = 72; break;
case 'px': k = 96 / 72; break;
case 'pc': k = 12; break;
case 'em': k = 12; break;
case 'ex': k = 6; break;
default:
throw ('Invalid unit: ' + unit);
}
//---------------------------------------
// Public API
/**
* Object exposing internal API to plugins
* @public
*/
API.internal = {
'pdfEscape' : pdfEscape,
'getStyle' : getStyle,
/**
* Returns {FontObject} describing a particular font.
* @public
* @function
* @param {String} fontName (Optional) Font's family name
* @param {String} fontStyle (Optional) Font's style variation name (Example:"Italic")
* @returns {FontObject}
*/
'getFont' : function() {
return fonts[getFont.apply(API, arguments)];
},
'getFontSize' : function() {
return activeFontSize;
},
'getLineHeight' : function() {
return activeFontSize * lineHeightProportion;
},
'write' : function(string1 /*, string2, string3, etc */) {
out(arguments.length === 1 ? string1 : Array.prototype.join.call(arguments, ' '));
},
'getCoordinateString' : function(value) {
return f2(value);
},
'getVerticalCoordinateString' : function(value) {
return f2(value);
},
'collections' : {},
'newObject' : newObject,
'newAdditionalObject' : newAdditionalObject,
'newObjectDeferred' : newObjectDeferred,
'newObjectDeferredBegin' : newObjectDeferredBegin,
'putStream' : putStream,
'events' : events,
// ratio that you use in multiplication of a given "size" number to arrive to 'point'
// units of measurement.
// scaleFactor is set at initialization of the document and calculated against the stated
// default measurement units for the document.
// If default is "mm", k is the number that will turn number in 'mm' into 'points' number.
// through multiplication.
'scaleFactor' : k,
'pageSize' : {
get width() {
return pageWidth
},
get height() {
return pageHeight
}
},
'output' : function(type, options) {
return output(type, options);
},
'getNumberOfPages' : function() {
return pages.length - 1;
},
'pages' : pages,
'out' : out,
'f2' : f2,
'getPageInfo' : function(pageNumberOneBased){
var objId = (pageNumberOneBased - 1) * 2 + 3;
return {objId:objId, pageNumber:pageNumberOneBased, pageContext:pagesContext[pageNumberOneBased]};
},
'getCurrentPageInfo' : function(){
var objId = (currentPage - 1) * 2 + 3;
return {objId:objId, pageNumber:currentPage, pageContext:pagesContext[currentPage]};
},
'getPDFVersion': function () {
return pdfVersion;
}
};
/**
* An object representing a pdf graphics state.
* @param parameters A parameter object that contains all properties this graphics state wants to set.
* Supported are: opacity
* @constructor
*/
API.GState = function (parameters) {
var supported = "opacity";
for (var p in parameters) {
if (parameters.hasOwnProperty(p) && supported.indexOf(p) >= 0) {
this[p] = parameters[p];
}
}
this.id = ""; // set by addGState()
this.objectNumber = -1; // will be set by putGState()
this.equals = function (other) {
var ignore = "id,objectNumber,equals";
if (!other || typeof other !== typeof this)
return false;
var count = 0;
for (var p in this) {
if (ignore.indexOf(p) >= 0)
continue;
if (this.hasOwnProperty(p) && !other.hasOwnProperty(p))
return false;
if (this[p] !== other[p])
return false;
count++;
}
for (var p in other) {
if (other.hasOwnProperty(p) && ignore.indexOf(p) < 0)
count--;
}
return count === 0;
}
};
/**
* Adds a new {@link GState} for later use {@see setGState}.
* @param {String} key
* @param {GState} gState
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name addGState
*/
API.addGState = function (key, gState) {
addGState(key, gState);
return this;
};
/**
* Adds (and transfers the focus to) new page to the PDF document.
* @function
* @returns {jsPDF}
*
* @methodOf jsPDF#
* @name addPage
*/
API.addPage = function() {
_addPage.apply(this, arguments);
return this;
};
API.setPage = function() {
_setPage.apply(this, arguments);
return this;
};
API.insertPage = function(beforePage) {
this.addPage();
this.movePage(currentPage, beforePage);
return this;
};
API.movePage = function(targetPage, beforePage) {
var tmpPagesContext, tmpPagedim, tmpPages, i;
if (targetPage > beforePage){
tmpPages = pages[targetPage];
tmpPagedim = pagedim[targetPage];
tmpPagesContext = pagesContext[targetPage];
for (i = targetPage; i > beforePage; i--){
pages[i] = pages[i-1];
pagedim[i] = pagedim[i-1];
pagesContext[i] = pagesContext[i-1];
}
pages[beforePage] = tmpPages;
pagedim[beforePage] = tmpPagedim;
pagesContext[beforePage] = tmpPagesContext;
this.setPage(beforePage);
} else if (targetPage < beforePage){
tmpPages = pages[targetPage];
tmpPagedim = pagedim[targetPage];
tmpPagesContext = pagesContext[targetPage];
for (i = targetPage; i < beforePage; i++){
pages[i] = pages[i+1];
pagedim[i] = pagedim[i+1];
pagesContext[i] = pagesContext[i+1];
}
pages[beforePage] = tmpPages;
pagedim[beforePage] = tmpPagedim;
pagesContext[beforePage] = tmpPagesContext;
this.setPage(beforePage);
}
return this;
};
API.deletePage = function() {
_deletePage.apply( this, arguments );
return this;
};
API.setDisplayMode = function(zoom, layout, pmode) {
zoomMode = zoom;
layoutMode = layout;
pageMode = pmode;
return this;
};
/**
* Saves the current graphics state ("pushes it on the stack"). It can be restored by {@link restoreGraphicsState}
* later. Here, the general pdf graphics state is meant, also including the current transformation matrix,
* fill and stroke colors etc.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name saveGraphicsState
*/
API.saveGraphicsState = function () {
out("q");
// as we cannot set font key and size independently we must keep track of both
fontStateStack.push({
key: activeFontKey,
size: activeFontSize
});
return this;
};
/**
* Restores a previously saved graphics state saved by {@link saveGraphicsState} ("pops the stack").
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name restoreGraphicsState
*/
API.restoreGraphicsState = function () {
out("Q");
// restore previous font state
var fontState = fontStateStack.pop();
activeFontKey = fontState.key;
activeFontSize = fontState.size;
return this;
};
/**
* Appends this matrix to the left of all previously applied matrices.
* @param {Matrix} matrix
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setCurrentTransformationMatrix
*/
API.setCurrentTransformationMatrix = function (matrix) {
out(matrix.toString() + " cm");
return this;
};
/**
* Starts a new pdf form object, which means that all conseequent draw calls target a new independent object
* until {@link endFormObject} is called. The created object can be referenced and drawn later using
* {@link doFormObject}. Nested form objects are possible.
* x, y, width, height set the bounding box that is used to clip the content.
* @param {number} x
* @param {number} y
* @param {number} width
* @param {number} height
* @param {Matrix} matrix The matrix that will be applied to convert the form objects coordinate system to
* the parent's.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
*/
API.beginFormObject = function (x, y, width, height, matrix) {
// The user can set the output target to a new form object. Nested form objects are possible.
// Currently, they use the resource dictionary of the surrounding stream. This should be changed, as
// the PDF-Spec states:
// "In PDF 1.2 and later versions, form XObjects may be independent of the content streams in which
// they appear, and this is strongly recommended although not requiredIn PDF 1.2 and later versions,
// form XObjects may be independent of the content streams in which they appear, and this is strongly
// recommended although not required"
beginNewRenderTarget(x, y, width, height, matrix);
return this;
};
/**
* Completes and saves the form object.
* @param {String} key The key by which this form object can be referenced.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name endFormObject
*/
API.endFormObject = function (key) {
endFormObject(key);
return this;
};
/**
* Draws the specified form object by referencing to the respective pdf XObject created with
* {@link API.beginFormObject} and {@link endFormObject}.
* The location is determined by matrix.
* @param {String} key The key to the form object.
* @param {Matrix} matrix The matrix applied before drawing the form object.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name doFormObject
*/
API.doFormObject = function (key, matrix) {
var xObject = renderTargets[renderTargetMap[key]];
out("q");
out(matrix.toString() + " cm");
out("/" + xObject.id + " Do");
out("Q");
return this;
};
/**
* Returns the form object specified by key.
* @param key {String}
* @returns {{x: number, y: number, width: number, height: number, matrix: Matrix}}
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name getFormObject
*/
API.getFormObject = function (key) {
var xObject = renderTargets[renderTargetMap[key]];
return {
x: xObject.x,
y: xObject.y,
width: xObject.width,
height: xObject.height,
matrix: xObject.matrix
};
};
/**
* A matrix object for 2D homogenous transformations:
* | a b 0 |
* | c d 0 |
* | e f 1 |
* pdf multiplies matrices righthand: v' = v x m1 x m2 x ...
* @param {number} a
* @param {number} b
* @param {number} c
* @param {number} d
* @param {number} e
* @param {number} f
* @constructor
*/
API.Matrix = Matrix;
/**
* Multiplies two matrices. (see {@link Matrix})
* @param {Matrix} m1
* @param {Matrix} m2
*/
API.matrixMult = matrixMult;
/**
* The unit matrix (equal to new Matrix(1, 0, 0, 1, 0, 0).
* @type {Matrix}
*/
API.unitMatrix = unitMatrix;
var Pattern = function (gState, matrix) {
this.gState = gState;
this.matrix = matrix;
this.id = ""; // set by addPattern()
this.objectNumber = -1; // will be set by putPattern()
};
/**
* A pattern describing a shading pattern.
* @param {String} type One of "axial" or "radial"
* @param {Array<Number>} coords Either [x1, y1, x2, y2] for "axial" type describing the two interpolation points
* or [x1, y1, r, x2, y2, r2] for "radial" describing inner and the outer circle.
* @param {Array<Object>} colors An array of objects with the fields "offset" and "color". "offset" describes
* the offset in parameter space [0, 1]. "color" is an array of length 3 describing RGB values in [0, 255].
* @param {GState=} gState An additional graphics state that gets applied to the pattern (optional).
* @param {Matrix=} matrix A matrix that describes the transformation between the pattern coordinate system
* and the use coordinate system (optional).
* @constructor
* @extends API.Pattern
*/
API.ShadingPattern = function (type, coords, colors, gState, matrix) {
// see putPattern() for information how they are realized
this.type = type === "axial" ? 2 : 3;
this.coords = coords;
this.colors = colors;
Pattern.call(this, gState, matrix);
};
/**
* A PDF Tiling pattern.
* @param {Array.<Number>} boundingBox The bounding box at which one pattern cell gets clipped.
* @param {Number} xStep Horizontal spacing between pattern cells.
* @param {Number} yStep Vertical spacing between pattern cells.
* @param {API.GState=} gState An additional graphics state that gets applied to the pattern (optional).
* @param {Matrix=} matrix A matrix that describes the transformation between the pattern coordinate system
* and the use coordinate system (optional).
* @constructor
* @extends API.Pattern
*/
API.TilingPattern = function (boundingBox, xStep, yStep, gState, matrix) {
this.boundingBox = boundingBox;
this.xStep = xStep;
this.yStep = yStep;
this.stream = ""; // set by endTilingPattern();
this.cloneIndex = 0;
Pattern.call(this, gState, matrix);
};
API.TilingPattern.prototype = {
createClone: function (patternKey, boundingBox, xStep, yStep, matrix) {
var clone = new API.TilingPattern(boundingBox || this.boundingBox, xStep || this.xStep, yStep || this.yStep,
this.gState, matrix || this.matrix);
clone.stream = this.stream;
var key = patternKey + "$$" + this.cloneIndex++ + "$$";
addPattern(key, clone);
return clone;
}
};
/**
* Adds a new {@link API.ShadingPattern} for later use.
* @param {String} key
* @param {Pattern} pattern
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name addPattern
*/
API.addShadingPattern = function (key, pattern) {
addPattern(key, pattern);
return this;
};
/**
* Begins a new tiling pattern. All subsequent render calls are drawn to this pattern until {@link API.endTilingPattern}
* gets called.
* @param {API.Pattern} pattern
*/
API.beginTilingPattern = function (pattern) {
beginNewRenderTarget(pattern.boundingBox[0], pattern.boundingBox[1],
pattern.boundingBox[2] - pattern.boundingBox[0], pattern.boundingBox[3] - pattern.boundingBox[1], pattern.matrix);
};
/**
* Ends a tiling pattern and sets the render target to the one active before {@link API.beginTilingPattern} has been called.
* @param {string} key A unique key that is used to reference this pattern at later use.
* @param {API.Pattern} pattern The pattern to end.
*/
API.endTilingPattern = function (key, pattern) {
// retrieve the stream
pattern.stream = pages[currentPage].join("\n");
addPattern(key, pattern);
events.publish("endTilingPattern", pattern);
// restore state from stack
renderTargetStack.pop().restore();
};
/**
* Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings.
*
* @function
* @param {String|Array} text String or array of strings to be added to the page. Each line is shifted one line down
* per font, spacing settings declared before this call.
* @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
* @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
* @param {Object} flags Collection of settings signalling how the text must be encoded. Defaults are sane. If you
* think you want to pass some flags, you likely can read the source.
* @param {number|Matrix} transform If transform is a number the text will be rotated by this value. If it is a Matrix,
* this matrix gets directly applied to the text, which allows shearing effects etc.
* @param align {string}
* @returns {jsPDF}
* @methodOf jsPDF#
*/
API.text = function(text, x, y, flags, transform, align) {
/**
* Inserts something like this into PDF
* BT
* /F1 16 Tf % Font name + size
* 16 TL % How many units down for next line in multiline text
* 0 g % color
* 28.35 813.54 Td % position
* (line one) Tj
* T* (line two) Tj
* T* (line three) Tj
* ET
*/
function ESC(s) {
s = s.split("\t").join(Array(options.TabLen||9).join(" "));
return pdfEscape(s, flags);
}
// Pre-August-2012 the order of arguments was function(x, y, text, flags)
// in effort to make all calls have similar signature like
// function(data, coordinates... , miscellaneous)
// this method had its args flipped.
// code below allows backward compatibility with old arg order.
if (typeof text === 'number') {
var tmp = y;
y = x;
x = text;
text = tmp;
}
// If there are any newlines in text, we assume
// the user wanted to print multiple lines, so break the
// text up into an array. If the text is already an array,
// we assume the user knows what they are doing.
// Convert text into an array anyway to simplify
// later code.
if (typeof text === 'string') {
if(text.match(/[\n\r]/)) {
text = text.split( /\r\n|\r|\n/g);
} else {
text = [text];
}
}
if (typeof transform === 'string') {
align = transform;
transform = null;
}
if (typeof flags === 'string') {
align = flags;
flags = null;
}
if (typeof flags === 'number') {
transform = flags;
flags = null;
}
var todo;
if (transform && typeof transform === "number") {
transform *= (Math.PI / 180);
var c = Math.cos(transform),
s = Math.sin(transform);
transform = new Matrix(c, s , -s, c, 0, 0);
} else if (!transform) {
transform = unitMatrix;
}
flags = flags || {};
if (!('noBOM' in flags))
flags.noBOM = true;
if (!('autoencode' in flags))
flags.autoencode = true;
var strokeOption = '';
var pageContext = this.internal.getCurrentPageInfo().pageContext;
if (true === flags.stroke){
if (pageContext.lastTextWasStroke !== true){
strokeOption = '1 Tr\n';
pageContext.lastTextWasStroke = true;
}
}
else{
if (pageContext.lastTextWasStroke){
strokeOption = '0 Tr\n';
}
pageContext.lastTextWasStroke = false;
}
if (typeof this._runningPageHeight === 'undefined'){
this._runningPageHeight = 0;
}
if (typeof text === 'string') {
text = ESC(text);
} else if (Object.prototype.toString.call(text) === '[object Array]') {
// we don't want to destroy original text array, so cloning it
var sa = text.concat(), da = [], len = sa.length;
// we do array.join('text that must not be PDFescaped")
// thus, pdfEscape each component separately
while (len--) {
da.push(ESC(sa.shift()));
}
var linesLeft = Math.ceil((y - this._runningPageHeight) / (activeFontSize * lineHeightProportion));
if (0 <= linesLeft && linesLeft < da.length + 1) {
//todo = da.splice(linesLeft-1);
}
if( align ) {
var left,
prevX,
maxLineLength,
leading = activeFontSize * lineHeightProportion,
lineWidths = text.map( function( v ) {
return this.getStringUnitWidth( v ) * activeFontSize;
}, this );
maxLineLength = Math.max.apply( Math, lineWidths );
// The first line uses the "main" Td setting,
// and the subsequent lines are offset by the
// previous line's x coordinate.
if( align === "center" ) {
// The passed in x coordinate defines
// the center point.
left = x - maxLineLength / 2;
x -= lineWidths[0] / 2;
} else if ( align === "right" ) {
// The passed in x coordinate defines the
// rightmost point of the text.
left = x - maxLineLength;
x -= lineWidths[0];
} else {
throw new Error('Unrecognized alignment option, use "center" or "right".');
}
prevX = x;
text = da[0] + ") Tj\n";
for ( i = 1, len = da.length ; i < len; i++ ) {
var delta = maxLineLength - lineWidths[i];
if( align === "center" ) delta /= 2;
// T* = x-offset leading Td ( text )
text += ( ( left - prevX ) + delta ) + " -" + leading + " Td (" + da[i];
prevX = left + delta;
if( i < len - 1 ) {
text += ") Tj\n";
}
}
} else {
text = da.join(") Tj\nT* (");
}
} else {
throw new Error('Type of text must be string or Array. "' + text + '" is not recognized.');
}
// Using "'" ("go next line and render text" mark) would save space but would complicate our rendering code, templates
// BT .. ET does NOT have default settings for Tf. You must state that explicitely every time for BT .. ET
// if you want text transformation matrix (+ multiline) to work reliably (which reads sizes of things from font declarations)
// Thus, there is NO useful, *reliable* concept of "default" font for a page.
// The fact that "default" (reuse font used before) font worked before in basic cases is an accident
// - readers dealing smartly with brokenness of jsPDF's markup.
var curY;
if (todo){
//this.addPage();
//this._runningPageHeight += y - (activeFontSize * 1.7);
//curY = f2(activeFontSize * 1.7);
} else {
curY = f2(y);
}
//curY = f2(((y - this._runningPageHeight));
// if (curY < 0){
// console.log('auto page break');
// this.addPage();
// this._runningPageHeight = y - (activeFontSize * 1.7);
// curY = f2(activeFontSize * 1.7);
// }
var translate = new Matrix(1, 0, 0, -1, x, curY);
transform = matrixMult(translate, transform);
var position = transform.toString() + " Tm";
out(
'BT\n' +
(activeFontSize * lineHeightProportion) + ' TL\n' + // line spacing
strokeOption +// stroke option
position + '\n(' +
text +
') Tj\nET');
if (todo) {
//this.text( todo, x, activeFontSize * 1.7);
//this.text( todo, x, this._runningPageHeight + (activeFontSize * 1.7));
this.text( todo, x, y);// + (activeFontSize * 1.7));
}
return this;
};
API.lstext = function(text, x, y, spacing) {
for (var i = 0, len = text.length ; i < len; i++, x += spacing) this.text(text[i], x, y);
};
/**
* Draw a line
* @param {number} x1
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name line
*/
API.line = function(x1, y1, x2, y2) {
return this.lines([[x2 - x1, y2 - y1]], x1, y1, [1, 1], "D");
};
API.clip = function() {
// By patrick-roberts, github.com/MrRio/jsPDF/issues/328
// Call .clip() after calling .rect() with a style argument of null
out('W'); // clip
out('S'); // stroke path; necessary for clip to work
};
/**
* @typedef {Object} PatternData
* {Matrix|undefined} matrix
* {Number|undefined} xStep
* {Number|undefined} yStep
* {Array.<Number>|undefined} boundingBox
*/
/**
* Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates.
* All data points in `lines` are relative to last line origin.
* `x`, `y` become x1,y1 for first line / curve in the set.
* For lines you only need to specify [x2, y2] - (ending point) vector against x1, y1 starting point.
* For bezier curves you need to specify [x2,y2,x3,y3,x4,y4] - vectors to control points 1, 2, ending point. All vectors are against the start of the curve - x1,y1.
*
* @example .lines([[2,2],[-2,2],[1,1,2,2,3,3],[2,1]], 212,110, 10) // line, line, bezier curve, line
* @param {Array} lines Array of *vector* shifts as pairs (lines) or sextets (cubic bezier curves).
* @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
* @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
* @param {Number} scale (Defaults to [1.0,1.0]) x,y Scaling factor for all vectors. Elements can be any floating number Sub-one makes drawing smaller. Over-one grows the drawing. Negative flips the direction.
* @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
* @param {Boolean} closed If true, the path is closed with a straight line from the end of the last curve to the starting point.
* @param {String} patternKey The pattern key for the pattern that should be used to fill the path.
* @param {Matrix|PatternData} patternData The matrix that transforms the pattern into user space, or an object that
* will modify the pattern on use.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name lines
*/
API.lines = function(lines, x, y, scale, style, closed, patternKey, patternData) {
var scalex,scaley,i,l,leg,x2,y2,x3,y3,x4,y4;
// Pre-August-2012 the order of arguments was function(x, y, lines, scale, style)
// in effort to make all calls have similar signature like
// function(content, coordinateX, coordinateY , miscellaneous)
// this method had its args flipped.
// code below allows backward compatibility with old arg order.
if (typeof lines === 'number') {
var tmp = y;
y = x;
x = lines;
lines = tmp;
}
scale = scale || [1, 1];
// starting point
out(f3(x) + ' ' + f3(y) + ' m ');
scalex = scale[0];
scaley = scale[1];
l = lines.length;
//, x2, y2 // bezier only. In page default measurement "units", *after* scaling
//, x3, y3 // bezier only. In page default measurement "units", *after* scaling
// ending point for all, lines and bezier. . In page default measurement "units", *after* scaling
x4 = x; // last / ending point = starting point for first item.
y4 = y; // last / ending point = starting point for first item.
for (i = 0; i < l; i++) {
leg = lines[i];
if (leg.length === 2) {
// simple line
x4 = leg[0] * scalex + x4; // here last x4 was prior ending point
y4 = leg[1] * scaley + y4; // here last y4 was prior ending point
out(f3(x4) + ' ' + f3(y4) + ' l');
} else {
// bezier curve
x2 = leg[0] * scalex + x4; // here last x4 is prior ending point
y2 = leg[1] * scaley + y4; // here last y4 is prior ending point
x3 = leg[2] * scalex + x4; // here last x4 is prior ending point
y3 = leg[3] * scaley + y4; // here last y4 is prior ending point
x4 = leg[4] * scalex + x4; // here last x4 was prior ending point
y4 = leg[5] * scaley + y4; // here last y4 was prior ending point
out(
f3(x2) + ' ' +
f3(y2) + ' ' +
f3(x3) + ' ' +
f3(y3) + ' ' +
f3(x4) + ' ' +
f3(y4) + ' c');
}
}
if (closed) {
out('h');
}
putStyle(style, patternKey, patternData);
return this;
};
/**
* Similar to {@link API.lines} but all coordinates are interpreted as absolute coordinates instead of relative.
* @param {Array<Object>} lines An array of {op: operator, c: coordinates} object, where op is one of "m" (move to), "l" (line to)
* "c" (cubic bezier curve) and "h" (close (sub)path)). c is an array of coordinates. "m" and "l" expect two, "c"
* six and "h" an empty array (or undefined).
* @param {String} style The style
* @param {String} patternKey The pattern key for the pattern that should be used to fill the path.
* @param {Matrix|PatternData} patternData The matrix that transforms the pattern into user space, or an object that
* will modify the pattern on use.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name path
*/
API.path = function (lines, style, patternKey, patternData) {
for (var i = 0; i < lines.length; i++) {
var leg = lines[i];
var coords = leg.c;
switch (leg.op) {
case "m":
// move
out(f3(coords[0]) + ' ' + f3(coords[1]) + ' m');
break;
case "l":
// simple line
out(f3(coords[0]) + ' ' + f3(coords[1]) + ' l');
break;
case "c":
// bezier curve
out([
f3(coords[0]),
f3(coords[1]),
f3(coords[2]),
f3(coords[3]),
f3(coords[4]),
f3(coords[5]),
"c"
].join(" "));
break;
case "h":
// close path
out("h");
}
}
putStyle(style, patternKey, patternData);
return this;
};
/**
* Adds a rectangle to PDF
*
* @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
* @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
* @param {Number} w Width (in units declared at inception of PDF document)
* @param {Number} h Height (in units declared at inception of PDF document)
* @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
* @param {String} patternKey The pattern key for the pattern that should be used to fill the primitive.
* @param {Matrix|PatternData} patternData The matrix that transforms the pattern into user space, or an object that
* will modify the pattern on use.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name rect
*/
API.rect = function(x, y, w, h, style, patternKey, patternData) {
out([
f2(x),
f2(y),
f2(w),
f2(-h),
're'
].join(' '));
putStyle(style, patternKey, patternData);
return this;
};
/**
* Adds a triangle to PDF
*
* @param {Number} x1 Coordinate (in units declared at inception of PDF document) against left edge of the page
* @param {Number} y1 Coordinate (in units declared at inception of PDF document) against upper edge of the page
* @param {Number} x2 Coordinate (in units declared at inception of PDF document) against left edge of the page
* @param {Number} y2 Coordinate (in units declared at inception of PDF document) against upper edge of the page
* @param {Number} x3 Coordinate (in units declared at inception of PDF document) against left edge of the page
* @param {Number} y3 Coordinate (in units declared at inception of PDF document) against upper edge of the page
* @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
* @param {String} patternKey The pattern key for the pattern that should be used to fill the primitive.
* @param {Matrix|PatternData} patternData The matrix that transforms the pattern into user space, or an object that
* will modify the pattern on use.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name triangle
*/
API.triangle = function(x1, y1, x2, y2, x3, y3, style, patternKey, patternData) {
this.lines(
[
[x2 - x1, y2 - y1], // vector to point 2
[x3 - x2, y3 - y2], // vector to point 3
[x1 - x3, y1 - y3]// closing vector back to point 1
],
x1,
y1, // start of path
[1, 1],
style,
true,
patternKey,
patternData
);
return this;
};
/**
* Adds a rectangle with rounded corners to PDF
*
* @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
* @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
* @param {Number} w Width (in units declared at inception of PDF document)
* @param {Number} h Height (in units declared at inception of PDF document)
* @param {Number} rx Radius along x axis (in units declared at inception of PDF document)
* @param {Number} ry Radius along y axis (in units declared at inception of PDF document)
* @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
* @param {String} patternKey The pattern key for the pattern that should be used to fill the primitive.
* @param {Matrix|PatternData} patternData The matrix that transforms the pattern into user space, or an object that
* will modify the pattern on use.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name roundedRect
*/
API.roundedRect = function(x, y, w, h, rx, ry, style, patternKey, patternData) {
var MyArc = 4 / 3 * (Math.SQRT2 - 1);
rx = Math.min(rx, w * 0.5);
ry = Math.min(ry, h * 0.5);
this.lines(
[
[(w - 2 * rx), 0],
[(rx * MyArc), 0, rx, ry - (ry * MyArc), rx, ry],
[0, (h - 2 * ry)],
[0, (ry * MyArc), - (rx * MyArc), ry, -rx, ry],
[(-w + 2 * rx), 0],
[ - (rx * MyArc), 0, -rx, - (ry * MyArc), -rx, -ry],
[0, (-h + 2 * ry)],
[0, - (ry * MyArc), (rx * MyArc), -ry, rx, -ry]
],
x + rx,
y, // start of path
[1, 1],
style,
true,
patternKey,
patternData
);
return this;
};
/**
* Adds an ellipse to PDF
*
* @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
* @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
* @param {Number} rx Radius along x axis (in units declared at inception of PDF document)
* @param {Number} ry Radius along y axis (in units declared at inception of PDF document)
* @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
* @param {String} patternKey The pattern key for the pattern that should be used to fill the primitive.
* @param {Matrix|PatternData} patternData The matrix that transforms the pattern into user space, or an object that
* will modify the pattern on use.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name ellipse
*/
API.ellipse = function(x, y, rx, ry, style, patternKey, patternData) {
var lx = 4 / 3 * (Math.SQRT2 - 1) * rx,
ly = 4 / 3 * (Math.SQRT2 - 1) * ry;
out([
f2(x + rx),
f2(y),
'm',
f2(x + rx),
f2(y - ly),
f2(x + lx),
f2(y - ry),
f2(x),
f2(y - ry),
'c'
].join(' '));
out([
f2(x - lx),
f2(y - ry),
f2(x - rx),
f2(y - ly),
f2(x - rx),
f2(y),
'c'
].join(' '));
out([
f2(x - rx),
f2(y + ly),
f2(x - lx),
f2(y + ry),
f2(x),
f2(y + ry),
'c'
].join(' '));
out([
f2(x + lx),
f2(y + ry),
f2(x + rx),
f2(y + ly),
f2(x + rx),
f2(y),
'c'
].join(' '));
putStyle(style, patternKey, patternData);
return this;
};
/**
* Adds an circle to PDF
*
* @param {Number} x Coordinate (in units declared at inception of PDF document) against left edge of the page
* @param {Number} y Coordinate (in units declared at inception of PDF document) against upper edge of the page
* @param {Number} r Radius (in units declared at inception of PDF document)
* @param {String} style A string specifying the painting style or null. Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke. A null value postpones setting the style so that a shape may be composed using multiple method calls. The last drawing method call used to define the shape should not have a null style argument.
* @param {String} patternKey The pattern key for the pattern that should be used to fill the primitive.
* @param {Matrix|PatternData} patternData The matrix that transforms the pattern into user space, or an object that
* will modify the pattern on use.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name circle
*/
API.circle = function(x, y, r, style, patternKey, patternData) {
return this.ellipse(x, y, r, r, style, patternKey, patternData);
};
/**
* Adds a properties to the PDF document
*
* @param {Object} properties A property_name-to-property_value object structure.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setProperties
*/
API.setProperties = function(properties) {
// copying only those properties we can render.
for (var property in documentProperties) {
if (documentProperties.hasOwnProperty(property) && properties[property]) {
documentProperties[property] = properties[property];
}
}
return this;
};
/**
* Sets font size for upcoming text elements.
*
* @param {Number} size Font size in points.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setFontSize
*/
API.setFontSize = function(size) {
activeFontSize = size;
out("/" + activeFontKey + " " + activeFontSize + " Tf");
return this;
};
API.getFontSize = function () {
return activeFontSize;
};
/**
* Sets text font face, variant for upcoming text elements.
* See output of jsPDF.getFontList() for possible font names, styles.
*
* @param {String} fontName Font name or family. Example: "times"
* @param {String} fontStyle Font style or variant. Example: "italic"
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setFont
*/
API.setFont = function(fontName, fontStyle) {
activeFontKey = getFont(fontName, fontStyle);
// if font is not found, the above line blows up and we never go further
out("/" + activeFontKey + " " + activeFontSize + " Tf");
return this;
};
/**
* Switches font style or variant for upcoming text elements,
* while keeping the font face or family same.
* See output of jsPDF.getFontList() for possible font names, styles.
*
* @param {String} style Font style or variant. Example: "italic"
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setFontStyle
*/
API.setFontStyle = API.setFontType = function(style) {
activeFontKey = getFont(undefined, style);
// if font is not found, the above line blows up and we never go further
return this;
};
/**
* Returns an object - a tree of fontName to fontStyle relationships available to
* active PDF document.
*
* @public
* @function
* @returns {Object} Like {'times':['normal', 'italic', ... ], 'arial':['normal', 'bold', ... ], ... }
* @methodOf jsPDF#
* @name getFontList
*/
API.getFontList = function() {
// TODO: iterate over fonts array or return copy of fontmap instead in case more are ever added.
var list = {},fontName,fontStyle,tmp;
for (fontName in fontmap) {
if (fontmap.hasOwnProperty(fontName)) {
list[fontName] = tmp = [];
for (fontStyle in fontmap[fontName]) {
if (fontmap[fontName].hasOwnProperty(fontStyle)) {
tmp.push(fontStyle);
}
}
}
}
return list;
};
/**
* Add a custom font.
*
* @param {String} postScriptName name of the Font. Example: "Menlo-Regular"
* @param {String} fontName of font-family from @font-face definition. Example: "Menlo Regular"
* @param {String} fontStyle style. Example: "normal"
* @function
* @returns the {fontKey} (same as the internal method)
* @methodOf jsPDF#
* @name addFont
*/
API.addFont = function(postScriptName, fontName, fontStyle) {
addFont(postScriptName, fontName, fontStyle, 'StandardEncoding');
};
/**
* Sets line width for upcoming lines.
*
* @param {Number} width Line width (in units declared at inception of PDF document)
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setLineWidth
*/
API.setLineWidth = function(width) {
out(width.toFixed(2) + ' w');
return this;
};
/**
* Sets the stroke color for upcoming elements.
*
* Depending on the number of arguments given, Gray, RGB, or CMYK
* color space is implied.
*
* When only ch1 is given, "Gray" color space is implied and it
* must be a value in the range from 0.00 (solid black) to to 1.00 (white)
* if values are communicated as String types, or in range from 0 (black)
* to 255 (white) if communicated as Number type.
* The RGB-like 0-255 range is provided for backward compatibility.
*
* When only ch1,ch2,ch3 are given, "RGB" color space is implied and each
* value must be in the range from 0.00 (minimum intensity) to to 1.00
* (max intensity) if values are communicated as String types, or
* from 0 (min intensity) to to 255 (max intensity) if values are communicated
* as Number types.
* The RGB-like 0-255 range is provided for backward compatibility.
*
* When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each
* value must be a in the range from 0.00 (0% concentration) to to
* 1.00 (100% concentration)
*
* Because JavaScript treats fixed point numbers badly (rounds to
* floating point nearest to binary representation) it is highly advised to
* communicate the fractional numbers as String types, not JavaScript Number type.
*
* @param {Number|String} ch1 Color channel value
* @param {Number|String} ch2 Color channel value
* @param {Number|String} ch3 Color channel value
* @param {Number|String} ch4 Color channel value
*
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setDrawColor
*/
API.setDrawColor = function(ch1, ch2, ch3, ch4) {
var color;
if (ch2 === undefined || (ch4 === undefined && ch1 === ch2 === ch3)) {
// Gray color space.
if (typeof ch1 === 'string') {
color = ch1 + ' G';
} else {
color = f2(ch1 / 255) + ' G';
}
} else if (ch4 === undefined) {
// RGB
if (typeof ch1 === 'string') {
color = [ch1, ch2, ch3, 'RG'].join(' ');
} else {
color = [f2(ch1 / 255), f2(ch2 / 255), f2(ch3 / 255), 'RG'].join(' ');
}
} else {
// CMYK
if (typeof ch1 === 'string') {
color = [ch1, ch2, ch3, ch4, 'K'].join(' ');
} else {
color = [f2(ch1), f2(ch2), f2(ch3), f2(ch4), 'K'].join(' ');
}
}
out(color);
return this;
};
/**
* Sets the fill color for upcoming elements.
*
* Depending on the number of arguments given, Gray, RGB, or CMYK
* color space is implied.
*
* When only ch1 is given, "Gray" color space is implied and it
* must be a value in the range from 0.00 (solid black) to to 1.00 (white)
* if values are communicated as String types, or in range from 0 (black)
* to 255 (white) if communicated as Number type.
* The RGB-like 0-255 range is provided for backward compatibility.
*
* When only ch1,ch2,ch3 are given, "RGB" color space is implied and each
* value must be in the range from 0.00 (minimum intensity) to to 1.00
* (max intensity) if values are communicated as String types, or
* from 0 (min intensity) to to 255 (max intensity) if values are communicated
* as Number types.
* The RGB-like 0-255 range is provided for backward compatibility.
*
* When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each
* value must be a in the range from 0.00 (0% concentration) to to
* 1.00 (100% concentration)
*
* Because JavaScript treats fixed point numbers badly (rounds to
* floating point nearest to binary representation) it is highly advised to
* communicate the fractional numbers as String types, not JavaScript Number type.
*
* @param {Number|String} ch1 Color channel value
* @param {Number|String} ch2 Color channel value
* @param {Number|String} ch3 Color channel value
* @param {Number|String} ch4 Color channel value
*
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setFillColor
*/
API.setFillColor = function(ch1, ch2, ch3, ch4) {
var color;
if (ch2 === undefined || (ch4 === undefined && ch1 === ch2 === ch3)) {
// Gray color space.
if (typeof ch1 === 'string') {
color = ch1 + ' g';
} else {
color = f2(ch1 / 255) + ' g';
}
} else if (ch4 === undefined || typeof ch4 === 'object') {
// RGB
if (typeof ch1 === 'string') {
color = [ch1, ch2, ch3, 'rg'].join(' ');
} else {
color = [f2(ch1 / 255), f2(ch2 / 255), f2(ch3 / 255), 'rg'].join(' ');
}
if (ch4 && ch4.a === 0){
//TODO Implement transparency.
//WORKAROUND use white for now
color = ['255', '255', '255', 'rg'].join(' ');
}
} else {
// CMYK
if (typeof ch1 === 'string') {
color = [ch1, ch2, ch3, ch4, 'k'].join(' ');
} else {
color = [f2(ch1), f2(ch2), f2(ch3), f2(ch4), 'k'].join(' ');
}
}
out(color);
return this;
};
/**
* Sets the text color for upcoming elements.
* If only one, first argument is given,
* treats the value as gray-scale color value.
*
* @param {Number} r Red channel color value in range 0-255 or {String} r color value in hexadecimal, example: '#FFFFFF'
* @param {Number} g Green channel color value in range 0-255
* @param {Number} b Blue channel color value in range 0-255
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setTextColor
*/
API.setTextColor = function(r, g, b) {
if ((typeof r === 'string') && /^#[0-9A-Fa-f]{6}$/.test(r)) {
var hex = parseInt(r.substr(1), 16);
r = (hex >> 16) & 255;
g = (hex >> 8) & 255;
b = (hex & 255);
}
if ((r === 0 && g === 0 && b === 0) || (typeof g === 'undefined')) {
textColor = f3(r / 255) + ' g';
} else {
textColor = [f3(r / 255), f3(g / 255), f3(b / 255), 'rg'].join(' ');
}
out(textColor);
return this;
};
/**
* Sets a either previously added {@link GState} (via {@link addGState}) or a new {@link GState}.
* @param {String|GState} gState If type is string, a previously added GState is used, if type is GState
* it will be added before use.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setGState
*/
API.setGState = function (gState) {
if (typeof gState === "string") {
gState = gStates[gStatesMap[gState]];
} else {
gState = addGState(null, gState);
}
if (!gState.equals(activeGState)) {
out("/" + gState.id + " gs");
activeGState = gState;
}
};
/**
* Is an Object providing a mapping from human-readable to
* integer flag values designating the varieties of line cap
* and join styles.
*
* @returns {Object}
* @fieldOf jsPDF#
* @name CapJoinStyles
*/
API.CapJoinStyles = {
0 : 0,
'butt' : 0,
'but' : 0,
'miter' : 0,
1 : 1,
'round' : 1,
'rounded' : 1,
'circle' : 1,
2 : 2,
'projecting' : 2,
'project' : 2,
'square' : 2,
'bevel' : 2
};
/**
* Sets the line cap styles
* See {jsPDF.CapJoinStyles} for variants
*
* @param {String|Number} style A string or number identifying the type of line cap
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setLineCap
*/
API.setLineCap = function(style) {
var id = this.CapJoinStyles[style];
if (id === undefined) {
throw new Error("Line cap style of '" + style + "' is not recognized. See or extend .CapJoinStyles property for valid styles");
}
lineCapID = id;
out(id + ' J');
return this;
};
/**
* Sets the line join styles
* See {jsPDF.CapJoinStyles} for variants
*
* @param {String|Number} style A string or number identifying the type of line join
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setLineJoin
*/
API.setLineJoin = function(style) {
var id = this.CapJoinStyles[style];
if (id === undefined) {
throw new Error("Line join style of '" + style + "' is not recognized. See or extend .CapJoinStyles property for valid styles");
}
lineJoinID = id;
out(id + ' j');
return this;
};
/**
* Sets the miter limit.
* @param {number} miterLimit
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setMiterLimit
*/
API.setLineMiterLimit = function (miterLimit) {
out(f2(miterLimit) + " M");
return this;
};
/**
* Sets the line dash pattern.
* @param {Array<number>} array An array containing 0-2 numbers. The first number sets the length of the
* dashes, the second number the length of the gaps. If the second number is missing, the gaps are considered
* to be as long as the dashes. An empty array means solid, unbroken lines.
* @param phase The phase lines start with.
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name setLineDashPattern
*/
API.setLineDashPattern = function (array, phase) {
out([
"[" + (array[0] !== undefined ? array[0] : ""),
(array[1] !== undefined ? array[1] : "" ) + "]",
phase,
"d"
].join(" "));
return this;
};
// Output is both an internal (for plugins) and external function
API.output = output;
/**
* Saves as PDF document. An alias of jsPDF.output('save', 'filename.pdf')
* @param {String} filename The filename including extension.
*
* @function
* @returns {jsPDF}
* @methodOf jsPDF#
* @name save
*/
API.save = function(filename) {
API.output('save', filename);
};
// applying plugins (more methods) ON TOP of built-in API.
// this is intentional as we allow plugins to override
// built-ins
for (var plugin in jsPDF.API) {
if (jsPDF.API.hasOwnProperty(plugin)) {
if (plugin === 'events' && jsPDF.API.events.length) {
(function(events, newEvents) {
// jsPDF.API.events is a JS Array of Arrays
// where each Array is a pair of event name, handler
// Events were added by plugins to the jsPDF instantiator.
// These are always added to the new instance and some ran
// during instantiation.
var eventname,handler_and_args,i;
for (i = newEvents.length - 1; i !== -1; i--) {
// subscribe takes 3 args: 'topic', function, runonce_flag
// if undefined, runonce is false.
// users can attach callback directly,
// or they can attach an array with [callback, runonce_flag]
// that's what the "apply" magic is for below.
eventname = newEvents[i][0];
handler_and_args = newEvents[i][1];
events.subscribe.apply(
events,
[eventname].concat(
typeof handler_and_args === 'function' ?
[handler_and_args] : handler_and_args));
}
}(events, jsPDF.API.events));
} else {
API[plugin] = jsPDF.API[plugin];
}
}
}
//////////////////////////////////////////////////////
// continuing initialization of jsPDF Document object
//////////////////////////////////////////////////////
// Add the first page automatically
addFonts();
activeFontKey = 'F1';
_addPage(format, orientation);
events.publish('initialized');
return API;
}
/**
* jsPDF.API is a STATIC property of jsPDF class.
* jsPDF.API is an object you can add methods and properties to.
* The methods / properties you add will show up in new jsPDF objects.
*
* One property is prepopulated. It is the 'events' Object. Plugin authors can add topics,
* callbacks to this object. These will be reassigned to all new instances of jsPDF.
* Examples:
* jsPDF.API.events['initialized'] = function(){ 'this' is API object }
* jsPDF.API.events['addFont'] = function(added_font_object){ 'this' is API object }
*
* @static
* @public
* @memberOf jsPDF
* @name API
*
* @example
* jsPDF.API.mymethod = function(){
* // 'this' will be ref to internal API object. see jsPDF source
* // , so you can refer to built-in methods like so:
* // this.line(....)
* // this.text(....)
* }
* var pdfdoc = new jsPDF()
* pdfdoc.mymethod() // <- !!!!!!
*/
jsPDF.API = {events:[]};
jsPDF.version = "1.0.0-trunk";
Iif (typeof define === 'function' && define.amd) {
define('jsPDF', function() {
return jsPDF;
});
} else Eif (typeof module !== 'undefined' && module.exports) {
module.exports = jsPDF;
} else {
global.jsPDF = jsPDF;
}
return jsPDF;
}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1 1 1 | /*
A class to parse color values
@author Stoyan Stefanov <sstoo@gmail.com>
@link http://www.phpied.com/rgb-color-parser-in-javascript/
@license Use it if you like it
*/
(function(f){function g(b){this.ok=!1;"#"==b.charAt(0)&&(b=b.substr(1,6));b=b.replace(/ /g,"");b=b.toLowerCase();var m={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",
darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",
gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",
lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",
oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",
slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},e;for(e in m)b==e&&(b=m[e]);var h=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(a){return[parseInt(a[1]),parseInt(a[2]),parseInt(a[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,
example:["#00ff00","336699"],process:function(a){return[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(a){return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)]}}];for(e=0;e<h.length;e++){var f=h[e].process,k=h[e].re.exec(b);k&&(channels=f(k),this.r=channels[0],this.g=channels[1],this.b=channels[2],this.ok=!0)}this.r=0>this.r||isNaN(this.r)?0:255<this.r?255:this.r;this.g=0>this.g||isNaN(this.g)?0:
255<this.g?255:this.g;this.b=0>this.b||isNaN(this.b)?0:255<this.b?255:this.b;this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"};this.toHex=function(){var a=this.r.toString(16),c=this.g.toString(16),d=this.b.toString(16);1==a.length&&(a="0"+a);1==c.length&&(c="0"+c);1==d.length&&(d="0"+d);return"#"+a+c+d};this.getHelpXML=function(){for(var a=[],c=0;c<h.length;c++)for(var d=h[c].example,b=0;b<d.length;b++)a[a.length]=d[b];for(var e in m)a[a.length]=e;d=document.createElement("ul");
d.setAttribute("id","rgbcolor-examples");for(c=0;c<a.length;c++)try{var f=document.createElement("li"),l=new g(a[c]),n=document.createElement("div");n.style.cssText="margin: 3px; border: 1px solid black; background:"+l.toHex()+"; color:"+l.toHex();n.appendChild(document.createTextNode("test"));var k=document.createTextNode(" "+a[c]+" -> "+l.toRGB()+" -> "+l.toHex());f.appendChild(n);f.appendChild(k);d.appendChild(f)}catch(p){}return d}}"function"===typeof define&&define.amd?define(function(){return g}):
"undefined"!==typeof module&&module.exports?module.exports=g:f.RGBColor=g;return g})("undefined"!==typeof self&&self||"undefined"!==typeof window&&window||this);
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | 1 1 1 1 1 1 | /** @preserve
* A class to parse color values
* @author Stoyan Stefanov <sstoo@gmail.com>
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
* @license Use it if you like it
*/
(function (global) {
function RGBColor(color_string)
{
this.ok = false;
// strip any leading #
if (color_string.charAt(0) == '#') { // remove # if any
color_string = color_string.substr(1,6);
}
color_string = color_string.replace(/ /g,'');
color_string = color_string.toLowerCase();
// before getting into regexps, try simple matches
// and overwrite the input
var simple_colors = {
aliceblue: 'f0f8ff',
antiquewhite: 'faebd7',
aqua: '00ffff',
aquamarine: '7fffd4',
azure: 'f0ffff',
beige: 'f5f5dc',
bisque: 'ffe4c4',
black: '000000',
blanchedalmond: 'ffebcd',
blue: '0000ff',
blueviolet: '8a2be2',
brown: 'a52a2a',
burlywood: 'deb887',
cadetblue: '5f9ea0',
chartreuse: '7fff00',
chocolate: 'd2691e',
coral: 'ff7f50',
cornflowerblue: '6495ed',
cornsilk: 'fff8dc',
crimson: 'dc143c',
cyan: '00ffff',
darkblue: '00008b',
darkcyan: '008b8b',
darkgoldenrod: 'b8860b',
darkgray: 'a9a9a9',
darkgreen: '006400',
darkkhaki: 'bdb76b',
darkmagenta: '8b008b',
darkolivegreen: '556b2f',
darkorange: 'ff8c00',
darkorchid: '9932cc',
darkred: '8b0000',
darksalmon: 'e9967a',
darkseagreen: '8fbc8f',
darkslateblue: '483d8b',
darkslategray: '2f4f4f',
darkturquoise: '00ced1',
darkviolet: '9400d3',
deeppink: 'ff1493',
deepskyblue: '00bfff',
dimgray: '696969',
dodgerblue: '1e90ff',
feldspar: 'd19275',
firebrick: 'b22222',
floralwhite: 'fffaf0',
forestgreen: '228b22',
fuchsia: 'ff00ff',
gainsboro: 'dcdcdc',
ghostwhite: 'f8f8ff',
gold: 'ffd700',
goldenrod: 'daa520',
gray: '808080',
green: '008000',
greenyellow: 'adff2f',
honeydew: 'f0fff0',
hotpink: 'ff69b4',
indianred : 'cd5c5c',
indigo : '4b0082',
ivory: 'fffff0',
khaki: 'f0e68c',
lavender: 'e6e6fa',
lavenderblush: 'fff0f5',
lawngreen: '7cfc00',
lemonchiffon: 'fffacd',
lightblue: 'add8e6',
lightcoral: 'f08080',
lightcyan: 'e0ffff',
lightgoldenrodyellow: 'fafad2',
lightgrey: 'd3d3d3',
lightgreen: '90ee90',
lightpink: 'ffb6c1',
lightsalmon: 'ffa07a',
lightseagreen: '20b2aa',
lightskyblue: '87cefa',
lightslateblue: '8470ff',
lightslategray: '778899',
lightsteelblue: 'b0c4de',
lightyellow: 'ffffe0',
lime: '00ff00',
limegreen: '32cd32',
linen: 'faf0e6',
magenta: 'ff00ff',
maroon: '800000',
mediumaquamarine: '66cdaa',
mediumblue: '0000cd',
mediumorchid: 'ba55d3',
mediumpurple: '9370d8',
mediumseagreen: '3cb371',
mediumslateblue: '7b68ee',
mediumspringgreen: '00fa9a',
mediumturquoise: '48d1cc',
mediumvioletred: 'c71585',
midnightblue: '191970',
mintcream: 'f5fffa',
mistyrose: 'ffe4e1',
moccasin: 'ffe4b5',
navajowhite: 'ffdead',
navy: '000080',
oldlace: 'fdf5e6',
olive: '808000',
olivedrab: '6b8e23',
orange: 'ffa500',
orangered: 'ff4500',
orchid: 'da70d6',
palegoldenrod: 'eee8aa',
palegreen: '98fb98',
paleturquoise: 'afeeee',
palevioletred: 'd87093',
papayawhip: 'ffefd5',
peachpuff: 'ffdab9',
peru: 'cd853f',
pink: 'ffc0cb',
plum: 'dda0dd',
powderblue: 'b0e0e6',
purple: '800080',
red: 'ff0000',
rosybrown: 'bc8f8f',
royalblue: '4169e1',
saddlebrown: '8b4513',
salmon: 'fa8072',
sandybrown: 'f4a460',
seagreen: '2e8b57',
seashell: 'fff5ee',
sienna: 'a0522d',
silver: 'c0c0c0',
skyblue: '87ceeb',
slateblue: '6a5acd',
slategray: '708090',
snow: 'fffafa',
springgreen: '00ff7f',
steelblue: '4682b4',
tan: 'd2b48c',
teal: '008080',
thistle: 'd8bfd8',
tomato: 'ff6347',
turquoise: '40e0d0',
violet: 'ee82ee',
violetred: 'd02090',
wheat: 'f5deb3',
white: 'ffffff',
whitesmoke: 'f5f5f5',
yellow: 'ffff00',
yellowgreen: '9acd32'
};
for (var key in simple_colors) {
if (color_string == key) {
color_string = simple_colors[key];
}
}
// emd of simple type-in colors
// array of color definition objects
var color_defs = [
{
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
process: function (bits){
return [
parseInt(bits[1]),
parseInt(bits[2]),
parseInt(bits[3])
];
}
},
{
re: /^(\w{2})(\w{2})(\w{2})$/,
example: ['#00ff00', '336699'],
process: function (bits){
return [
parseInt(bits[1], 16),
parseInt(bits[2], 16),
parseInt(bits[3], 16)
];
}
},
{
re: /^(\w{1})(\w{1})(\w{1})$/,
example: ['#fb0', 'f0f'],
process: function (bits){
return [
parseInt(bits[1] + bits[1], 16),
parseInt(bits[2] + bits[2], 16),
parseInt(bits[3] + bits[3], 16)
];
}
}
];
// search through the definitions to find a match
for (var i = 0; i < color_defs.length; i++) {
var re = color_defs[i].re;
var processor = color_defs[i].process;
var bits = re.exec(color_string);
if (bits) {
channels = processor(bits);
this.r = channels[0];
this.g = channels[1];
this.b = channels[2];
this.ok = true;
}
}
// validate/cleanup values
this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);
this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);
this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);
// some getters
this.toRGB = function () {
return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';
}
this.toHex = function () {
var r = this.r.toString(16);
var g = this.g.toString(16);
var b = this.b.toString(16);
if (r.length == 1) r = '0' + r;
if (g.length == 1) g = '0' + g;
if (b.length == 1) b = '0' + b;
return '#' + r + g + b;
}
// help
this.getHelpXML = function () {
var examples = new Array();
// add regexps
for (var i = 0; i < color_defs.length; i++) {
var example = color_defs[i].example;
for (var j = 0; j < example.length; j++) {
examples[examples.length] = example[j];
}
}
// add type-in colors
for (var sc in simple_colors) {
examples[examples.length] = sc;
}
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
for (var i = 0; i < examples.length; i++) {
try {
var list_item = document.createElement('li');
var list_color = new RGBColor(examples[i]);
var example_div = document.createElement('div');
example_div.style.cssText =
'margin: 3px; '
+ 'border: 1px solid black; '
+ 'background:' + list_color.toHex() + '; '
+ 'color:' + list_color.toHex()
;
example_div.appendChild(document.createTextNode('test'));
var list_item_value = document.createTextNode(
' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex()
);
list_item.appendChild(example_div);
list_item.appendChild(list_item_value);
xml.appendChild(list_item);
} catch(e){}
}
return xml;
}
}
Iif (typeof define === "function" && define.amd) {
define(function () {
return RGBColor;
});
} else Eif (typeof module !== "undefined" && module.exports) {
module.exports = RGBColor;
} else {
global.RGBColor = RGBColor;
}
return RGBColor;
})(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this);
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 11 1 | /**
* Modules in this bundle
* @license
*
* svg2pdf.js:
* license: MIT (http://opensource.org/licenses/MIT)
* author: yFiles for HTML Support Team <yfileshtml@yworks.com>
* homepage: https://github.com/yWorks/svg2pdf.js#readme
* version: 1.0.5
*
* svgpath:
* license: MIT (http://opensource.org/licenses/MIT)
* maintainers: vitaly <vitaly@rcdesign.ru>
* homepage: https://github.com/fontello/svgpath#readme
* version: 2.2.1
*
* This header is generated by licensify (https://github.com/twada/licensify)
*/
!function(t){Eif("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.svg2pdf=t()}}(function(){var t;return function t(e,r,a){function i(s,o){if(!r[s]){Iif(!e[s]){var u="function"==typeof require&&require;if(!o&&u)return u(s,!0);if(n)return n(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=r[s]={exports:{}};e[s][0].call(h.exports,function(t){var r=e[s][1][t];return i(r||t)},h,h.exports,t,e,r,a)}return r[s].exports}for(var n="function"==typeof require&&require,s=0;s<a.length;s++)i(a[s]);return i}({1:[function(t,e,r){"use strict";e.exports=t("./lib/svgpath")},{"./lib/svgpath":6}],2:[function(t,e,r){"use strict";function a(t,e,r,a){var i=t*a-e*r<0?-1:1,n=Math.sqrt(t*t+e*e),s=Math.sqrt(t*t+e*e),o=t*r+e*a,u=o/(n*s);return u>1&&(u=1),u<-1&&(u=-1),i*Math.acos(u)}function i(t,e,r,i,n,o,u,c,h,f){var l=f*(t-r)/2+h*(e-i)/2,d=-h*(t-r)/2+f*(e-i)/2,g=u*u,p=c*c,b=l*l,x=d*d,m=g*p-g*x-p*b;m<0&&(m=0),m/=g*x+p*b,m=Math.sqrt(m)*(n===o?-1:1);var v=m*u/c*d,y=m*-c/u*l,A=f*v-h*y+(t+r)/2,w=h*v+f*y+(e+i)/2,k=(l-v)/u,M=(d-y)/c,F=(-l-v)/u,C=(-d-y)/c,S=a(1,0,k,M),I=a(k,M,F,C);return 0===o&&I>0&&(I-=s),1===o&&I<0&&(I+=s),[A,w,S,I]}function n(t,e){var r=4/3*Math.tan(e/4),a=Math.cos(t),i=Math.sin(t),n=Math.cos(t+e),s=Math.sin(t+e);return[a,i,a-i*r,i+a*r,n+s*r,s-n*r,n,s]}var s=2*Math.PI;e.exports=function(t,e,r,a,o,u,c,h,f){var l=Math.sin(f*s/360),d=Math.cos(f*s/360),g=d*(t-r)/2+l*(e-a)/2,p=-l*(t-r)/2+d*(e-a)/2;if(0===g&&0===p)return[];if(0===c||0===h)return[];c=Math.abs(c),h=Math.abs(h);var b=g*g/(c*c)+p*p/(h*h);b>1&&(c*=Math.sqrt(b),h*=Math.sqrt(b));var x=i(t,e,r,a,o,u,c,h,l,d),m=[],v=x[2],y=x[3],A=Math.max(Math.ceil(Math.abs(y)/(s/4)),1);y/=A;for(var w=0;w<A;w++)m.push(n(v,y)),v+=y;return m.map(function(t){for(var e=0;e<t.length;e+=2){var r=t[e+0],a=t[e+1];r*=c,a*=h;var i=d*r-l*a,n=l*r+d*a;t[e+0]=i+x[0],t[e+1]=n+x[1]}return t})}},{}],3:[function(t,e,r){"use strict";function a(t,e,r){if(!(this instanceof a))return new a(t,e,r);this.rx=t,this.ry=e,this.ax=r}var i=Math.PI/180;a.prototype.transform=function(t){var e=Math.cos(this.ax*i),r=Math.sin(this.ax*i),a=[this.rx*(t[0]*e+t[2]*r),this.rx*(t[1]*e+t[3]*r),this.ry*(-t[0]*r+t[2]*e),this.ry*(-t[1]*r+t[3]*e)],n=a[0]*a[0]+a[2]*a[2],s=a[1]*a[1]+a[3]*a[3],o=((a[0]-a[3])*(a[0]-a[3])+(a[2]+a[1])*(a[2]+a[1]))*((a[0]+a[3])*(a[0]+a[3])+(a[2]-a[1])*(a[2]-a[1])),u=(n+s)/2;if(o<1e-10*u)return this.rx=this.ry=Math.sqrt(u),this.ax=0,this;var c=a[0]*a[1]+a[2]*a[3];o=Math.sqrt(o);var h=u+o/2,f=u-o/2;return this.ax=Math.abs(c)<1e-10&&Math.abs(h-s)<1e-10?90:180*Math.atan(Math.abs(c)>Math.abs(h-s)?(h-n)/c:c/(h-s))/Math.PI,this.ax>=0?(this.rx=Math.sqrt(h),this.ry=Math.sqrt(f)):(this.ax+=90,this.rx=Math.sqrt(f),this.ry=Math.sqrt(h)),this},a.prototype.isDegenerate=function(){return this.rx<1e-10*this.ry||this.ry<1e-10*this.rx},e.exports=a},{}],4:[function(t,e,r){"use strict";function a(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}function i(){if(!(this instanceof i))return new i;this.queue=[],this.cache=null}i.prototype.matrix=function(t){return 1===t[0]&&0===t[1]&&0===t[2]&&1===t[3]&&0===t[4]&&0===t[5]?this:(this.cache=null,this.queue.push(t),this)},i.prototype.translate=function(t,e){return 0===t&&0===e||(this.cache=null,this.queue.push([1,0,0,1,t,e])),this},i.prototype.scale=function(t,e){return 1===t&&1===e||(this.cache=null,this.queue.push([t,0,0,e,0,0])),this},i.prototype.rotate=function(t,e,r){var a,i,n;return 0!==t&&(this.translate(e,r),a=t*Math.PI/180,i=Math.cos(a),n=Math.sin(a),this.queue.push([i,n,-n,i,0,0]),this.cache=null,this.translate(-e,-r)),this},i.prototype.skewX=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,0,Math.tan(t*Math.PI/180),1,0,0])),this},i.prototype.skewY=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,Math.tan(t*Math.PI/180),0,1,0,0])),this},i.prototype.toArray=function(){if(this.cache)return this.cache;if(!this.queue.length)return this.cache=[1,0,0,1,0,0],this.cache;if(this.cache=this.queue[0],1===this.queue.length)return this.cache;for(var t=1;t<this.queue.length;t++)this.cache=a(this.cache,this.queue[t]);return this.cache},i.prototype.calc=function(t,e,r){var a;return this.queue.length?(this.cache||(this.cache=this.toArray()),a=this.cache,[t*a[0]+e*a[2]+(r?0:a[4]),t*a[1]+e*a[3]+(r?0:a[5])]):[t,e]},e.exports=i},{}],5:[function(t,e,r){"use strict";function a(t){return 10===t||13===t||8232===t||8233===t||32===t||9===t||11===t||12===t||160===t||t>=5760&&d.indexOf(t)>=0}function i(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:case 114:return!0}return!1}function n(t){return t>=48&&t<=57}function s(t){return t>=48&&t<=57||43===t||45===t||46===t}function o(t){this.index=0,this.path=t,this.max=t.length,this.result=[],this.param=0,this.err="",this.segmentStart=0,this.data=[]}function u(t){for(;t.index<t.max&&a(t.path.charCodeAt(t.index));)t.index++}function c(t){var e,r=t.index,a=r,i=t.max,s=!1,o=!1,u=!1,c=!1;if(a>=i)return void(t.err="SvgPath: missed param (at pos "+a+")");if(e=t.path.charCodeAt(a),43!==e&&45!==e||(a++,e=a<i?t.path.charCodeAt(a):0),!n(e)&&46!==e)return void(t.err="SvgPath: param should start with 0..9 or `.` (at pos "+a+")");if(46!==e){if(s=48===e,a++,e=a<i?t.path.charCodeAt(a):0,s&&a<i&&e&&n(e))return void(t.err="SvgPath: numbers started with `0` such as `09` are ilegal (at pos "+r+")");for(;a<i&&n(t.path.charCodeAt(a));)a++,o=!0;e=a<i?t.path.charCodeAt(a):0}if(46===e){for(c=!0,a++;n(t.path.charCodeAt(a));)a++,u=!0;e=a<i?t.path.charCodeAt(a):0}if(101===e||69===e){if(c&&!o&&!u)return void(t.err="SvgPath: invalid float exponent (at pos "+a+")");if(a++,e=a<i?t.path.charCodeAt(a):0,43!==e&&45!==e||a++,!(a<i&&n(t.path.charCodeAt(a))))return void(t.err="SvgPath: invalid float exponent (at pos "+a+")");for(;a<i&&n(t.path.charCodeAt(a));)a++}t.index=a,t.param=parseFloat(t.path.slice(r,a))+0}function h(t){var e,r;e=t.path[t.segmentStart],r=e.toLowerCase();var a=t.data;if("m"===r&&a.length>2&&(t.result.push([e,a[0],a[1]]),a=a.slice(2),r="l",e="m"===e?"l":"L"),"r"===r)t.result.push([e].concat(a));else for(;a.length>=l[r]&&(t.result.push([e].concat(a.splice(0,l[r]))),l[r]););}function f(t){var e,r,a,n,o=t.max;if(t.segmentStart=t.index,e=t.path.charCodeAt(t.index),!i(e))return void(t.err="SvgPath: bad command "+t.path[t.index]+" (at pos "+t.index+")");if(a=l[t.path[t.index].toLowerCase()],t.index++,u(t),t.data=[],!a)return void h(t);for(r=!1;;){for(n=a;n>0;n--){if(c(t),t.err.length)return;t.data.push(t.param),u(t),r=!1,t.index<o&&44===t.path.charCodeAt(t.index)&&(t.index++,u(t),r=!0)}if(!r){if(t.index>=t.max)break;if(!s(t.path.charCodeAt(t.index)))break}}h(t)}var l={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},d=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];e.exports=function(t){var e=new o(t),r=e.max;for(u(e);e.index<r&&!e.err.length;)f(e);return e.err.length?e.result=[]:e.result.length&&("mM".indexOf(e.result[0][0])<0?(e.err="SvgPath: string should start with `M` or `m`",e.result=[]):e.result[0][0]="M"),{err:e.err,segments:e.result}}},{}],6:[function(t,e,r){"use strict";function a(t){if(!(this instanceof a))return new a(t);var e=i(t);this.segments=e.segments,this.err=e.err,this.__stack=[]}var i=t("./path_parse"),n=t("./transform_parse"),s=t("./matrix"),o=t("./a2c"),u=t("./ellipse");a.prototype.__matrix=function(t){var e,r=this;t.queue.length&&this.iterate(function(a,i,n,s){var o,c,h,f;switch(a[0]){case"v":o=t.calc(0,a[1],!0),c=0===o[0]?["v",o[1]]:["l",o[0],o[1]];break;case"V":o=t.calc(n,a[1],!1),c=o[0]===t.calc(n,s,!1)[0]?["V",o[1]]:["L",o[0],o[1]];break;case"h":o=t.calc(a[1],0,!0),c=0===o[1]?["h",o[0]]:["l",o[0],o[1]];break;case"H":o=t.calc(a[1],s,!1),c=o[1]===t.calc(n,s,!1)[1]?["H",o[0]]:["L",o[0],o[1]];break;case"a":case"A":var l=t.toArray(),d=u(a[1],a[2],a[3]).transform(l);if(l[0]*l[3]-l[1]*l[2]<0&&(a[5]=a[5]?"0":"1"),o=t.calc(a[6],a[7],"a"===a[0]),"A"===a[0]&&a[6]===n&&a[7]===s||"a"===a[0]&&0===a[6]&&0===a[7]){c=["a"===a[0]?"l":"L",o[0],o[1]];break}c=d.isDegenerate()?["a"===a[0]?"l":"L",o[0],o[1]]:[a[0],d.rx,d.ry,d.ax,a[4],a[5],o[0],o[1]];break;case"m":f=i>0,o=t.calc(a[1],a[2],f),c=["m",o[0],o[1]];break;default:for(h=a[0],c=[h],f=h.toLowerCase()===h,e=1;e<a.length;e+=2)o=t.calc(a[e],a[e+1],f),c.push(o[0],o[1])}r.segments[i]=c},!0)},a.prototype.__evaluateStack=function(){var t,e;if(this.__stack.length){if(1===this.__stack.length)return this.__matrix(this.__stack[0]),void(this.__stack=[]);for(t=s(),e=this.__stack.length;--e>=0;)t.matrix(this.__stack[e].toArray());this.__matrix(t),this.__stack=[]}},a.prototype.toString=function(){var t,e,r=[];this.__evaluateStack();for(var a=0;a<this.segments.length;a++)e=this.segments[a][0],t=a>0&&"m"!==e&&"M"!==e&&e===this.segments[a-1][0],r=r.concat(t?this.segments[a].slice(1):this.segments[a]);return r.join(" ").replace(/ ?([achlmqrstvz]) ?/gi,"$1").replace(/ \-/g,"-").replace(/zm/g,"z m")},a.prototype.translate=function(t,e){return this.__stack.push(s().translate(t,e||0)),this},a.prototype.scale=function(t,e){return this.__stack.push(s().scale(t,e||0===e?e:t)),this},a.prototype.rotate=function(t,e,r){return this.__stack.push(s().rotate(t,e||0,r||0)),this},a.prototype.skewX=function(t){return this.__stack.push(s().skewX(t)),this},a.prototype.skewY=function(t){return this.__stack.push(s().skewY(t)),this},a.prototype.matrix=function(t){return this.__stack.push(s().matrix(t)),this},a.prototype.transform=function(t){return t.trim()?(this.__stack.push(n(t)),this):this},a.prototype.round=function(t){var e,r=0,a=0,i=0,n=0;return t=t||0,this.__evaluateStack(),this.segments.forEach(function(s){var o=s[0].toLowerCase()===s[0];switch(s[0]){case"H":case"h":return o&&(s[1]+=i),i=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"V":case"v":return o&&(s[1]+=n),n=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"Z":case"z":return i=r,void(n=a);case"M":case"m":return o&&(s[1]+=i,s[2]+=n),i=s[1]-s[1].toFixed(t),n=s[2]-s[2].toFixed(t),r=i,a=n,s[1]=+s[1].toFixed(t),void(s[2]=+s[2].toFixed(t));case"A":case"a":return o&&(s[6]+=i,s[7]+=n),i=s[6]-s[6].toFixed(t),n=s[7]-s[7].toFixed(t),s[1]=+s[1].toFixed(t),s[2]=+s[2].toFixed(t),s[3]=+s[3].toFixed(t+2),s[6]=+s[6].toFixed(t),void(s[7]=+s[7].toFixed(t));default:return e=s.length,o&&(s[e-2]+=i,s[e-1]+=n),i=s[e-2]-s[e-2].toFixed(t),n=s[e-1]-s[e-1].toFixed(t),void s.forEach(function(e,r){r&&(s[r]=+s[r].toFixed(t))})}}),this},a.prototype.iterate=function(t,e){var r,a,i,n=this.segments,s={},o=!1,u=0,c=0,h=0,f=0;if(e||this.__evaluateStack(),n.forEach(function(e,r){var a=t(e,r,u,c);Array.isArray(a)&&(s[r]=a,o=!0);var i=e[0]===e[0].toLowerCase();switch(e[0]){case"m":case"M":return u=e[1]+(i?u:0),c=e[2]+(i?c:0),h=u,void(f=c);case"h":case"H":return void(u=e[1]+(i?u:0));case"v":case"V":return void(c=e[1]+(i?c:0));case"z":case"Z":return u=h,void(c=f);default:u=e[e.length-2]+(i?u:0),c=e[e.length-1]+(i?c:0)}}),!o)return this;for(i=[],r=0;r<n.length;r++)if(void 0!==s[r])for(a=0;a<s[r].length;a++)i.push(s[r][a]);else i.push(n[r]);return this.segments=i,this},a.prototype.abs=function(){return this.iterate(function(t,e,r,a){var i,n=t[0],s=n.toUpperCase();if(n!==s)switch(t[0]=s,n){case"v":return void(t[1]+=a);case"a":return t[6]+=r,void(t[7]+=a);default:for(i=1;i<t.length;i++)t[i]+=i%2?r:a}},!0),this},a.prototype.rel=function(){return this.iterate(function(t,e,r,a){var i,n=t[0],s=n.toLowerCase();if(n!==s&&(0!==e||"M"!==n))switch(t[0]=s,n){case"V":return void(t[1]-=a);case"A":return t[6]-=r,void(t[7]-=a);default:for(i=1;i<t.length;i++)t[i]-=i%2?r:a}},!0),this},a.prototype.unarc=function(){return this.iterate(function(t,e,r,a){var i,n,s,u=[],c=t[0];return"A"!==c&&"a"!==c?null:("a"===c?(n=r+t[6],s=a+t[7]):(n=t[6],s=t[7]),i=o(r,a,n,s,t[4],t[5],t[1],t[2],t[3]),0===i.length?[["a"===t[0]?"l":"L",t[6],t[7]]]:(i.forEach(function(t){u.push(["C",t[2],t[3],t[4],t[5],t[6],t[7]])}),u))}),this},a.prototype.unshort=function(){var t,e,r,a,i,n=this.segments;return this.iterate(function(s,o,u,c){var h,f=s[0],l=f.toUpperCase();o&&("T"===l?(h="t"===f,r=n[o-1],"Q"===r[0]?(t=r[1]-u,e=r[2]-c):"q"===r[0]?(t=r[1]-r[3],e=r[2]-r[4]):(t=0,e=0),a=-t,i=-e,h||(a+=u,i+=c),n[o]=[h?"q":"Q",a,i,s[1],s[2]]):"S"===l&&(h="s"===f,r=n[o-1],"C"===r[0]?(t=r[3]-u,e=r[4]-c):"c"===r[0]?(t=r[3]-r[5],e=r[4]-r[6]):(t=0,e=0),a=-t,i=-e,h||(a+=u,i+=c),n[o]=[h?"c":"C",a,i,s[1],s[2],s[3],s[4]]))}),this},e.exports=a},{"./a2c":2,"./ellipse":3,"./matrix":4,"./path_parse":5,"./transform_parse":7}],7:[function(t,e,r){"use strict";var a=t("./matrix"),i={matrix:!0,scale:!0,rotate:!0,translate:!0,skewX:!0,skewY:!0};e.exports=function(t){var e,r,n=new a;return t.split(/\s*(matrix|translate|scale|rotate|skewX|skewY)\s*\(\s*(.+?)\s*\)[\s,]*/).forEach(function(t){if(t.length){if(void 0!==i[t])return void(e=t);switch(r=t.split(/[\s,]+/).map(function(t){return+t||0}),e){case"matrix":return void(6===r.length&&n.matrix(r));case"scale":return void(1===r.length?n.scale(r[0],r[0]):2===r.length&&n.scale(r[0],r[1]));case"rotate":return void(1===r.length?n.rotate(r[0],0,0):3===r.length&&n.rotate(r[0],r[1],r[2]));case"translate":return void(1===r.length?n.translate(r[0],0):2===r.length&&n.translate(r[0],r[1]));case"skewX":return void(1===r.length&&n.skewX(r[0]));case"skewY":return void(1===r.length&&n.skewY(r[0]))}}}),n}},{"./matrix":4}],8:[function(e,r,a){/**
* A class to parse color values
* @author Stoyan Stefanov <sstoo@gmail.com>
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
* @license Use it if you like it
*/
!function(e){function a(t){this.ok=!1,"#"==t.charAt(0)&&(t=t.substr(1,6)),t=t.replace(/ /g,""),t=t.toLowerCase();var e={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var r in e)t==r&&(t=e[r]);for(var i=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}],n=0;n<i.length;n++){var s=i[n].re,o=i[n].process,u=s.exec(t);if(u){var c=o(u);this.r=c[0],this.g=c[1],this.b=c[2],this.ok=!0}}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),r=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==r.length&&(r="0"+r),"#"+t+e+r},this.getHelpXML=function(){for(var t=new Array,r=0;r<i.length;r++)for(var n=i[r].example,s=0;s<n.length;s++)t[t.length]=n[s];for(var o in e)t[t.length]=o;var u=document.createElement("ul");u.setAttribute("id","rgbcolor-examples");for(var r=0;r<t.length;r++)try{var c=document.createElement("li"),h=new a(t[r]),f=document.createElement("div");f.style.cssText="margin: 3px; border: 1px solid black; background:"+h.toHex()+"; color:"+h.toHex(),f.appendChild(document.createTextNode("test"));var l=document.createTextNode(" "+t[r]+" -> "+h.toRGB()+" -> "+h.toHex());c.appendChild(f),c.appendChild(l),u.appendChild(c)}catch(t){}return u}}"function"==typeof t&&t.amd?t(function(){return a}):void 0!==r&&r.exports?r.exports=a:e.RGBColor=a,a}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this)},{}],9:[function(e,r,a){!function(a){function i(t,e){var r=h(t,"font-family");r&&o.setFont(r),e&&e.ok&&o.setTextColor(e.r,e.g,e.b);var a,i=h(t,"font-weight");i&&"bold"===i&&(a="bold");var n=h(t,"font-style");n&&"italic"===n&&(a+="italic"),o.setFontType(a);var s=16,u=h(t,"font-size");u&&(s=parseFloat(u),o.setFontSize(s))}var n,s,o,u=/url\(#([^)]+)\)/,c=function(t){var e=t.getAttribute("d");s&&(e=s(e).unshort().unarc().abs().toString(),t.setAttribute("d",e));var r=t.pathSegList;if(r)return r;r=[];for(var a,i=/([a-df-zA-DF-Z])([^a-df-zA-DF-Z]*)/g;a=i.exec(e);){var n=M(a[2]),o=a[1],u="zZ".indexOf(o)>=0?0:"hHvV".indexOf(o)>=0?1:"mMlLtT".indexOf(o)>=0?2:"sSqQ".indexOf(o)>=0?4:"aA".indexOf(o)>=0?7:"cC".indexOf(o)>=0?6:-1,c=0;do{var h={pathSegTypeAsLetter:o};switch(o){case"h":case"H":h.x=n[c];break;case"v":case"V":h.y=n[c];break;case"c":case"C":h.x1=n[c+u-6],h.y1=n[c+u-5];case"s":case"S":h.x2=n[c+u-4],h.y2=n[c+u-3];case"t":case"T":case"l":case"L":case"m":case"M":h.x=n[c+u-2],h.y=n[c+u-1];break;case"q":case"Q":h.x1=n[c],h.y1=n[c+1],h.x=n[c+2],h.y=n[c+3];break;case"a":case"A":throw new Error("Cannot convert Arcs without SvgPath package")}r.push(h),c+=u}while(c<n.length)}return r.getItem=function(t){return this[t]},r.numberOfItems=r.length,r},h=function(t,e,r){return r=r||e,t.getAttribute(e)||t.style[r]},f=function(t,e){return e.split(",").indexOf(t.tagName.toLowerCase())>=0},l=function(t,e){for(var r=[],a=0;a<t.childNodes.length;a++){var i=t.childNodes[a];"#"!==i.nodeName.charAt(0)&&r.push(i)}for(a=0;a<r.length;a++)e(a,r[a])},d=function(t,e){return Math.atan2(e[1]-t[1],e[0]-t[0])},g=function(t,e){var r=e[0]-t[0],a=e[1]-t[1];return[t[0]+2*r,t[1]+2*a]},p=function(t,e){return[2/3*(e[0]-t[0])+t[0],2/3*(e[1]-t[1])+t[1]]},b=function(t,e,r,a,i){var n=r.getItem(t-1);return t>0&&("C"===n.pathSegTypeAsLetter||"S"===n.pathSegTypeAsLetter)?g([n.x2,n.y2],e):t>0&&("c"===n.pathSegTypeAsLetter||"s"===n.pathSegTypeAsLetter)?g([n.x2+a,n.y2+i],e):[e[0],e[1]]},x=function(t){this.prefix=t,this.id=0,this.nextChild=function(){return new x("_"+this.id+++"_"+this.get())},this.get=function(){return this.prefix}},m=function(t,e){for(var r=/_\d+_/;!e[t]&&r.exec(t);)t=t.replace(r,"");return e[t]},v=function(t){return t.replace(/[\n\s\r]+/," ").trim()},y=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},A=function(t){var e,r,a,i,n,s,u,c,h=o.unitMatrix;if(f(t,"svg,g"))c=parseFloat(t.getAttribute("x"))||0,u=parseFloat(t.getAttribute("y"))||0,s=t.getAttribute("viewBox"),s?(n=M(s),i=n[2]-n[0],a=n[3]-n[1],r=parseFloat(t.getAttribute("width"))||i,e=parseFloat(t.getAttribute("height"))||a,h=new o.Matrix(r/i,0,0,e/a,c-n[0],u-n[1])):h=new o.Matrix(1,0,0,1,c,u);else if(f(t,"marker"))if(c=-parseFloat(t.getAttribute("refX"))||0,u=-parseFloat(t.getAttribute("refY"))||0,s=t.getAttribute("viewBox")){n=M(s),i=n[2]-n[0],a=n[3]-n[1],r=parseFloat(t.getAttribute("markerWidth"))||i,e=parseFloat(t.getAttribute("markerHeight"))||a;var l=new o.Matrix(r/i,0,0,e/a,0,0),d=new o.Matrix(1,0,0,1,c,u);h=o.matrixMult(d,l)}else h=new o.Matrix(1,0,0,1,c,u);var g=t.getAttribute("transform");return g?o.matrixMult(h,k(g)):h},w=function(t){for(var e=M(t),r=[],a=0;a<e.length-1;a+=2){var i=e[a],n=e[a+1];r.push([i,n])}return r},k=function(t){if(!t)return o.unitMatrix;for(var e,r=/^\s*matrix\(([^\)]+)\)\s*/,a=/^\s*translate\(([^\)]+)\)\s*/,i=/^\s*rotate\(([^\)]+)\)\s*/,n=/^\s*scale\(([^\)]+)\)\s*/,s=/^\s*skewX\(([^\)]+)\)\s*/,u=/^\s*skewY\(([^\)]+)\)\s*/,c=o.unitMatrix;t.length>0;){var h=r.exec(t);if(h&&(e=M(h[1]),c=o.matrixMult(new o.Matrix(e[0],e[1],e[2],e[3],e[4],e[5]),c),t=t.substr(h[0].length)),h=i.exec(t)){e=M(h[1]);var f=Math.PI*e[0]/180;if(c=o.matrixMult(new o.Matrix(Math.cos(f),Math.sin(f),-Math.sin(f),Math.cos(f),0,0),c),e[1]&&e[2]){var l=new o.Matrix(1,0,0,1,e[1],e[2]),d=new o.Matrix(1,0,0,1,-e[1],-e[2]);c=o.matrixMult(d,o.matrixMult(c,l))}t=t.substr(h[0].length)}h=a.exec(t),h&&(e=M(h[1]),c=o.matrixMult(new o.Matrix(1,0,0,1,e[0],e[1]||0),c),t=t.substr(h[0].length)),h=n.exec(t),h&&(e=M(h[1]),e[1]||(e[1]=e[0]),c=o.matrixMult(new o.Matrix(e[0],0,0,e[1],0,0),c),t=t.substr(h[0].length)),h=s.exec(t),h&&(e=parseFloat(h[1]),c=o.matrixMult(new o.Matrix(1,0,Math.tan(e),1,0,0),c),t=t.substr(h[0].length)),h=u.exec(t),h&&(e=parseFloat(h[1]),c=o.matrixMult(new o.Matrix(1,Math.tan(e),0,1,0,0),c),t=t.substr(h[0].length))}return c},M=function(t){for(var e,r=[],a=/[+-]?(?:(?:\d+\.?\d*)|(?:\d*\.?\d+))(?:[eE][+-]?\d+)?/g;e=a.exec(t);)r.push(parseFloat(e[0]));return r},F=function(t){var e=/\s*rgba\(((?:[^,\)]*,){3}[^,\)]*)\)\s*/.exec(t);if(e){var r=M(e[1]),a=new n("rgb("+r.slice(0,3).join(",")+")");return a.a=r[3],a}return new n(t)},C=function(t,e){var r=t[0],a=t[1];return[e.a*r+e.c*a+e.e,e.b*r+e.d*a+e.f]},S=function(t){var e,r,a,i,n,s,o,u,d=parseFloat;if(f(t,"polygon")){var g=w(t.getAttribute("points"));for(r=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY,e=0;e<g.length;e++){var x=g[e];r=Math.min(r,x[0]),i=Math.max(i,x[0]),a=Math.min(a,x[1]),n=Math.max(n,x[1])}u=[r,a,i-r,n-a]}else if(f(t,"path")){var m=c(t);r=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;var v,y,A,k,F,C,I,_=0,T=0;for(e=0;e<m.numberOfItems;e++){var q=m.getItem(e),L=q.pathSegTypeAsLetter;switch(L){case"H":A=q.x,k=T;break;case"h":A=q.x+_,k=T;break;case"V":A=_,k=q.y;break;case"v":A=_,k=q.y+T;break;case"C":F=[q.x1,q.y1],C=[q.x2,q.y2],I=[q.x,q.y];break;case"c":F=[q.x1+_,q.y1+T],C=[q.x2+_,q.y2+T],I=[q.x+_,q.y+T];break;case"S":F=b(e,[_,T],m,v,y),C=[q.x2,q.y2],I=[q.x,q.y];break;case"s":F=b(e,[_,T],m,v,y),C=[q.x2+_,q.y2+T],I=[q.x+_,q.y+T];break;case"Q":d=[q.x1,q.y1],F=p([_,T],d),C=p([q.x,q.y],d),I=[q.x,q.y];break;case"q":d=[q.x1+_,q.y1+T],F=p([_,T],d),C=p([_+q.x,T+q.y],d),I=[q.x+_,q.y+T];break;case"T":F=b(e,[_,T],m,v,y),F=p([_,T],d),C=p([q.x,q.y],d),I=[q.x,q.y];break;case"t":d=b(e,[_,T],m,v,y),F=p([_,T],d),C=p([_+q.x,T+q.y],d),I=[q.x+_,q.y+T]}"sScCqQtT".indexOf(L)>=0&&(v=_,y=T),"MLCSQT".indexOf(L)>=0?(_=q.x,T=q.y):"mlcsqt".indexOf(L)>=0?(_=q.x+_,T=q.y+T):"zZ".indexOf(L)<0&&(_=A,T=k),"CSQTcsqt".indexOf(L)>=0?(r=Math.min(r,_,F[0],C[0],I[0]),i=Math.max(i,_,F[0],C[0],I[0]),a=Math.min(a,T,F[1],C[1],I[1]),n=Math.max(n,T,F[1],C[1],I[1])):(r=Math.min(r,_),i=Math.max(i,_),a=Math.min(a,T),n=Math.max(n,T))}u=[r,a,i-r,n-a]}else{if(f(t,"svg"))return s=t.getAttribute("viewBox"),s&&(o=M(s)),[d(t.getAttribute("x"))||o&&o[0]||0,d(t.getAttribute("y"))||o&&o[1]||0,d(t.getAttribute("width"))||o&&o[2]||0,d(t.getAttribute("height"))||o&&o[3]||0];if(f(t,"g"))u=[0,0,0,0],l(t,function(t,e){var r=S(e);u=[Math.min(u[0],r[0]),Math.min(u[1],r[1]),Math.max(u[0]+u[2],r[0]+r[2])-Math.min(u[0],r[0]),Math.max(u[1]+u[3],r[1]+r[3])-Math.min(u[1],r[1])]});else{if(f(t,"marker"))return s=t.getAttribute("viewBox"),s&&(o=M(s)),[o&&o[0]||0,o&&o[1]||0,o&&o[2]||d(t.getAttribute("marker-width"))||0,o&&o[3]||d(t.getAttribute("marker-height"))||0];if(f(t,"pattern"))return[d(t.getAttribute("x"))||0,d(t.getAttribute("y"))||0,d(t.getAttribute("width"))||0,d(t.getAttribute("height"))||0];var N=d(t.getAttribute("x1"))||d(t.getAttribute("x"))||d(t.getAttribute("cx")-d(t.getAttribute("r")))||0,O=d(t.getAttribute("x2"))||N+d(t.getAttribute("width"))||d(t.getAttribute("cx"))+d(t.getAttribute("r"))||0,P=d(t.getAttribute("y1"))||d(t.getAttribute("y"))||d(t.getAttribute("cy"))-d(t.getAttribute("r"))||0,E=d(t.getAttribute("y2"))||P+d(t.getAttribute("height"))||d(t.getAttribute("cy"))+d(t.getAttribute("r"))||0;u=[Math.min(N,O),Math.min(P,E),Math.max(N,O)-Math.min(N,O),Math.max(P,E)-Math.min(P,E)]}}if(!f(t,"marker,svg,g")){var G=h(t,"stroke-width")||1;return h(t,"stroke-miterlimit")&&(G*=.5/Math.sin(Math.PI/12)),[u[0]-G,u[1]-G,u[2]+2*G,u[3]+2*G]}return u},I=function(t,e,r,a,i){for(var n=w(t.getAttribute("points")),s=[{op:"m",c:C(n[0],e)}],u=1;u<n.length;u++){var c=n[u],h=C(c,e);s.push({op:"l",c:h})}s.push({op:"h"}),o.path(s,r,a,i)},_=function(t){var e=t.getAttribute("xlink:href")||t.getAttribute("href"),r=new Image;r.src=e;var a=document.createElement("canvas"),i=parseFloat(t.getAttribute("width")),n=parseFloat(t.getAttribute("height")),s=parseFloat(t.getAttribute("x")||0),u=parseFloat(t.getAttribute("y")||0);a.width=i,a.height=n;var c=a.getContext("2d");c.fillStyle="#fff",c.fillRect(0,0,i,n),c.drawImage(r,0,0,i,n);var h=a.toDataURL("image/jpeg");o.addImage(h,"jpeg",s,u,i,n)},T=function(t,e,r,a,i,n){var s=c(t),h=t.getAttribute("marker-end"),f=t.getAttribute("marker-start"),l=t.getAttribute("marker-mid"),g=function(t,e){for(var r,a,i,n,u,c,g,x,m,v,y=0,A=0,w=y,k=A,M=[],F=[],S=0,I=function(t,r,a){var i,n=Math.cos(t),s=Math.sin(t);i=new o.Matrix(n,s,-s,n,r[0],r[1]),F.push({type:a,tf:o.matrixMult(i,e)})},_=0;_<s.numberOfItems;_++){var T=s.getItem(_),q=T.pathSegTypeAsLetter;switch(q){case"M":w=y,k=A,u=[T.x,T.y],m="m";break;case"m":w=y,k=A,u=[T.x+y,T.y+A],m="m";break;case"L":u=[T.x,T.y],m="l";break;case"l":u=[T.x+y,T.y+A],m="l";break;case"H":u=[T.x,A],m="l",i=T.x,n=A;break;case"h":u=[T.x+y,A],m="l",i=T.x+y,n=A;break;case"V":u=[y,T.y],m="l",i=y,n=T.y;break;case"v":u=[y,T.y+A],m="l",i=y,n=T.y+A;break;case"C":g=[T.x1,T.y1],x=[T.x2,T.y2],u=[T.x,T.y];break;case"c":g=[T.x1+y,T.y1+A],x=[T.x2+y,T.y2+A],u=[T.x+y,T.y+A];break;case"S":g=b(_,[y,A],s,r,a),x=[T.x2,T.y2],u=[T.x,T.y];break;case"s":g=b(_,[y,A],s,r,a),x=[T.x2+y,T.y2+A],u=[T.x+y,T.y+A];break;case"Q":c=[T.x1,T.y1],g=p([y,A],c),x=p([T.x,T.y],c),u=[T.x,T.y];break;case"q":c=[T.x1+y,T.y1+A],g=p([y,A],c),x=p([y+T.x,A+T.y],c),u=[T.x+y,T.y+A];break;case"T":g=b(_,[y,A],s,r,a),g=p([y,A],c),x=p([T.x,T.y],c),u=[T.x,T.y];break;case"t":c=b(_,[y,A],s,r,a),g=p([y,A],c),x=p([y+T.x,A+T.y],c),u=[T.x+y,T.y+A];break;case"Z":case"z":y=w,A=k,M.push({op:"h"})}var L=f&&(1===_||"mM".indexOf(q)<0&&"mM".indexOf(s.getItem(_-1).pathSegTypeAsLetter)>=0),N=h&&(_===s.numberOfItems-1||"mM".indexOf(q)<0&&"mM".indexOf(s.getItem(_+1).pathSegTypeAsLetter)>=0),O=l&&_>0&&!(1===_&&"mM".indexOf(s.getItem(_-1).pathSegTypeAsLetter)>=0);if("sScCqQtT".indexOf(q)>=0)L&&I(d([y,A],g),[y,A],"start"),N&&I(d(x,u),u,"end"),O&&(v=d([y,A],g),v="mM".indexOf(s.getItem(_-1).pathSegTypeAsLetter)>=0?v:.5*(S+v),I(v,[y,A],"mid")),S=d(x,u),r=y,a=A,g=C(g,e),x=C(x,e),c=C(u,e),M.push({op:"c",c:[g[0],g[1],x[0],x[1],c[0],c[1]]});else if("lLhHvVmM".indexOf(q)>=0){if(v=d([y,A],u),L&&I(v,[y,A],"start"),N&&I(v,u,"end"),O){var P="mM".indexOf(q)>=0?S:"mM".indexOf(s.getItem(_-1).pathSegTypeAsLetter)>=0?v:.5*(S+v);I(P,[y,A],"mid")}S=v,c=C(u,e),M.push({op:m,c:c})}"MLCSQT".indexOf(q)>=0?(y=T.x,A=T.y):"mlcsqt".indexOf(q)>=0?(y=T.x+y,A=T.y+A):"zZ".indexOf(q)<0&&(y=i,A=n)}return{lines:M,markers:F}}(0,e);if(h||f||l)for(var x=0;x<g.markers.length;x++){var m,v=g.markers[x];switch(v.type){case"start":m=r.get()+u.exec(f)[1];break;case"end":m=r.get()+u.exec(h)[1];break;case"mid":m=r.get()+u.exec(l)[1]}o.doFormObject(m,v.tf)}g.lines.length>0&&o.path(g.lines,a,i,n)},q=function(t,e,r){var a=t.getAttribute("href")||t.getAttribute("xlink:href");if(a){var i=o.getFormObject(r.get()+a.substring(1)),n=t.getAttribute("x")||0,s=t.getAttribute("y")||0,u=t.getAttribute("width")||i.width,c=t.getAttribute("height")||i.height,h=new o.Matrix(u/i.width||0,0,0,c/i.height||0,n,s);h=o.matrixMult(h,e),o.doFormObject(r.get()+a.substring(1),h)}},L=function(t,e){var r=C([parseFloat(t.getAttribute("x1")),parseFloat(t.getAttribute("y1"))],e),a=C([parseFloat(t.getAttribute("x2")),parseFloat(t.getAttribute("y2"))],e);o.line(r[0],r[1],a[0],a[1])},N=function(t,e,r,a){o.roundedRect(parseFloat(t.getAttribute("x"))||0,parseFloat(t.getAttribute("y"))||0,parseFloat(t.getAttribute("width")),parseFloat(t.getAttribute("height")),parseFloat(t.getAttribute("rx"))||0,parseFloat(t.getAttribute("ry"))||0,e,r,a)},O=function(t,e,r,a){o.ellipse(parseFloat(t.getAttribute("cx"))||0,parseFloat(t.getAttribute("cy"))||0,parseFloat(t.getAttribute("rx")),parseFloat(t.getAttribute("ry")),e,r,a)},P=function(t,e,r,a){var i=parseFloat(t.getAttribute("r"))||0;o.ellipse(parseFloat(t.getAttribute("cx"))||0,parseFloat(t.getAttribute("cy"))||0,i,i,e,r,a)},E=function(t,e){switch(h(t,"text-transform")){case"uppercase":return e.toUpperCase();case"lowercase":return e.toLowerCase();default:return e}},G=function(t,e,r,a){o.saveGraphicsState(),i(t,a);var s=function(t,e){var r;return(r=t&&t.toString().match(/^([\-0-9.]+)em$/))?parseFloat(r[1])*e:(r=t&&t.toString().match(/^([\-0-9.]+)(px|)$/),r?parseFloat(r[1]):0)},u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.appendChild(t),u.setAttribute("visibility","hidden"),document.body.appendChild(u);var c,d,g=t.getBBox(),p=0,b=h(t,"text-anchor");b&&(p=function(t,e){var r=0;switch(t){case"end":r=e;break;case"middle":r=e/2}return r}(b,g.width));var x=o.getFontSize(),m=s(t.getAttribute("x"),x),y=s(t.getAttribute("y"),x),A=o.matrixMult(new o.Matrix(1,0,0,1,m,y),e);c=s(t.getAttribute("dx"),x),d=s(t.getAttribute("dy"),x),0===t.childElementCount?o.text(c-p,d,E(t,v(t.textContent)),void 0,A):l(t,function(e,r){if(r.textContent&&!f(r,"title,desc,metadata")){o.saveGraphicsState();var a=h(r,"fill");i(r,a&&new n(a));var s=r.getExtentOfChar(0);o.text(s.x-m,s.y+.7*s.height-y,E(t,v(r.textContent)),void 0,A),o.restoreGraphicsState()}}),document.body.removeChild(u),o.restoreGraphicsState()},j=function(t,e,r,a,i){l(t,function(t,n){"defs"===n.tagName.toLowerCase()&&(B(n,e,r,a,i),n.parentNode.removeChild(n))})},V=function(t,e,r,a,i){var n=a.nextChild(),s=y(r);j(t,e,s,n,i),Y(t,e,s,n,i)},Y=function(t,e,r,a,i){l(t,function(t,n){B(n,e,r,a,i)})},z=function(t,e,r,a,i){var s,u=[],c=0,f=!1;l(t,function(t,e){if("stop"===e.tagName.toLowerCase()){var r=new n(h(e,"stop-color"));u.push({offset:parseFloat(e.getAttribute("offset")),color:[r.r,r.g,r.b]});var a=h(e,"stop-opacity");a&&1!=a&&(c+=parseFloat(a),f=!0)}}),f&&(s=new o.GState({opacity:c/r.length}));var d=new o.ShadingPattern(e,r,u,s),g=i.get()+t.getAttribute("id");o.addShadingPattern(g,d),a[g]=t},H=function(t,e,r){var a=r.get()+t.getAttribute("id");e[a]=t;var i=S(t),n=new o.TilingPattern([i[0],i[1],i[0]+i[2],i[1]+i[3]],i[2],i[3],null,A(t));o.beginTilingPattern(n),Y(t,o.unitMatrix,e,r,!1),o.endTilingPattern(a,n)},B=function(t,e,r,a,s){function c(){p=new n("rgb(0, 0, 0)"),g=!0,b="F"}var l,d,g=!1,p=null,b=null,x=null,v=null,y=s&&!f(t,"lineargradient,radialgradient,pattern");if(y?(l=A(t),d=S(t),o.beginFormObject(d[0],d[1],d[2],d[3],l),l=o.unitMatrix,s=!1):(l=o.matrixMult(A(t),e),o.saveGraphicsState()),f(t,"g,path,rect,text,ellipse,line,circle,polygon")){var w=h(t,"fill");if(w){var C=u.exec(w);if(C){x=a.get()+C[1];var E=m(x,r);if(E&&f(E,"lineargradient,radialgradient")){var B=l;if(!E.hasAttribute("gradientUnits")||"objectboundingbox"===E.getAttribute("gradientUnits").toLowerCase()){d||(d=S(t)),B=new o.Matrix(d[2],0,0,d[3],d[0],d[1]);var U=A(t);B=o.matrixMult(B,U)}var Q=k(E.getAttribute("gradientTransform"));v=o.matrixMult(Q,B)}else if(E&&f(E,"pattern")){var D,X,Z,R,$;v={};var W=o.unitMatrix;E.hasAttribute("patternUnits")&&"objectboundingbox"!==E.getAttribute("patternUnits").toLowerCase()||(d||(d=S(t)),W=new o.Matrix(1,0,0,1,d[0],d[1]),D=S(E),$=D[0]*d[0],X=D[1]*d[1],Z=D[2]*d[2],R=D[3]*d[3],v.boundingBox=[$,X,$+Z,X+R],v.xStep=Z,v.yStep=R);var J=o.unitMatrix;E.hasAttribute("patternContentUnits")&&"objectboundingbox"===E.getAttribute("patternContentUnits").toLowerCase()&&(d||(d=S(t)),J=new o.Matrix(d[2],0,0,d[3],0,0),D=v.boundingBox||S(E),$=D[0]/d[0],X=D[1]/d[1],Z=D[2]/d[2],R=D[3]/d[3],v.boundingBox=[$,X,$+Z,X+R],v.xStep=Z,v.yStep=R),v.matrix=o.matrixMult(o.matrixMult(J,W),l),b="F"}else x=E=null,c()}else p=F(w),p.ok?(g=!0,b="F"):b=null}else c();var K=1,tt=t.getAttribute("opacity")||t.getAttribute("fill-opacity");tt&&(K*=parseFloat(tt)),p&&"number"==typeof p.a&&(K*=p.a),o.setGState(new o.GState({opacity:K}))}if(f(t,"g,path,rect,ellipse,line,circle,polygon")){g&&o.setFillColor(p.r,p.g,p.b);var et=t.getAttribute("stroke");if(et){var rt;t.hasAttribute("stroke-width")&&(rt=Math.abs(parseFloat(t.getAttribute("stroke-width"))),o.setLineWidth(rt));var at=new n(et);at.ok&&(o.setDrawColor(at.r,at.g,at.b),0!==rt&&(b=(b||"")+"D")),t.hasAttribute("stroke-linecap")&&o.setLineCap(t.getAttribute("stroke-linecap")),t.hasAttribute("stroke-linejoin")&&o.setLineJoin(t.getAttribute("stroke-linejoin")),t.hasAttribute("stroke-dasharray")&&o.setLineDashPattern(M(t.getAttribute("stroke-dasharray")),parseInt(t.getAttribute("stroke-dashoffset"))||0),t.hasAttribute("stroke-miterlimit")&&o.setLineMiterLimit(parseFloat(t.getAttribute("stroke-miterlimit")))}}switch(i(t,p),t.tagName.toLowerCase()){case"svg":V(t,l,r,a,s);break;case"g":j(t,l,r,a,s);case"a":case"marker":Y(t,l,r,a,s);break;case"defs":Y(t,l,r,a,!0);break;case"use":q(t,l,a);break;case"line":L(t,l);break;case"rect":o.setCurrentTransformationMatrix(l),N(t,b,x,v);break;case"ellipse":o.setCurrentTransformationMatrix(l),O(t,b,x,v);break;case"circle":o.setCurrentTransformationMatrix(l),P(t,b,x,v);break;case"text":G(t,l,0,p);break;case"path":T(t,l,a,b,x,v);break;case"polygon":I(t,l,b,x,v);break;case"image":o.setCurrentTransformationMatrix(l),_(t);break;case"lineargradient":z(t,"axial",[t.getAttribute("x1"),t.getAttribute("y1"),t.getAttribute("x2"),t.getAttribute("y2")],r,a);break;case"radialgradient":z(t,"radial",[t.getAttribute("fx")||t.getAttribute("cx"),t.getAttribute("fy")||t.getAttribute("cy"),0,t.getAttribute("cx")||0,t.getAttribute("cy")||0,t.getAttribute("r")||0],r,a);break;case"pattern":H(t,r,a)}y?o.endFormObject(a.get()+t.getAttribute("id")):o.restoreGraphicsState()},U=function(t,e,r){o=e;var a=r.scale||1,i=r.xOffset||0,n=r.yOffset||0;return o.saveGraphicsState(),o.setCurrentTransformationMatrix(new o.Matrix(a,0,0,a,i,n)),B(t.cloneNode(!0),o.unitMatrix,{},new x(""),!1),o.restoreGraphicsState(),o};"function"==typeof t&&t.amd?t(["./rgbcolor","SvgPath"],function(t,e){return n=t,s=e,U}):void 0!==r&&r.exports?(n=e("./rgbcolor.js"),s=e("SvgPath"),r.exports=U):(s=a.SvgPath,n=a.RGBColor,a.svg2pdf=U,a.svgElementToPdf=U),U}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this)},{"./rgbcolor.js":8,SvgPath:1}]},{},[9])(9)});
//# sourceMappingURL=svg2pdf.min.js.map
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 | 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /**
* Modules in this bundle
* @license
*
* svg2pdf.js:
* license: MIT (http://opensource.org/licenses/MIT)
* author: yFiles for HTML Support Team <yfileshtml@yworks.com>
* homepage: https://github.com/yWorks/svg2pdf.js#readme
* version: 1.0.5
*
* svgpath:
* license: MIT (http://opensource.org/licenses/MIT)
* maintainers: vitaly <vitaly@rcdesign.ru>
* homepage: https://github.com/fontello/svgpath#readme
* version: 2.2.1
*
* This header is generated by licensify (https://github.com/twada/licensify)
*/
(function(f){Eif(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.svg2pdf = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){Iif(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
module.exports = require('./lib/svgpath');
},{"./lib/svgpath":6}],2:[function(require,module,exports){
// Convert an arc to a sequence of cubic bézier curves
//
'use strict';
var TAU = Math.PI * 2;
/* eslint-disable space-infix-ops */
// Calculate an angle between two vectors
//
function vector_angle(ux, uy, vx, vy) {
var sign = (ux * vy - uy * vx < 0) ? -1 : 1;
var umag = Math.sqrt(ux * ux + uy * uy);
var vmag = Math.sqrt(ux * ux + uy * uy);
var dot = ux * vx + uy * vy;
var div = dot / (umag * vmag);
// rounding errors, e.g. -1.0000000000000002 can screw up this
if (div > 1.0) { div = 1.0; }
if (div < -1.0) { div = -1.0; }
return sign * Math.acos(div);
}
// Convert from endpoint to center parameterization,
// see http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
//
// Return [cx, cy, theta1, delta_theta]
//
function get_arc_center(x1, y1, x2, y2, fa, fs, rx, ry, sin_phi, cos_phi) {
// Step 1.
//
// Moving an ellipse so origin will be the middlepoint between our two
// points. After that, rotate it to line up ellipse axes with coordinate
// axes.
//
var x1p = cos_phi*(x1-x2)/2 + sin_phi*(y1-y2)/2;
var y1p = -sin_phi*(x1-x2)/2 + cos_phi*(y1-y2)/2;
var rx_sq = rx * rx;
var ry_sq = ry * ry;
var x1p_sq = x1p * x1p;
var y1p_sq = y1p * y1p;
// Step 2.
//
// Compute coordinates of the centre of this ellipse (cx', cy')
// in the new coordinate system.
//
var radicant = (rx_sq * ry_sq) - (rx_sq * y1p_sq) - (ry_sq * x1p_sq);
if (radicant < 0) {
// due to rounding errors it might be e.g. -1.3877787807814457e-17
radicant = 0;
}
radicant /= (rx_sq * y1p_sq) + (ry_sq * x1p_sq);
radicant = Math.sqrt(radicant) * (fa === fs ? -1 : 1);
var cxp = radicant * rx/ry * y1p;
var cyp = radicant * -ry/rx * x1p;
// Step 3.
//
// Transform back to get centre coordinates (cx, cy) in the original
// coordinate system.
//
var cx = cos_phi*cxp - sin_phi*cyp + (x1+x2)/2;
var cy = sin_phi*cxp + cos_phi*cyp + (y1+y2)/2;
// Step 4.
//
// Compute angles (theta1, delta_theta).
//
var v1x = (x1p - cxp) / rx;
var v1y = (y1p - cyp) / ry;
var v2x = (-x1p - cxp) / rx;
var v2y = (-y1p - cyp) / ry;
var theta1 = vector_angle(1, 0, v1x, v1y);
var delta_theta = vector_angle(v1x, v1y, v2x, v2y);
if (fs === 0 && delta_theta > 0) {
delta_theta -= TAU;
}
if (fs === 1 && delta_theta < 0) {
delta_theta += TAU;
}
return [ cx, cy, theta1, delta_theta ];
}
//
// Approximate one unit arc segment with bézier curves,
// see http://math.stackexchange.com/questions/873224
//
function approximate_unit_arc(theta1, delta_theta) {
var alpha = 4/3 * Math.tan(delta_theta/4);
var x1 = Math.cos(theta1);
var y1 = Math.sin(theta1);
var x2 = Math.cos(theta1 + delta_theta);
var y2 = Math.sin(theta1 + delta_theta);
return [ x1, y1, x1 - y1*alpha, y1 + x1*alpha, x2 + y2*alpha, y2 - x2*alpha, x2, y2 ];
}
module.exports = function a2c(x1, y1, x2, y2, fa, fs, rx, ry, phi) {
var sin_phi = Math.sin(phi * TAU / 360);
var cos_phi = Math.cos(phi * TAU / 360);
// Make sure radii are valid
//
var x1p = cos_phi*(x1-x2)/2 + sin_phi*(y1-y2)/2;
var y1p = -sin_phi*(x1-x2)/2 + cos_phi*(y1-y2)/2;
if (x1p === 0 && y1p === 0) {
// we're asked to draw line to itself
return [];
}
if (rx === 0 || ry === 0) {
// one of the radii is zero
return [];
}
// Compensate out-of-range radii
//
rx = Math.abs(rx);
ry = Math.abs(ry);
var lambda = (x1p * x1p) / (rx * rx) + (y1p * y1p) / (ry * ry);
if (lambda > 1) {
rx *= Math.sqrt(lambda);
ry *= Math.sqrt(lambda);
}
// Get center parameters (cx, cy, theta1, delta_theta)
//
var cc = get_arc_center(x1, y1, x2, y2, fa, fs, rx, ry, sin_phi, cos_phi);
var result = [];
var theta1 = cc[2];
var delta_theta = cc[3];
// Split an arc to multiple segments, so each segment
// will be less than τ/4 (= 90°)
//
var segments = Math.max(Math.ceil(Math.abs(delta_theta) / (TAU / 4)), 1);
delta_theta /= segments;
for (var i = 0; i < segments; i++) {
result.push(approximate_unit_arc(theta1, delta_theta));
theta1 += delta_theta;
}
// We have a bezier approximation of a unit circle,
// now need to transform back to the original ellipse
//
return result.map(function (curve) {
for (var i = 0; i < curve.length; i += 2) {
var x = curve[i + 0];
var y = curve[i + 1];
// scale
x *= rx;
y *= ry;
// rotate
var xp = cos_phi*x - sin_phi*y;
var yp = sin_phi*x + cos_phi*y;
// translate
curve[i + 0] = xp + cc[0];
curve[i + 1] = yp + cc[1];
}
return curve;
});
};
},{}],3:[function(require,module,exports){
'use strict';
/* eslint-disable space-infix-ops */
// The precision used to consider an ellipse as a circle
//
var epsilon = 0.0000000001;
// To convert degree in radians
//
var torad = Math.PI / 180;
// Class constructor :
// an ellipse centred at 0 with radii rx,ry and x - axis - angle ax.
//
function Ellipse(rx, ry, ax) {
if (!(this instanceof Ellipse)) { return new Ellipse(rx, ry, ax); }
this.rx = rx;
this.ry = ry;
this.ax = ax;
}
// Apply a linear transform m to the ellipse
// m is an array representing a matrix :
// - -
// | m[0] m[2] |
// | m[1] m[3] |
// - -
//
Ellipse.prototype.transform = function (m) {
// We consider the current ellipse as image of the unit circle
// by first scale(rx,ry) and then rotate(ax) ...
// So we apply ma = m x rotate(ax) x scale(rx,ry) to the unit circle.
var c = Math.cos(this.ax * torad), s = Math.sin(this.ax * torad);
var ma = [
this.rx * (m[0]*c + m[2]*s),
this.rx * (m[1]*c + m[3]*s),
this.ry * (-m[0]*s + m[2]*c),
this.ry * (-m[1]*s + m[3]*c)
];
// ma * transpose(ma) = [ J L ]
// [ L K ]
// L is calculated later (if the image is not a circle)
var J = ma[0]*ma[0] + ma[2]*ma[2],
K = ma[1]*ma[1] + ma[3]*ma[3];
// the discriminant of the characteristic polynomial of ma * transpose(ma)
var D = ((ma[0]-ma[3])*(ma[0]-ma[3]) + (ma[2]+ma[1])*(ma[2]+ma[1])) *
((ma[0]+ma[3])*(ma[0]+ma[3]) + (ma[2]-ma[1])*(ma[2]-ma[1]));
// the "mean eigenvalue"
var JK = (J + K) / 2;
// check if the image is (almost) a circle
if (D < epsilon * JK) {
// if it is
this.rx = this.ry = Math.sqrt(JK);
this.ax = 0;
return this;
}
// if it is not a circle
var L = ma[0]*ma[1] + ma[2]*ma[3];
D = Math.sqrt(D);
// {l1,l2} = the two eigen values of ma * transpose(ma)
var l1 = JK + D/2,
l2 = JK - D/2;
// the x - axis - rotation angle is the argument of the l1 - eigenvector
this.ax = (Math.abs(L) < epsilon && Math.abs(l1 - K) < epsilon) ?
90
:
Math.atan(Math.abs(L) > Math.abs(l1 - K) ?
(l1 - J) / L
:
L / (l1 - K)
) * 180 / Math.PI;
// if ax > 0 => rx = sqrt(l1), ry = sqrt(l2), else exchange axes and ax += 90
if (this.ax >= 0) {
// if ax in [0,90]
this.rx = Math.sqrt(l1);
this.ry = Math.sqrt(l2);
} else {
// if ax in ]-90,0[ => exchange axes
this.ax += 90;
this.rx = Math.sqrt(l2);
this.ry = Math.sqrt(l1);
}
return this;
};
// Check if the ellipse is (almost) degenerate, i.e. rx = 0 or ry = 0
//
Ellipse.prototype.isDegenerate = function () {
return (this.rx < epsilon * this.ry || this.ry < epsilon * this.rx);
};
module.exports = Ellipse;
},{}],4:[function(require,module,exports){
'use strict';
// combine 2 matrixes
// m1, m2 - [a, b, c, d, e, g]
//
function combine(m1, m2) {
return [
m1[0] * m2[0] + m1[2] * m2[1],
m1[1] * m2[0] + m1[3] * m2[1],
m1[0] * m2[2] + m1[2] * m2[3],
m1[1] * m2[2] + m1[3] * m2[3],
m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
];
}
function Matrix() {
if (!(this instanceof Matrix)) { return new Matrix(); }
this.queue = []; // list of matrixes to apply
this.cache = null; // combined matrix cache
}
Matrix.prototype.matrix = function (m) {
if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1 && m[4] === 0 && m[5] === 0) {
return this;
}
this.cache = null;
this.queue.push(m);
return this;
};
Matrix.prototype.translate = function (tx, ty) {
if (tx !== 0 || ty !== 0) {
this.cache = null;
this.queue.push([ 1, 0, 0, 1, tx, ty ]);
}
return this;
};
Matrix.prototype.scale = function (sx, sy) {
if (sx !== 1 || sy !== 1) {
this.cache = null;
this.queue.push([ sx, 0, 0, sy, 0, 0 ]);
}
return this;
};
Matrix.prototype.rotate = function (angle, rx, ry) {
var rad, cos, sin;
if (angle !== 0) {
this.translate(rx, ry);
rad = angle * Math.PI / 180;
cos = Math.cos(rad);
sin = Math.sin(rad);
this.queue.push([ cos, sin, -sin, cos, 0, 0 ]);
this.cache = null;
this.translate(-rx, -ry);
}
return this;
};
Matrix.prototype.skewX = function (angle) {
if (angle !== 0) {
this.cache = null;
this.queue.push([ 1, 0, Math.tan(angle * Math.PI / 180), 1, 0, 0 ]);
}
return this;
};
Matrix.prototype.skewY = function (angle) {
if (angle !== 0) {
this.cache = null;
this.queue.push([ 1, Math.tan(angle * Math.PI / 180), 0, 1, 0, 0 ]);
}
return this;
};
// Flatten queue
//
Matrix.prototype.toArray = function () {
if (this.cache) {
return this.cache;
}
if (!this.queue.length) {
this.cache = [ 1, 0, 0, 1, 0, 0 ];
return this.cache;
}
this.cache = this.queue[0];
if (this.queue.length === 1) {
return this.cache;
}
for (var i = 1; i < this.queue.length; i++) {
this.cache = combine(this.cache, this.queue[i]);
}
return this.cache;
};
// Apply list of matrixes to (x,y) point.
// If `isRelative` set, `translate` component of matrix will be skipped
//
Matrix.prototype.calc = function (x, y, isRelative) {
var m;
// Don't change point on empty transforms queue
if (!this.queue.length) { return [ x, y ]; }
// Calculate final matrix, if not exists
//
// NB. if you deside to apply transforms to point one-by-one,
// they should be taken in reverse order
if (!this.cache) {
this.cache = this.toArray();
}
m = this.cache;
// Apply matrix to point
return [
x * m[0] + y * m[2] + (isRelative ? 0 : m[4]),
x * m[1] + y * m[3] + (isRelative ? 0 : m[5])
];
};
module.exports = Matrix;
},{}],5:[function(require,module,exports){
'use strict';
var paramCounts = { a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0 };
var SPECIAL_SPACES = [
0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006,
0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF
];
function isSpace(ch) {
return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029) || // Line terminators
// White spaces
(ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) ||
(ch >= 0x1680 && SPECIAL_SPACES.indexOf(ch) >= 0);
}
function isCommand(code) {
/*eslint-disable no-bitwise*/
switch (code | 0x20) {
case 0x6D/* m */:
case 0x7A/* z */:
case 0x6C/* l */:
case 0x68/* h */:
case 0x76/* v */:
case 0x63/* c */:
case 0x73/* s */:
case 0x71/* q */:
case 0x74/* t */:
case 0x61/* a */:
case 0x72/* r */:
return true;
}
return false;
}
function isDigit(code) {
return (code >= 48 && code <= 57); // 0..9
}
function isDigitStart(code) {
return (code >= 48 && code <= 57) || /* 0..9 */
code === 0x2B || /* + */
code === 0x2D || /* - */
code === 0x2E; /* . */
}
function State(path) {
this.index = 0;
this.path = path;
this.max = path.length;
this.result = [];
this.param = 0.0;
this.err = '';
this.segmentStart = 0;
this.data = [];
}
function skipSpaces(state) {
while (state.index < state.max && isSpace(state.path.charCodeAt(state.index))) {
state.index++;
}
}
function scanParam(state) {
var start = state.index,
index = start,
max = state.max,
zeroFirst = false,
hasCeiling = false,
hasDecimal = false,
hasDot = false,
ch;
if (index >= max) {
state.err = 'SvgPath: missed param (at pos ' + index + ')';
return;
}
ch = state.path.charCodeAt(index);
if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
index++;
ch = (index < max) ? state.path.charCodeAt(index) : 0;
}
// This logic is shamelessly borrowed from Esprima
// https://github.com/ariya/esprimas
//
if (!isDigit(ch) && ch !== 0x2E/* . */) {
state.err = 'SvgPath: param should start with 0..9 or `.` (at pos ' + index + ')';
return;
}
if (ch !== 0x2E/* . */) {
zeroFirst = (ch === 0x30/* 0 */);
index++;
ch = (index < max) ? state.path.charCodeAt(index) : 0;
if (zeroFirst && index < max) {
// decimal number starts with '0' such as '09' is illegal.
if (ch && isDigit(ch)) {
state.err = 'SvgPath: numbers started with `0` such as `09` are ilegal (at pos ' + start + ')';
return;
}
}
while (index < max && isDigit(state.path.charCodeAt(index))) {
index++;
hasCeiling = true;
}
ch = (index < max) ? state.path.charCodeAt(index) : 0;
}
if (ch === 0x2E/* . */) {
hasDot = true;
index++;
while (isDigit(state.path.charCodeAt(index))) {
index++;
hasDecimal = true;
}
ch = (index < max) ? state.path.charCodeAt(index) : 0;
}
if (ch === 0x65/* e */ || ch === 0x45/* E */) {
if (hasDot && !hasCeiling && !hasDecimal) {
state.err = 'SvgPath: invalid float exponent (at pos ' + index + ')';
return;
}
index++;
ch = (index < max) ? state.path.charCodeAt(index) : 0;
if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
index++;
}
if (index < max && isDigit(state.path.charCodeAt(index))) {
while (index < max && isDigit(state.path.charCodeAt(index))) {
index++;
}
} else {
state.err = 'SvgPath: invalid float exponent (at pos ' + index + ')';
return;
}
}
state.index = index;
state.param = parseFloat(state.path.slice(start, index)) + 0.0;
}
function finalizeSegment(state) {
var cmd, cmdLC;
// Process duplicated commands (without comand name)
// This logic is shamelessly borrowed from Raphael
// https://github.com/DmitryBaranovskiy/raphael/
//
cmd = state.path[state.segmentStart];
cmdLC = cmd.toLowerCase();
var params = state.data;
if (cmdLC === 'm' && params.length > 2) {
state.result.push([ cmd, params[0], params[1] ]);
params = params.slice(2);
cmdLC = 'l';
cmd = (cmd === 'm') ? 'l' : 'L';
}
if (cmdLC === 'r') {
state.result.push([ cmd ].concat(params));
} else {
while (params.length >= paramCounts[cmdLC]) {
state.result.push([ cmd ].concat(params.splice(0, paramCounts[cmdLC])));
if (!paramCounts[cmdLC]) {
break;
}
}
}
}
function scanSegment(state) {
var max = state.max,
cmdCode, comma_found, need_params, i;
state.segmentStart = state.index;
cmdCode = state.path.charCodeAt(state.index);
if (!isCommand(cmdCode)) {
state.err = 'SvgPath: bad command ' + state.path[state.index] + ' (at pos ' + state.index + ')';
return;
}
need_params = paramCounts[state.path[state.index].toLowerCase()];
state.index++;
skipSpaces(state);
state.data = [];
if (!need_params) {
// Z
finalizeSegment(state);
return;
}
comma_found = false;
for (;;) {
for (i = need_params; i > 0; i--) {
scanParam(state);
if (state.err.length) {
return;
}
state.data.push(state.param);
skipSpaces(state);
comma_found = false;
if (state.index < max && state.path.charCodeAt(state.index) === 0x2C/* , */) {
state.index++;
skipSpaces(state);
comma_found = true;
}
}
// after ',' param is mandatory
if (comma_found) {
continue;
}
if (state.index >= state.max) {
break;
}
// Stop on next segment
if (!isDigitStart(state.path.charCodeAt(state.index))) {
break;
}
}
finalizeSegment(state);
}
/* Returns array of segments:
*
* [
* [ command, coord1, coord2, ... ]
* ]
*/
module.exports = function pathParse(svgPath) {
var state = new State(svgPath);
var max = state.max;
skipSpaces(state);
while (state.index < max && !state.err.length) {
scanSegment(state);
}
if (state.err.length) {
state.result = [];
} else if (state.result.length) {
if ('mM'.indexOf(state.result[0][0]) < 0) {
state.err = 'SvgPath: string should start with `M` or `m`';
state.result = [];
} else {
state.result[0][0] = 'M';
}
}
return {
err: state.err,
segments: state.result
};
};
},{}],6:[function(require,module,exports){
// SVG Path transformations library
//
// Usage:
//
// SvgPath('...')
// .translate(-150, -100)
// .scale(0.5)
// .translate(-150, -100)
// .toFixed(1)
// .toString()
//
'use strict';
var pathParse = require('./path_parse');
var transformParse = require('./transform_parse');
var matrix = require('./matrix');
var a2c = require('./a2c');
var ellipse = require('./ellipse');
// Class constructor
//
function SvgPath(path) {
if (!(this instanceof SvgPath)) { return new SvgPath(path); }
var pstate = pathParse(path);
// Array of path segments.
// Each segment is array [command, param1, param2, ...]
this.segments = pstate.segments;
// Error message on parse error.
this.err = pstate.err;
// Transforms stack for lazy evaluation
this.__stack = [];
}
SvgPath.prototype.__matrix = function (m) {
var self = this, i;
// Quick leave for empty matrix
if (!m.queue.length) { return; }
this.iterate(function (s, index, x, y) {
var p, result, name, isRelative;
switch (s[0]) {
// Process 'assymetric' commands separately
case 'v':
p = m.calc(0, s[1], true);
result = (p[0] === 0) ? [ 'v', p[1] ] : [ 'l', p[0], p[1] ];
break;
case 'V':
p = m.calc(x, s[1], false);
result = (p[0] === m.calc(x, y, false)[0]) ? [ 'V', p[1] ] : [ 'L', p[0], p[1] ];
break;
case 'h':
p = m.calc(s[1], 0, true);
result = (p[1] === 0) ? [ 'h', p[0] ] : [ 'l', p[0], p[1] ];
break;
case 'H':
p = m.calc(s[1], y, false);
result = (p[1] === m.calc(x, y, false)[1]) ? [ 'H', p[0] ] : [ 'L', p[0], p[1] ];
break;
case 'a':
case 'A':
// ARC is: ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
// Drop segment if arc is empty (end point === start point)
/*if ((s[0] === 'A' && s[6] === x && s[7] === y) ||
(s[0] === 'a' && s[6] === 0 && s[7] === 0)) {
return [];
}*/
// Transform rx, ry and the x-axis-rotation
var ma = m.toArray();
var e = ellipse(s[1], s[2], s[3]).transform(ma);
// flip sweep-flag if matrix is not orientation-preserving
if (ma[0] * ma[3] - ma[1] * ma[2] < 0) {
s[5] = s[5] ? '0' : '1';
}
// Transform end point as usual (without translation for relative notation)
p = m.calc(s[6], s[7], s[0] === 'a');
// Empty arcs can be ignored by renderer, but should not be dropped
// to avoid collisions with `S A S` and so on. Replace with empty line.
if ((s[0] === 'A' && s[6] === x && s[7] === y) ||
(s[0] === 'a' && s[6] === 0 && s[7] === 0)) {
result = [ s[0] === 'a' ? 'l' : 'L', p[0], p[1] ];
break;
}
// if the resulting ellipse is (almost) a segment ...
if (e.isDegenerate()) {
// replace the arc by a line
result = [ s[0] === 'a' ? 'l' : 'L', p[0], p[1] ];
} else {
// if it is a real ellipse
// s[0], s[4] and s[5] are not modified
result = [ s[0], e.rx, e.ry, e.ax, s[4], s[5], p[0], p[1] ];
}
break;
case 'm':
// Edge case. The very first `m` should be processed as absolute, if happens.
// Make sense for coord shift transforms.
isRelative = index > 0;
p = m.calc(s[1], s[2], isRelative);
result = [ 'm', p[0], p[1] ];
break;
default:
name = s[0];
result = [ name ];
isRelative = (name.toLowerCase() === name);
// Apply transformations to the segment
for (i = 1; i < s.length; i += 2) {
p = m.calc(s[i], s[i + 1], isRelative);
result.push(p[0], p[1]);
}
}
self.segments[index] = result;
}, true);
};
// Apply stacked commands
//
SvgPath.prototype.__evaluateStack = function () {
var m, i;
if (!this.__stack.length) { return; }
if (this.__stack.length === 1) {
this.__matrix(this.__stack[0]);
this.__stack = [];
return;
}
m = matrix();
i = this.__stack.length;
while (--i >= 0) {
m.matrix(this.__stack[i].toArray());
}
this.__matrix(m);
this.__stack = [];
};
// Convert processed SVG Path back to string
//
SvgPath.prototype.toString = function () {
var elements = [], skipCmd, cmd;
this.__evaluateStack();
for (var i = 0; i < this.segments.length; i++) {
// remove repeating commands names
cmd = this.segments[i][0];
skipCmd = i > 0 && cmd !== 'm' && cmd !== 'M' && cmd === this.segments[i - 1][0];
elements = elements.concat(skipCmd ? this.segments[i].slice(1) : this.segments[i]);
}
return elements.join(' ')
// Optimizations: remove spaces around commands & before `-`
//
// We could also remove leading zeros for `0.5`-like values,
// but their count is too small to spend time for.
.replace(/ ?([achlmqrstvz]) ?/gi, '$1')
.replace(/ \-/g, '-')
// workaround for FontForge SVG importing bug
.replace(/zm/g, 'z m');
};
// Translate path to (x [, y])
//
SvgPath.prototype.translate = function (x, y) {
this.__stack.push(matrix().translate(x, y || 0));
return this;
};
// Scale path to (sx [, sy])
// sy = sx if not defined
//
SvgPath.prototype.scale = function (sx, sy) {
this.__stack.push(matrix().scale(sx, (!sy && (sy !== 0)) ? sx : sy));
return this;
};
// Rotate path around point (sx [, sy])
// sy = sx if not defined
//
SvgPath.prototype.rotate = function (angle, rx, ry) {
this.__stack.push(matrix().rotate(angle, rx || 0, ry || 0));
return this;
};
// Skew path along the X axis by `degrees` angle
//
SvgPath.prototype.skewX = function (degrees) {
this.__stack.push(matrix().skewX(degrees));
return this;
};
// Skew path along the Y axis by `degrees` angle
//
SvgPath.prototype.skewY = function (degrees) {
this.__stack.push(matrix().skewY(degrees));
return this;
};
// Apply matrix transform (array of 6 elements)
//
SvgPath.prototype.matrix = function (m) {
this.__stack.push(matrix().matrix(m));
return this;
};
// Transform path according to "transform" attr of SVG spec
//
SvgPath.prototype.transform = function (transformString) {
if (!transformString.trim()) {
return this;
}
this.__stack.push(transformParse(transformString));
return this;
};
// Round coords with given decimal precition.
// 0 by default (to integers)
//
SvgPath.prototype.round = function (d) {
var contourStartDeltaX = 0, contourStartDeltaY = 0, deltaX = 0, deltaY = 0, l;
d = d || 0;
this.__evaluateStack();
this.segments.forEach(function (s) {
var isRelative = (s[0].toLowerCase() === s[0]);
switch (s[0]) {
case 'H':
case 'h':
if (isRelative) { s[1] += deltaX; }
deltaX = s[1] - s[1].toFixed(d);
s[1] = +s[1].toFixed(d);
return;
case 'V':
case 'v':
if (isRelative) { s[1] += deltaY; }
deltaY = s[1] - s[1].toFixed(d);
s[1] = +s[1].toFixed(d);
return;
case 'Z':
case 'z':
deltaX = contourStartDeltaX;
deltaY = contourStartDeltaY;
return;
case 'M':
case 'm':
if (isRelative) {
s[1] += deltaX;
s[2] += deltaY;
}
deltaX = s[1] - s[1].toFixed(d);
deltaY = s[2] - s[2].toFixed(d);
contourStartDeltaX = deltaX;
contourStartDeltaY = deltaY;
s[1] = +s[1].toFixed(d);
s[2] = +s[2].toFixed(d);
return;
case 'A':
case 'a':
// [cmd, rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
if (isRelative) {
s[6] += deltaX;
s[7] += deltaY;
}
deltaX = s[6] - s[6].toFixed(d);
deltaY = s[7] - s[7].toFixed(d);
s[1] = +s[1].toFixed(d);
s[2] = +s[2].toFixed(d);
s[3] = +s[3].toFixed(d + 2); // better precision for rotation
s[6] = +s[6].toFixed(d);
s[7] = +s[7].toFixed(d);
return;
default:
// a c l q s t
l = s.length;
if (isRelative) {
s[l - 2] += deltaX;
s[l - 1] += deltaY;
}
deltaX = s[l - 2] - s[l - 2].toFixed(d);
deltaY = s[l - 1] - s[l - 1].toFixed(d);
s.forEach(function (val, i) {
if (!i) { return; }
s[i] = +s[i].toFixed(d);
});
return;
}
});
return this;
};
// Apply iterator function to all segments. If function returns result,
// current segment will be replaced to array of returned segments.
// If empty array is returned, current regment will be deleted.
//
SvgPath.prototype.iterate = function (iterator, keepLazyStack) {
var segments = this.segments,
replacements = {},
needReplace = false,
lastX = 0,
lastY = 0,
countourStartX = 0,
countourStartY = 0;
var i, j, newSegments;
if (!keepLazyStack) {
this.__evaluateStack();
}
segments.forEach(function (s, index) {
var res = iterator(s, index, lastX, lastY);
if (Array.isArray(res)) {
replacements[index] = res;
needReplace = true;
}
var isRelative = (s[0] === s[0].toLowerCase());
// calculate absolute X and Y
switch (s[0]) {
case 'm':
case 'M':
lastX = s[1] + (isRelative ? lastX : 0);
lastY = s[2] + (isRelative ? lastY : 0);
countourStartX = lastX;
countourStartY = lastY;
return;
case 'h':
case 'H':
lastX = s[1] + (isRelative ? lastX : 0);
return;
case 'v':
case 'V':
lastY = s[1] + (isRelative ? lastY : 0);
return;
case 'z':
case 'Z':
// That make sence for multiple contours
lastX = countourStartX;
lastY = countourStartY;
return;
default:
lastX = s[s.length - 2] + (isRelative ? lastX : 0);
lastY = s[s.length - 1] + (isRelative ? lastY : 0);
}
});
// Replace segments if iterator return results
if (!needReplace) { return this; }
newSegments = [];
for (i = 0; i < segments.length; i++) {
if (typeof replacements[i] !== 'undefined') {
for (j = 0; j < replacements[i].length; j++) {
newSegments.push(replacements[i][j]);
}
} else {
newSegments.push(segments[i]);
}
}
this.segments = newSegments;
return this;
};
// Converts segments from relative to absolute
//
SvgPath.prototype.abs = function () {
this.iterate(function (s, index, x, y) {
var name = s[0],
nameUC = name.toUpperCase(),
i;
// Skip absolute commands
if (name === nameUC) { return; }
s[0] = nameUC;
switch (name) {
case 'v':
// v has shifted coords parity
s[1] += y;
return;
case 'a':
// ARC is: ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
// touch x, y only
s[6] += x;
s[7] += y;
return;
default:
for (i = 1; i < s.length; i++) {
s[i] += i % 2 ? x : y; // odd values are X, even - Y
}
}
}, true);
return this;
};
// Converts segments from absolute to relative
//
SvgPath.prototype.rel = function () {
this.iterate(function (s, index, x, y) {
var name = s[0],
nameLC = name.toLowerCase(),
i;
// Skip relative commands
if (name === nameLC) { return; }
// Don't touch the first M to avoid potential confusions.
if (index === 0 && name === 'M') { return; }
s[0] = nameLC;
switch (name) {
case 'V':
// V has shifted coords parity
s[1] -= y;
return;
case 'A':
// ARC is: ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y]
// touch x, y only
s[6] -= x;
s[7] -= y;
return;
default:
for (i = 1; i < s.length; i++) {
s[i] -= i % 2 ? x : y; // odd values are X, even - Y
}
}
}, true);
return this;
};
// Converts arcs to cubic bézier curves
//
SvgPath.prototype.unarc = function () {
this.iterate(function (s, index, x, y) {
var new_segments, nextX, nextY, result = [], name = s[0];
// Skip anything except arcs
if (name !== 'A' && name !== 'a') { return null; }
if (name === 'a') {
// convert relative arc coordinates to absolute
nextX = x + s[6];
nextY = y + s[7];
} else {
nextX = s[6];
nextY = s[7];
}
new_segments = a2c(x, y, nextX, nextY, s[4], s[5], s[1], s[2], s[3]);
// Degenerated arcs can be ignored by renderer, but should not be dropped
// to avoid collisions with `S A S` and so on. Replace with empty line.
if (new_segments.length === 0) {
return [ [ s[0] === 'a' ? 'l' : 'L', s[6], s[7] ] ];
}
new_segments.forEach(function (s) {
result.push([ 'C', s[2], s[3], s[4], s[5], s[6], s[7] ]);
});
return result;
});
return this;
};
// Converts smooth curves (with missed control point) to generic curves
//
SvgPath.prototype.unshort = function () {
var segments = this.segments;
var prevControlX, prevControlY, prevSegment;
var curControlX, curControlY;
// TODO: add lazy evaluation flag when relative commands supported
this.iterate(function (s, idx, x, y) {
var name = s[0], nameUC = name.toUpperCase(), isRelative;
// First command MUST be M|m, it's safe to skip.
// Protect from access to [-1] for sure.
if (!idx) { return; }
if (nameUC === 'T') { // quadratic curve
isRelative = (name === 't');
prevSegment = segments[idx - 1];
if (prevSegment[0] === 'Q') {
prevControlX = prevSegment[1] - x;
prevControlY = prevSegment[2] - y;
} else if (prevSegment[0] === 'q') {
prevControlX = prevSegment[1] - prevSegment[3];
prevControlY = prevSegment[2] - prevSegment[4];
} else {
prevControlX = 0;
prevControlY = 0;
}
curControlX = -prevControlX;
curControlY = -prevControlY;
if (!isRelative) {
curControlX += x;
curControlY += y;
}
segments[idx] = [
isRelative ? 'q' : 'Q',
curControlX, curControlY,
s[1], s[2]
];
} else if (nameUC === 'S') { // cubic curve
isRelative = (name === 's');
prevSegment = segments[idx - 1];
if (prevSegment[0] === 'C') {
prevControlX = prevSegment[3] - x;
prevControlY = prevSegment[4] - y;
} else if (prevSegment[0] === 'c') {
prevControlX = prevSegment[3] - prevSegment[5];
prevControlY = prevSegment[4] - prevSegment[6];
} else {
prevControlX = 0;
prevControlY = 0;
}
curControlX = -prevControlX;
curControlY = -prevControlY;
if (!isRelative) {
curControlX += x;
curControlY += y;
}
segments[idx] = [
isRelative ? 'c' : 'C',
curControlX, curControlY,
s[1], s[2], s[3], s[4]
];
}
});
return this;
};
module.exports = SvgPath;
},{"./a2c":2,"./ellipse":3,"./matrix":4,"./path_parse":5,"./transform_parse":7}],7:[function(require,module,exports){
'use strict';
var Matrix = require('./matrix');
var operations = {
matrix: true,
scale: true,
rotate: true,
translate: true,
skewX: true,
skewY: true
};
var CMD_SPLIT_RE = /\s*(matrix|translate|scale|rotate|skewX|skewY)\s*\(\s*(.+?)\s*\)[\s,]*/;
var PARAMS_SPLIT_RE = /[\s,]+/;
module.exports = function transformParse(transformString) {
var matrix = new Matrix();
var cmd, params;
// Split value into ['', 'translate', '10 50', '', 'scale', '2', '', 'rotate', '-45', '']
transformString.split(CMD_SPLIT_RE).forEach(function (item) {
// Skip empty elements
if (!item.length) { return; }
// remember operation
if (typeof operations[item] !== 'undefined') {
cmd = item;
return;
}
// extract params & att operation to matrix
params = item.split(PARAMS_SPLIT_RE).map(function (i) {
return +i || 0;
});
// If params count is not correct - ignore command
switch (cmd) {
case 'matrix':
if (params.length === 6) {
matrix.matrix(params);
}
return;
case 'scale':
if (params.length === 1) {
matrix.scale(params[0], params[0]);
} else if (params.length === 2) {
matrix.scale(params[0], params[1]);
}
return;
case 'rotate':
if (params.length === 1) {
matrix.rotate(params[0], 0, 0);
} else if (params.length === 3) {
matrix.rotate(params[0], params[1], params[2]);
}
return;
case 'translate':
if (params.length === 1) {
matrix.translate(params[0], 0);
} else if (params.length === 2) {
matrix.translate(params[0], params[1]);
}
return;
case 'skewX':
if (params.length === 1) {
matrix.skewX(params[0]);
}
return;
case 'skewY':
if (params.length === 1) {
matrix.skewY(params[0]);
}
return;
}
});
return matrix;
};
},{"./matrix":4}],8:[function(require,module,exports){
/**
* A class to parse color values
* @author Stoyan Stefanov <sstoo@gmail.com>
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
* @license Use it if you like it
*/
(function (global) {
function RGBColor(color_string)
{
this.ok = false;
// strip any leading #
if (color_string.charAt(0) == '#') { // remove # if any
color_string = color_string.substr(1,6);
}
color_string = color_string.replace(/ /g,'');
color_string = color_string.toLowerCase();
// before getting into regexps, try simple matches
// and overwrite the input
var simple_colors = {
aliceblue: 'f0f8ff',
antiquewhite: 'faebd7',
aqua: '00ffff',
aquamarine: '7fffd4',
azure: 'f0ffff',
beige: 'f5f5dc',
bisque: 'ffe4c4',
black: '000000',
blanchedalmond: 'ffebcd',
blue: '0000ff',
blueviolet: '8a2be2',
brown: 'a52a2a',
burlywood: 'deb887',
cadetblue: '5f9ea0',
chartreuse: '7fff00',
chocolate: 'd2691e',
coral: 'ff7f50',
cornflowerblue: '6495ed',
cornsilk: 'fff8dc',
crimson: 'dc143c',
cyan: '00ffff',
darkblue: '00008b',
darkcyan: '008b8b',
darkgoldenrod: 'b8860b',
darkgray: 'a9a9a9',
darkgreen: '006400',
darkkhaki: 'bdb76b',
darkmagenta: '8b008b',
darkolivegreen: '556b2f',
darkorange: 'ff8c00',
darkorchid: '9932cc',
darkred: '8b0000',
darksalmon: 'e9967a',
darkseagreen: '8fbc8f',
darkslateblue: '483d8b',
darkslategray: '2f4f4f',
darkturquoise: '00ced1',
darkviolet: '9400d3',
deeppink: 'ff1493',
deepskyblue: '00bfff',
dimgray: '696969',
dodgerblue: '1e90ff',
feldspar: 'd19275',
firebrick: 'b22222',
floralwhite: 'fffaf0',
forestgreen: '228b22',
fuchsia: 'ff00ff',
gainsboro: 'dcdcdc',
ghostwhite: 'f8f8ff',
gold: 'ffd700',
goldenrod: 'daa520',
gray: '808080',
green: '008000',
greenyellow: 'adff2f',
honeydew: 'f0fff0',
hotpink: 'ff69b4',
indianred : 'cd5c5c',
indigo : '4b0082',
ivory: 'fffff0',
khaki: 'f0e68c',
lavender: 'e6e6fa',
lavenderblush: 'fff0f5',
lawngreen: '7cfc00',
lemonchiffon: 'fffacd',
lightblue: 'add8e6',
lightcoral: 'f08080',
lightcyan: 'e0ffff',
lightgoldenrodyellow: 'fafad2',
lightgrey: 'd3d3d3',
lightgreen: '90ee90',
lightpink: 'ffb6c1',
lightsalmon: 'ffa07a',
lightseagreen: '20b2aa',
lightskyblue: '87cefa',
lightslateblue: '8470ff',
lightslategray: '778899',
lightsteelblue: 'b0c4de',
lightyellow: 'ffffe0',
lime: '00ff00',
limegreen: '32cd32',
linen: 'faf0e6',
magenta: 'ff00ff',
maroon: '800000',
mediumaquamarine: '66cdaa',
mediumblue: '0000cd',
mediumorchid: 'ba55d3',
mediumpurple: '9370d8',
mediumseagreen: '3cb371',
mediumslateblue: '7b68ee',
mediumspringgreen: '00fa9a',
mediumturquoise: '48d1cc',
mediumvioletred: 'c71585',
midnightblue: '191970',
mintcream: 'f5fffa',
mistyrose: 'ffe4e1',
moccasin: 'ffe4b5',
navajowhite: 'ffdead',
navy: '000080',
oldlace: 'fdf5e6',
olive: '808000',
olivedrab: '6b8e23',
orange: 'ffa500',
orangered: 'ff4500',
orchid: 'da70d6',
palegoldenrod: 'eee8aa',
palegreen: '98fb98',
paleturquoise: 'afeeee',
palevioletred: 'd87093',
papayawhip: 'ffefd5',
peachpuff: 'ffdab9',
peru: 'cd853f',
pink: 'ffc0cb',
plum: 'dda0dd',
powderblue: 'b0e0e6',
purple: '800080',
red: 'ff0000',
rosybrown: 'bc8f8f',
royalblue: '4169e1',
saddlebrown: '8b4513',
salmon: 'fa8072',
sandybrown: 'f4a460',
seagreen: '2e8b57',
seashell: 'fff5ee',
sienna: 'a0522d',
silver: 'c0c0c0',
skyblue: '87ceeb',
slateblue: '6a5acd',
slategray: '708090',
snow: 'fffafa',
springgreen: '00ff7f',
steelblue: '4682b4',
tan: 'd2b48c',
teal: '008080',
thistle: 'd8bfd8',
tomato: 'ff6347',
turquoise: '40e0d0',
violet: 'ee82ee',
violetred: 'd02090',
wheat: 'f5deb3',
white: 'ffffff',
whitesmoke: 'f5f5f5',
yellow: 'ffff00',
yellowgreen: '9acd32'
};
for (var key in simple_colors) {
if (color_string == key) {
color_string = simple_colors[key];
}
}
// emd of simple type-in colors
// array of color definition objects
var color_defs = [
{
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
process: function (bits){
return [
parseInt(bits[1]),
parseInt(bits[2]),
parseInt(bits[3])
];
}
},
{
re: /^(\w{2})(\w{2})(\w{2})$/,
example: ['#00ff00', '336699'],
process: function (bits){
return [
parseInt(bits[1], 16),
parseInt(bits[2], 16),
parseInt(bits[3], 16)
];
}
},
{
re: /^(\w{1})(\w{1})(\w{1})$/,
example: ['#fb0', 'f0f'],
process: function (bits){
return [
parseInt(bits[1] + bits[1], 16),
parseInt(bits[2] + bits[2], 16),
parseInt(bits[3] + bits[3], 16)
];
}
}
];
// search through the definitions to find a match
for (var i = 0; i < color_defs.length; i++) {
var re = color_defs[i].re;
var processor = color_defs[i].process;
var bits = re.exec(color_string);
if (bits) {
var channels = processor(bits);
this.r = channels[0];
this.g = channels[1];
this.b = channels[2];
this.ok = true;
}
}
// validate/cleanup values
this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);
this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);
this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);
// some getters
this.toRGB = function () {
return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';
}
this.toHex = function () {
var r = this.r.toString(16);
var g = this.g.toString(16);
var b = this.b.toString(16);
if (r.length == 1) r = '0' + r;
if (g.length == 1) g = '0' + g;
if (b.length == 1) b = '0' + b;
return '#' + r + g + b;
}
// help
this.getHelpXML = function () {
var examples = new Array();
// add regexps
for (var i = 0; i < color_defs.length; i++) {
var example = color_defs[i].example;
for (var j = 0; j < example.length; j++) {
examples[examples.length] = example[j];
}
}
// add type-in colors
for (var sc in simple_colors) {
examples[examples.length] = sc;
}
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
for (var i = 0; i < examples.length; i++) {
try {
var list_item = document.createElement('li');
var list_color = new RGBColor(examples[i]);
var example_div = document.createElement('div');
example_div.style.cssText =
'margin: 3px; '
+ 'border: 1px solid black; '
+ 'background:' + list_color.toHex() + '; '
+ 'color:' + list_color.toHex()
;
example_div.appendChild(document.createTextNode('test'));
var list_item_value = document.createTextNode(
' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex()
);
list_item.appendChild(example_div);
list_item.appendChild(list_item_value);
xml.appendChild(list_item);
} catch(e){}
}
return xml;
}
}
Iif (typeof define === "function" && define.amd) {
define(function () {
return RGBColor;
});
} else Eif (typeof module !== "undefined" && module.exports) {
module.exports = RGBColor;
} else {
global.RGBColor = RGBColor;
}
return RGBColor;
})(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this);
},{}],9:[function(require,module,exports){
/*
The MIT License (MIT)
Copyright (c) 2015-2016 yWorks GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* Renders an svg element to a jsPDF document.
* For accurate results a DOM document is required (mainly used for text size measurement and image format conversion)
* @param element {HTMLElement} The svg element, which will be cloned, so the original stays unchanged.
* @param pdf {jsPDF} The jsPDF object.
* @param options {object} An object that may contain render options. Currently supported are:
* scale: The global factor by which everything is scaled.
* xOffset, yOffset: Offsets that are added to every coordinate AFTER scaling (They are not
* influenced by the scale attribute).
*/
(function (global) {
var RGBColor;
var SvgPath;
var _pdf; // jsPDF pdf-document
var cToQ = 2 / 3; // ratio to convert quadratic bezier curves to cubic ones
var iriReference = /url\(#([^)]+)\)/;
// pathSegList is marked deprecated in chrome, so parse the d attribute manually if necessary
var getPathSegList = function (node) {
var d = node.getAttribute("d");
// Replace arcs before path segment list is handled
if (SvgPath) {
d = SvgPath(d).unshort().unarc().abs().toString();
node.setAttribute('d', d);
}
var pathSegList = node.pathSegList;
if (pathSegList) {
return pathSegList;
}
pathSegList = [];
var regex = /([a-df-zA-DF-Z])([^a-df-zA-DF-Z]*)/g,
match;
while (match = regex.exec(d)) {
var coords = parseFloats(match[2]);
var type = match[1];
var length = "zZ".indexOf(type) >= 0 ? 0 :
"hHvV".indexOf(type) >= 0 ? 1 :
"mMlLtT".indexOf(type) >= 0 ? 2 :
"sSqQ".indexOf(type) >= 0 ? 4 :
"aA".indexOf(type) >= 0 ? 7 :
"cC".indexOf(type) >= 0 ? 6 : -1;
var i = 0;
do {
var pathSeg = {pathSegTypeAsLetter: type};
switch (type) {
case "h":
case "H":
pathSeg.x = coords[i];
break;
case "v":
case "V":
pathSeg.y = coords[i];
break;
case "c":
case "C":
pathSeg.x1 = coords[i + length - 6];
pathSeg.y1 = coords[i + length - 5];
case "s":
case "S":
pathSeg.x2 = coords[i + length - 4];
pathSeg.y2 = coords[i + length - 3];
case "t":
case "T":
case "l":
case "L":
case "m":
case "M":
pathSeg.x = coords[i + length - 2];
pathSeg.y = coords[i + length - 1];
break;
case "q":
case "Q":
pathSeg.x1 = coords[i];
pathSeg.y1 = coords[i + 1];
pathSeg.x = coords[i + 2];
pathSeg.y = coords[i + 3];
break;
case "a":
case "A":
throw new Error("Cannot convert Arcs without SvgPath package");
}
pathSegList.push(pathSeg);
i += length;
} while(i < coords.length);
}
pathSegList.getItem = function (i) {
return this[i]
};
pathSegList.numberOfItems = pathSegList.length;
return pathSegList;
};
// returns an attribute of a node, either from the node directly or from css
var getAttribute = function (node, propertyNode, propertyCss) {
propertyCss = propertyCss || propertyNode;
return node.getAttribute(propertyNode) || node.style[propertyCss];
};
var nodeIs = function (node, tagsString) {
return tagsString.split(",").indexOf(node.tagName.toLowerCase()) >= 0;
};
var forEachChild = function (node, fn) {
// copy list of children, as the original might be modified
var children = [];
for (var i = 0; i < node.childNodes.length; i++) {
var childNode = node.childNodes[i];
if (childNode.nodeName.charAt(0) !== "#")
children.push(childNode);
}
for (i = 0; i < children.length; i++) {
fn(i, children[i]);
}
};
var getAngle = function (from, to) {
return Math.atan2(to[1] - from[1], to[0] - from[0]);
};
// mirrors p1 at p2
var mirrorPoint = function (p1, p2) {
var dx = p2[0] - p1[0];
var dy = p2[1] - p1[1];
return [p1[0] + 2 * dx, p1[1] + 2 * dy];
};
// transforms a cubic bezier control point to a quadratic one: returns from + (2/3) * (to - from)
var toCubic = function (from, to) {
return [cToQ * (to[0] - from[0]) + from[0], cToQ * (to[1] - from[1]) + from[1]];
};
// extracts a control point from a previous path segment (for t,T,s,S segments)
var getControlPointFromPrevious = function (i, from, list, prevX, prevY) {
var prev = list.getItem(i - 1);
var p2;
if (i > 0 && (prev.pathSegTypeAsLetter === "C" || prev.pathSegTypeAsLetter === "S")) {
p2 = mirrorPoint([prev.x2, prev.y2], from);
} else if (i > 0 && (prev.pathSegTypeAsLetter === "c" || prev.pathSegTypeAsLetter === "s")) {
p2 = mirrorPoint([prev.x2 + prevX, prev.y2 + prevY], from);
} else {
p2 = [from[0], from[1]];
}
return p2;
};
// an id prefix to handle duplicate ids
var SvgPrefix = function (prefix) {
this.prefix = prefix;
this.id = 0;
this.nextChild = function () {
return new SvgPrefix("_" + this.id++ + "_" + this.get());
};
this.get = function () {
return this.prefix;
}
};
// returns the node for the specified id or incrementally removes prefixes to search "higher" levels
var getFromDefs = function (id, defs) {
var regExp = /_\d+_/;
while (!defs[id] && regExp.exec(id)) {
id = id.replace(regExp, "");
}
return defs[id];
};
// replace any newline characters by space and trim
var removeNewlinesAndTrim = function (str) {
return str.replace(/[\n\s\r]+/, " ").trim();
};
// clones the defs object (or basically any object)
var cloneDefs = function (defs) {
var clone = {};
for (var key in defs) {
if (defs.hasOwnProperty(key)) {
clone[key] = defs[key];
}
}
return clone;
};
// computes the transform directly applied at the node (such as viewbox scaling and the "transform" atrribute)
// x,y,cx,cy,r,... are omitted
var computeNodeTransform = function (node) {
var height, width, viewBoxHeight, viewBoxWidth, bounds, viewBox, y, x;
var nodeTransform = _pdf.unitMatrix;
if (nodeIs(node, "svg,g")) {
x = parseFloat(node.getAttribute("x")) || 0;
y = parseFloat(node.getAttribute("y")) || 0;
// jquery doesn't like camelCase notation...
viewBox = node.getAttribute("viewBox");
if (viewBox) {
bounds = parseFloats(viewBox);
viewBoxWidth = bounds[2] - bounds[0];
viewBoxHeight = bounds[3] - bounds[1];
width = parseFloat(node.getAttribute("width")) || viewBoxWidth;
height = parseFloat(node.getAttribute("height")) || viewBoxHeight;
nodeTransform = new _pdf.Matrix(width / viewBoxWidth, 0, 0, height / viewBoxHeight, x - bounds[0], y - bounds[1]);
} else {
nodeTransform = new _pdf.Matrix(1, 0, 0, 1, x, y);
}
} else if (nodeIs(node, "marker")) {
x = -parseFloat(node.getAttribute("refX")) || 0;
y = -parseFloat(node.getAttribute("refY")) || 0;
viewBox = node.getAttribute("viewBox");
if (viewBox) {
bounds = parseFloats(viewBox);
viewBoxWidth = bounds[2] - bounds[0];
viewBoxHeight = bounds[3] - bounds[1];
width = parseFloat(node.getAttribute("markerWidth")) || viewBoxWidth;
height = parseFloat(node.getAttribute("markerHeight")) || viewBoxHeight;
var s = new _pdf.Matrix(width / viewBoxWidth, 0, 0, height / viewBoxHeight, 0, 0);
var t = new _pdf.Matrix(1, 0, 0, 1, x, y);
nodeTransform = _pdf.matrixMult(t, s);
} else {
nodeTransform = new _pdf.Matrix(1, 0, 0, 1, x, y);
}
}
var transformString = node.getAttribute("transform");
if (!transformString)
return nodeTransform;
else
return _pdf.matrixMult(nodeTransform, parseTransform(transformString));
};
// parses the "points" string used by polygons and returns an array of points
var parsePointsString = function (string) {
var floats = parseFloats(string);
var result = [];
for (var i = 0; i < floats.length - 1; i += 2) {
var x = floats[i];
var y = floats[i + 1];
result.push([x, y]);
}
return result;
};
// parses the "transform" string
var parseTransform = function (transformString) {
if (!transformString)
return _pdf.unitMatrix;
var mRegex = /^\s*matrix\(([^\)]+)\)\s*/,
tRegex = /^\s*translate\(([^\)]+)\)\s*/,
rRegex = /^\s*rotate\(([^\)]+)\)\s*/,
sRegex = /^\s*scale\(([^\)]+)\)\s*/,
sXRegex = /^\s*skewX\(([^\)]+)\)\s*/,
sYRegex = /^\s*skewY\(([^\)]+)\)\s*/;
var resultMatrix = _pdf.unitMatrix, m;
while (transformString.length > 0) {
var match = mRegex.exec(transformString);
if (match) {
m = parseFloats(match[1]);
resultMatrix = _pdf.matrixMult(new _pdf.Matrix(m[0], m[1], m[2], m[3], m[4], m[5]), resultMatrix);
transformString = transformString.substr(match[0].length);
}
match = rRegex.exec(transformString);
if (match) {
m = parseFloats(match[1]);
var a = Math.PI * m[0] / 180;
resultMatrix = _pdf.matrixMult(new _pdf.Matrix(Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0), resultMatrix);
if (m[1] && m[2]) {
var t1 = new _pdf.Matrix(1, 0, 0, 1, m[1], m[2]);
var t2 = new _pdf.Matrix(1, 0, 0, 1, -m[1], -m[2]);
resultMatrix = _pdf.matrixMult(t2, _pdf.matrixMult(resultMatrix, t1));
}
transformString = transformString.substr(match[0].length);
}
match = tRegex.exec(transformString);
if (match) {
m = parseFloats(match[1]);
resultMatrix = _pdf.matrixMult(new _pdf.Matrix(1, 0, 0, 1, m[0], m[1] || 0), resultMatrix);
transformString = transformString.substr(match[0].length);
}
match = sRegex.exec(transformString);
if (match) {
m = parseFloats(match[1]);
if (!m[1])
m[1] = m[0];
resultMatrix = _pdf.matrixMult(new _pdf.Matrix(m[0], 0, 0, m[1], 0, 0), resultMatrix);
transformString = transformString.substr(match[0].length);
}
match = sXRegex.exec(transformString);
if (match) {
m = parseFloat(match[1]);
resultMatrix = _pdf.matrixMult(new _pdf.Matrix(1, 0, Math.tan(m), 1, 0, 0), resultMatrix);
transformString = transformString.substr(match[0].length);
}
match = sYRegex.exec(transformString);
if (match) {
m = parseFloat(match[1]);
resultMatrix = _pdf.matrixMult(new _pdf.Matrix(1, Math.tan(m), 0, 1, 0, 0), resultMatrix);
transformString = transformString.substr(match[0].length);
}
}
return resultMatrix;
};
// parses a comma, sign and/or whitespace separated string of floats and returns the single floats in an array
var parseFloats = function (str) {
var floats = [], match,
regex = /[+-]?(?:(?:\d+\.?\d*)|(?:\d*\.?\d+))(?:[eE][+-]?\d+)?/g;
while(match = regex.exec(str)) {
floats.push(parseFloat(match[0]));
}
return floats;
};
// extends RGBColor by rgba colors as RGBColor is not capable of it
var parseColor = function (colorString) {
var match = /\s*rgba\(((?:[^,\)]*,){3}[^,\)]*)\)\s*/.exec(colorString);
if (match) {
var floats = parseFloats(match[1]);
var color = new RGBColor("rgb(" + floats.slice(0,3).join(",") + ")");
color.a = floats[3];
return color;
} else {
return new RGBColor(colorString);
}
};
// multiplies a vector with a matrix: vec' = vec * matrix
var multVecMatrix = function (vec, matrix) {
var x = vec[0];
var y = vec[1];
return [
matrix.a * x + matrix.c * y + matrix.e,
matrix.b * x + matrix.d * y + matrix.f
];
};
// returns the untransformed bounding box [x, y, width, height] of an svg element (quite expensive for path and polygon objects, as
// the whole points/d-string has to be processed)
var getUntransformedBBox = function (node) {
var i, minX, minY, maxX, maxY, viewBox, vb, boundingBox;
var pf = parseFloat;
if (nodeIs(node, "polygon")) {
var points = parsePointsString(node.getAttribute("points"));
minX = Number.POSITIVE_INFINITY;
minY = Number.POSITIVE_INFINITY;
maxX = Number.NEGATIVE_INFINITY;
maxY = Number.NEGATIVE_INFINITY;
for (i = 0; i < points.length; i++) {
var point = points[i];
minX = Math.min(minX, point[0]);
maxX = Math.max(maxX, point[0]);
minY = Math.min(minY, point[1]);
maxY = Math.max(maxY, point[1]);
}
boundingBox = [
minX,
minY,
maxX - minX,
maxY - minY
];
} else if (nodeIs(node, "path")) {
var list = getPathSegList(node);
minX = Number.POSITIVE_INFINITY;
minY = Number.POSITIVE_INFINITY;
maxX = Number.NEGATIVE_INFINITY;
maxY = Number.NEGATIVE_INFINITY;
var x = 0, y = 0;
var prevX, prevY, newX, newY;
var p2, p3, to;
for (i = 0; i < list.numberOfItems; i++) {
var seg = list.getItem(i);
var cmd = seg.pathSegTypeAsLetter;
switch (cmd) {
case "H":
newX = seg.x;
newY = y;
break;
case "h":
newX = seg.x + x;
newY = y;
break;
case "V":
newX = x;
newY = seg.y;
break;
case "v":
newX = x;
newY = seg.y + y;
break;
case "C":
p2 = [seg.x1, seg.y1];
p3 = [seg.x2, seg.y2];
to = [seg.x, seg.y];
break;
case "c":
p2 = [seg.x1 + x, seg.y1 + y];
p3 = [seg.x2 + x, seg.y2 + y];
to = [seg.x + x, seg.y + y];
break;
case "S":
p2 = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
p3 = [seg.x2, seg.y2];
to = [seg.x, seg.y];
break;
case "s":
p2 = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
p3 = [seg.x2 + x, seg.y2 + y];
to = [seg.x + x, seg.y + y];
break;
case "Q":
pf = [seg.x1, seg.y1];
p2 = toCubic([x, y], pf);
p3 = toCubic([seg.x, seg.y], pf);
to = [seg.x, seg.y];
break;
case "q":
pf = [seg.x1 + x, seg.y1 + y];
p2 = toCubic([x, y], pf);
p3 = toCubic([x + seg.x, y + seg.y], pf);
to = [seg.x + x, seg.y + y];
break;
case "T":
p2 = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
p2 = toCubic([x, y], pf);
p3 = toCubic([seg.x, seg.y], pf);
to = [seg.x, seg.y];
break;
case "t":
pf = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
p2 = toCubic([x, y], pf);
p3 = toCubic([x + seg.x, y + seg.y], pf);
to = [seg.x + x, seg.y + y];
break;
// TODO: A,a
}
if ("sScCqQtT".indexOf(cmd) >= 0) {
prevX = x;
prevY = y;
}
if ("MLCSQT".indexOf(cmd) >= 0) {
x = seg.x;
y = seg.y;
} else if ("mlcsqt".indexOf(cmd) >= 0) {
x = seg.x + x;
y = seg.y + y;
} else if ("zZ".indexOf(cmd) < 0) {
x = newX;
y = newY;
}
if ("CSQTcsqt".indexOf(cmd) >= 0) {
minX = Math.min(minX, x, p2[0], p3[0], to[0]);
maxX = Math.max(maxX, x, p2[0], p3[0], to[0]);
minY = Math.min(minY, y, p2[1], p3[1], to[1]);
maxY = Math.max(maxY, y, p2[1], p3[1], to[1]);
} else {
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
minY = Math.min(minY, y);
maxY = Math.max(maxY, y);
}
}
boundingBox = [
minX,
minY,
maxX - minX,
maxY - minY
];
} else if (nodeIs(node, "svg")) {
viewBox = node.getAttribute("viewBox");
if (viewBox) {
vb = parseFloats(viewBox);
}
return [
pf(node.getAttribute("x")) || (vb && vb[0]) || 0,
pf(node.getAttribute("y")) || (vb && vb[1]) || 0,
pf(node.getAttribute("width")) || (vb && vb[2]) || 0,
pf(node.getAttribute("height")) || (vb && vb[3]) || 0
];
} else if (nodeIs(node, "g")) {
boundingBox = [0, 0, 0, 0];
forEachChild(node, function (i, node) {
var nodeBox = getUntransformedBBox(node);
boundingBox = [
Math.min(boundingBox[0], nodeBox[0]),
Math.min(boundingBox[1], nodeBox[1]),
Math.max(boundingBox[0] + boundingBox[2], nodeBox[0] + nodeBox[2]) - Math.min(boundingBox[0], nodeBox[0]),
Math.max(boundingBox[1] + boundingBox[3], nodeBox[1] + nodeBox[3]) - Math.min(boundingBox[1], nodeBox[1])
];
});
} else if (nodeIs(node, "marker")) {
viewBox = node.getAttribute("viewBox");
if (viewBox) {
vb = parseFloats(viewBox);
}
return [
(vb && vb[0]) || 0,
(vb && vb[1]) || 0,
(vb && vb[2]) || pf(node.getAttribute("marker-width")) || 0,
(vb && vb[3]) || pf(node.getAttribute("marker-height")) || 0
];
} else if (nodeIs(node, "pattern")) {
return [
pf(node.getAttribute("x")) || 0,
pf(node.getAttribute("y")) || 0,
pf(node.getAttribute("width")) || 0,
pf(node.getAttribute("height")) || 0
]
} else {
// TODO: check if there are other possible coordinate attributes
var x1 = pf(node.getAttribute("x1")) || pf(node.getAttribute("x")) || pf((node.getAttribute("cx")) - pf(node.getAttribute("r"))) || 0;
var x2 = pf(node.getAttribute("x2")) || (x1 + pf(node.getAttribute("width"))) || (pf(node.getAttribute("cx")) + pf(node.getAttribute("r"))) || 0;
var y1 = pf(node.getAttribute("y1")) || pf(node.getAttribute("y")) || (pf(node.getAttribute("cy")) - pf(node.getAttribute("r"))) || 0;
var y2 = pf(node.getAttribute("y2")) || (y1 + pf(node.getAttribute("height"))) || (pf(node.getAttribute("cy")) + pf(node.getAttribute("r"))) || 0;
boundingBox = [
Math.min(x1, x2),
Math.min(y1, y2),
Math.max(x1, x2) - Math.min(x1, x2),
Math.max(y1, y2) - Math.min(y1, y2)
];
}
if (!nodeIs(node, "marker,svg,g")) {
// add line-width
var lineWidth = getAttribute(node, "stroke-width") || 1;
var miterLimit = getAttribute(node, "stroke-miterlimit");
// miterLength / lineWidth = 1 / sin(phi / 2)
miterLimit && (lineWidth *= 0.5 / (Math.sin(Math.PI / 12)));
return [
boundingBox[0] - lineWidth,
boundingBox[1] - lineWidth,
boundingBox[2] + 2 * lineWidth,
boundingBox[3] + 2 * lineWidth
];
}
return boundingBox;
};
// transforms a bounding box and returns a new rect that contains it
var transformBBox = function (box, matrix) {
var bl = multVecMatrix([box[0], box[1]], matrix);
var br = multVecMatrix([box[0] + box[2], box[1]], matrix);
var tl = multVecMatrix([box[0], box[1] + box[3]], matrix);
var tr = multVecMatrix([box[0] + box[2], box[1] + box[3]], matrix);
var bottom = Math.min(bl[1], br[1], tl[1], tr[1]);
var left = Math.min(bl[0], br[0], tl[0], tr[0]);
var top = Math.max(bl[1], br[1], tl[1], tr[1]);
var right = Math.max(bl[0], br[0], tl[0], tr[0]);
return [
left,
bottom,
right - left,
top - bottom
]
};
// draws a polygon
var polygon = function (node, tfMatrix, colorMode, gradient, gradientMatrix) {
var points = parsePointsString(node.getAttribute("points"));
var lines = [{op: "m", c: multVecMatrix(points[0], tfMatrix)}];
for (var i = 1; i < points.length; i++) {
var p = points[i];
var to = multVecMatrix(p, tfMatrix);
lines.push({op: "l", c: to});
}
lines.push({op: "h"});
_pdf.path(lines, colorMode, gradient, gradientMatrix);
};
// draws an image (converts it to jpeg first, as jsPDF doesn't support png or other formats)
var image = function (node) {
// convert image to jpeg
var imageUrl = node.getAttribute("xlink:href") || node.getAttribute("href");
var image = new Image();
image.src = imageUrl;
var canvas = document.createElement("canvas");
var width = parseFloat(node.getAttribute("width")),
height = parseFloat(node.getAttribute("height")),
x = parseFloat(node.getAttribute("x") || 0),
y = parseFloat(node.getAttribute("y") || 0);
canvas.width = width;
canvas.height = height;
var context = canvas.getContext("2d");
context.fillStyle = "#fff";
context.fillRect(0, 0, width, height);
context.drawImage(image, 0, 0, width, height);
var jpegUrl = canvas.toDataURL("image/jpeg");
_pdf.addImage(jpegUrl,
"jpeg",
x,
y,
width,
height
);
};
// draws a path
var path = function (node, tfMatrix, svgIdPrefix, colorMode, gradient, gradientMatrix) {
var list = getPathSegList(node);
var markerEnd = node.getAttribute("marker-end"),
markerStart = node.getAttribute("marker-start"),
markerMid = node.getAttribute("marker-mid");
var getLinesFromPath = function (pathSegList, tfMatrix) {
var x = 0, y = 0;
var x0 = x, y0 = y;
var prevX, prevY, newX, newY;
var to, p, p2, p3;
var lines = [];
var markers = [];
var op;
var prevAngle = 0, curAngle;
var addMarker = function (angle, anchor, type) {
var cos = Math.cos(angle);
var sin = Math.sin(angle);
var tf;
tf = new _pdf.Matrix(cos, sin, -sin, cos, anchor[0], anchor[1]);
markers.push({type: type, tf: _pdf.matrixMult(tf, tfMatrix)});
};
for (var i = 0; i < list.numberOfItems; i++) {
var seg = list.getItem(i);
var cmd = seg.pathSegTypeAsLetter;
switch (cmd) {
case "M":
x0 = x;
y0 = y;
to = [seg.x, seg.y];
op = "m";
break;
case "m":
x0 = x;
y0 = y;
to = [seg.x + x, seg.y + y];
op = "m";
break;
case "L":
to = [seg.x, seg.y];
op = "l";
break;
case "l":
to = [seg.x + x, seg.y + y];
op = "l";
break;
case "H":
to = [seg.x, y];
op = "l";
newX = seg.x;
newY = y;
break;
case "h":
to = [seg.x + x, y];
op = "l";
newX = seg.x + x;
newY = y;
break;
case "V":
to = [x, seg.y];
op = "l";
newX = x;
newY = seg.y;
break;
case "v":
to = [x, seg.y + y];
op = "l";
newX = x;
newY = seg.y + y;
break;
case "C":
p2 = [seg.x1, seg.y1];
p3 = [seg.x2, seg.y2];
to = [seg.x, seg.y];
break;
case "c":
p2 = [seg.x1 + x, seg.y1 + y];
p3 = [seg.x2 + x, seg.y2 + y];
to = [seg.x + x, seg.y + y];
break;
case "S":
p2 = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
p3 = [seg.x2, seg.y2];
to = [seg.x, seg.y];
break;
case "s":
p2 = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
p3 = [seg.x2 + x, seg.y2 + y];
to = [seg.x + x, seg.y + y];
break;
case "Q":
p = [seg.x1, seg.y1];
p2 = toCubic([x, y], p);
p3 = toCubic([seg.x, seg.y], p);
to = [seg.x, seg.y];
break;
case "q":
p = [seg.x1 + x, seg.y1 + y];
p2 = toCubic([x, y], p);
p3 = toCubic([x + seg.x, y + seg.y], p);
to = [seg.x + x, seg.y + y];
break;
case "T":
p2 = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
p2 = toCubic([x, y], p);
p3 = toCubic([seg.x, seg.y], p);
to = [seg.x, seg.y];
break;
case "t":
p = getControlPointFromPrevious(i, [x, y], list, prevX, prevY);
p2 = toCubic([x, y], p);
p3 = toCubic([x + seg.x, y + seg.y], p);
to = [seg.x + x, seg.y + y];
break;
// TODO: A,a
case "Z":
case "z":
x = x0;
y = y0;
lines.push({op: "h"});
break;
}
var hasStartMarker = markerStart
&& (i === 1
|| ("mM".indexOf(cmd) < 0 && "mM".indexOf(list.getItem(i - 1).pathSegTypeAsLetter) >= 0));
var hasEndMarker = markerEnd
&& (i === list.numberOfItems - 1
|| ("mM".indexOf(cmd) < 0 && "mM".indexOf(list.getItem(i + 1).pathSegTypeAsLetter) >= 0));
var hasMidMarker = markerMid
&& i > 0
&& !(i === 1 && "mM".indexOf(list.getItem(i - 1).pathSegTypeAsLetter) >= 0);
if ("sScCqQtT".indexOf(cmd) >= 0) {
hasStartMarker && addMarker(getAngle([x, y], p2), [x, y], "start");
hasEndMarker && addMarker(getAngle(p3, to), to, "end");
if (hasMidMarker) {
curAngle = getAngle([x, y], p2);
curAngle = "mM".indexOf(list.getItem(i - 1).pathSegTypeAsLetter) >= 0 ?
curAngle : .5 * (prevAngle + curAngle);
addMarker(curAngle, [x, y], "mid");
}
prevAngle = getAngle(p3, to);
prevX = x;
prevY = y;
p2 = multVecMatrix(p2, tfMatrix);
p3 = multVecMatrix(p3, tfMatrix);
p = multVecMatrix(to, tfMatrix);
lines.push({
op: "c", c: [
p2[0], p2[1],
p3[0], p3[1],
p[0], p[1]
]
});
} else if ("lLhHvVmM".indexOf(cmd) >= 0) {
curAngle = getAngle([x, y], to);
hasStartMarker && addMarker(curAngle, [x, y], "start");
hasEndMarker && addMarker(curAngle, to, "end");
if (hasMidMarker) {
var angle = "mM".indexOf(cmd) >= 0 ?
prevAngle : "mM".indexOf(list.getItem(i - 1).pathSegTypeAsLetter) >= 0 ?
curAngle : .5 * (prevAngle + curAngle);
addMarker(angle, [x, y], "mid");
}
prevAngle = curAngle;
p = multVecMatrix(to, tfMatrix);
lines.push({op: op, c: p});
}
if ("MLCSQT".indexOf(cmd) >= 0) {
x = seg.x;
y = seg.y;
} else if ("mlcsqt".indexOf(cmd) >= 0) {
x = seg.x + x;
y = seg.y + y;
} else if ("zZ".indexOf(cmd) < 0) {
x = newX;
y = newY;
}
}
return {lines: lines, markers: markers};
};
var lines = getLinesFromPath(list, tfMatrix);
if (markerEnd || markerStart || markerMid) {
for (var i = 0; i < lines.markers.length; i++) {
var marker = lines.markers[i];
var markerElement;
switch (marker.type) {
case "start":
markerElement = svgIdPrefix.get() + iriReference.exec(markerStart)[1];
break;
case "end":
markerElement = svgIdPrefix.get() + iriReference.exec(markerEnd)[1];
break;
case "mid":
markerElement = svgIdPrefix.get() + iriReference.exec(markerMid)[1];
break;
}
_pdf.doFormObject(markerElement, marker.tf);
}
}
if (lines.lines.length > 0) {
_pdf.path(lines.lines, colorMode, gradient, gradientMatrix);
}
};
// draws the element referenced by a use node, makes use of pdf's XObjects/FormObjects so nodes are only written once
// to the pdf document. This highly reduces the file size and computation time.
var use = function (node, tfMatrix, svgIdPrefix) {
var url = (node.getAttribute("href") || node.getAttribute("xlink:href"));
// just in case someone has the idea to use empty use-tags, wtf???
if (!url)
return;
// get the size of the referenced form object (to apply the correct scaling)
var formObject = _pdf.getFormObject(svgIdPrefix.get() + url.substring(1));
// scale and position it right
var x = node.getAttribute("x") || 0;
var y = node.getAttribute("y") || 0;
var width = node.getAttribute("width") || formObject.width;
var height = node.getAttribute("height") || formObject.height;
var t = new _pdf.Matrix(width / formObject.width || 0, 0, 0, height / formObject.height || 0, x, y);
t = _pdf.matrixMult(t, tfMatrix);
_pdf.doFormObject(svgIdPrefix.get() + url.substring(1), t);
};
// draws a line
var line = function (node, tfMatrix) {
var p1 = multVecMatrix([parseFloat(node.getAttribute('x1')), parseFloat(node.getAttribute('y1'))], tfMatrix);
var p2 = multVecMatrix([parseFloat(node.getAttribute('x2')), parseFloat(node.getAttribute('y2'))], tfMatrix);
_pdf.line(p1[0], p1[1], p2[0], p2[1]);
};
// draws a rect
var rect = function (node, colorMode, gradient, gradientMatrix) {
_pdf.roundedRect(
parseFloat(node.getAttribute('x')) || 0,
parseFloat(node.getAttribute('y')) || 0,
parseFloat(node.getAttribute('width')),
parseFloat(node.getAttribute('height')),
parseFloat(node.getAttribute('rx')) || 0,
parseFloat(node.getAttribute('ry')) || 0,
colorMode,
gradient,
gradientMatrix
);
};
// draws an ellipse
var ellipse = function (node, colorMode, gradient, gradientMatrix) {
_pdf.ellipse(
parseFloat(node.getAttribute('cx')) || 0,
parseFloat(node.getAttribute('cy')) || 0,
parseFloat(node.getAttribute('rx')),
parseFloat(node.getAttribute('ry')),
colorMode,
gradient,
gradientMatrix
);
};
// draws a circle
var circle = function (node, colorMode, gradient, gradientMatrix) {
var radius = parseFloat(node.getAttribute('r')) || 0;
_pdf.ellipse(
parseFloat(node.getAttribute('cx')) || 0,
parseFloat(node.getAttribute('cy')) || 0,
radius,
radius,
colorMode,
gradient,
gradientMatrix
);
};
// applies text transformations to a text node
var transformText = function (node, text) {
var textTransform = getAttribute(node, "text-transform");
switch (textTransform) {
case "uppercase": return text.toUpperCase();
case "lowercase": return text.toLowerCase();
default: return text;
// TODO: capitalize, full-width
}
};
// draws a text element and its tspan children
var text = function (node, tfMatrix, hasFillColor, fillRGB) {
_pdf.saveGraphicsState();
setTextProperties(node, fillRGB);
var getTextOffset = function (textAnchor, width) {
var xOffset = 0;
switch (textAnchor) {
case 'end':
xOffset = width;
break;
case 'middle':
xOffset = width / 2;
break;
case 'start':
break;
}
return xOffset;
};
/**
* Convert em, px and bare number attributes to pixel values
*/
var toPixels = function (value, pdfFontSize) {
var match;
// em
match = value && value.toString().match(/^([\-0-9.]+)em$/);
if (match) {
return parseFloat(match[1]) * pdfFontSize;
}
// pixels
match = value && value.toString().match(/^([\-0-9.]+)(px|)$/);
if (match) {
return parseFloat(match[1]);
}
return 0;
};
// creates an svg element and append the text node to properly measure the text size
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.appendChild(node);
svg.setAttribute("visibility", "hidden");
document.body.appendChild(svg);
var box = node.getBBox();
var x, y, xOffset = 0;
var textAnchor = getAttribute(node, "text-anchor");
if (textAnchor) {
xOffset = getTextOffset(textAnchor, box.width);
}
var pdfFontSize = _pdf.getFontSize();
var textX = toPixels(node.getAttribute('x'), pdfFontSize);
var textY = toPixels(node.getAttribute('y'), pdfFontSize);
var m = _pdf.matrixMult(new _pdf.Matrix(1, 0, 0, 1, textX, textY), tfMatrix);
x = toPixels(node.getAttribute("dx"), pdfFontSize);
y = toPixels(node.getAttribute("dy"), pdfFontSize);
// when there are no tspans draw the text directly
if (node.childElementCount === 0) {
_pdf.text(
(x - xOffset),
y,
transformText(node, removeNewlinesAndTrim(node.textContent)),
void 0,
m
);
} else {
// otherwise loop over tspans and position each relative to the previous one
forEachChild(node, function (i, tSpan) {
if (!tSpan.textContent || nodeIs(tSpan, 'title,desc,metadata')) {
return;
}
_pdf.saveGraphicsState();
var tSpanColor = getAttribute(tSpan, "fill");
setTextProperties(tSpan, tSpanColor && new RGBColor(tSpanColor));
var extent = tSpan.getExtentOfChar(0);
_pdf.text(
extent.x - textX,//x - xOffset,
extent.y + extent.height * 0.7 - textY, // 0.7 roughly mimicks the text baseline
transformText(node, removeNewlinesAndTrim(tSpan.textContent)),
void 0,
m
);
_pdf.restoreGraphicsState();
});
}
document.body.removeChild(svg);
_pdf.restoreGraphicsState();
};
// As defs elements are allowed to appear after they are referenced, we search for them first
var findAndRenderDefs = function (node, tfMatrix, defs, svgIdPrefix, withinDefs) {
forEachChild(node, function (i, child) {
if (child.tagName.toLowerCase() === "defs") {
renderNode(child, tfMatrix, defs, svgIdPrefix, withinDefs);
// prevent defs from being evaluated twice // TODO: make this better
child.parentNode.removeChild(child);
}
});
};
// processes a svg node
var svg = function (node, tfMatrix, defs, svgIdPrefix, withinDefs) {
// create a new prefix and clone the defs, as defs within the svg should not be visible outside
var newSvgIdPrefix = svgIdPrefix.nextChild();
var newDefs = cloneDefs(defs);
findAndRenderDefs(node, tfMatrix, newDefs, newSvgIdPrefix, withinDefs);
renderChildren(node, tfMatrix, newDefs, newSvgIdPrefix, withinDefs);
};
// renders all children of a node
var renderChildren = function (node, tfMatrix, defs, svgIdPrefix, withinDefs) {
forEachChild(node, function (i, node) {
renderNode(node, tfMatrix, defs, svgIdPrefix, withinDefs);
});
};
// adds a gradient to defs and the pdf document for later use, type is either "axial" or "radial"
// opacity is only supported rudimentary by averaging over all stops
// transforms are applied on use
var putGradient = function (node, type, coords, defs, svgIdPrefix) {
var colors = [];
var opacitySum = 0;
var hasOpacity = false;
var gState;
forEachChild(node, function (i, element) {
// since opacity gradients are hard to realize, average the opacity over the control points
if (element.tagName.toLowerCase() === "stop") {
var color = new RGBColor(getAttribute(element, "stop-color"));
colors.push({
offset: parseFloat(element.getAttribute("offset")),
color: [color.r, color.g, color.b]
});
var opacity = getAttribute(element, "stop-opacity");
if (opacity && opacity != 1) {
opacitySum += parseFloat(opacity);
hasOpacity = true;
}
}
});
if (hasOpacity) {
gState = new _pdf.GState({opacity: opacitySum / coords.length});
}
var pattern = new _pdf.ShadingPattern(type, coords, colors, gState);
var id = svgIdPrefix.get() + node.getAttribute("id");
_pdf.addShadingPattern(id, pattern);
defs[id] = node;
};
var pattern = function (node, defs, svgIdPrefix) {
var id = svgIdPrefix.get() + node.getAttribute("id");
defs[id] = node;
// the transformations directly at the node are written to the pattern transformation matrix
var bBox = getUntransformedBBox(node);
var pattern = new _pdf.TilingPattern([bBox[0], bBox[1], bBox[0] + bBox[2], bBox[1] + bBox[3]], bBox[2], bBox[3],
null, computeNodeTransform(node));
_pdf.beginTilingPattern(pattern);
// continue without transformation
renderChildren(node, _pdf.unitMatrix, defs, svgIdPrefix, false);
_pdf.endTilingPattern(id, pattern);
};
function setTextProperties(node, fillRGB) {
var fontFamily = getAttribute(node, "font-family");
if (fontFamily) {
_pdf.setFont(fontFamily);
}
if (fillRGB && fillRGB.ok) {
_pdf.setTextColor(fillRGB.r, fillRGB.g, fillRGB.b);
}
var fontType;
var fontWeight = getAttribute(node, "font-weight");
if (fontWeight) {
if (fontWeight === "bold") {
fontType = "bold";
}
}
var fontStyle = getAttribute(node, "font-style");
if (fontStyle) {
if (fontStyle === "italic") {
fontType += "italic";
}
}
_pdf.setFontType(fontType);
var pdfFontSize = 16;
var fontSize = getAttribute(node, "font-size");
if (fontSize) {
pdfFontSize = parseFloat(fontSize);
_pdf.setFontSize(pdfFontSize);
}
}
/**
* Renders a svg node.
* @param node The svg element
* @param contextTransform The current transformation matrix
* @param defs The defs map holding all svg nodes that can be referenced
* @param svgIdPrefix The current id prefix
* @param withinDefs True iff we are top-level within a defs node, so the target can be switched to an pdf form object
*/
var renderNode = function (node, contextTransform, defs, svgIdPrefix, withinDefs) {
var tfMatrix,
hasFillColor = false,
fillRGB = null,
colorMode = null,
fillUrl = null,
fillData = null,
bBox;
//
// Decide about the render target and set the correct transformation
//
// if we are within a defs node, start a new pdf form object and draw this node and all children on that instead
// of the top-level page
var targetIsFormObject = withinDefs && !nodeIs(node, "lineargradient,radialgradient,pattern");
if (targetIsFormObject) {
// the transformations directly at the node are written to the pdf form object transformation matrix
tfMatrix = computeNodeTransform(node);
bBox = getUntransformedBBox(node);
_pdf.beginFormObject(bBox[0], bBox[1], bBox[2], bBox[3], tfMatrix);
// continue without transformation and set withinDefs to false to prevent child nodes from starting new form objects
tfMatrix = _pdf.unitMatrix;
withinDefs = false;
} else {
tfMatrix = _pdf.matrixMult(computeNodeTransform(node), contextTransform);
_pdf.saveGraphicsState();
}
//
// extract fill and stroke mode
//
// fill mode
if (nodeIs(node, "g,path,rect,text,ellipse,line,circle,polygon")) {
function setDefaultColor() {
fillRGB = new RGBColor("rgb(0, 0, 0)");
hasFillColor = true;
colorMode = "F";
}
var fillColor = getAttribute(node, "fill");
if (fillColor) {
var url = iriReference.exec(fillColor);
if (url) {
// probably a gradient (or something unsupported)
fillUrl = svgIdPrefix.get() + url[1];
var fill = getFromDefs(fillUrl, defs);
if (fill && nodeIs(fill, "lineargradient,radialgradient")) {
// matrix to convert between gradient space and user space
// for "userSpaceOnUse" this is the current transformation: tfMatrix
// for "objectBoundingBox" or default, the gradient gets scaled and transformed to the bounding box
var gradientUnitsMatrix = tfMatrix;
if (!fill.hasAttribute("gradientUnits")
|| fill.getAttribute("gradientUnits").toLowerCase() === "objectboundingbox") {
bBox || (bBox = getUntransformedBBox(node));
gradientUnitsMatrix = new _pdf.Matrix(bBox[2], 0, 0, bBox[3], bBox[0], bBox[1]);
var nodeTransform = computeNodeTransform(node);
gradientUnitsMatrix = _pdf.matrixMult(gradientUnitsMatrix, nodeTransform);
}
// matrix that is applied to the gradient before any other transformations
var gradientTransform = parseTransform(fill.getAttribute("gradientTransform"));
fillData = _pdf.matrixMult(gradientTransform, gradientUnitsMatrix);
} else if (fill && nodeIs(fill, "pattern")) {
var fillBBox, y, width, height, x;
fillData = {};
var patternUnitsMatrix = _pdf.unitMatrix;
if (!fill.hasAttribute("patternUnits")
|| fill.getAttribute("patternUnits").toLowerCase() === "objectboundingbox") {
bBox || (bBox = getUntransformedBBox(node));
patternUnitsMatrix = new _pdf.Matrix(1, 0, 0, 1, bBox[0], bBox[1]);
// TODO: slightly inaccurate (rounding errors? line width bBoxes?)
fillBBox = getUntransformedBBox(fill);
x = fillBBox[0] * bBox[0];
y = fillBBox[1] * bBox[1];
width = fillBBox[2] * bBox[2];
height = fillBBox[3] * bBox[3];
fillData.boundingBox = [x, y, x + width, y + height];
fillData.xStep = width;
fillData.yStep = height;
}
var patternContentUnitsMatrix = _pdf.unitMatrix;
if (fill.hasAttribute("patternContentUnits")
&& fill.getAttribute("patternContentUnits").toLowerCase() === "objectboundingbox") {
bBox || (bBox = getUntransformedBBox(node));
patternContentUnitsMatrix = new _pdf.Matrix(bBox[2], 0, 0, bBox[3], 0, 0);
fillBBox = fillData.boundingBox || getUntransformedBBox(fill);
x = fillBBox[0] / bBox[0];
y = fillBBox[1] / bBox[1];
width = fillBBox[2] / bBox[2];
height = fillBBox[3] / bBox[3];
fillData.boundingBox = [x, y, x + width, y + height];
fillData.xStep = width;
fillData.yStep = height;
}
fillData.matrix = _pdf.matrixMult(
_pdf.matrixMult(patternContentUnitsMatrix, patternUnitsMatrix), tfMatrix);
colorMode = "F";
} else {
// unsupported fill argument (e.g. patterns) -> fill black
fillUrl = fill = null;
setDefaultColor();
}
} else {
// plain color
fillRGB = parseColor(fillColor);
if (fillRGB.ok) {
hasFillColor = true;
colorMode = 'F';
} else {
colorMode = null;
}
}
} else {
// if no fill attribute is provided the default fill color is black
setDefaultColor();
}
// opacity is realized via a pdf graphics state
var opacity = 1.0;
var nodeOpacity = node.getAttribute("opacity") || node.getAttribute("fill-opacity");
if (nodeOpacity) {
opacity *= parseFloat(nodeOpacity);
}
if (fillRGB && typeof fillRGB.a === "number") {
opacity *= fillRGB.a;
}
_pdf.setGState(new _pdf.GState({opacity: opacity}));
}
if (nodeIs(node, "g,path,rect,ellipse,line,circle,polygon")) {
// text has no fill color, so don't apply it until here
if (hasFillColor) {
_pdf.setFillColor(fillRGB.r, fillRGB.g, fillRGB.b);
}
// stroke mode
var strokeColor = node.getAttribute('stroke');
if (strokeColor) {
var strokeWidth;
if (node.hasAttribute("stroke-width")) {
strokeWidth = Math.abs(parseFloat(node.getAttribute('stroke-width')));
_pdf.setLineWidth(strokeWidth);
}
var strokeRGB = new RGBColor(strokeColor);
if (strokeRGB.ok) {
_pdf.setDrawColor(strokeRGB.r, strokeRGB.g, strokeRGB.b);
if (strokeWidth !== 0) {
// pdf spec states: "A line width of 0 denotes the thinnest line that can be rendered at device resolution:
// 1 device pixel wide". SVG, however, does not draw zero width lines.
colorMode = (colorMode || "") + "D";
}
}
if (node.hasAttribute("stroke-linecap")) {
_pdf.setLineCap(node.getAttribute("stroke-linecap"));
}
if (node.hasAttribute("stroke-linejoin")) {
_pdf.setLineJoin(node.getAttribute("stroke-linejoin"));
}
if (node.hasAttribute("stroke-dasharray")) {
_pdf.setLineDashPattern(
parseFloats(node.getAttribute("stroke-dasharray")),
parseInt(node.getAttribute("stroke-dashoffset")) || 0
);
}
if (node.hasAttribute("stroke-miterlimit")) {
_pdf.setLineMiterLimit(parseFloat(node.getAttribute("stroke-miterlimit")));
}
}
}
setTextProperties(node, fillRGB);
// do the actual drawing
switch (node.tagName.toLowerCase()) {
case 'svg':
svg(node, tfMatrix, defs, svgIdPrefix, withinDefs);
break;
case 'g':
findAndRenderDefs(node, tfMatrix, defs, svgIdPrefix, withinDefs);
case 'a':
case "marker":
renderChildren(node, tfMatrix, defs, svgIdPrefix, withinDefs);
break;
case 'defs':
renderChildren(node, tfMatrix, defs, svgIdPrefix, true);
break;
case 'use':
use(node, tfMatrix, svgIdPrefix);
break;
case 'line':
line(node, tfMatrix);
break;
case 'rect':
_pdf.setCurrentTransformationMatrix(tfMatrix);
rect(node, colorMode, fillUrl, fillData);
break;
case 'ellipse':
_pdf.setCurrentTransformationMatrix(tfMatrix);
ellipse(node, colorMode, fillUrl, fillData);
break;
case 'circle':
_pdf.setCurrentTransformationMatrix(tfMatrix);
circle(node, colorMode, fillUrl, fillData);
break;
case 'text':
text(node, tfMatrix, hasFillColor, fillRGB);
break;
case 'path':
path(node, tfMatrix, svgIdPrefix, colorMode, fillUrl, fillData);
break;
case 'polygon':
polygon(node, tfMatrix, colorMode, fillUrl, fillData);
break;
case 'image':
_pdf.setCurrentTransformationMatrix(tfMatrix);
image(node);
break;
case "lineargradient":
putGradient(node, "axial", [
node.getAttribute("x1"),
node.getAttribute("y1"),
node.getAttribute("x2"),
node.getAttribute("y2")
], defs, svgIdPrefix);
break;
case "radialgradient":
putGradient(node, "radial", [
node.getAttribute("fx") || node.getAttribute("cx"),
node.getAttribute("fy") || node.getAttribute("cy"),
0,
node.getAttribute("cx") || 0,
node.getAttribute("cy") || 0,
node.getAttribute("r") || 0
], defs, svgIdPrefix);
break;
case "pattern":
pattern(node, defs, svgIdPrefix);
break;
}
// close either the formObject or the graphics context
if (targetIsFormObject) {
_pdf.endFormObject(svgIdPrefix.get() + node.getAttribute("id"));
} else {
_pdf.restoreGraphicsState();
}
};
// the actual svgToPdf function (see above)
var svg2pdf = function (element, pdf, options) {
_pdf = pdf;
var k = options.scale || 1.0,
xOffset = options.xOffset || 0.0,
yOffset = options.yOffset || 0.0;
// set offsets and scale everything by k
_pdf.saveGraphicsState();
_pdf.setCurrentTransformationMatrix(new _pdf.Matrix(k, 0, 0, k, xOffset, yOffset));
renderNode(element.cloneNode(true), _pdf.unitMatrix, {}, new SvgPrefix(""), false);
_pdf.restoreGraphicsState();
return _pdf;
};
Iif (typeof define === "function" && define.amd) {
define(["./rgbcolor", "SvgPath"], function (rgbcolor, svgpath) {
RGBColor = rgbcolor;
SvgPath = svgpath;
return svg2pdf;
});
} else Eif (typeof module !== "undefined" && module.exports) {
RGBColor = require("./rgbcolor.js");
SvgPath = require("SvgPath");
module.exports = svg2pdf;
} else {
SvgPath = global.SvgPath;
RGBColor = global.RGBColor;
global.svg2pdf = svg2pdf;
// for compatibility reasons
global.svgElementToPdf = svg2pdf;
}
return svg2pdf;
}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this));
},{"./rgbcolor.js":8,"SvgPath":1}]},{},[9])(9)
});
//# sourceMappingURL=svg2pdf.js.map
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| accessibility.js | 2.66% | (8 / 301) | 0.63% | (3 / 475) | 1.28% | (1 / 78) | 8.82% | (3 / 34) | |
| accessibility.src.js | 2.17% | (9 / 415) | 0.6% | (3 / 497) | 1.28% | (1 / 78) | 2.17% | (9 / 415) | |
| annotations.js | 2.53% | (2 / 79) | 3.26% | (3 / 92) | 6.25% | (1 / 16) | 14.29% | (1 / 7) | |
| annotations.src.js | 3.68% | (5 / 136) | 3.13% | (3 / 96) | 5.56% | (1 / 18) | 3.68% | (5 / 136) | |
| boost-canvas.js | 3.42% | (4 / 117) | 1.34% | (3 / 224) | 2.86% | (1 / 35) | 8.33% | (1 / 12) | |
| boost-canvas.src.js | 2.9% | (7 / 241) | 1.25% | (3 / 240) | 2.86% | (1 / 35) | 2.9% | (7 / 241) | |
| boost.js | 8.55% | (30 / 351) | 0.55% | (3 / 549) | 1.03% | (1 / 97) | 33.33% | (12 / 36) | |
| boost.src.js | 8.74% | (65 / 744) | 0.51% | (3 / 587) | 1.02% | (1 / 98) | 8.74% | (65 / 744) | |
| broken-axis.js | 3.85% | (4 / 104) | 2.54% | (3 / 118) | 5.26% | (1 / 19) | 14.29% | (1 / 7) | |
| broken-axis.src.js | 3.29% | (5 / 152) | 2.44% | (3 / 123) | 5.26% | (1 / 19) | 3.29% | (5 / 152) | |
| canvas-tools.js | 0.31% | (4 / 1307) | 0% | (0 / 817) | 0% | (0 / 240) | 3.67% | (4 / 109) | |
| canvas-tools.src.js | 0.49% | (9 / 1849) | 0% | (0 / 860) | 0% | (0 / 246) | 0.54% | (9 / 1675) | |
| data.js | 1.09% | (2 / 183) | 1.06% | (3 / 284) | 2.22% | (1 / 45) | 5.56% | (1 / 18) | |
| data.src.js | 0.93% | (3 / 321) | 1% | (3 / 299) | 2.17% | (1 / 46) | 0.93% | (3 / 321) | |
| drilldown.js | 1.86% | (3 / 161) | 1.42% | (3 / 211) | 2.27% | (1 / 44) | 5.56% | (1 / 18) | |
| drilldown.src.js | 1.48% | (4 / 270) | 1.29% | (3 / 233) | 2.17% | (1 / 46) | 1.48% | (4 / 270) | |
| exporting.js | 1.29% | (2 / 155) | 2.24% | (3 / 134) | 2.17% | (1 / 46) | 5.26% | (1 / 19) | |
| exporting.src.js | 1.79% | (4 / 223) | 2.21% | (3 / 136) | 2.13% | (1 / 47) | 1.79% | (4 / 223) | |
| funnel.js | 4.17% | (2 / 48) | 7.5% | (3 / 40) | 8.33% | (1 / 12) | 25% | (1 / 4) | |
| funnel.src.js | 4.29% | (3 / 70) | 7.14% | (3 / 42) | 8.33% | (1 / 12) | 4.29% | (3 / 70) | |
| gantt.js | 2.46% | (3 / 122) | 1.76% | (3 / 170) | 3.03% | (1 / 33) | 13.33% | (2 / 15) | |
| gantt.src.js | 1.69% | (4 / 236) | 1.69% | (3 / 178) | 2.94% | (1 / 34) | 1.69% | (4 / 236) | |
| grid-axis.js | 2.86% | (2 / 70) | 2.65% | (3 / 113) | 5% | (1 / 20) | 11.11% | (1 / 9) | |
| grid-axis.src.js | 1.95% | (3 / 154) | 2.5% | (3 / 120) | 5% | (1 / 20) | 1.95% | (3 / 154) | |
| heatmap.js | 1.32% | (2 / 152) | 1.74% | (3 / 172) | 2% | (1 / 50) | 5.56% | (1 / 18) | |
| heatmap.src.js | 1.29% | (3 / 233) | 1.7% | (3 / 176) | 2% | (1 / 50) | 1.29% | (3 / 233) | |
| map.js | 1.18% | (6 / 508) | 0.46% | (3 / 657) | 0.68% | (1 / 148) | 6.56% | (4 / 61) | |
| map.src.js | 0.83% | (7 / 842) | 0.44% | (3 / 687) | 0.68% | (1 / 148) | 0.83% | (7 / 842) | |
| no-data-to-display.js | 13.33% | (4 / 30) | 14.29% | (3 / 21) | 9.09% | (1 / 11) | 33.33% | (1 / 3) | |
| no-data-to-display.src.js | 12.2% | (5 / 41) | 14.29% | (3 / 21) | 9.09% | (1 / 11) | 12.2% | (5 / 41) | |
| offline-exporting.js | 3.55% | (5 / 141) | 2.86% | (3 / 105) | 2.56% | (1 / 39) | 18.18% | (2 / 11) | |
| offline-exporting.src.js | 3.16% | (6 / 190) | 2.83% | (3 / 106) | 2.5% | (1 / 40) | 3.16% | (6 / 190) | |
| overlapping-datalabels.js | 9.68% | (3 / 31) | 6% | (3 / 50) | 7.69% | (1 / 13) | 33.33% | (1 / 3) | |
| overlapping-datalabels.src.js | 7.27% | (4 / 55) | 5.66% | (3 / 53) | 7.69% | (1 / 13) | 7.27% | (4 / 55) | |
| series-label.js | 6.86% | (7 / 102) | 1.94% | (3 / 155) | 5.56% | (1 / 18) | 16.67% | (2 / 12) | |
| series-label.src.js | 5.81% | (10 / 172) | 1.9% | (3 / 158) | 5% | (1 / 20) | 5.81% | (10 / 172) | |
| solid-gauge.js | 3.28% | (2 / 61) | 3.85% | (3 / 78) | 6.25% | (1 / 16) | 14.29% | (1 / 7) | |
| solid-gauge.src.js | 2.91% | (3 / 103) | 3.8% | (3 / 79) | 6.25% | (1 / 16) | 2.91% | (3 / 103) | |
| static-scale.js | 20% | (2 / 10) | 25% | (3 / 12) | 20% | (1 / 5) | 50% | (1 / 2) | |
| static-scale.src.js | 16.67% | (3 / 18) | 23.08% | (3 / 13) | 20% | (1 / 5) | 16.67% | (3 / 18) | |
| stock.js | 0.86% | (9 / 1044) | 0.2% | (3 / 1512) | 0.41% | (1 / 244) | 7.02% | (8 / 114) | |
| stock.src.js | 0.62% | (11 / 1767) | 0.19% | (3 / 1590) | 0.41% | (1 / 246) | 0.62% | (11 / 1767) | |
| treemap.js | 0.93% | (2 / 215) | 1.32% | (3 / 227) | 1.45% | (1 / 69) | 4.35% | (1 / 23) | |
| treemap.src.js | 0.86% | (3 / 350) | 1.29% | (3 / 233) | 1.45% | (1 / 69) | 0.86% | (3 / 350) | |
| xrange-series.js | 5.56% | (3 / 54) | 4.92% | (3 / 61) | 6.67% | (1 / 15) | 33.33% | (2 / 6) | |
| xrange-series.src.js | 4.71% | (4 / 85) | 4.84% | (3 / 62) | 6.67% | (1 / 15) | 4.71% | (4 / 85) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 1 1 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Accessibility module
(c) 2010-2017 Highsoft AS
Author: Oystein Moseng
License: www.highcharts.com/license
*/
(function(q){"object"===typeof module&&module.exports?module.exports=q:q(Highcharts)})(function(q){(function(e){function q(a){return a.replace(/&/g,"\x26amp;").replace(/</g,"\x26lt;").replace(/>/g,"\x26gt;").replace(/"/g,"\x26quot;").replace(/'/g,"\x26#x27;").replace(/\//g,"\x26#x2F;")}function z(a){for(var c=a.childNodes.length;c--;)a.appendChild(a.childNodes[c])}function l(a){var c;a&&a.onclick&&k.createEvent&&(c=k.createEvent("Events"),c.initEvent("click",!0,!1),a.onclick(c))}var y=e.win,k=y.document,
g=e.each,A=e.erase,v=e.addEvent,B=e.removeEvent,x=e.fireEvent,C=e.dateFormat,w=e.merge,r={"default":["series","data point","data points"],line:["line","data point","data points"],spline:["line","data point","data points"],area:["line","data point","data points"],areaspline:["line","data point","data points"],pie:["pie","slice","slices"],column:["column series","column","columns"],bar:["bar series","bar","bars"],scatter:["scatter series","data point","data points"],boxplot:["boxplot series","box",
"boxes"],arearange:["arearange series","data point","data points"],areasplinerange:["areasplinerange series","data point","data points"],bubble:["bubble series","bubble","bubbles"],columnrange:["columnrange series","column","columns"],errorbar:["errorbar series","errorbar","errorbars"],funnel:["funnel","data point","data points"],pyramid:["pyramid","data point","data points"],waterfall:["waterfall series","column","columns"],map:["map","area","areas"],mapline:["line","data point","data points"],mappoint:["point series",
"data point","data points"],mapbubble:["bubble series","bubble","bubbles"]},D={boxplot:" Box plot charts are typically used to display groups of statistical data. Each data point in the chart can have up to 5 values: minimum, lower quartile, median, upper quartile and maximum. ",arearange:" Arearange charts are line charts displaying a range between a lower and higher value for each point. ",areasplinerange:" These charts are line charts displaying a range between a lower and higher value for each point. ",
bubble:" Bubble charts are scatter charts where each data point also has a size value. ",columnrange:" Columnrange charts are column charts displaying a range between a lower and higher value for each point. ",errorbar:" Errorbar series are used to display the variability of the data. ",funnel:" Funnel charts are used to display reduction of data in stages. ",pyramid:" Pyramid charts consist of a single pyramid with item heights corresponding to each point value. ",waterfall:" A waterfall chart is a column chart where each column contributes towards a total end value. "};
e.Series.prototype.commonKeys="name id category x value y".split(" ");e.Series.prototype.specialKeys="z open high q3 median q1 low close".split(" ");e.seriesTypes.pie&&(e.seriesTypes.pie.prototype.specialKeys=[]);e.setOptions({accessibility:{enabled:!0,pointDescriptionThreshold:30,keyboardNavigation:{enabled:!0}}});e.wrap(e.Series.prototype,"render",function(a){a.apply(this,Array.prototype.slice.call(arguments,1));this.chart.options.accessibility.enabled&&this.setA11yDescription()});e.Series.prototype.setA11yDescription=
function(){var a=this.chart.options.accessibility,c=this.points&&this.points.length&&this.points[0].graphic&&this.points[0].graphic.element,d=c&&c.parentNode||this.graph&&this.graph.element||this.group&&this.group.element;d&&(d.lastChild===c&&z(d),this.points&&(this.points.length<a.pointDescriptionThreshold||!1===a.pointDescriptionThreshold)&&g(this.points,function(b){b.graphic&&(b.graphic.element.setAttribute("role","img"),b.graphic.element.setAttribute("tabindex","-1"),b.graphic.element.setAttribute("aria-label",
a.pointDescriptionFormatter&&a.pointDescriptionFormatter(b)||b.buildPointInfoString()))}),1<this.chart.series.length||a.describeSingleSeries)&&(d.setAttribute("role","region"),d.setAttribute("tabindex","-1"),d.setAttribute("aria-label",a.seriesDescriptionFormatter&&a.seriesDescriptionFormatter(this)||this.buildSeriesInfoString()))};e.Series.prototype.buildSeriesInfoString=function(){var a=r[this.type]||r["default"],c=this.description||this.options.description;return(this.name?this.name+", ":"")+(1===
this.chart.types.length?a[0]:"series")+" "+(this.index+1)+" of "+this.chart.series.length+(1===this.chart.types.length?" with ":". "+a[0]+" with ")+(this.points.length+" "+(1===this.points.length?a[1]:a[2]))+(c?". "+c:"")+(1<this.chart.yAxis.length&&this.yAxis?". Y axis, "+this.yAxis.getDescription():"")+(1<this.chart.xAxis.length&&this.xAxis?". X axis, "+this.xAxis.getDescription():"")};e.Point.prototype.buildPointInfoString=function(){var a=this,c=a.series,d=c.chart.options.accessibility,b="",f=
c.xAxis&&c.xAxis.isDatetimeAxis,d=f&&C(d.pointDateFormatter&&d.pointDateFormatter(a)||d.pointDateFormat||e.Tooltip.prototype.getXDateFormat(a,c.chart.options.tooltip,c.xAxis),a.x);e.find(c.specialKeys,function(b){return void 0!==a[b]})?(f&&(b=d),g(c.commonKeys.concat(c.specialKeys),function(c){void 0===a[c]||f&&"x"===c||(b+=(b?". ":"")+c+", "+a[c])})):b=(this.name||d||this.category||this.id||"x, "+this.x)+", "+(void 0!==this.value?this.value:this.y);return this.index+1+". "+b+"."+(this.description?
" "+this.description:"")};e.Axis.prototype.getDescription=function(){return this.userOptions&&this.userOptions.description||this.axisTitle&&this.axisTitle.textStr||this.options.id||this.categories&&"categories"||"values"};e.Axis.prototype.panStep=function(a,c){var d=c||3;c=this.getExtremes();var b=(c.max-c.min)/d*a,d=c.max+b,b=c.min+b,f=d-b;0>a&&b<c.dataMin?(b=c.dataMin,d=b+f):0<a&&d>c.dataMax&&(d=c.dataMax,b=d-f);this.setExtremes(b,d)};e.wrap(e.Series.prototype,"init",function(a){a.apply(this,Array.prototype.slice.call(arguments,
1));var c=this.chart;c.options.accessibility.enabled&&(c.types=c.types||[],0>c.types.indexOf(this.type)&&c.types.push(this.type),v(this,"remove",function(){var a=this,b=!1;g(c.series,function(f){f!==a&&0>c.types.indexOf(a.type)&&(b=!0)});b||A(c.types,a.type)}))});e.Chart.prototype.getTypeDescription=function(){var a=this.types&&this.types[0],c=this.series[0]&&this.series[0].mapTitle;if(a){if("map"===a)return c?"Map of "+c:"Map of unspecified region.";if(1<this.types.length)return"Combination chart.";
if(-1<["spline","area","areaspline"].indexOf(a))return"Line chart."}else return"Empty chart.";return a+" chart."+(D[a]||"")};e.Chart.prototype.getAxesDescription=function(){var a=this.xAxis.length,c=this.yAxis.length,d={},b;if(a)if(d.xAxis="The chart has "+a+(1<a?" X axes":" X axis")+" displaying ",2>a)d.xAxis+=this.xAxis[0].getDescription()+".";else{for(b=0;b<a-1;++b)d.xAxis+=(b?", ":"")+this.xAxis[b].getDescription();d.xAxis+=" and "+this.xAxis[b].getDescription()+"."}if(c)if(d.yAxis="The chart has "+
c+(1<c?" Y axes":" Y axis")+" displaying ",2>c)d.yAxis+=this.yAxis[0].getDescription()+".";else{for(b=0;b<c-1;++b)d.yAxis+=(b?", ":"")+this.yAxis[b].getDescription();d.yAxis+=" and "+this.yAxis[b].getDescription()+"."}return d};e.Chart.prototype.addAccessibleContextMenuAttribs=function(){var a=this.exportDivElements;a&&(g(a,function(a){"DIV"!==a.tagName||a.children&&a.children.length||(a.setAttribute("role","menuitem"),a.setAttribute("tabindex",-1))}),a[0].parentNode.setAttribute("role","menu"),a[0].parentNode.setAttribute("aria-label",
"Chart export"))};e.Point.prototype.highlight=function(){var a=this.series.chart;this.graphic&&this.graphic.element.focus&&this.graphic.element.focus();this.isNull?a.tooltip&&a.tooltip.hide(0):(this.onMouseOver(),a.tooltip&&a.tooltip.refresh(a.tooltip.shared?[this]:this));a.highlightedPoint=this;return this};e.Chart.prototype.highlightAdjacentPoint=function(a){var c=this.series,d=this.highlightedPoint,b=d&&d.index||0,f=d&&d.series.points,E=d&&d.series.connectEnds&&b>f.length-3?2:1;if(!c[0]||!c[0].points)return!1;
if(!d)return c[0].points[0].highlight();if(f[b]!==d)for(var e=0;e<f.length;++e)if(f[e]===d){b=e;break}c=c[d.series.index+(a?1:-1)];b=f[b+(a?E:-1)]||c&&c.points[a?0:c.points.length-(c.connectEnds?2:1)];return void 0===b?!1:b.isNull&&this.options.accessibility.keyboardNavigation&&this.options.accessibility.keyboardNavigation.skipNullPoints?(this.highlightedPoint=b,this.highlightAdjacentPoint(a)):b.highlight()};e.Chart.prototype.showExportMenu=function(){this.exportSVGElements&&this.exportSVGElements[0]&&
(this.exportSVGElements[0].element.onclick(),this.highlightExportItem(0))};e.Chart.prototype.highlightExportItem=function(a){var c=this.exportDivElements&&this.exportDivElements[a],d=this.exportDivElements&&this.exportDivElements[this.highlightedExportItem];if(c&&"DIV"===c.tagName&&(!c.children||!c.children.length)){c.focus&&c.focus();if(d&&d.onmouseout)d.onmouseout();if(c.onmouseover)c.onmouseover();this.highlightedExportItem=a;return!0}};e.Chart.prototype.highlightRangeSelectorButton=function(a){var c=
this.rangeSelector.buttons;c[this.highlightedRangeSelectorItemIx]&&c[this.highlightedRangeSelectorItemIx].setState(this.oldRangeSelectorItemState||0);this.highlightedRangeSelectorItemIx=a;return c[a]?(c[a].element.focus&&c[a].element.focus(),this.oldRangeSelectorItemState=c[a].state,c[a].setState(2),!0):!1};e.Chart.prototype.highlightLegendItem=function(a){var c=this.legend.allItems;c[this.highlightedLegendItemIx]&&x(c[this.highlightedLegendItemIx].legendGroup.element,"mouseout");this.highlightedLegendItemIx=
a;return c[a]?(c[a].legendGroup.element.focus&&c[a].legendGroup.element.focus(),x(c[a].legendGroup.element,"mouseover"),!0):!1};e.Chart.prototype.hideExportMenu=function(){var a=this.exportDivElements;if(a){g(a,function(a){x(a,"mouseleave")});if(a[this.highlightedExportItem]&&a[this.highlightedExportItem].onmouseout)a[this.highlightedExportItem].onmouseout();this.highlightedExportItem=0;this.renderTo.focus()}};e.Chart.prototype.addKeyboardNavEvents=function(){function a(b){this.keyCodeMap=b.keyCodeMap;
this.move=b.move;this.validate=b.validate;this.init=b.init;this.transformTabs=!1!==b.transformTabs}function c(c,d){return new a(w({keyCodeMap:c,move:function(a){b.keyboardNavigationModuleIndex+=a;var c=b.keyboardNavigationModules[b.keyboardNavigationModuleIndex];if(c){if(c.validate&&!c.validate())return this.move(a);if(c.init)return c.init(a),!0}b.keyboardNavigationModuleIndex=0;b.slipNextTab=!0;return!1}},d))}function d(a){a=a||y.event;var c=b.keyboardNavigationModules[b.keyboardNavigationModuleIndex];
9===(a.which||a.keyCode)&&b.slipNextTab?b.slipNextTab=!1:(b.slipNextTab=!1,c&&c.run(a)&&a.preventDefault())}var b=this;a.prototype={run:function(b){var a=this,c=b.which||b.keyCode,f=!1,c=this.transformTabs&&9===c?b.shiftKey?37:39:c;g(this.keyCodeMap,function(d){-1<d[0].indexOf(c)&&(f=!1===d[1].call(a,c,b)?!1:!0)});return f}};b.keyboardNavigationModules=[c([[[37,39],function(a){if(!b.highlightAdjacentPoint(39===a))return this.move(39===a?1:-1)}],[[38,40],function(a){var c;if(b.highlightedPoint)if((c=
b.series[b.highlightedPoint.series.index+(38===a?-1:1)])&&c.points[0])c.points[0].highlight();else return this.move(40===a?1:-1)}],[[13,32],function(){b.highlightedPoint&&b.highlightedPoint.firePointEvent("click")}]],{init:function(a){var c=b.series&&b.series[b.series.length-1],c=c&&c.points&&c.points[c.points.length-1];0>a&&c&&c.highlight()}}),c([[[37,38],function(){for(var a=b.highlightedExportItem||0,c=!0,d=b.series;a--;)if(b.highlightExportItem(a)){c=!1;break}if(c)return b.hideExportMenu(),d&&
d.length&&(a=d[d.length-1],a.points.length&&a.points[a.points.length-1].highlight()),this.move(-1)}],[[39,40],function(){for(var a=!0,c=(b.highlightedExportItem||0)+1;c<b.exportDivElements.length;++c)if(b.highlightExportItem(c)){a=!1;break}if(a)return b.hideExportMenu(),this.move(1)}],[[13,32],function(){l(b.exportDivElements[b.highlightedExportItem])}]],{validate:function(){return b.exportChart&&!(b.options.exporting&&!1===b.options.exporting.enabled)},init:function(a){b.highlightedPoint=null;b.showExportMenu();
if(0>a&&b.exportDivElements)for(a=b.exportDivElements.length;-1<a&&!b.highlightExportItem(a);--a);}}),c([[[38,40,37,39],function(a){b[38===a||40===a?"yAxis":"xAxis"][0].panStep(39>a?-1:1)}],[[9],function(a,c){b.mapNavButtons[b.focusedMapNavButtonIx].setState(0);if(c.shiftKey&&!b.focusedMapNavButtonIx||!c.shiftKey&&b.focusedMapNavButtonIx)return b.mapZoom(),this.move(c.shiftKey?-1:1);b.focusedMapNavButtonIx+=c.shiftKey?-1:1;a=b.mapNavButtons[b.focusedMapNavButtonIx];a.element.focus&&a.element.focus();
a.setState(2)}],[[13,32],function(){l(b.mapNavButtons[b.focusedMapNavButtonIx].element)}]],{validate:function(){return b.mapZoom&&b.mapNavButtons&&2===b.mapNavButtons.length},transformTabs:!1,init:function(a){var c=b.mapNavButtons[0],d=b.mapNavButtons[1],c=0<a?c:d;g(b.mapNavButtons,function(a,b){a.element.setAttribute("tabindex",-1);a.element.setAttribute("role","button");a.element.setAttribute("aria-label","Zoom "+(b?"out":"")+"chart")});c.element.focus&&c.element.focus();c.setState(2);b.focusedMapNavButtonIx=
0<a?0:1}}),c([[[37,39,38,40],function(a){a=37===a||38===a?-1:1;if(!b.highlightRangeSelectorButton(b.highlightedRangeSelectorItemIx+a))return this.move(a)}],[[13,32],function(){3!==b.oldRangeSelectorItemState&&l(b.rangeSelector.buttons[b.highlightedRangeSelectorItemIx].element)}]],{validate:function(){return b.rangeSelector&&b.rangeSelector.buttons&&b.rangeSelector.buttons.length},init:function(a){g(b.rangeSelector.buttons,function(a){a.element.setAttribute("tabindex","-1");a.element.setAttribute("role",
"button");a.element.setAttribute("aria-label","Select range "+(a.text&&a.text.textStr))});b.highlightRangeSelectorButton(0<a?0:b.rangeSelector.buttons.length-1)}}),c([[[9,38,40],function(a,c){a=9===a&&c.shiftKey||38===a?-1:1;c=b.highlightedInputRangeIx+=a;if(1<c||0>c)return this.move(a);b.rangeSelector[c?"maxInput":"minInput"].focus()}]],{validate:function(){return b.rangeSelector&&b.rangeSelector.inputGroup&&"hidden"!==b.rangeSelector.inputGroup.element.getAttribute("visibility")&&!1!==b.options.rangeSelector.inputEnabled&&
b.rangeSelector.minInput&&b.rangeSelector.maxInput},transformTabs:!1,init:function(a){b.highlightedInputRangeIx=0<a?0:1;b.rangeSelector[b.highlightedInputRangeIx?"maxInput":"minInput"].focus()}}),c([[[37,39,38,40],function(a){a=37===a||38===a?-1:1;if(!b.highlightLegendItem(b.highlightedLegendItemIx+a))return this.move(a)}],[[13,32],function(){l(b.legend.allItems[b.highlightedLegendItemIx].legendItem.element.parentNode)}]],{validate:function(){return b.legend&&b.legend.allItems&&!b.colorAxis},init:function(a){g(b.legend.allItems,
function(a){a.legendGroup.element.setAttribute("tabindex","-1");a.legendGroup.element.setAttribute("role","button");a.legendGroup.element.setAttribute("aria-label","Toggle visibility of series "+a.name)});b.highlightLegendItem(0<a?0:b.legend.allItems.length-1)}})];b.keyboardNavigationModuleIndex=0;b.container.hasAttribute&&!b.container.hasAttribute("tabIndex")&&b.container.setAttribute("tabindex","0");v(b.renderTo,"keydown",d);v(b,"destroy",function(){B(b.renderTo,"keydown",d)})};e.Chart.prototype.addScreenReaderRegion=
function(a,c){var d=this,b=d.series,e=d.options,g=e.accessibility,m=d.screenReaderRegion=k.createElement("div"),l=k.createElement("h4"),n=k.createElement("a"),t=k.createElement("h4"),u={position:"absolute",left:"-9999px",top:"auto",width:"1px",height:"1px",overflow:"hidden"},h=d.types||[],h=(1===h.length&&"pie"===h[0]||"map"===h[0])&&{}||d.getAxesDescription(),p=b[0]&&r[b[0].type]||r["default"];m.setAttribute("id",a);m.setAttribute("role","region");m.setAttribute("aria-label","Chart screen reader information.");
m.innerHTML=g.screenReaderSectionFormatter&&g.screenReaderSectionFormatter(d)||"\x3cdiv\x3eUse regions/landmarks to skip ahead to chart"+(1<b.length?" and navigate between data series":"")+".\x3c/div\x3e\x3ch3\x3e"+(e.title.text?q(e.title.text):"Chart")+(e.subtitle&&e.subtitle.text?". "+q(e.subtitle.text):"")+"\x3c/h3\x3e\x3ch4\x3eLong description.\x3c/h4\x3e\x3cdiv\x3e"+(e.chart.description||"No description available.")+"\x3c/div\x3e\x3ch4\x3eStructure.\x3c/h4\x3e\x3cdiv\x3eChart type: "+(e.chart.typeDescription||
d.getTypeDescription())+"\x3c/div\x3e"+(1===b.length?"\x3cdiv\x3e"+p[0]+" with "+b[0].points.length+" "+(1===b[0].points.length?p[1]:p[2])+".\x3c/div\x3e":"")+(h.xAxis?"\x3cdiv\x3e"+h.xAxis+"\x3c/div\x3e":"")+(h.yAxis?"\x3cdiv\x3e"+h.yAxis+"\x3c/div\x3e":"");d.getCSV&&(n.innerHTML="View as data table.",n.href="#"+c,n.setAttribute("tabindex","-1"),n.onclick=g.onTableAnchorClick||function(){d.viewData();k.getElementById(c).focus()},l.appendChild(n),m.appendChild(l));t.innerHTML="Chart graphic.";d.renderTo.insertBefore(t,
d.renderTo.firstChild);d.renderTo.insertBefore(m,d.renderTo.firstChild);w(!0,t.style,u);w(!0,m.style,u)};e.Chart.prototype.callbacks.push(function(a){var c=a.options,d=c.accessibility;if(d.enabled){var b=k.createElementNS("http://www.w3.org/2000/svg","title"),f=k.createElementNS("http://www.w3.org/2000/svg","g"),l=a.container.getElementsByTagName("desc")[0],m=a.container.getElementsByTagName("text"),r="highcharts-title-"+a.index,n="highcharts-data-table-"+a.index,t="highcharts-information-region-"+
a.index,u=c.title.text||"Chart",h=c.exporting&&c.exporting.csv&&c.exporting.csv.columnHeaderFormatter,p=[];b.textContent=q(u);b.id=r;l.parentNode.insertBefore(b,l);a.renderTo.setAttribute("role","region");a.container.setAttribute("aria-details",t);a.renderTo.setAttribute("aria-label","Interactive chart. "+u+". Use up and down arrows to navigate with most screen readers.");if(a.exportSVGElements&&a.exportSVGElements[0]&&a.exportSVGElements[0].element){var v=a.exportSVGElements[0].element.onclick,b=
a.exportSVGElements[0].element.parentNode;a.exportSVGElements[0].element.onclick=function(){v.apply(this,Array.prototype.slice.call(arguments));a.addAccessibleContextMenuAttribs();a.highlightExportItem(0)};a.exportSVGElements[0].element.setAttribute("role","button");a.exportSVGElements[0].element.setAttribute("aria-label","View export menu");f.appendChild(a.exportSVGElements[0].element);f.setAttribute("role","region");f.setAttribute("aria-label","Chart export menu");b.appendChild(f)}a.rangeSelector&&
g(["minInput","maxInput"],function(b,c){a.rangeSelector[b]&&(a.rangeSelector[b].setAttribute("tabindex","-1"),a.rangeSelector[b].setAttribute("role","textbox"),a.rangeSelector[b].setAttribute("aria-label","Select "+(c?"end":"start")+" date."))});g(m,function(a){a.setAttribute("aria-hidden","true")});a.addScreenReaderRegion(t,n);d.keyboardNavigation&&a.addKeyboardNavEvents();w(!0,c.exporting,{csv:{columnHeaderFormatter:function(a,b,c){var d=p[p.length-1];1<c&&(d&&d.text)!==a.name&&p.push({text:a.name,
span:c});return h?h.call(this,a,b,c):1<c?b:a.name}}});e.wrap(a,"getTable",function(a){return a.apply(this,Array.prototype.slice.call(arguments,1)).replace("\x3ctable\x3e",'\x3ctable id\x3d"'+n+'" summary\x3d"Table representation of chart"\x3e\x3ccaption\x3e'+u+"\x3c/caption\x3e")});e.wrap(a,"viewData",function(a){if(!this.insertedTable){a.apply(this,Array.prototype.slice.call(arguments,1));var b=k.getElementById(n),c=b.getElementsByTagName("tbody")[0],d=c.firstChild.children,e="\x3ctr\x3e\x3ctd\x3e\x3c/td\x3e",
f,h;b.setAttribute("tabindex","-1");g(c.children,function(a){f=a.firstChild;h=k.createElement("th");h.setAttribute("scope","row");h.innerHTML=f.innerHTML;f.parentNode.replaceChild(h,f)});g(d,function(a){"TH"===a.tagName&&a.setAttribute("scope","col")});p.length&&(g(p,function(a){e+='\x3cth scope\x3d"col" colspan\x3d"'+a.span+'"\x3e'+a.text+"\x3c/th\x3e"}),c.insertAdjacentHTML("afterbegin",e))}})}})})(q)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 | 1 1 1 1 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Accessibility module
*
* (c) 2010-2017 Highsoft AS
* Author: Oystein Moseng
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* Accessibility module
*
* (c) 2010-2017 Highsoft AS
* Author: Oystein Moseng
*
* License: www.highcharts.com/license
*/
var win = H.win,
doc = win.document,
each = H.each,
erase = H.erase,
addEvent = H.addEvent,
removeEvent = H.removeEvent,
fireEvent = H.fireEvent,
dateFormat = H.dateFormat,
merge = H.merge,
// Human readable description of series and each point in singular and plural
typeToSeriesMap = {
'default': ['series', 'data point', 'data points'],
'line': ['line', 'data point', 'data points'],
'spline': ['line', 'data point', 'data points'],
'area': ['line', 'data point', 'data points'],
'areaspline': ['line', 'data point', 'data points'],
'pie': ['pie', 'slice', 'slices'],
'column': ['column series', 'column', 'columns'],
'bar': ['bar series', 'bar', 'bars'],
'scatter': ['scatter series', 'data point', 'data points'],
'boxplot': ['boxplot series', 'box', 'boxes'],
'arearange': ['arearange series', 'data point', 'data points'],
'areasplinerange': ['areasplinerange series', 'data point', 'data points'],
'bubble': ['bubble series', 'bubble', 'bubbles'],
'columnrange': ['columnrange series', 'column', 'columns'],
'errorbar': ['errorbar series', 'errorbar', 'errorbars'],
'funnel': ['funnel', 'data point', 'data points'],
'pyramid': ['pyramid', 'data point', 'data points'],
'waterfall': ['waterfall series', 'column', 'columns'],
'map': ['map', 'area', 'areas'],
'mapline': ['line', 'data point', 'data points'],
'mappoint': ['point series', 'data point', 'data points'],
'mapbubble': ['bubble series', 'bubble', 'bubbles']
},
// Descriptions for exotic chart types
typeDescriptionMap = {
boxplot: ' Box plot charts are typically used to display groups of statistical data. ' +
'Each data point in the chart can have up to 5 values: minimum, lower quartile, median, upper quartile and maximum. ',
arearange: ' Arearange charts are line charts displaying a range between a lower and higher value for each point. ',
areasplinerange: ' These charts are line charts displaying a range between a lower and higher value for each point. ',
bubble: ' Bubble charts are scatter charts where each data point also has a size value. ',
columnrange: ' Columnrange charts are column charts displaying a range between a lower and higher value for each point. ',
errorbar: ' Errorbar series are used to display the variability of the data. ',
funnel: ' Funnel charts are used to display reduction of data in stages. ',
pyramid: ' Pyramid charts consist of a single pyramid with item heights corresponding to each point value. ',
waterfall: ' A waterfall chart is a column chart where each column contributes towards a total end value. '
};
// If a point has one of the special keys defined, we expose all keys to the
// screen reader.
H.Series.prototype.commonKeys = ['name', 'id', 'category', 'x', 'value', 'y'];
H.Series.prototype.specialKeys = [
'z', 'open', 'high', 'q3', 'median', 'q1', 'low', 'close'
];
// A pie is always simple. Don't quote me on that.
if (H.seriesTypes.pie) {
H.seriesTypes.pie.prototype.specialKeys = [];
}
// Default a11y options
H.setOptions({
accessibility: {
enabled: true,
pointDescriptionThreshold: 30, // set to false to disable
keyboardNavigation: {
enabled: true
// skipNullPoints: false
}
// describeSingleSeries: false
}
});
/**
* HTML encode some characters vulnerable for XSS.
* @param {string} html The input string
* @return {string} The excaped string
*/
function htmlencode(html) {
return html
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/\//g, '/');
}
// Utility function. Reverses child nodes of a DOM element
function reverseChildNodes(node) {
var i = node.childNodes.length;
while (i--) {
node.appendChild(node.childNodes[i]);
}
}
// Utility function to attempt to fake a click event on an element
function fakeClickEvent(element) {
var fakeEvent;
if (element && element.onclick && doc.createEvent) {
fakeEvent = doc.createEvent('Events');
fakeEvent.initEvent('click', true, false);
element.onclick(fakeEvent);
}
}
// Whenever drawing series, put info on DOM elements
H.wrap(H.Series.prototype, 'render', function(proceed) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
if (this.chart.options.accessibility.enabled) {
this.setA11yDescription();
}
});
// Put accessible info on series and points of a series
H.Series.prototype.setA11yDescription = function() {
var a11yOptions = this.chart.options.accessibility,
firstPointEl = this.points && this.points.length && this.points[0].graphic && this.points[0].graphic.element,
seriesEl = firstPointEl && firstPointEl.parentNode || this.graph && this.graph.element || this.group && this.group.element; // Could be tracker series depending on series type
if (seriesEl) {
// For some series types the order of elements do not match the order of points in series
// In that case we have to reverse them in order for AT to read them out in an understandable order
if (seriesEl.lastChild === firstPointEl) {
reverseChildNodes(seriesEl);
}
// Make individual point elements accessible if possible. Note: If markers are disabled there might not be any elements there to make accessible.
if (this.points && (this.points.length < a11yOptions.pointDescriptionThreshold || a11yOptions.pointDescriptionThreshold === false)) {
each(this.points, function(point) {
if (point.graphic) {
point.graphic.element.setAttribute('role', 'img');
point.graphic.element.setAttribute('tabindex', '-1');
point.graphic.element.setAttribute('aria-label', a11yOptions.pointDescriptionFormatter && a11yOptions.pointDescriptionFormatter(point) ||
point.buildPointInfoString());
}
});
}
// Make series element accessible
if (this.chart.series.length > 1 || a11yOptions.describeSingleSeries) {
seriesEl.setAttribute('role', 'region');
seriesEl.setAttribute('tabindex', '-1');
seriesEl.setAttribute('aria-label', a11yOptions.seriesDescriptionFormatter && a11yOptions.seriesDescriptionFormatter(this) ||
this.buildSeriesInfoString());
}
}
};
// Return string with information about series
H.Series.prototype.buildSeriesInfoString = function() {
var typeInfo = typeToSeriesMap[this.type] || typeToSeriesMap['default'], // eslint-disable-line dot-notation
description = this.description || this.options.description;
return (this.name ? this.name + ', ' : '') +
(this.chart.types.length === 1 ? typeInfo[0] : 'series') + ' ' + (this.index + 1) + ' of ' + (this.chart.series.length) +
(this.chart.types.length === 1 ? ' with ' : '. ' + typeInfo[0] + ' with ') +
(this.points.length + ' ' + (this.points.length === 1 ? typeInfo[1] : typeInfo[2])) +
(description ? '. ' + description : '') +
(this.chart.yAxis.length > 1 && this.yAxis ? '. Y axis, ' + this.yAxis.getDescription() : '') +
(this.chart.xAxis.length > 1 && this.xAxis ? '. X axis, ' + this.xAxis.getDescription() : '');
};
// Return string with information about point
H.Point.prototype.buildPointInfoString = function() {
var point = this,
series = point.series,
a11yOptions = series.chart.options.accessibility,
infoString = '',
dateTimePoint = series.xAxis && series.xAxis.isDatetimeAxis,
timeDesc = dateTimePoint && dateFormat(a11yOptions.pointDateFormatter && a11yOptions.pointDateFormatter(point) || a11yOptions.pointDateFormat ||
H.Tooltip.prototype.getXDateFormat(point, series.chart.options.tooltip, series.xAxis), point.x),
hasSpecialKey = H.find(series.specialKeys, function(key) {
return point[key] !== undefined;
});
// If the point has one of the less common properties defined, display all that are defined
if (hasSpecialKey) {
if (dateTimePoint) {
infoString = timeDesc;
}
each(series.commonKeys.concat(series.specialKeys), function(key) {
if (point[key] !== undefined && !(dateTimePoint && key === 'x')) {
infoString += (infoString ? '. ' : '') + key + ', ' + point[key];
}
});
} else {
// Pick and choose properties for a succint label
infoString = (this.name || timeDesc || this.category || this.id || 'x, ' + this.x) + ', ' +
(this.value !== undefined ? this.value : this.y);
}
return (this.index + 1) + '. ' + infoString + '.' + (this.description ? ' ' + this.description : '');
};
// Get descriptive label for axis
H.Axis.prototype.getDescription = function() {
return this.userOptions && this.userOptions.description || this.axisTitle && this.axisTitle.textStr ||
this.options.id || this.categories && 'categories' || 'values';
};
// Pan along axis in a direction (1 or -1), optionally with a defined granularity (number of steps it takes to walk across current view)
H.Axis.prototype.panStep = function(direction, granularity) {
var gran = granularity || 3,
extremes = this.getExtremes(),
step = (extremes.max - extremes.min) / gran * direction,
newMax = extremes.max + step,
newMin = extremes.min + step,
size = newMax - newMin;
if (direction < 0 && newMin < extremes.dataMin) {
newMin = extremes.dataMin;
newMax = newMin + size;
} else if (direction > 0 && newMax > extremes.dataMax) {
newMax = extremes.dataMax;
newMin = newMax - size;
}
this.setExtremes(newMin, newMax);
};
// Whenever adding or removing series, keep track of types present in chart
H.wrap(H.Series.prototype, 'init', function(proceed) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
var chart = this.chart;
if (chart.options.accessibility.enabled) {
chart.types = chart.types || [];
// Add type to list if does not exist
if (chart.types.indexOf(this.type) < 0) {
chart.types.push(this.type);
}
addEvent(this, 'remove', function() {
var removedSeries = this,
hasType = false;
// Check if any of the other series have the same type as this one. Otherwise remove it from the list.
each(chart.series, function(s) {
if (s !== removedSeries && chart.types.indexOf(removedSeries.type) < 0) {
hasType = true;
}
});
if (!hasType) {
erase(chart.types, removedSeries.type);
}
});
}
});
// Return simplified description of chart type. Some types will not be familiar to most screen reader users, but we try.
H.Chart.prototype.getTypeDescription = function() {
var firstType = this.types && this.types[0],
mapTitle = this.series[0] && this.series[0].mapTitle;
if (!firstType) {
return 'Empty chart.';
} else if (firstType === 'map') {
return mapTitle ? 'Map of ' + mapTitle : 'Map of unspecified region.';
} else if (this.types.length > 1) {
return 'Combination chart.';
} else if (['spline', 'area', 'areaspline'].indexOf(firstType) > -1) {
return 'Line chart.';
}
return firstType + ' chart.' + (typeDescriptionMap[firstType] || '');
};
// Return object with text description of each of the chart's axes
H.Chart.prototype.getAxesDescription = function() {
var numXAxes = this.xAxis.length,
numYAxes = this.yAxis.length,
desc = {},
i;
if (numXAxes) {
desc.xAxis = 'The chart has ' + numXAxes + (numXAxes > 1 ? ' X axes' : ' X axis') + ' displaying ';
if (numXAxes < 2) {
desc.xAxis += this.xAxis[0].getDescription() + '.';
} else {
for (i = 0; i < numXAxes - 1; ++i) {
desc.xAxis += (i ? ', ' : '') + this.xAxis[i].getDescription();
}
desc.xAxis += ' and ' + this.xAxis[i].getDescription() + '.';
}
}
if (numYAxes) {
desc.yAxis = 'The chart has ' + numYAxes + (numYAxes > 1 ? ' Y axes' : ' Y axis') + ' displaying ';
if (numYAxes < 2) {
desc.yAxis += this.yAxis[0].getDescription() + '.';
} else {
for (i = 0; i < numYAxes - 1; ++i) {
desc.yAxis += (i ? ', ' : '') + this.yAxis[i].getDescription();
}
desc.yAxis += ' and ' + this.yAxis[i].getDescription() + '.';
}
}
return desc;
};
// Set a11y attribs on exporting menu
H.Chart.prototype.addAccessibleContextMenuAttribs = function() {
var exportList = this.exportDivElements;
if (exportList) {
// Set tabindex on the menu items to allow focusing by script
// Set role to give screen readers a chance to pick up the contents
each(exportList, function(item) {
if (item.tagName === 'DIV' &&
!(item.children && item.children.length)) {
item.setAttribute('role', 'menuitem');
item.setAttribute('tabindex', -1);
}
});
// Set accessibility properties on parent div
exportList[0].parentNode.setAttribute('role', 'menu');
exportList[0].parentNode.setAttribute('aria-label', 'Chart export');
}
};
// Highlight a point (show tooltip and display hover state). Returns the highlighted point.
H.Point.prototype.highlight = function() {
var chart = this.series.chart;
if (this.graphic && this.graphic.element.focus) {
this.graphic.element.focus();
}
if (!this.isNull) {
this.onMouseOver(); // Show the hover marker
// Show the tooltip
if (chart.tooltip) {
chart.tooltip.refresh(chart.tooltip.shared ? [this] : this);
}
} else {
if (chart.tooltip) {
chart.tooltip.hide(0);
}
// Don't call blur on the element, as it messes up the chart div's focus
}
chart.highlightedPoint = this;
return this;
};
// Function to highlight next/previous point in chart
// Returns highlighted point on success, false on failure (no adjacent point to highlight in chosen direction)
H.Chart.prototype.highlightAdjacentPoint = function(next) {
var series = this.series,
curPoint = this.highlightedPoint,
curPointIndex = curPoint && curPoint.index || 0,
curPoints = curPoint && curPoint.series.points,
newSeries,
newPoint,
// Handle connecting ends - where the points array has an extra last
// point that is a reference to the first one. We skip this.
forwardSkipAmount = curPoint && curPoint.series.connectEnds &&
curPointIndex > curPoints.length - 3 ? 2 : 1;
// If no points, return false
if (!series[0] || !series[0].points) {
return false;
}
// Use first point if none already highlighted
if (!curPoint) {
return series[0].points[0].highlight();
}
// Find index of current point in series.points array. Necessary for dataGrouping (and maybe zoom?)
if (curPoints[curPointIndex] !== curPoint) {
for (var i = 0; i < curPoints.length; ++i) {
if (curPoints[i] === curPoint) {
curPointIndex = i;
break;
}
}
}
// Grab next/prev point & series
newSeries = series[curPoint.series.index + (next ? 1 : -1)];
newPoint = curPoints[curPointIndex + (next ? forwardSkipAmount : -1)] ||
// Done with this series, try next one
newSeries &&
newSeries.points[next ? 0 : newSeries.points.length - (
newSeries.connectEnds ? 2 : 1
)];
// If there is no adjacent point, we return false
if (newPoint === undefined) {
return false;
}
// Recursively skip null points
if (newPoint.isNull && this.options.accessibility.keyboardNavigation &&
this.options.accessibility.keyboardNavigation.skipNullPoints) {
this.highlightedPoint = newPoint;
return this.highlightAdjacentPoint(next);
}
// There is an adjacent point, highlight it
return newPoint.highlight();
};
// Show the export menu and focus the first item (if exists)
H.Chart.prototype.showExportMenu = function() {
if (this.exportSVGElements && this.exportSVGElements[0]) {
this.exportSVGElements[0].element.onclick();
this.highlightExportItem(0);
}
};
// Highlight export menu item by index
H.Chart.prototype.highlightExportItem = function(ix) {
var listItem = this.exportDivElements && this.exportDivElements[ix],
curHighlighted = this.exportDivElements && this.exportDivElements[this.highlightedExportItem];
if (listItem && listItem.tagName === 'DIV' && !(listItem.children && listItem.children.length)) {
if (listItem.focus) {
listItem.focus();
}
if (curHighlighted && curHighlighted.onmouseout) {
curHighlighted.onmouseout();
}
if (listItem.onmouseover) {
listItem.onmouseover();
}
this.highlightedExportItem = ix;
return true;
}
};
// Highlight range selector button by index
H.Chart.prototype.highlightRangeSelectorButton = function(ix) {
var buttons = this.rangeSelector.buttons;
// Deselect old
if (buttons[this.highlightedRangeSelectorItemIx]) {
buttons[this.highlightedRangeSelectorItemIx].setState(this.oldRangeSelectorItemState || 0);
}
// Select new
this.highlightedRangeSelectorItemIx = ix;
if (buttons[ix]) {
if (buttons[ix].element.focus) {
buttons[ix].element.focus();
}
this.oldRangeSelectorItemState = buttons[ix].state;
buttons[ix].setState(2);
return true;
}
return false;
};
// Highlight legend item by index
H.Chart.prototype.highlightLegendItem = function(ix) {
var items = this.legend.allItems;
if (items[this.highlightedLegendItemIx]) {
fireEvent(items[this.highlightedLegendItemIx].legendGroup.element, 'mouseout');
}
this.highlightedLegendItemIx = ix;
if (items[ix]) {
if (items[ix].legendGroup.element.focus) {
items[ix].legendGroup.element.focus();
}
fireEvent(items[ix].legendGroup.element, 'mouseover');
return true;
}
return false;
};
// Hide export menu
H.Chart.prototype.hideExportMenu = function() {
var exportList = this.exportDivElements;
if (exportList) {
each(exportList, function(el) {
fireEvent(el, 'mouseleave');
});
if (exportList[this.highlightedExportItem] && exportList[this.highlightedExportItem].onmouseout) {
exportList[this.highlightedExportItem].onmouseout();
}
this.highlightedExportItem = 0;
this.renderTo.focus();
}
};
// Add keyboard navigation handling to chart
H.Chart.prototype.addKeyboardNavEvents = function() {
var chart = this;
// Abstraction layer for keyboard navigation. Keep a map of keyCodes to handler functions, and a next/prev move handler for tab order.
// The module's keyCode handlers determine when to move to another module.
// Validate holds a function to determine if there are prerequisites for this module to run that are not met.
// Init holds a function to run once before any keyCodes are interpreted.
// transformTabs determines whether to transform tabs to left/right events or not. Defaults to true.
function KeyboardNavigationModule(options) {
this.keyCodeMap = options.keyCodeMap;
this.move = options.move;
this.validate = options.validate;
this.init = options.init;
this.transformTabs = options.transformTabs !== false;
}
KeyboardNavigationModule.prototype = {
// Find handler function(s) for key code in the keyCodeMap and run it.
run: function(e) {
var navModule = this,
keyCode = e.which || e.keyCode,
handled = false;
keyCode = this.transformTabs && keyCode === 9 ? (e.shiftKey ? 37 : 39) : keyCode; // Transform tabs
each(this.keyCodeMap, function(codeSet) {
if (codeSet[0].indexOf(keyCode) > -1) {
handled = codeSet[1].call(navModule, keyCode, e) === false ? false : true; // If explicitly returning false, we haven't handled it
}
});
return handled;
}
};
// Maintain abstraction between KeyboardNavigationModule and Highcharts
// The chart object keeps track of a list of KeyboardNavigationModules that we move through
function navModuleFactory(keyMap, options) {
return new KeyboardNavigationModule(merge({
keyCodeMap: keyMap,
// Move to next/prev valid module, or undefined if none, and init it.
// Returns true on success and false if there is no valid module to move to.
move: function(direction) {
chart.keyboardNavigationModuleIndex += direction;
var newModule = chart.keyboardNavigationModules[chart.keyboardNavigationModuleIndex];
if (newModule) {
if (newModule.validate && !newModule.validate()) {
return this.move(direction); // Invalid module
}
if (newModule.init) {
newModule.init(direction); // Valid module, init it
return true;
}
}
// No module
chart.keyboardNavigationModuleIndex = 0; // Reset counter
chart.slipNextTab = true; // Allow next tab to slip, as we will have focus on chart now
return false;
}
}, options));
}
// Route keydown events
function keydownHandler(ev) {
var e = ev || win.event,
keyCode = e.which || e.keyCode,
curNavModule = chart.keyboardNavigationModules[chart.keyboardNavigationModuleIndex];
// Handle tabbing
if (keyCode === 9) {
// If we reached end of chart, we need to let this tab slip through to allow users to tab further
if (chart.slipNextTab) {
chart.slipNextTab = false;
return;
}
}
// If key was not tab, don't slip the next tab
chart.slipNextTab = false;
// If there is a navigation module for the current index, run it. Otherwise, we are outside of the chart in some direction.
if (curNavModule) {
if (curNavModule.run(e)) {
e.preventDefault(); // If successfully handled, stop the event here.
}
}
}
// List of the different keyboard handling modes we use depending on where we are in the chart.
// Each mode has a set of handling functions mapped to key codes.
// Each mode determines when to move to the next/prev mode.
chart.keyboardNavigationModules = [
// Points
navModuleFactory([
// Left/Right
[
[37, 39],
function(keyCode) {
if (!chart.highlightAdjacentPoint(keyCode === 39)) { // Try to highlight adjacent point
return this.move(keyCode === 39 ? 1 : -1); // Failed. Move to next/prev module
}
}
],
// Up/Down
[
[38, 40],
function(keyCode) {
var newSeries;
if (chart.highlightedPoint) {
newSeries = chart.series[chart.highlightedPoint.series.index + (keyCode === 38 ? -1 : 1)]; // Find prev/next series
if (newSeries && newSeries.points[0]) { // If series exists and has data, go for it
newSeries.points[0].highlight();
} else {
return this.move(keyCode === 40 ? 1 : -1); // Otherwise, attempt to move to next/prev module
}
}
}
],
// Enter/Spacebar
[
[13, 32],
function() {
if (chart.highlightedPoint) {
chart.highlightedPoint.firePointEvent('click');
}
}
]
], {
// If coming back to points from other module, highlight last point
init: function(direction) {
var lastSeries = chart.series && chart.series[chart.series.length - 1],
lastPoint = lastSeries && lastSeries.points && lastSeries.points[lastSeries.points.length - 1];
if (direction < 0 && lastPoint) {
lastPoint.highlight();
}
}
}),
// Exporting
navModuleFactory([
// Left/Up
[
[37, 38],
function() {
var i = chart.highlightedExportItem || 0,
reachedEnd = true,
series = chart.series,
newSeries;
// Try to highlight prev item in list. Highlighting e.g. separators will fail.
while (i--) {
if (chart.highlightExportItem(i)) {
reachedEnd = false;
break;
}
}
if (reachedEnd) {
chart.hideExportMenu();
// Wrap to last point
if (series && series.length) {
newSeries = series[series.length - 1];
if (newSeries.points.length) {
newSeries.points[newSeries.points.length - 1].highlight();
}
}
// Try to move to prev module (should be points, since we wrapped to last point)
return this.move(-1);
}
}
],
// Right/Down
[
[39, 40],
function() {
var highlightedExportItem = chart.highlightedExportItem || 0,
reachedEnd = true;
// Try to highlight next item in list. Highlighting e.g. separators will fail.
for (var i = highlightedExportItem + 1; i < chart.exportDivElements.length; ++i) {
if (chart.highlightExportItem(i)) {
reachedEnd = false;
break;
}
}
if (reachedEnd) {
chart.hideExportMenu();
return this.move(1); // Next module
}
}
],
// Enter/Spacebar
[
[13, 32],
function() {
fakeClickEvent(chart.exportDivElements[chart.highlightedExportItem]);
}
]
], {
// Only run exporting navigation if exporting support exists and is enabled on chart
validate: function() {
return chart.exportChart && !(chart.options.exporting && chart.options.exporting.enabled === false);
},
// Show export menu
init: function(direction) {
chart.highlightedPoint = null;
chart.showExportMenu();
// If coming back to export menu from other module, try to highlight last item in menu
if (direction < 0 && chart.exportDivElements) {
for (var i = chart.exportDivElements.length; i > -1; --i) {
if (chart.highlightExportItem(i)) {
break;
}
}
}
}
}),
// Map zoom
navModuleFactory([
// Up/down/left/right
[
[38, 40, 37, 39],
function(keyCode) {
chart[keyCode === 38 || keyCode === 40 ? 'yAxis' : 'xAxis'][0].panStep(keyCode < 39 ? -1 : 1);
}
],
// Tabs
[
[9],
function(keyCode, e) {
var button;
chart.mapNavButtons[chart.focusedMapNavButtonIx].setState(0); // Deselect old
if (e.shiftKey && !chart.focusedMapNavButtonIx || !e.shiftKey && chart.focusedMapNavButtonIx) { // trying to go somewhere we can't?
chart.mapZoom(); // Reset zoom
return this.move(e.shiftKey ? -1 : 1); // Nowhere to go, go to prev/next module
}
chart.focusedMapNavButtonIx += e.shiftKey ? -1 : 1;
button = chart.mapNavButtons[chart.focusedMapNavButtonIx];
if (button.element.focus) {
button.element.focus();
}
button.setState(2);
}
],
// Enter/Spacebar
[
[13, 32],
function() {
fakeClickEvent(chart.mapNavButtons[chart.focusedMapNavButtonIx].element);
}
]
], {
// Only run this module if we have map zoom on the chart
validate: function() {
return chart.mapZoom && chart.mapNavButtons && chart.mapNavButtons.length === 2;
},
// Handle tabs separately
transformTabs: false,
// Make zoom buttons do their magic
init: function(direction) {
var zoomIn = chart.mapNavButtons[0],
zoomOut = chart.mapNavButtons[1],
initialButton = direction > 0 ? zoomIn : zoomOut;
each(chart.mapNavButtons, function(button, i) {
button.element.setAttribute('tabindex', -1);
button.element.setAttribute('role', 'button');
button.element.setAttribute('aria-label', 'Zoom ' + (i ? 'out' : '') + 'chart');
});
if (initialButton.element.focus) {
initialButton.element.focus();
}
initialButton.setState(2);
chart.focusedMapNavButtonIx = direction > 0 ? 0 : 1;
}
}),
// Highstock range selector (minus input boxes)
navModuleFactory([
// Left/Right/Up/Down
[
[37, 39, 38, 40],
function(keyCode) {
var direction = (keyCode === 37 || keyCode === 38) ? -1 : 1;
// Try to highlight next/prev button
if (!chart.highlightRangeSelectorButton(chart.highlightedRangeSelectorItemIx + direction)) {
return this.move(direction);
}
}
],
// Enter/Spacebar
[
[13, 32],
function() {
if (chart.oldRangeSelectorItemState !== 3) { // Don't allow click if button used to be disabled
fakeClickEvent(chart.rangeSelector.buttons[chart.highlightedRangeSelectorItemIx].element);
}
}
]
], {
// Only run this module if we have range selector
validate: function() {
return chart.rangeSelector && chart.rangeSelector.buttons && chart.rangeSelector.buttons.length;
},
// Make elements focusable and accessible
init: function(direction) {
each(chart.rangeSelector.buttons, function(button) {
button.element.setAttribute('tabindex', '-1');
button.element.setAttribute('role', 'button');
button.element.setAttribute('aria-label', 'Select range ' + (button.text && button.text.textStr));
});
// Focus first/last button
chart.highlightRangeSelectorButton(direction > 0 ? 0 : chart.rangeSelector.buttons.length - 1);
}
}),
// Highstock range selector, input boxes
navModuleFactory([
// Tab/Up/Down
[
[9, 38, 40],
function(keyCode, e) {
var direction = (keyCode === 9 && e.shiftKey || keyCode === 38) ? -1 : 1,
newIx = chart.highlightedInputRangeIx = chart.highlightedInputRangeIx + direction;
// Try to highlight next/prev item in list.
if (newIx > 1 || newIx < 0) { // Out of range
return this.move(direction);
}
chart.rangeSelector[newIx ? 'maxInput' : 'minInput'].focus(); // Input boxes are HTML, and should have focus support in all browsers
}
]
], {
// Only run if we have range selector with input boxes
validate: function() {
var inputVisible = chart.rangeSelector && chart.rangeSelector.inputGroup && chart.rangeSelector.inputGroup.element.getAttribute('visibility') !== 'hidden';
return inputVisible && chart.options.rangeSelector.inputEnabled !== false && chart.rangeSelector.minInput && chart.rangeSelector.maxInput;
},
// Handle tabs different from left/right (because we don't want to catch left/right in a text area)
transformTabs: false,
// Highlight first/last input box
init: function(direction) {
chart.highlightedInputRangeIx = direction > 0 ? 0 : 1;
chart.rangeSelector[chart.highlightedInputRangeIx ? 'maxInput' : 'minInput'].focus();
}
}),
// Legend navigation
navModuleFactory([
// Left/Right/Up/Down
[
[37, 39, 38, 40],
function(keyCode) {
var direction = (keyCode === 37 || keyCode === 38) ? -1 : 1;
// Try to highlight next/prev legend item
if (!chart.highlightLegendItem(chart.highlightedLegendItemIx + direction)) {
return this.move(direction);
}
}
],
// Enter/Spacebar
[
[13, 32],
function() {
fakeClickEvent(chart.legend.allItems[chart.highlightedLegendItemIx].legendItem.element.parentNode);
}
]
], {
// Only run this module if we have at least one legend - wait for it - item.
validate: function() {
return chart.legend && chart.legend.allItems && !chart.colorAxis;
},
// Make elements focusable and accessible
init: function(direction) {
each(chart.legend.allItems, function(item) {
item.legendGroup.element.setAttribute('tabindex', '-1');
item.legendGroup.element.setAttribute('role', 'button');
item.legendGroup.element.setAttribute('aria-label', 'Toggle visibility of series ' + item.name);
});
// Focus first/last item
chart.highlightLegendItem(direction > 0 ? 0 : chart.legend.allItems.length - 1);
}
})
];
// Init nav module index. We start at the first module, and as the user navigates through the chart the index will increase to use different handler modules.
chart.keyboardNavigationModuleIndex = 0;
// Make chart reachable by tab
if (
chart.container.hasAttribute &&
!chart.container.hasAttribute('tabIndex')
) {
chart.container.setAttribute('tabindex', '0');
}
// Handle keyboard events
addEvent(chart.renderTo, 'keydown', keydownHandler);
addEvent(chart, 'destroy', function() {
removeEvent(chart.renderTo, 'keydown', keydownHandler);
});
};
// Add screen reader region to chart.
// tableId is the HTML id of the table to focus when clicking the table anchor in the screen reader region.
H.Chart.prototype.addScreenReaderRegion = function(id, tableId) {
var chart = this,
series = chart.series,
options = chart.options,
a11yOptions = options.accessibility,
hiddenSection = chart.screenReaderRegion = doc.createElement('div'),
tableShortcut = doc.createElement('h4'),
tableShortcutAnchor = doc.createElement('a'),
chartHeading = doc.createElement('h4'),
hiddenStyle = { // CSS style to hide element from visual users while still exposing it to screen readers
position: 'absolute',
left: '-9999px',
top: 'auto',
width: '1px',
height: '1px',
overflow: 'hidden'
},
chartTypes = chart.types || [],
// Build axis info - but not for pies and maps. Consider not adding for certain other types as well (funnel, pyramid?)
axesDesc = (chartTypes.length === 1 && chartTypes[0] === 'pie' || chartTypes[0] === 'map') && {} || chart.getAxesDescription(),
chartTypeInfo = series[0] && typeToSeriesMap[series[0].type] || typeToSeriesMap['default']; // eslint-disable-line dot-notation
hiddenSection.setAttribute('id', id);
hiddenSection.setAttribute('role', 'region');
hiddenSection.setAttribute('aria-label', 'Chart screen reader information.');
hiddenSection.innerHTML = a11yOptions.screenReaderSectionFormatter && a11yOptions.screenReaderSectionFormatter(chart) ||
'<div>Use regions/landmarks to skip ahead to chart' +
(series.length > 1 ? ' and navigate between data series' : '') +
'.</div><h3>' + (options.title.text ? htmlencode(options.title.text) : 'Chart') +
(options.subtitle && options.subtitle.text ? '. ' + htmlencode(options.subtitle.text) : '') +
'</h3><h4>Long description.</h4><div>' + (options.chart.description || 'No description available.') +
'</div><h4>Structure.</h4><div>Chart type: ' + (options.chart.typeDescription || chart.getTypeDescription()) + '</div>' +
(series.length === 1 ? '<div>' + chartTypeInfo[0] + ' with ' + series[0].points.length + ' ' +
(series[0].points.length === 1 ? chartTypeInfo[1] : chartTypeInfo[2]) + '.</div>' : '') +
(axesDesc.xAxis ? ('<div>' + axesDesc.xAxis + '</div>') : '') +
(axesDesc.yAxis ? ('<div>' + axesDesc.yAxis + '</div>') : '');
// Add shortcut to data table if export-csv is loaded
if (chart.getCSV) {
tableShortcutAnchor.innerHTML = 'View as data table.';
tableShortcutAnchor.href = '#' + tableId;
tableShortcutAnchor.setAttribute('tabindex', '-1'); // Make this unreachable by user tabbing
tableShortcutAnchor.onclick = a11yOptions.onTableAnchorClick || function() {
chart.viewData();
doc.getElementById(tableId).focus();
};
tableShortcut.appendChild(tableShortcutAnchor);
hiddenSection.appendChild(tableShortcut);
}
// Note: JAWS seems to refuse to read aria-label on the container, so add an
// h4 element as title for the chart.
chartHeading.innerHTML = 'Chart graphic.';
chart.renderTo.insertBefore(chartHeading, chart.renderTo.firstChild);
chart.renderTo.insertBefore(hiddenSection, chart.renderTo.firstChild);
// Hide the section and the chart heading
merge(true, chartHeading.style, hiddenStyle);
merge(true, hiddenSection.style, hiddenStyle);
};
// Make chart container accessible, and wrap table functionality
H.Chart.prototype.callbacks.push(function(chart) {
var options = chart.options,
a11yOptions = options.accessibility;
if (!a11yOptions.enabled) {
return;
}
var titleElement = doc.createElementNS('http://www.w3.org/2000/svg', 'title'),
exportGroupElement = doc.createElementNS('http://www.w3.org/2000/svg', 'g'),
descElement = chart.container.getElementsByTagName('desc')[0],
textElements = chart.container.getElementsByTagName('text'),
titleId = 'highcharts-title-' + chart.index,
tableId = 'highcharts-data-table-' + chart.index,
hiddenSectionId = 'highcharts-information-region-' + chart.index,
chartTitle = options.title.text || 'Chart',
oldColumnHeaderFormatter = options.exporting && options.exporting.csv && options.exporting.csv.columnHeaderFormatter,
topLevelColumns = [];
// Add SVG title/desc tags
titleElement.textContent = htmlencode(chartTitle);
titleElement.id = titleId;
descElement.parentNode.insertBefore(titleElement, descElement);
chart.renderTo.setAttribute('role', 'region');
chart.container.setAttribute('aria-details', hiddenSectionId);
chart.renderTo.setAttribute('aria-label', 'Interactive chart. ' + chartTitle +
'. Use up and down arrows to navigate with most screen readers.');
// Set screen reader properties on export menu
if (chart.exportSVGElements && chart.exportSVGElements[0] && chart.exportSVGElements[0].element) {
var oldExportCallback = chart.exportSVGElements[0].element.onclick,
parent = chart.exportSVGElements[0].element.parentNode;
chart.exportSVGElements[0].element.onclick = function() {
oldExportCallback.apply(this, Array.prototype.slice.call(arguments));
chart.addAccessibleContextMenuAttribs();
chart.highlightExportItem(0);
};
chart.exportSVGElements[0].element.setAttribute('role', 'button');
chart.exportSVGElements[0].element.setAttribute('aria-label', 'View export menu');
exportGroupElement.appendChild(chart.exportSVGElements[0].element);
exportGroupElement.setAttribute('role', 'region');
exportGroupElement.setAttribute('aria-label', 'Chart export menu');
parent.appendChild(exportGroupElement);
}
// Set screen reader properties on input boxes for range selector. We need to do this regardless of whether or not these are visible, as they are
// by default part of the page's tabindex unless we set them to -1.
if (chart.rangeSelector) {
each(['minInput', 'maxInput'], function(key, i) {
if (chart.rangeSelector[key]) {
chart.rangeSelector[key].setAttribute('tabindex', '-1');
chart.rangeSelector[key].setAttribute('role', 'textbox');
chart.rangeSelector[key].setAttribute('aria-label', 'Select ' + (i ? 'end' : 'start') + ' date.');
}
});
}
// Hide text elements from screen readers
each(textElements, function(el) {
el.setAttribute('aria-hidden', 'true');
});
// Add top-secret screen reader region
chart.addScreenReaderRegion(hiddenSectionId, tableId);
// Enable keyboard navigation
if (a11yOptions.keyboardNavigation) {
chart.addKeyboardNavEvents();
}
/* Wrap table functionality from export-csv */
// Keep track of columns
merge(true, options.exporting, {
csv: {
columnHeaderFormatter: function(series, key, keyLength) {
var prevCol = topLevelColumns[topLevelColumns.length - 1];
if (keyLength > 1) {
// We need multiple levels of column headers
// Populate a list of column headers to add in addition to the ones added by export-csv
if ((prevCol && prevCol.text) !== series.name) {
topLevelColumns.push({
text: series.name,
span: keyLength
});
}
}
if (oldColumnHeaderFormatter) {
return oldColumnHeaderFormatter.call(this, series, key, keyLength);
}
return keyLength > 1 ? key : series.name;
}
}
});
// Add ID and title/caption to table HTML
H.wrap(chart, 'getTable', function(proceed) {
return proceed.apply(this, Array.prototype.slice.call(arguments, 1))
.replace('<table>', '<table id="' + tableId + '" summary="Table representation of chart"><caption>' + chartTitle + '</caption>');
});
// Add accessibility attributes and top level columns
H.wrap(chart, 'viewData', function(proceed) {
if (!this.insertedTable) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
var table = doc.getElementById(tableId),
body = table.getElementsByTagName('tbody')[0],
firstRow = body.firstChild.children,
columnHeaderRow = '<tr><td></td>',
cell,
newCell;
// Make table focusable by script
table.setAttribute('tabindex', '-1');
// Create row headers
each(body.children, function(el) {
cell = el.firstChild;
newCell = doc.createElement('th');
newCell.setAttribute('scope', 'row');
newCell.innerHTML = cell.innerHTML;
cell.parentNode.replaceChild(newCell, cell);
});
// Set scope for column headers
each(firstRow, function(el) {
if (el.tagName === 'TH') {
el.setAttribute('scope', 'col');
}
});
// Add top level columns
if (topLevelColumns.length) {
each(topLevelColumns, function(col) {
columnHeaderRow += '<th scope="col" colspan="' + col.span + '">' + col.text + '</th>';
});
body.insertAdjacentHTML('afterbegin', columnHeaderRow);
}
}
});
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
(c) 2009-2017 Torstein Honsi
License: www.highcharts.com/license
*/
(function(n){"object"===typeof module&&module.exports?module.exports=n:n(Highcharts)})(function(n){(function(f){var q=f.defined,k=f.isNumber,n=f.inArray,v=f.isArray,w=f.merge,B=f.Chart,x=f.extend,C=f.each,r,D;D=["path","rect","circle"];r={top:0,left:0,center:.5,middle:.5,bottom:1,right:1};var E=function(){this.init.apply(this,arguments)};E.prototype={init:function(a,d){var c=d.shape&&d.shape.type;this.chart=a;var b;b={xAxis:0,yAxis:0,title:{style:{},text:"",x:0,y:0},shape:{params:{stroke:"#000000",
fill:"transparent",strokeWidth:2}}};a={circle:{params:{x:0,y:0}}};a[c]&&(b.shape=w(b.shape,a[c]));this.options=w({},b,d)},render:function(a){var d=this.chart,c=this.chart.renderer,b=this.group,f=this.title,e=this.shape,h=this.options,k=h.title,p=h.shape;b||(b=this.group=c.g());!e&&p&&-1!==n(p.type,D)&&(e=this.shape=c[h.shape.type](p.params),e.add(b));!f&&k&&(f=this.title=c.label(k),f.add(b));b.add(d.annotations.group);this.linkObjects();!1!==a&&this.redraw()},redraw:function(){var a=this.options,
d=this.chart,c=this.group,b=this.title,F=this.shape,e=this.linkedObject,h=d.xAxis[a.xAxis],d=d.yAxis[a.yAxis],y=a.width,p=a.height,z=r[a.anchorY],A=r[a.anchorX],t,l,g,u;e&&(t=e instanceof f.Point?"point":e instanceof f.Series?"series":null,"point"===t?(a.xValue=e.x,a.yValue=e.y,l=e.series):"series"===t&&(l=e),c.visibility!==l.group.visibility&&c.attr({visibility:l.group.visibility}));e=q(a.xValue)?h.toPixels(a.xValue+h.minPointOffset)-h.minPixelPadding:a.x;l=q(a.yValue)?d.toPixels(a.yValue):a.y;if(k(e)&&
k(l)){b&&(b.attr(a.title),b.css(a.title.style));if(F){b=x({},a.shape.params);if("values"===a.units){for(g in b)-1<n(g,["width","x"])?b[g]=h.translate(b[g]):-1<n(g,["height","y"])&&(b[g]=d.translate(b[g]));b.width&&(b.width-=h.toPixels(0)-h.left);b.x&&(b.x+=h.minPixelPadding);if("path"===a.shape.type){g=b.d;t=e;for(var v=l,w=g.length,m=0;m<w;)k(g[m])&&k(g[m+1])?(g[m]=h.toPixels(g[m])-t,g[m+1]=d.toPixels(g[m+1])-v,m+=2):m+=1}}"circle"===a.shape.type&&(b.x+=b.r,b.y+=b.r);F.attr(b)}c.bBox=null;k(y)||
(u=c.getBBox(),y=u.width);k(p)||(u||(u=c.getBBox()),p=u.height);k(A)||(A=r.center);k(z)||(z=r.center);e-=y*A;l-=p*z;q(c.translateX)&&q(c.translateY)?c.animate({translateX:e,translateY:l}):c.translate(e,l)}},destroy:function(){var a=this,d=this.chart.annotations.allItems,c=d.indexOf(a);-1<c&&d.splice(c,1);C(["title","shape","group"],function(b){a[b]&&(a[b].destroy(),a[b]=null)});a.group=a.title=a.shape=a.chart=a.options=null},update:function(a,d){x(this.options,a);this.linkObjects();this.render(d)},
linkObjects:function(){var a=this.chart,d=this.linkedObject,c=d&&(d.id||d.options.id),b=this.options.linkedTo;q(b)?q(d)&&b===c||(this.linkedObject=a.get(b)):this.linkedObject=null}};x(B.prototype,{annotations:{add:function(a,d){var c=this.allItems,b=this.chart,f,e;v(a)||(a=[a]);for(e=a.length;e--;)f=new E(b,a[e]),c.push(f),f.render(d)},redraw:function(){C(this.allItems,function(a){a.redraw()})}}});B.prototype.callbacks.push(function(a){var d=a.options.annotations,c;c=a.renderer.g("annotations");c.attr({zIndex:7});
c.add();a.annotations.allItems=[];a.annotations.chart=a;a.annotations.group=c;v(d)&&0<d.length&&a.annotations.add(a.options.annotations);f.addEvent(a,"redraw",function(){a.annotations.redraw()})})})(n)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var defined = H.defined,
isNumber = H.isNumber,
inArray = H.inArray,
isArray = H.isArray,
merge = H.merge,
Chart = H.Chart,
extend = H.extend,
each = H.each;
var ALIGN_FACTOR,
ALLOWED_SHAPES;
ALLOWED_SHAPES = ['path', 'rect', 'circle'];
ALIGN_FACTOR = {
top: 0,
left: 0,
center: 0.5,
middle: 0.5,
bottom: 1,
right: 1
};
function defaultOptions(shapeType) {
var shapeOptions,
options;
options = {
xAxis: 0,
yAxis: 0,
title: {
style: {},
text: '',
x: 0,
y: 0
},
shape: {
params: {
stroke: '#000000',
fill: 'transparent',
strokeWidth: 2
}
}
};
shapeOptions = {
circle: {
params: {
x: 0,
y: 0
}
}
};
if (shapeOptions[shapeType]) {
options.shape = merge(options.shape, shapeOptions[shapeType]);
}
return options;
}
function translatePath(d, xAxis, yAxis, xOffset, yOffset) {
var len = d.length,
i = 0;
while (i < len) {
if (isNumber(d[i]) && isNumber(d[i + 1])) {
d[i] = xAxis.toPixels(d[i]) - xOffset;
d[i + 1] = yAxis.toPixels(d[i + 1]) - yOffset;
i += 2;
} else {
i += 1;
}
}
return d;
}
// Define annotation prototype
var Annotation = function() {
this.init.apply(this, arguments);
};
Annotation.prototype = {
/*
* Initialize the annotation
*/
init: function(chart, options) {
var shapeType = options.shape && options.shape.type;
this.chart = chart;
this.options = merge({}, defaultOptions(shapeType), options);
},
/*
* Render the annotation
*/
render: function(redraw) {
var annotation = this,
chart = this.chart,
renderer = annotation.chart.renderer,
group = annotation.group,
title = annotation.title,
shape = annotation.shape,
options = annotation.options,
titleOptions = options.title,
shapeOptions = options.shape;
if (!group) {
group = annotation.group = renderer.g();
}
if (!shape && shapeOptions && inArray(shapeOptions.type, ALLOWED_SHAPES) !== -1) {
shape = annotation.shape = renderer[options.shape.type](shapeOptions.params);
shape.add(group);
}
if (!title && titleOptions) {
title = annotation.title = renderer.label(titleOptions);
title.add(group);
}
group.add(chart.annotations.group);
// link annotations to point or series
annotation.linkObjects();
if (redraw !== false) {
annotation.redraw();
}
},
/*
* Redraw the annotation title or shape after options update
*/
redraw: function() {
var options = this.options,
chart = this.chart,
group = this.group,
title = this.title,
shape = this.shape,
linkedTo = this.linkedObject,
xAxis = chart.xAxis[options.xAxis],
yAxis = chart.yAxis[options.yAxis],
width = options.width,
height = options.height,
anchorY = ALIGN_FACTOR[options.anchorY],
anchorX = ALIGN_FACTOR[options.anchorX],
shapeParams,
linkType,
series,
param,
bbox,
x,
y;
if (linkedTo) {
linkType = (linkedTo instanceof H.Point) ? 'point' :
(linkedTo instanceof H.Series) ? 'series' : null;
if (linkType === 'point') {
options.xValue = linkedTo.x;
options.yValue = linkedTo.y;
series = linkedTo.series;
} else if (linkType === 'series') {
series = linkedTo;
}
if (group.visibility !== series.group.visibility) {
group.attr({
visibility: series.group.visibility
});
}
}
// Based on given options find annotation pixel position
x = (defined(options.xValue) ? xAxis.toPixels(options.xValue + xAxis.minPointOffset) - xAxis.minPixelPadding : options.x);
y = defined(options.yValue) ? yAxis.toPixels(options.yValue) : options.y;
if (!isNumber(x) || !isNumber(y)) {
return;
}
if (title) {
title.attr(options.title);
title.css(options.title.style);
}
if (shape) {
shapeParams = extend({}, options.shape.params);
if (options.units === 'values') {
for (param in shapeParams) {
if (inArray(param, ['width', 'x']) > -1) {
shapeParams[param] = xAxis.translate(shapeParams[param]);
} else if (inArray(param, ['height', 'y']) > -1) {
shapeParams[param] = yAxis.translate(shapeParams[param]);
}
}
if (shapeParams.width) {
shapeParams.width -= xAxis.toPixels(0) - xAxis.left;
}
if (shapeParams.x) {
shapeParams.x += xAxis.minPixelPadding;
}
if (options.shape.type === 'path') {
translatePath(shapeParams.d, xAxis, yAxis, x, y);
}
}
// move the center of the circle to shape x/y
if (options.shape.type === 'circle') {
shapeParams.x += shapeParams.r;
shapeParams.y += shapeParams.r;
}
shape.attr(shapeParams);
}
group.bBox = null;
// If annotation width or height is not defined in options use bounding box size
if (!isNumber(width)) {
bbox = group.getBBox();
width = bbox.width;
}
if (!isNumber(height)) {
// get bbox only if it wasn't set before
if (!bbox) {
bbox = group.getBBox();
}
height = bbox.height;
}
// Calculate anchor point
if (!isNumber(anchorX)) {
anchorX = ALIGN_FACTOR.center;
}
if (!isNumber(anchorY)) {
anchorY = ALIGN_FACTOR.center;
}
// Translate group according to its dimension and anchor point
x = x - width * anchorX;
y = y - height * anchorY;
if (defined(group.translateX) && defined(group.translateY)) {
group.animate({
translateX: x,
translateY: y
});
} else {
group.translate(x, y);
}
},
/*
* Destroy the annotation
*/
destroy: function() {
var annotation = this,
chart = this.chart,
allItems = chart.annotations.allItems,
index = allItems.indexOf(annotation);
if (index > -1) {
allItems.splice(index, 1);
}
each(['title', 'shape', 'group'], function(element) {
if (annotation[element]) {
annotation[element].destroy();
annotation[element] = null;
}
});
annotation.group = annotation.title = annotation.shape = annotation.chart = annotation.options = null;
},
/*
* Update the annotation with a given options
*/
update: function(options, redraw) {
extend(this.options, options);
// update link to point or series
this.linkObjects();
this.render(redraw);
},
linkObjects: function() {
var annotation = this,
chart = annotation.chart,
linkedTo = annotation.linkedObject,
linkedId = linkedTo && (linkedTo.id || linkedTo.options.id),
options = annotation.options,
id = options.linkedTo;
if (!defined(id)) {
annotation.linkedObject = null;
} else if (!defined(linkedTo) || id !== linkedId) {
annotation.linkedObject = chart.get(id);
}
}
};
// Add annotations methods to chart prototype
extend(Chart.prototype, {
annotations: {
/*
* Unified method for adding annotations to the chart
*/
add: function(options, redraw) {
var annotations = this.allItems,
chart = this.chart,
item,
len;
if (!isArray(options)) {
options = [options];
}
len = options.length;
while (len--) {
item = new Annotation(chart, options[len]);
annotations.push(item);
item.render(redraw);
}
},
/**
* Redraw all annotations, method used in chart events
*/
redraw: function() {
each(this.allItems, function(annotation) {
annotation.redraw();
});
}
}
});
// Initialize on chart load
Chart.prototype.callbacks.push(function(chart) {
var options = chart.options.annotations,
group;
group = chart.renderer.g('annotations');
group.attr({
zIndex: 7
});
group.add();
// initialize empty array for annotations
chart.annotations.allItems = [];
// link chart object to annotations
chart.annotations.chart = chart;
// link annotations group element to the chart
chart.annotations.group = group;
if (isArray(options) && options.length > 0) {
chart.annotations.add(chart.options.annotations);
}
// update annotations after chart redraw
H.addEvent(chart, 'redraw', function() {
chart.annotations.redraw();
});
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Boost module
(c) 2010-2017 Highsoft AS
Author: Torstein Honsi
License: www.highcharts.com/license
*/
(function(p){"object"===typeof module&&module.exports?module.exports=p:p(Highcharts)})(function(p){(function(d){function p(a,b,c,g,e){e=e||0;g=g||5E4;for(var d=e+g,f=!0;f&&e<d&&e<a.length;)f=b(a[e],e),e+=1;f&&(e<a.length?setTimeout(function(){p(a,b,c,g,e)}):c&&c())}function x(a){return a.series.length>=((a.options.boost?a.options.boost.seriesThreshold:0)||a.options.chart.seriesBoostThreshold||10)}var A=d.win.document,Z=function(){},aa=d.Color,m=d.Series,k=d.seriesTypes,w=d.each,B=d.extend,y=d.addEvent,
ba=d.fireEvent,r=d.isNumber,ca=d.merge,da=d.pick,n=d.wrap,L;d.initCanvasBoost=function(){d.seriesTypes.heatmap&&d.wrap(d.seriesTypes.heatmap.prototype,"drawPoints",function(){var a=this.getContext();a?(w(this.points,function(b){var c=b.plotY;void 0===c||isNaN(c)||null===b.y||(c=b.shapeArgs,b=b.pointAttr&&b.pointAttr[""]||b.series.pointAttribs(b),a.fillStyle=b.fill,a.fillRect(c.x,c.y,c.width,c.height))}),this.canvasToSVG()):this.chart.showLoading("Your browser doesn't support HTML5 canvas, \x3cbr\x3eplease use a modern browser")});
d.extend(m.prototype,{directTouch:!1,pointRange:0,allowDG:!1,hasExtremes:function(a){var b=this.options,c=this.xAxis&&this.xAxis.options,g=this.yAxis&&this.yAxis.options;return b.data.length>(b.boostThreshold||Number.MAX_VALUE)&&r(g.min)&&r(g.max)&&(!a||r(c.min)&&r(c.max))},destroyGraphics:function(){var a=this,b=this.points,c,g;if(b)for(g=0;g<b.length;g+=1)(c=b[g])&&c.graphic&&(c.graphic=c.graphic.destroy());w(["graph","area","tracker"],function(c){a[c]&&(a[c]=a[c].destroy())})},getContext:function(){var a=
this.chart,b=a.chartWidth,c=a.chartHeight,g=this.group,e=this,d,f=function(a,c,b,e,g,d,f){a.call(this,b,c,e,g,d,f)};x(a)&&(e=a,g=a.seriesGroup);d=e.ctx;e.canvas||(e.canvas=A.createElement("canvas"),e.image=a.renderer.image("",0,0,b,c).add(g),e.ctx=d=e.canvas.getContext("2d"),a.inverted&&w(["moveTo","lineTo","rect","arc"],function(a){n(d,a,f)}),e.boostClipRect=a.renderer.clipRect(a.plotLeft,a.plotTop,a.plotWidth,a.chartHeight),e.image.clip(e.boostClipRect));e.canvas.width!==b&&(e.canvas.width=b);e.canvas.height!==
c&&(e.canvas.height=c);e.image.attr({x:0,y:0,width:b,height:c,style:"pointer-events: none"});e.boostClipRect.attr({x:0,y:0,width:a.plotWidth,height:a.chartHeight});return d},canvasToSVG:function(){x(this.chart)?this.image&&this.image.attr({href:""}):this.image.attr({href:this.canvas.toDataURL("image/png")})},cvsLineTo:function(a,b,c){a.lineTo(b,c)},renderCanvas:function(){var a=this,b=a.options,c=a.chart,g=this.xAxis,e=this.yAxis,k=(c.options.boost||{}).timeRendering||!1,f,t=0,m=a.processedXData,
w=a.processedYData,n=b.data,l=g.getExtremes(),C=l.min,D=l.max,l=e.getExtremes(),x=l.min,y=l.max,M={},E,A=!!a.sampling,N,F=b.marker&&b.marker.radius,O=this.cvsDrawPoint,G=b.lineWidth?this.cvsLineTo:!1,P=F&&1>=F?this.cvsMarkerSquare:this.cvsMarkerCircle,ea=this.cvsStrokeBatch||1E3,fa=!1!==b.enableMouseTracking,Q,l=b.threshold,u=e.getThreshold(l),R=r(l),S=u,ga=this.fill,T=a.pointArrayMap&&"low,high"===a.pointArrayMap.join(","),U=!!b.stacking,ha=a.cropStart||0,l=c.options.loading,ia=a.requireSorting,
V,ja=b.connectNulls,W=!m,H,I,v,z,J,q=U?a.data:m||n,ka=a.fillOpacity?(new aa(a.color)).setOpacity(da(b.fillOpacity,.75)).get():a.color,X=function(){ga?(f.fillStyle=ka,f.fill()):(f.strokeStyle=a.color,f.lineWidth=b.lineWidth,f.stroke())},Y=function(b,e,g,d){0===t&&(f.beginPath(),G&&(f.lineJoin="round"));c.scroller&&"highcharts-navigator-series"===a.options.className?(e+=c.scroller.top,g&&(g+=c.scroller.top)):e+=c.plotTop;b+=c.plotLeft;V?f.moveTo(b,e):O?O(f,b,e,g,Q):G?G(f,b,e):P&&P.call(a,f,b,e,F,d);
t+=1;t===ea&&(X(),t=0);Q={clientX:b,plotY:e,yBottom:g}},K=function(a,b,d){J=a+","+b;fa&&!M[J]&&(M[J]=!0,c.inverted&&(a=g.len-a,b=e.len-b),N.push({clientX:a,plotX:a,plotY:b,i:ha+d}))};(this.points||this.graph)&&this.destroyGraphics();a.plotGroup("group","series",a.visible?"visible":"hidden",b.zIndex,c.seriesGroup);a.markerGroup=a.group;N=this.points=[];f=this.getContext();a.buildKDTree=Z;99999<n.length&&(c.options.loading=ca(l,{labelStyle:{backgroundColor:d.color("#ffffff").setOpacity(.75).get(),padding:"1em",
borderRadius:"0.5em"},style:{backgroundColor:"none",opacity:1}}),clearTimeout(L),c.showLoading("Drawing..."),c.options.loading=l);k&&console.time("canvas rendering");p(q,function(b,d){var f,h,k,l=!1,p=!1,m=!1,n=!1,r="undefined"===typeof c.index,t=!0;if(!r){W?(f=b[0],h=b[1],q[d+1]&&(m=q[d+1][0]),q[d-1]&&(n=q[d-1][0])):(f=b,h=w[d],q[d+1]&&(m=q[d+1]),q[d-1]&&(n=q[d-1]));m&&m>=C&&m<=D&&(l=!0);n&&n>=C&&n<=D&&(p=!0);T?(W&&(h=b.slice(1,3)),k=h[0],h=h[1]):U&&(f=b.x,h=b.stackY,k=h-b.y);b=null===h;ia||(t=h>=
x&&h<=y);if(!b&&(f>=C&&f<=D&&t||l||p))if(f=Math.round(g.toPixels(f,!0)),A){if(void 0===v||f===E){T||(k=h);if(void 0===z||h>I)I=h,z=d;if(void 0===v||k<H)H=k,v=d}f!==E&&(void 0!==v&&(h=e.toPixels(I,!0),u=e.toPixels(H,!0),Y(f,R?Math.min(h,S):h,R?Math.max(u,S):u,d),K(f,h,z),u!==h&&K(f,u,v)),v=z=void 0,E=f)}else h=Math.round(e.toPixels(h,!0)),Y(f,h,u,d),K(f,h,d);V=b&&!ja;0===d%5E4&&a.canvasToSVG()}return!r},function(){var b=c.loadingDiv,e=c.loadingShown;X();a.canvasToSVG();k&&console.timeEnd("canvas rendering");
ba(a,"renderedCanvas");e&&(B(b.style,{transition:"opacity 250ms",opacity:0}),c.loadingShown=!1,L=setTimeout(function(){b.parentNode&&b.parentNode.removeChild(b);c.loadingDiv=c.loadingSpan=null},250));a.directTouch=!1;a.options.stickyTracking=!0;delete a.buildKDTree;a.buildKDTree()},c.renderer.forExport?Number.MAX_VALUE:void 0)}});n(m.prototype,"setData",function(a){this.hasExtremes&&this.hasExtremes(!0)&&"heatmap"!==this.type||a.apply(this,Array.prototype.slice.call(arguments,1))});n(m.prototype,
"processData",function(a){this.hasExtremes&&this.hasExtremes(!0)&&"heatmap"!==this.type||a.apply(this,Array.prototype.slice.call(arguments,1))});k.scatter.prototype.cvsMarkerCircle=function(a,b,c,d){a.moveTo(b,c);a.arc(b,c,d,0,2*Math.PI,!1)};k.scatter.prototype.cvsMarkerSquare=function(a,b,c,d){a.rect(b-d,c-d,2*d,2*d)};k.scatter.prototype.fill=!0;k.bubble&&(k.bubble.prototype.cvsMarkerCircle=function(a,b,c,d,e){a.moveTo(b,c);a.arc(b,c,this.radii&&this.radii[e],0,2*Math.PI,!1)},k.bubble.prototype.cvsStrokeBatch=
1);B(k.area.prototype,{cvsDrawPoint:function(a,b,c,d,e){e&&b!==e.clientX&&(a.moveTo(e.clientX,e.yBottom),a.lineTo(e.clientX,e.plotY),a.lineTo(b,c),a.lineTo(b,d))},fill:!0,fillOpacity:!0,sampling:!0});B(k.column.prototype,{cvsDrawPoint:function(a,b,c,d){a.rect(b-1,c,1,d-c)},fill:!0,sampling:!0});d.Chart.prototype.callbacks.push(function(a){y(a,"predraw",function(){a.image&&a.image.attr({href:""});a.canvas&&a.canvas.getContext("2d").clearRect(0,0,a.canvas.width,a.canvas.height)});y(a,"render",function(){a.image&&
a.canvas&&a.image.attr({href:a.canvas.toDataURL("image/png")})})})}})(p)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 | 1 1 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Boost module
*
* (c) 2010-2017 Highsoft AS
* Author: Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* License: www.highcharts.com/license
* Author: Torstein Honsi, Christer Vasseng
*
* This is an experimental Highcharts module that draws long data series on a canvas
* in order to increase performance of the initial load time and tooltip responsiveness.
*
* Compatible with HTML5 canvas compatible browsers (not IE < 9).
*
*
*
* Development plan
* - Column range.
* - Heatmap. Modify the heatmap-canvas demo so that it uses this module.
* - Treemap.
* - Check how it works with Highstock and data grouping. Currently it only works when navigator.adaptToUpdatedData
* is false. It is also recommended to set scrollbar.liveRedraw to false.
* - Check inverted charts.
* - Check reversed axes.
* - Chart callback should be async after last series is drawn. (But not necessarily, we don't do
that with initial series animation).
* - Cache full-size image so we don't have to redraw on hide/show and zoom up. But k-d-tree still
* needs to be built.
* - Test IE9 and IE10.
* - Stacking is not perhaps not correct since it doesn't use the translation given in
* the translate method. If this gets to complicated, a possible way out would be to
* have a simplified renderCanvas method that simply draws the areaPath on a canvas.
*
* If this module is taken in as part of the core
* - All the loading logic should be merged with core. Update styles in the core.
* - Most of the method wraps should probably be added directly in parent methods.
*
* Notes for boost mode
* - Area lines are not drawn
* - Point markers are not drawn on line-type series
* - Lines are not drawn on scatter charts
* - Zones and negativeColor don't work
* - Initial point colors aren't rendered
* - Columns are always one pixel wide. Don't set the threshold too low.
*
* Optimizing tips for users
* - For scatter plots, use a marker.radius of 1 or less. It results in a rectangle being drawn, which is
* considerably faster than a circle.
* - Set extremes (min, max) explicitly on the axes in order for Highcharts to avoid computing extremes.
* - Set enableMouseTracking to false on the series to improve total rendering time.
* - The default threshold is set based on one series. If you have multiple, dense series, the combined
* number of points drawn gets higher, and you may want to set the threshold lower in order to
* use optimizations.
*/
var win = H.win,
doc = win.document,
noop = function() {},
Color = H.Color,
Series = H.Series,
seriesTypes = H.seriesTypes,
each = H.each,
extend = H.extend,
addEvent = H.addEvent,
fireEvent = H.fireEvent,
isNumber = H.isNumber,
merge = H.merge,
pick = H.pick,
wrap = H.wrap,
CHUNK_SIZE = 50000,
destroyLoadingDiv;
function eachAsync(arr, fn, finalFunc, chunkSize, i) {
i = i || 0;
chunkSize = chunkSize || CHUNK_SIZE;
var threshold = i + chunkSize,
proceed = true;
while (proceed && i < threshold && i < arr.length) {
proceed = fn(arr[i], i);
i = i + 1;
}
if (proceed) {
if (i < arr.length) {
setTimeout(function() {
eachAsync(arr, fn, finalFunc, chunkSize, i);
});
} else if (finalFunc) {
finalFunc();
}
}
}
/*
* Returns true if the chart is in series boost mode
* @param chart {Highchart.Chart} - the chart to check
* @returns {Boolean} - true if the chart is in series boost mode
*/
function isChartSeriesBoosting(chart) {
var threshold = (chart.options.boost ? chart.options.boost.seriesThreshold : 0) ||
chart.options.chart.seriesBoostThreshold ||
10;
return chart.series.length >= threshold;
}
H.initCanvasBoost = function() {
if (H.seriesTypes.heatmap) {
H.wrap(H.seriesTypes.heatmap.prototype, 'drawPoints', function() {
var ctx = this.getContext();
if (ctx) {
// draw the columns
each(this.points, function(point) {
var plotY = point.plotY,
shapeArgs,
pointAttr;
if (plotY !== undefined && !isNaN(plotY) && point.y !== null) {
shapeArgs = point.shapeArgs;
pointAttr = (point.pointAttr && point.pointAttr['']) || point.series.pointAttribs(point);
ctx.fillStyle = pointAttr.fill;
ctx.fillRect(shapeArgs.x, shapeArgs.y, shapeArgs.width, shapeArgs.height);
}
});
this.canvasToSVG();
} else {
this.chart.showLoading('Your browser doesn\'t support HTML5 canvas, <br>please use a modern browser');
// Uncomment this to provide low-level (slow) support in oldIE. It will cause script errors on
// charts with more than a few thousand points.
// arguments[0].call(this);
}
});
}
/**
* Override a bunch of methods the same way. If the number of points is below the threshold,
* run the original method. If not, check for a canvas version or do nothing.
*/
// each(['translate', 'generatePoints', 'drawTracker', 'drawPoints', 'render'], function (method) {
// function branch(proceed) {
// var letItPass = this.options.stacking && (method === 'translate' || method === 'generatePoints');
// if (((this.processedXData || this.options.data).length < (this.options.boostThreshold || Number.MAX_VALUE) ||
// letItPass) || !isChartSeriesBoosting(this.chart)) {
// // Clear image
// if (method === 'render' && this.image) {
// this.image.attr({ href: '' });
// this.animate = null; // We're zooming in, don't run animation
// }
// proceed.call(this);
// // If a canvas version of the method exists, like renderCanvas(), run
// } else if (this[method + 'Canvas']) {
// this[method + 'Canvas']();
// }
// }
// wrap(Series.prototype, method, branch);
// // A special case for some types - its translate method is already wrapped
// if (method === 'translate') {
// each(['arearange', 'bubble', 'column'], function (type) {
// if (seriesTypes[type]) {
// wrap(seriesTypes[type].prototype, method, branch);
// }
// });
// }
// });
H.extend(Series.prototype, {
directTouch: false,
pointRange: 0,
allowDG: false, // No data grouping, let boost handle large data
hasExtremes: function(checkX) {
var options = this.options,
data = options.data,
xAxis = this.xAxis && this.xAxis.options,
yAxis = this.yAxis && this.yAxis.options;
return data.length > (options.boostThreshold || Number.MAX_VALUE) && isNumber(yAxis.min) && isNumber(yAxis.max) &&
(!checkX || (isNumber(xAxis.min) && isNumber(xAxis.max)));
},
/**
* If implemented in the core, parts of this can probably be shared with other similar
* methods in Highcharts.
*/
destroyGraphics: function() {
var series = this,
points = this.points,
point,
i;
if (points) {
for (i = 0; i < points.length; i = i + 1) {
point = points[i];
if (point && point.graphic) {
point.graphic = point.graphic.destroy();
}
}
}
each(['graph', 'area', 'tracker'], function(prop) {
if (series[prop]) {
series[prop] = series[prop].destroy();
}
});
},
/**
* Create a hidden canvas to draw the graph on. The contents is later copied over
* to an SVG image element.
*/
getContext: function() {
var chart = this.chart,
width = chart.chartWidth,
height = chart.chartHeight,
targetGroup = this.group,
target = this,
ctx,
swapXY = function(proceed, x, y, a, b, c, d) {
proceed.call(this, y, x, a, b, c, d);
};
if (isChartSeriesBoosting(chart)) {
target = chart;
targetGroup = chart.seriesGroup;
}
ctx = target.ctx;
if (!target.canvas) {
target.canvas = doc.createElement('canvas');
target.image = chart.renderer.image(
'',
0,
0,
width,
height
).add(targetGroup);
target.ctx = ctx = target.canvas.getContext('2d');
if (chart.inverted) {
each(['moveTo', 'lineTo', 'rect', 'arc'], function(fn) {
wrap(ctx, fn, swapXY);
});
}
target.boostClipRect = chart.renderer.clipRect(
chart.plotLeft,
chart.plotTop,
chart.plotWidth,
chart.chartHeight
);
target.image.clip(target.boostClipRect);
} else if (!(target instanceof H.Chart)) {
//ctx.clearRect(0, 0, width, height);
}
if (target.canvas.width !== width) {
target.canvas.width = width;
}
if (target.canvas.height !== height) {
target.canvas.height = height;
}
target.image.attr({
x: 0,
y: 0,
width: width,
height: height,
style: 'pointer-events: none'
});
target.boostClipRect.attr({
x: 0,
y: 0,
width: chart.plotWidth,
height: chart.chartHeight
});
return ctx;
},
/**
* Draw the canvas image inside an SVG image
*/
canvasToSVG: function() {
if (!isChartSeriesBoosting(this.chart)) {
this.image.attr({
href: this.canvas.toDataURL('image/png')
});
} else if (this.image) {
this.image.attr({
href: ''
});
}
},
cvsLineTo: function(ctx, clientX, plotY) {
ctx.lineTo(clientX, plotY);
},
renderCanvas: function() {
var series = this,
options = series.options,
chart = series.chart,
xAxis = this.xAxis,
yAxis = this.yAxis,
activeBoostSettings = chart.options.boost || {},
boostSettings = {
timeRendering: activeBoostSettings.timeRendering || false,
timeSeriesProcessing: activeBoostSettings.timeSeriesProcessing || false,
timeSetup: activeBoostSettings.timeSetup || false
},
ctx,
c = 0,
xData = series.processedXData,
yData = series.processedYData,
rawData = options.data,
xExtremes = xAxis.getExtremes(),
xMin = xExtremes.min,
xMax = xExtremes.max,
yExtremes = yAxis.getExtremes(),
yMin = yExtremes.min,
yMax = yExtremes.max,
pointTaken = {},
lastClientX,
sampling = !!series.sampling,
points,
r = options.marker && options.marker.radius,
cvsDrawPoint = this.cvsDrawPoint,
cvsLineTo = options.lineWidth ? this.cvsLineTo : false,
cvsMarker = r && r <= 1 ?
this.cvsMarkerSquare :
this.cvsMarkerCircle,
strokeBatch = this.cvsStrokeBatch || 1000,
enableMouseTracking = options.enableMouseTracking !== false,
lastPoint,
threshold = options.threshold,
yBottom = yAxis.getThreshold(threshold),
hasThreshold = isNumber(threshold),
translatedThreshold = yBottom,
doFill = this.fill,
isRange = series.pointArrayMap && series.pointArrayMap.join(',') === 'low,high',
isStacked = !!options.stacking,
cropStart = series.cropStart || 0,
loadingOptions = chart.options.loading,
requireSorting = series.requireSorting,
wasNull,
connectNulls = options.connectNulls,
useRaw = !xData,
minVal,
maxVal,
minI,
maxI,
kdIndex,
sdata = isStacked ? series.data : (xData || rawData),
fillColor = series.fillOpacity ?
new Color(series.color).setOpacity(pick(options.fillOpacity, 0.75)).get() :
series.color,
stroke = function() {
if (doFill) {
ctx.fillStyle = fillColor;
ctx.fill();
} else {
ctx.strokeStyle = series.color;
ctx.lineWidth = options.lineWidth;
ctx.stroke();
}
},
drawPoint = function(clientX, plotY, yBottom, i) {
if (c === 0) {
ctx.beginPath();
if (cvsLineTo) {
ctx.lineJoin = 'round';
}
}
if (chart.scroller && series.options.className === 'highcharts-navigator-series') {
plotY += chart.scroller.top;
if (yBottom) {
yBottom += chart.scroller.top;
}
} else {
plotY += chart.plotTop;
}
clientX += chart.plotLeft;
if (wasNull) {
ctx.moveTo(clientX, plotY);
} else {
if (cvsDrawPoint) {
cvsDrawPoint(ctx, clientX, plotY, yBottom, lastPoint);
} else if (cvsLineTo) {
cvsLineTo(ctx, clientX, plotY);
} else if (cvsMarker) {
cvsMarker.call(series, ctx, clientX, plotY, r, i);
}
}
// We need to stroke the line for every 1000 pixels. It will crash the browser
// memory use if we stroke too infrequently.
c = c + 1;
if (c === strokeBatch) {
stroke();
c = 0;
}
// Area charts need to keep track of the last point
lastPoint = {
clientX: clientX,
plotY: plotY,
yBottom: yBottom
};
},
addKDPoint = function(clientX, plotY, i) {
// Avoid more string concatination than required
kdIndex = clientX + ',' + plotY;
// The k-d tree requires series points. Reduce the amount of points, since the time to build the
// tree increases exponentially.
if (enableMouseTracking && !pointTaken[kdIndex]) {
pointTaken[kdIndex] = true;
if (chart.inverted) {
clientX = xAxis.len - clientX;
plotY = yAxis.len - plotY;
}
points.push({
clientX: clientX,
plotX: clientX,
plotY: plotY,
i: cropStart + i
});
}
};
// If we are zooming out from SVG mode, destroy the graphics
if (this.points || this.graph) {
this.destroyGraphics();
}
// The group
series.plotGroup(
'group',
'series',
series.visible ? 'visible' : 'hidden',
options.zIndex,
chart.seriesGroup
);
series.markerGroup = series.group;
// addEvent(series, 'destroy', function () {
// series.markerGroup = null;
// });
points = this.points = [];
ctx = this.getContext();
series.buildKDTree = noop; // Do not start building while drawing
// Display a loading indicator
if (rawData.length > 99999) {
chart.options.loading = merge(loadingOptions, {
labelStyle: {
backgroundColor: H.color('#ffffff').setOpacity(0.75).get(),
padding: '1em',
borderRadius: '0.5em'
},
style: {
backgroundColor: 'none',
opacity: 1
}
});
clearTimeout(destroyLoadingDiv);
chart.showLoading('Drawing...');
chart.options.loading = loadingOptions; // reset
}
if (boostSettings.timeRendering) {
console.time('canvas rendering'); // eslint-disable-line no-console
}
// Loop over the points
eachAsync(sdata, function(d, i) {
var x,
y,
clientX,
plotY,
isNull,
low,
isNextInside = false,
isPrevInside = false,
nx = false,
px = false,
chartDestroyed = typeof chart.index === 'undefined',
isYInside = true;
if (!chartDestroyed) {
if (useRaw) {
x = d[0];
y = d[1];
if (sdata[i + 1]) {
nx = sdata[i + 1][0];
}
if (sdata[i - 1]) {
px = sdata[i - 1][0];
}
} else {
x = d;
y = yData[i];
if (sdata[i + 1]) {
nx = sdata[i + 1];
}
if (sdata[i - 1]) {
px = sdata[i - 1];
}
}
if (nx && nx >= xMin && nx <= xMax) {
isNextInside = true;
}
if (px && px >= xMin && px <= xMax) {
isPrevInside = true;
}
// Resolve low and high for range series
if (isRange) {
if (useRaw) {
y = d.slice(1, 3);
}
low = y[0];
y = y[1];
} else if (isStacked) {
x = d.x;
y = d.stackY;
low = y - d.y;
}
isNull = y === null;
// Optimize for scatter zooming
if (!requireSorting) {
isYInside = y >= yMin && y <= yMax;
}
if (!isNull &&
(
(x >= xMin && x <= xMax && isYInside) ||
(isNextInside || isPrevInside)
)) {
clientX = Math.round(xAxis.toPixels(x, true));
if (sampling) {
if (minI === undefined || clientX === lastClientX) {
if (!isRange) {
low = y;
}
if (maxI === undefined || y > maxVal) {
maxVal = y;
maxI = i;
}
if (minI === undefined || low < minVal) {
minVal = low;
minI = i;
}
}
if (clientX !== lastClientX) { // Add points and reset
if (minI !== undefined) { // then maxI is also a number
plotY = yAxis.toPixels(maxVal, true);
yBottom = yAxis.toPixels(minVal, true);
drawPoint(
clientX,
hasThreshold ? Math.min(plotY, translatedThreshold) : plotY,
hasThreshold ? Math.max(yBottom, translatedThreshold) : yBottom,
i
);
addKDPoint(clientX, plotY, maxI);
if (yBottom !== plotY) {
addKDPoint(clientX, yBottom, minI);
}
}
minI = maxI = undefined;
lastClientX = clientX;
}
} else {
plotY = Math.round(yAxis.toPixels(y, true));
drawPoint(clientX, plotY, yBottom, i);
addKDPoint(clientX, plotY, i);
}
}
wasNull = isNull && !connectNulls;
if (i % CHUNK_SIZE === 0) {
series.canvasToSVG();
}
}
return !chartDestroyed;
}, function() {
var loadingDiv = chart.loadingDiv,
loadingShown = chart.loadingShown;
stroke();
series.canvasToSVG();
if (boostSettings.timeRendering) {
console.timeEnd('canvas rendering'); // eslint-disable-line no-console
}
fireEvent(series, 'renderedCanvas');
// Do not use chart.hideLoading, as it runs JS animation and will be blocked by buildKDTree.
// CSS animation looks good, but then it must be deleted in timeout. If we add the module to core,
// change hideLoading so we can skip this block.
if (loadingShown) {
extend(loadingDiv.style, {
transition: 'opacity 250ms',
opacity: 0
});
chart.loadingShown = false;
destroyLoadingDiv = setTimeout(function() {
if (loadingDiv.parentNode) { // In exporting it is falsy
loadingDiv.parentNode.removeChild(loadingDiv);
}
chart.loadingDiv = chart.loadingSpan = null;
}, 250);
}
// Pass tests in Pointer.
// Replace this with a single property, and replace when zooming in
// below boostThreshold.
series.directTouch = false;
series.options.stickyTracking = true;
delete series.buildKDTree; // Go back to prototype, ready to build
series.buildKDTree();
// Don't do async on export, the exportChart, getSVGForExport and getSVG methods are not chained for it.
}, chart.renderer.forExport ? Number.MAX_VALUE : undefined);
}
});
wrap(Series.prototype, 'setData', function(proceed) {
if (!this.hasExtremes || !this.hasExtremes(true) || this.type === 'heatmap') {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
}
});
wrap(Series.prototype, 'processData', function(proceed) {
if (!this.hasExtremes || !this.hasExtremes(true) || this.type === 'heatmap') {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
}
});
seriesTypes.scatter.prototype.cvsMarkerCircle = function(ctx, clientX, plotY, r) {
ctx.moveTo(clientX, plotY);
ctx.arc(clientX, plotY, r, 0, 2 * Math.PI, false);
};
// Rect is twice as fast as arc, should be used for small markers
seriesTypes.scatter.prototype.cvsMarkerSquare = function(ctx, clientX, plotY, r) {
ctx.rect(clientX - r, plotY - r, r * 2, r * 2);
};
seriesTypes.scatter.prototype.fill = true;
if (seriesTypes.bubble) {
seriesTypes.bubble.prototype.cvsMarkerCircle = function(ctx, clientX, plotY, r, i) {
ctx.moveTo(clientX, plotY);
ctx.arc(clientX, plotY, this.radii && this.radii[i], 0, 2 * Math.PI, false);
};
seriesTypes.bubble.prototype.cvsStrokeBatch = 1;
}
extend(seriesTypes.area.prototype, {
cvsDrawPoint: function(ctx, clientX, plotY, yBottom, lastPoint) {
if (lastPoint && clientX !== lastPoint.clientX) {
ctx.moveTo(lastPoint.clientX, lastPoint.yBottom);
ctx.lineTo(lastPoint.clientX, lastPoint.plotY);
ctx.lineTo(clientX, plotY);
ctx.lineTo(clientX, yBottom);
}
},
fill: true,
fillOpacity: true,
sampling: true
});
extend(seriesTypes.column.prototype, {
cvsDrawPoint: function(ctx, clientX, plotY, yBottom) {
ctx.rect(clientX - 1, plotY, 1, yBottom - plotY);
},
fill: true,
sampling: true
});
H.Chart.prototype.callbacks.push(function(chart) {
function canvasToSVG() {
if (chart.image && chart.canvas) {
chart.image.attr({
href: chart.canvas.toDataURL('image/png')
});
}
}
function clear() {
if (chart.image) {
chart.image.attr({
href: ''
});
}
if (chart.canvas) {
chart.canvas.getContext('2d').clearRect(
0,
0,
chart.canvas.width,
chart.canvas.height
);
}
}
addEvent(chart, 'predraw', clear);
addEvent(chart, 'render', canvasToSVG);
});
};
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 1 1 1 1 1 1 1 1 1 1 1 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Boost module
(c) 2010-2017 Highsoft AS
Author: Torstein Honsi
License: www.highcharts.com/license
*/
(function(H){"object"===typeof module&&module.exports?module.exports=H:H(Highcharts)})(function(H){(function(h){function w(a){return a.series.length>=D(a.options.boost&&a.options.boost.seriesThreshold,10)}function x(a){function c(){var a=Array.prototype.slice.call(arguments),c=-Number.MAX_VALUE;y(a,function(a){if("undefined"!==typeof a&&"undefined"!==typeof a.length&&0<a.length)return c=a.length,!0});return c}return w(a.chart)||c(a.processedXData,a.options.data,a.points)>=(a.options.boostThreshold||
Number.MAX_VALUE)}function H(a){function c(b,c){c=a.createShader("vertex"===c?a.VERTEX_SHADER:a.FRAGMENT_SHADER);a.shaderSource(c,b);a.compileShader(c);return a.getShaderParameter(c,a.COMPILE_STATUS)?c:!1}function d(){function d(b){return a.getUniformLocation(l,b)}var e=c("#version 100\nprecision highp float;\nattribute vec4 aVertexPosition;\nattribute vec4 aColor;\nvarying highp vec2 position;\nvarying highp vec4 vColor;\nuniform mat4 uPMatrix;\nuniform float pSize;\nuniform float translatedThreshold;\nuniform bool hasThreshold;\nuniform bool skipTranslation;\nuniform float xAxisTrans;\nuniform float xAxisMin;\nuniform float xAxisMinPad;\nuniform float xAxisPointRange;\nuniform float xAxisLen;\nuniform bool xAxisPostTranslate;\nuniform float xAxisOrdinalSlope;\nuniform float xAxisOrdinalOffset;\nuniform float xAxisPos;\nuniform bool xAxisCVSCoord;\nuniform float yAxisTrans;\nuniform float yAxisMin;\nuniform float yAxisMinPad;\nuniform float yAxisPointRange;\nuniform float yAxisLen;\nuniform bool yAxisPostTranslate;\nuniform float yAxisOrdinalSlope;\nuniform float yAxisOrdinalOffset;\nuniform float yAxisPos;\nuniform bool yAxisCVSCoord;\nuniform bool isBubble;\nuniform bool bubbleSizeByArea;\nuniform float bubbleZMin;\nuniform float bubbleZMax;\nuniform float bubbleZThreshold;\nuniform float bubbleMinSize;\nuniform float bubbleMaxSize;\nuniform bool bubbleSizeAbs;\nuniform bool isInverted;\nfloat bubbleRadius(){\nfloat value \x3d aVertexPosition.w;\nfloat zMax \x3d bubbleZMax;\nfloat zMin \x3d bubbleZMin;\nfloat radius \x3d 0.0;\nfloat pos \x3d 0.0;\nfloat zRange \x3d zMax - zMin;\nif (bubbleSizeAbs){\nvalue \x3d value - bubbleZThreshold;\nzMax \x3d max(zMax - bubbleZThreshold, zMin - bubbleZThreshold);\nzMin \x3d 0.0;\n}\nif (value \x3c zMin){\nradius \x3d bubbleZMin / 2.0 - 1.0;\n} else {\npos \x3d zRange \x3e 0.0 ? (value - zMin) / zRange : 0.5;\nif (bubbleSizeByArea \x26\x26 pos \x3e 0.0){\npos \x3d sqrt(pos);\n}\nradius \x3d ceil(bubbleMinSize + pos * (bubbleMaxSize - bubbleMinSize)) / 2.0;\n}\nreturn radius * 2.0;\n}\nfloat translate(float val,\nfloat pointPlacement,\nfloat localA,\nfloat localMin,\nfloat minPixelPadding,\nfloat pointRange,\nfloat len,\nbool cvsCoord\n){\nfloat sign \x3d 1.0;\nfloat cvsOffset \x3d 0.0;\nif (cvsCoord) {\nsign *\x3d -1.0;\ncvsOffset \x3d len;\n}\nreturn sign * (val - localMin) * localA + cvsOffset + \n(sign * minPixelPadding);\n}\nfloat xToPixels(float value){\nif (skipTranslation){\nreturn value;// + xAxisPos;\n}\nreturn translate(value, 0.0, xAxisTrans, xAxisMin, xAxisMinPad, xAxisPointRange, xAxisLen, xAxisCVSCoord);// + xAxisPos;\n}\nfloat yToPixels(float value, float checkTreshold){\nfloat v;\nif (skipTranslation){\nv \x3d value;// + yAxisPos;\n} else {\nv \x3d translate(value, 0.0, yAxisTrans, yAxisMin, yAxisMinPad, yAxisPointRange, yAxisLen, yAxisCVSCoord);// + yAxisPos;\n}\nif (checkTreshold \x3e 0.0 \x26\x26 hasThreshold) {\nv \x3d min(v, translatedThreshold);\n}\nreturn v;\n}\nvoid main(void) {\nif (isBubble){\ngl_PointSize \x3d bubbleRadius();\n} else {\ngl_PointSize \x3d pSize;\n}\nvColor \x3d aColor;\nif (isInverted) {\ngl_Position \x3d uPMatrix * vec4(xToPixels(aVertexPosition.y) + yAxisPos, yToPixels(aVertexPosition.x, aVertexPosition.z) + xAxisPos, 0.0, 1.0);\n} else {\ngl_Position \x3d uPMatrix * vec4(xToPixels(aVertexPosition.x) + xAxisPos, yToPixels(aVertexPosition.y, aVertexPosition.z) + yAxisPos, 0.0, 1.0);\n}\n}",
"vertex"),k=c("precision highp float;\nuniform vec4 fillColor;\nvarying highp vec2 position;\nvarying highp vec4 vColor;\nuniform sampler2D uSampler;\nuniform bool isCircle;\nuniform bool hasColor;\nvoid main(void) {\nvec4 col \x3d fillColor;\nif (hasColor) {\ncol \x3d vColor;\n}\nif (isCircle) {\ngl_FragColor \x3d col * texture2D(uSampler, gl_PointCoord.st);\n} else {\ngl_FragColor \x3d col;\n}\n}","fragment");if(!e||!k)return l=!1;l=a.createProgram();a.attachShader(l,e);a.attachShader(l,k);a.linkProgram(l);
a.useProgram(l);a.bindAttribLocation(l,0,"aVertexPosition");h=d("uPMatrix");v=d("pSize");E=d("fillColor");F=d("isBubble");f=d("bubbleSizeAbs");r=d("bubbleSizeByArea");z=d("uSampler");b=d("skipTranslation");n=d("isCircle");g=d("isInverted");return!0}function k(b,c){b=e[b]=e[b]||a.getUniformLocation(l,b);a.uniform1f(b,c)}var e={},l,h,v,E,F,f,r,b,n,g,z;a&&d();return{psUniform:function(){return v},pUniform:function(){return h},fillColorUniform:function(){return E},setBubbleUniforms:function(b,c,d){var e=
b.options,l=Number.MAX_VALUE,h=-Number.MAX_VALUE;"bubble"===b.type&&(l=D(e.zMin,Math.min(l,Math.max(c,!1===e.displayNegative?e.zThreshold:-Number.MAX_VALUE))),h=D(e.zMax,Math.max(h,d)),a.uniform1i(F,1),a.uniform1i(n,1),a.uniform1i(r,"width"!==b.options.sizeBy),a.uniform1i(f,b.options.sizeByAbsoluteValue),k("bubbleZMin",l),k("bubbleZMax",h),k("bubbleZThreshold",b.options.zThreshold),k("bubbleMinSize",b.minPxSize),k("bubbleMaxSize",b.maxPxSize))},bind:function(){a.useProgram(l)},program:function(){return l},
create:d,setUniform:k,setPMatrix:function(b){a.uniformMatrix4fv(h,!1,b)},setColor:function(b){a.uniform4f(E,b[0]/255,b[1]/255,b[2]/255,b[3])},setPointSize:function(b){a.uniform1f(v,b)},setSkipTranslation:function(c){a.uniform1i(b,!0===c?1:0)},setTexture:function(){a.uniform1i(z,0)},setDrawAsCircle:function(b){a.uniform1i(n,b?1:0)},reset:function(){a.uniform1i(F,0);a.uniform1i(n,0)},setInverted:function(b){a.uniform1i(g,b)},destroy:function(){a&&l&&a.deleteProgram(l)}}}function X(a,c,d){var k=!1,e=
!1,l=d||2,h=!1,v=0,g;return{destroy:function(){k&&a.deleteBuffer(k)},bind:function(){if(!k)return!1;a.vertexAttribPointer(e,l,a.FLOAT,!1,0,0)},data:g,build:function(d,f,r){g=d||[];if(!(g&&0!==g.length||h))return k=!1;l=r||l;k&&a.deleteBuffer(k);k=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,k);a.bufferData(a.ARRAY_BUFFER,h||new Float32Array(g),a.STATIC_DRAW);e=a.getAttribLocation(c.program(),f);a.enableVertexAttribArray(e);return!0},render:function(c,d,e){var b=h?h.length:g.length;if(!k||!b)return!1;
if(!c||c>b||0>c)c=0;if(!d||d>b)d=b;a.drawArrays(a[(e||"points").toUpperCase()],c/l,(d-c)/l);return!0},allocate:function(a){v=-1;h=new Float32Array(4*a)},push:function(a,c,d,b){h&&(h[++v]=a,h[++v]=c,h[++v]=d,h[++v]=b)}}}function ga(a){function c(a){var b,c;return x(a)?(b=!!a.options.stacking,c=a.xData||a.options.xData||a.processedXData,b=(b?a.data:c||a.options.data).length,"treemap"===a.type?b*=12:"heatmap"===a.type?b*=6:O[a.type]&&(b*=2),b):0}function d(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)}
function k(a,b){function c(a){a&&(b.colorData.push(a[0]),b.colorData.push(a[1]),b.colorData.push(a[2]),b.colorData.push(a[3]))}function d(a,b,d,e,k){c(k);p.usePreallocated?r.push(a,b,d?1:0,e||1):(z.push(a),z.push(b),z.push(d?1:0),z.push(e||1))}function e(a,b,e,k,f){c(f);d(a+e,b);c(f);d(a,b);c(f);d(a,b+k);c(f);d(a,b+k);c(f);d(a+e,b+k);c(f);d(a+e,b)}var k=a.pointArrayMap&&"low,high"===a.pointArrayMap.join(","),B=a.chart,f=a.options,N=!!f.stacking,l=f.data,g=a.xAxis.getExtremes(),v=g.min,n=g.max,g=a.yAxis.getExtremes(),
u=g.min,q=g.max,g=a.xData||f.xData||a.processedXData,w=a.yData||f.yData||a.processedYData,m=a.zData||f.zData||a.processedZData,F=a.yAxis,A=a.xAxis,x=!g||0===g.length,t=a.points||!1,C=!1,E,I,J,G=N?a.data:g||l;f.boostData&&0<f.boostData.length||(a.closestPointRangePx=Number.MAX_VALUE,t&&0<t.length?(b.skipTranslation=!0,b.drawMode="triangles",t[0].node&&t[0].node.levelDynamic&&t.sort(function(a,b){if(a.node){if(a.node.levelDynamic>b.node.levelDynamic)return 1;if(a.node.levelDynamic<b.node.levelDynamic)return-1}return 0}),
y(t,function(b){var c=b.plotY,d;void 0===c||isNaN(c)||null===b.y||(c=b.shapeArgs,d=b.pointAttr&&b.pointAttr[""]||b.series.pointAttribs(b),b=d["stroke-width"],I=h.color(d.fill).rgba,I[0]/=255,I[1]/=255,I[2]/=255,"treemap"===a.type&&(b=b||1,J=h.color(d.stroke).rgba,J[0]/=255,J[1]/=255,J[2]/=255,e(c.x,c.y,c.width,c.height,J),b/=2),e(c.x+b,c.y+b,c.width-2*b,c.height-2*b,I))})):y(G,function(c,e){var f,h,l,g=!1,K=!1,Y=!1,Z=!1,r=O[a.type],t=!1,T=!0;if("undefined"===typeof B.index)return!1;x?(f=c[0],h=c[1],
G[e+1]&&(K=G[e+1][0]),G[e-1]&&(g=G[e-1][0]),3<=c.length&&(l=c[2],c[2]>b.zMax&&(b.zMax=c[2]),c[2]<b.zMin&&(b.zMin=c[2]))):(f=c,h=w[e],G[e+1]&&(K=G[e+1]),G[e-1]&&(g=G[e-1]),m&&m.length&&(l=m[e],m[e]>b.zMax&&(b.zMax=m[e]),m[e]<b.zMin&&(b.zMin=m[e])));K&&K>=v&&K<=n&&(Y=!0);g&&g>=v&&g<=n&&(Z=!0);k?(x&&(h=c.slice(1,3)),h=h[1]):N&&(f=c.x,h=c.stackY);a.requireSorting||(T=h>=u&&h<=q);h&&T&&(f>=v&&f<=n&&(t=!0),t||Y||Z)&&(p.useGPUTranslations||(b.skipTranslation=!0,f=A.toPixels(f,!0),h=F.toPixels(h,!0)),r&&
(E=0,0>h&&(E=h,h=0),p.useGPUTranslations||(E=F.toPixels(E,!0)),d(f,E,0,0,!1)),b.hasMarkers&&!1!==C&&(a.closestPointRangePx=Math.min(a.closestPointRangePx,Math.abs(f-C))),d(f,h,0,"bubble"===a.type?l||1:2,!1),C=f)}))}function e(){u=[];C.data=z=[];w=[]}function l(a){f&&(f.setUniform("xAxisTrans",a.transA),f.setUniform("xAxisMin",a.min),f.setUniform("xAxisMinPad",a.minPixelPadding),f.setUniform("xAxisPointRange",a.pointRange),f.setUniform("xAxisLen",a.len),f.setUniform("xAxisPos",a.pos),f.setUniform("xAxisCVSCoord",
!a.horiz))}function g(a){f&&(f.setUniform("yAxisTrans",a.transA),f.setUniform("yAxisMin",a.min),f.setUniform("yAxisMinPad",a.minPixelPadding),f.setUniform("yAxisPointRange",a.pointRange),f.setUniform("yAxisLen",a.len),f.setUniform("yAxisPos",a.pos),f.setUniform("yAxisCVSCoord",!a.horiz))}function v(a,b){f.setUniform("hasThreshold",a);f.setUniform("translatedThreshold",b)}function q(c){if(c)n=c.chartWidth||800,A=c.chartHeight||400;else return!1;if(!b||!n||!A)return!1;p.timeRendering&&console.time("gl rendering");
f.bind();b.viewport(0,0,n,A);f.setPMatrix([2/n,0,0,0,0,-(2/A),0,0,0,0,-2,0,-1,1,-1,1]);b.lineWidth(p.lineWidth);r.build(C.data,"aVertexPosition",4);r.bind();m&&(b.bindTexture(b.TEXTURE_2D,L),f.setTexture(L));f.setInverted(c.options.chart?c.options.chart.inverted:!1);y(u,function(a,c){var d=a.series.options,e=d.threshold,k=P(e),e=a.series.yAxis.getThreshold(e),K=D(d.marker?d.marker.enabled:null,a.series.xAxis.isRadial?!0:null,a.series.closestPointRangePx>2*((d.marker?d.marker.radius:10)||10)),B=a.series.fillOpacity?
(new aa(a.series.color)).setOpacity(D(d.fillOpacity,.85)).get():a.series.color;r.bind();d.colorByPoint&&(B=a.series.chart.options.colors[c]);B=h.color(B).rgba;p.useAlpha||(B[3]=1);"add"===d.boostBlending?(b.blendFunc(b.SRC_ALPHA,b.ONE),b.blendEquation(b.FUNC_ADD)):"mult"===d.boostBlending?b.blendFunc(b.DST_COLOR,b.ZERO):"darken"===d.boostBlending?(b.blendFunc(b.ONE,b.ONE),b.blendEquation(b.FUNC_MIN)):(b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA),b.blendEquation(b.FUNC_ADD));f.reset();0<a.colorData.length&&
(f.setUniform("hasColor",1),c=X(b,f),c.build(a.colorData,"aColor",4),c.bind());f.setColor(B);l(a.series.xAxis);g(a.series.yAxis);v(k,e);"points"===a.drawMode&&(d.marker&&d.marker.radius?f.setPointSize(2*d.marker.radius):f.setPointSize(1));f.setSkipTranslation(a.skipTranslation);"bubble"===a.series.type&&f.setBubbleUniforms(a.series,a.zMin,a.zMax);f.setDrawAsCircle(ha[a.series.type]&&m||!1);r.render(a.from,a.to,a.drawMode);a.hasMarkers&&K&&(d.marker&&d.marker.radius?f.setPointSize(2*d.marker.radius):
f.setPointSize(10),f.setDrawAsCircle(!0),r.render(a.from,a.to,"POINTS"))});r.destroy();p.timeRendering&&console.timeEnd("gl rendering");e();a&&a()}function F(a){d();if(a.renderer.forExport)return q(a);t?q(a):setTimeout(function(){F(a)},1)}var f=!1,r=!1,b=!1,n=0,A=0,z=!1,w=!1,m=!1,C={},t=!1,u=[],M=U.createElement("canvas"),Q=M.getContext("2d"),L,O={column:!0,area:!0},ha={scatter:!0,bubble:!0},p={pointSize:1,lineWidth:3,fillColor:"#AA00AA",useAlpha:!0,usePreallocated:!1,useGPUTranslations:!1,timeRendering:!1,
timeSeriesProcessing:!1,timeSetup:!1};return C={allocateBufferForSingleSeries:function(a){var b=0;p.usePreallocated&&(x(a)&&(b=c(a)),r.allocate(b))},pushSeries:function(a){0<u.length&&(u[u.length-1].to=z.length,u[u.length-1].hasMarkers&&(u[u.length-1].markerTo=w.length));p.timeSeriesProcessing&&console.time("building "+a.type+" series");u.push({from:z.length,markerFrom:w.length,colorData:[],series:a,zMin:Number.MAX_VALUE,zMax:-Number.MAX_VALUE,hasMarkers:a.options.marker?!1!==a.options.marker.enabled:
!1,showMarksers:!0,drawMode:{area:"lines",arearange:"lines",areaspline:"line_strip",column:"lines",line:"line_strip",scatter:"points",heatmap:"triangles",treemap:"triangles",bubble:"points"}[a.type]||"line_strip"});k(a,u[u.length-1]);p.timeSeriesProcessing&&console.timeEnd("building "+a.type+" series")},setSize:function(a,b){if(n!==a||b!==b)n=a,A=b,f.bind(),f.setPMatrix([2/n,0,0,0,0,-(2/A),0,0,0,0,-2,0,-1,1,-1,1])},inited:function(){return t},setThreshold:v,init:function(a,c){var d=0,k=["webgl","experimental-webgl",
"moz-webgl","webkit-3d"];t=!1;if(!a)return!1;for(p.timeSetup&&console.time("gl setup");d<k.length&&!(b=a.getContext(k[d]));d++);if(b)c||e();else return!1;b.enable(b.BLEND);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);b.disable(b.DEPTH_TEST);b.depthMask(b.FALSE);f=H(b);r=X(b,f);m=!1;L=b.createTexture();M.width=512;M.height=512;Q.fillStyle="#FFF";Q.beginPath();Q.arc(256,256,256,0,2*Math.PI);Q.fill();try{b.bindTexture(b.TEXTURE_2D,L),b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,M),b.texParameteri(b.TEXTURE_2D,
b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR),b.generateMipmap(b.TEXTURE_2D),b.bindTexture(b.TEXTURE_2D,null),m=!0}catch(T){}t=!0;p.timeSetup&&console.timeEnd("gl setup");return!0},render:F,settings:p,valid:function(){return!1!==b},clear:d,flush:e,setXAxis:l,setYAxis:g,data:z,gl:function(){return b},allocateBuffer:function(a){var b=
0;p.usePreallocated&&(y(a.series,function(a){x(a)&&(b+=c(a))}),r.allocate(b))},destroy:function(){r.destroy();f.destroy()},setOptions:function(a){ia(!0,p,a)}}}function ba(a,c){var d=a.chartWidth,k=a.chartHeight,e=a,g=a.seriesGroup||c.group,m=function(a,d,e,f,k,b,h){a.call(c,e,d,f,k,b,h)},e=w(a)?a:c;e.image||(e.canvas=U.createElement("canvas"),e.image=a.renderer.image("",0,0,d,k).add(g),e.boostClipRect=a.renderer.clipRect(a.plotLeft,a.plotTop,a.plotWidth,a.chartHeight),e.image.clip(e.boostClipRect),
e.inverted&&y(["moveTo","lineTo","rect","arc"],function(a){q(!1,a,m)}),e instanceof h.Chart&&(e.markerGroup=e.renderer.g().add(g),e.markerGroup.translate(c.xAxis.pos,c.yAxis.pos)));e.canvas.width=d;e.canvas.height=k;e.image.attr({x:0,y:0,width:d,height:k,style:"pointer-events: none"});e.boostClipRect.attr({x:a.plotLeft,y:a.plotTop,width:a.plotWidth,height:a.chartHeight});e.ogl||(e.ogl=ga(function(){e.image.attr({href:e.canvas.toDataURL("image/png")})}),e.ogl.init(e.canvas),e.ogl.setOptions(a.options.boost||
{}),e instanceof h.Chart&&e.ogl.allocateBuffer(a));e.ogl.setSize(d,k);return e.ogl}function ca(a,c,d){a&&c.image&&c.canvas&&!w(d||c.chart)&&a.render(d||c.chart)}function da(a,c){a&&c.image&&c.canvas&&!w(c.chart)&&a.allocateBufferForSingleSeries(c)}function R(a,c,d,k,e,h){e=e||0;k=k||5E4;for(var g=e+k,l=!0;l&&e<g&&e<a.length;)l=c(a[e],e),++e;l&&(e<a.length?h?R(a,c,d,k,e,h):S.requestAnimationFrame?S.requestAnimationFrame(function(){R(a,c,d,k,e)}):setTimeout(function(){R(a,c,d,k,e)}):d&&d())}function ja(a){if(!x(this))return a.call(this);
if(a=ba(this.chart,this))da(a,this),a.pushSeries(this);ca(a,this)}var S=h.win,U=S.document,ka=function(){},aa=h.Color,m=h.Series,g=h.seriesTypes,y=h.each,ea=h.extend,fa=h.addEvent,la=h.fireEvent,ma=h.grep,P=h.isNumber,ia=h.merge,D=h.pick,q=h.wrap,V=h.getOptions().plotOptions,W;aa.prototype.names={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",
brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",
darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",feldspar:"#d19275",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",
lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslateblue:"#8470ff",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",
mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",
peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",violetred:"#d02090",
wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};m.prototype.getPoint=function(a){var c=a,d=this.xData||this.options.xData||this.processedXData||!1;!a||a instanceof this.pointClass||(c=(new this.pointClass).init(this,this.options.data[a.i],d?d[a.i]:void 0),c.category=c.x,c.dist=a.dist,c.distX=a.distX,c.plotX=a.plotX,c.plotY=a.plotY,c.index=a.i);return c};q(m.prototype,"searchPoint",function(a){return this.getPoint(a.apply(this,[].slice.call(arguments,1)))});
q(m.prototype,"destroy",function(a){var c=this,d=c.chart;d.markerGroup===c.markerGroup&&(c.markerGroup=null);d.hoverPoints&&(d.hoverPoints=ma(d.hoverPoints,function(a){return a.series===c}));d.hoverPoint&&d.hoverPoint.series===c&&(d.hoverPoint=null);a.call(this)});q(m.prototype,"getExtremes",function(a){if(!x(this)||!this.hasExtremes||!this.hasExtremes())return a.apply(this,Array.prototype.slice.call(arguments,1))});y("area arearange column line scatter heatmap bubble treemap heatmap".split(" "),
function(a){V[a]&&(V[a].boostThreshold=5E3,V[a].boostData=[])});y(["translate","generatePoints","drawTracker","drawPoints","render"],function(a){function c(c){var d=this.options.stacking&&("translate"===a||"generatePoints"===a);if(!x(this)||d||"heatmap"===this.type||"treemap"===this.type)"render"===a&&this.image&&!w(this.chart)&&(this.image.attr({href:""}),this.animate=null),c.call(this);else if(this[a+"Canvas"])this[a+"Canvas"]()}q(m.prototype,a,c);"translate"===a&&(g.column&&q(g.column.prototype,
a,c),g.arearange&&q(g.arearange.prototype,a,c),g.treemap&&q(g.treemap.prototype,a,c))});(function(){var a=0,c,d=["webgl","experimental-webgl","moz-webgl","webkit-3d"],k=!1;if("undefined"!==typeof S.WebGLRenderingContext)for(c=U.createElement("canvas");a<d.length;a++)try{if(k=c.getContext(d[a]),"undefined"!==typeof k&&null!==k)return!0}catch(e){}return!1})()?(q(m.prototype,"processData",function(a){x(this)&&"heatmap"!==this.type&&"treemap"!==this.type||a.apply(this,Array.prototype.slice.call(arguments,
1));this.hasExtremes&&this.hasExtremes(!0)||a.apply(this,Array.prototype.slice.call(arguments,1))}),h.extend(m.prototype,{pointRange:0,directTouch:!1,allowDG:!1,hasExtremes:function(a){var c=this.options,d=this.xAxis&&this.xAxis.options,k=this.yAxis&&this.yAxis.options;return c.data.length>(c.boostThreshold||Number.MAX_VALUE)&&P(k.min)&&P(k.max)&&(!a||P(d.min)&&P(d.max))},destroyGraphics:function(){var a=this,c=this.points,d,k;if(c)for(k=0;k<c.length;k+=1)(d=c[k])&&d.graphic&&(d.graphic=d.graphic.destroy());
y(["graph","area","tracker"],function(c){a[c]&&(a[c]=a[c].destroy())})},renderCanvas:function(){var a=this,c=a.options||{},d=!1,k=a.chart,e=this.xAxis,h=this.yAxis,g=c.xData||a.processedXData,m=c.yData||a.processedYData,q=c.data,d=e.getExtremes(),x=d.min,f=d.max,d=h.getExtremes(),r=d.min,b=d.max,n={},A,z=!!a.sampling,y,H=!1!==c.enableMouseTracking,d=c.threshold,C=h.getThreshold(d);P(d);var t=a.pointArrayMap&&"low,high"===a.pointArrayMap.join(","),u=!!c.stacking,M=a.cropStart||0,Q=a.requireSorting,
L=!g,O,D,p,B,N=function(a,b,c){W=a+","+b;H&&!n[W]&&(n[W]=!0,k.inverted&&(a=e.len-a,b=h.len-b),y.push({clientX:a,plotX:a,plotY:b,i:M+c}))},d=ba(k,a);this.visible?((this.points||this.graph)&&this.destroyGraphics(),w(k)?this.markerGroup=k.markerGroup:this.markerGroup=a.plotGroup("markerGroup","markers",!0,1,k.seriesGroup),y=this.points=[],a.buildKDTree=ka,d&&(da(d,this),d.pushSeries(a),ca(d,this,k)),R(u?a.data:g||q,function(a,c){var d,g,l,n="undefined"===typeof k.index,q=!0;if(!n&&(L?(d=a[0],g=a[1]):
(d=a,g=m[c]),t?(L&&(g=a.slice(1,3)),l=g[0],g=g[1]):u&&(d=a.x,g=a.stackY,l=g-a.y),Q||(q=g>=r&&g<=b),null!==g&&d>=x&&d<=f&&q))if(a=Math.ceil(e.toPixels(d,!0)),z){if(void 0===p||a===A){t||(l=g);if(void 0===B||g>D)D=g,B=c;if(void 0===p||l<O)O=l,p=c}a!==A&&(void 0!==p&&(g=h.toPixels(D,!0),C=h.toPixels(O,!0),N(a,g,B),C!==g&&N(a,C,p)),p=B=void 0,A=a)}else g=Math.ceil(h.toPixels(g,!0)),N(a,g,c);return!n},function(){la(a,"renderedCanvas");a.directTouch=!1;a.options.stickyTracking=!0;delete a.buildKDTree;a.buildKDTree()},
k.renderer.forExport?Number.MAX_VALUE:void 0)):!w(k)&&d&&(d.clear(),this.image.attr({href:""}))}}),y(["heatmap","treemap"],function(a){g[a]&&(q(g[a].prototype,"drawPoints",ja),g[a].prototype.directTouch=!1)}),g.bubble&&(delete g.bubble.prototype.buildKDTree,g.bubble.prototype.directTouch=!1,q(g.bubble.prototype,"markerAttribs",function(a){return x(this)?!1:a.apply(this,[].slice.call(arguments,1))})),g.scatter.prototype.fill=!0,ea(g.area.prototype,{fill:!0,fillOpacity:!0,sampling:!0}),ea(g.column.prototype,
{fill:!0,sampling:!0}),q(m.prototype,"setVisible",function(a,c){a.call(this,c,!1);!1===this.visible&&this.ogl&&this.canvas&&this.image?(this.ogl.clear(),this.image.attr({href:""})):this.chart.redraw()}),h.Chart.prototype.callbacks.push(function(a){fa(a,"predraw",function(){a.canvas&&a.ogl&&w(a)&&a.ogl.allocateBuffer(a);a.markerGroup&&a.markerGroup.translate(a.xAxis[0].pos,a.yAxis[0].pos)});fa(a,"render",function(){a.ogl&&w(a)&&a.ogl.render(a)})})):"undefined"!==typeof h.initCanvasBoost?h.initCanvasBoost():
h.error(26)})(H)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Boost module
*
* (c) 2010-2017 Highsoft AS
* Author: Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* License: www.highcharts.com/license
* Author: Christer Vasseng, Torstein Honsi
*
* This is an experimental Highcharts module that draws long data series on a canvas
* in order to increase performance of the initial load time and tooltip responsiveness.
*
* Compatible with WebGL compatible browsers (not IE < 11).
*
* Development plan
* - Column range.
* - Check how it works with Highstock and data grouping. Currently it only works when navigator.adaptToUpdatedData
* is false. It is also recommended to set scrollbar.liveRedraw to false.
* - Check inverted charts.
* - Chart callback should be async after last series is drawn. (But not necessarily, we don't do
that with initial series animation).
*
* If this module is taken in as part of the core
* - All the loading logic should be merged with core. Update styles in the core.
* - Most of the method wraps should probably be added directly in parent methods.
*
* Notes for boost mode
* - Area lines are not drawn
* - Lines are not drawn on scatter charts
* - Zones and negativeColor don't work
* - Columns are always one pixel wide. Don't set the threshold too low.
* - Disable animations
* - Marker shapes are not supported: markers will always be circles
*
* Optimizing tips for users
* - Set extremes (min, max) explicitly on the axes in order for Highcharts to avoid computing extremes.
* - Set enableMouseTracking to false on the series to improve total rendering time.
* - The default threshold is set based on one series. If you have multiple, dense series, the combined
* number of points drawn gets higher, and you may want to set the threshold lower in order to
* use optimizations.
* - If drawing large scatter charts, it's beneficial to set the marker radius to a value
* less than 1. This is to add additional spacing to make the chart more readable.
* - If the value increments on both the X and Y axis aren't small, consider setting
* useGPUTranslations to true on the boost settings object. If you do this and
* the increments are small (e.g. datetime axis with small time increments)
* it may cause rendering issues due to floating point rounding errors,
* so your millage may vary.
*
* Settings
* There are two ways of setting the boost threshold:
* - Per. series: boost based on number of points in individual series
* - Per. chart: boost based on the number of series
*
* To set the series boost threshold, set seriesBoostThreshold on the chart object.
* To set the series-specific threshold, set boostThreshold on the series object.
*
* In addition, the following can be set in the boost object:
* {
* //Wether or not to use alpha blending
* useAlpha: boolean - default: true
* //Set to true to perform translations on the GPU.
* //Much faster, but may cause rendering issues
* //when using values far from 0 due to floating point
* //rounding issues
* useGPUTranslations: boolean - default: false
* //Use pre-allocated buffers, much faster,
* //but may cause rendering issues with some data sets
* usePreallocated: boolean - default: false
* //Output rendering time in console
* timeRendering: boolean - default: false
* //Output processing time in console
* timeSeriesProcessing: boolean - default: false
* //Output setup time in console
* timeSetup: boolean - default: false
* }
*/
/**
* Set the series threshold for when the boost should kick in globally.
*
* Setting to e.g. 20 will cause the whole chart to enter boost mode
* if there are 20 or more series active. When the chart is in boost mode,
* every series in it will be rendered to a common canvas. This offers
* a significant speed improvment in charts with a very high
* amount of series.
*
* Note: only available when including the boost module.
*
* @default null
* @apioption boost.seriesThreshold
*/
/**
* Set the point threshold for when a series should enter boost mode.
*
* Setting it to e.g. 2000 will cause the series to enter boost mode
* when there are 2000 or more points in the series.
*
* Note: only available when including the boost module.
*
* @default 5000
* @apioption series.boostThreshold
*/
/* global Float32Array, Image */
var win = H.win,
doc = win.document,
noop = function() {},
Color = H.Color,
Series = H.Series,
seriesTypes = H.seriesTypes,
each = H.each,
extend = H.extend,
addEvent = H.addEvent,
fireEvent = H.fireEvent,
grep = H.grep,
isNumber = H.isNumber,
merge = H.merge,
pick = H.pick,
wrap = H.wrap,
plotOptions = H.getOptions().plotOptions,
CHUNK_SIZE = 50000,
index;
// Register color names since GL can't render those directly.
Color.prototype.names = {
aliceblue: '#f0f8ff',
antiquewhite: '#faebd7',
aqua: '#00ffff',
aquamarine: '#7fffd4',
azure: '#f0ffff',
beige: '#f5f5dc',
bisque: '#ffe4c4',
black: '#000000',
blanchedalmond: '#ffebcd',
blue: '#0000ff',
blueviolet: '#8a2be2',
brown: '#a52a2a',
burlywood: '#deb887',
cadetblue: '#5f9ea0',
chartreuse: '#7fff00',
chocolate: '#d2691e',
coral: '#ff7f50',
cornflowerblue: '#6495ed',
cornsilk: '#fff8dc',
crimson: '#dc143c',
cyan: '#00ffff',
darkblue: '#00008b',
darkcyan: '#008b8b',
darkgoldenrod: '#b8860b',
darkgray: '#a9a9a9',
darkgreen: '#006400',
darkkhaki: '#bdb76b',
darkmagenta: '#8b008b',
darkolivegreen: '#556b2f',
darkorange: '#ff8c00',
darkorchid: '#9932cc',
darkred: '#8b0000',
darksalmon: '#e9967a',
darkseagreen: '#8fbc8f',
darkslateblue: '#483d8b',
darkslategray: '#2f4f4f',
darkturquoise: '#00ced1',
darkviolet: '#9400d3',
deeppink: '#ff1493',
deepskyblue: '#00bfff',
dimgray: '#696969',
dodgerblue: '#1e90ff',
feldspar: '#d19275',
firebrick: '#b22222',
floralwhite: '#fffaf0',
forestgreen: '#228b22',
fuchsia: '#ff00ff',
gainsboro: '#dcdcdc',
ghostwhite: '#f8f8ff',
gold: '#ffd700',
goldenrod: '#daa520',
gray: '#808080',
green: '#008000',
greenyellow: '#adff2f',
honeydew: '#f0fff0',
hotpink: '#ff69b4',
indianred: '#cd5c5c',
indigo: '#4b0082',
ivory: '#fffff0',
khaki: '#f0e68c',
lavender: '#e6e6fa',
lavenderblush: '#fff0f5',
lawngreen: '#7cfc00',
lemonchiffon: '#fffacd',
lightblue: '#add8e6',
lightcoral: '#f08080',
lightcyan: '#e0ffff',
lightgoldenrodyellow: '#fafad2',
lightgrey: '#d3d3d3',
lightgreen: '#90ee90',
lightpink: '#ffb6c1',
lightsalmon: '#ffa07a',
lightseagreen: '#20b2aa',
lightskyblue: '#87cefa',
lightslateblue: '#8470ff',
lightslategray: '#778899',
lightsteelblue: '#b0c4de',
lightyellow: '#ffffe0',
lime: '#00ff00',
limegreen: '#32cd32',
linen: '#faf0e6',
magenta: '#ff00ff',
maroon: '#800000',
mediumaquamarine: '#66cdaa',
mediumblue: '#0000cd',
mediumorchid: '#ba55d3',
mediumpurple: '#9370d8',
mediumseagreen: '#3cb371',
mediumslateblue: '#7b68ee',
mediumspringgreen: '#00fa9a',
mediumturquoise: '#48d1cc',
mediumvioletred: '#c71585',
midnightblue: '#191970',
mintcream: '#f5fffa',
mistyrose: '#ffe4e1',
moccasin: '#ffe4b5',
navajowhite: '#ffdead',
navy: '#000080',
oldlace: '#fdf5e6',
olive: '#808000',
olivedrab: '#6b8e23',
orange: '#ffa500',
orangered: '#ff4500',
orchid: '#da70d6',
palegoldenrod: '#eee8aa',
palegreen: '#98fb98',
paleturquoise: '#afeeee',
palevioletred: '#d87093',
papayawhip: '#ffefd5',
peachpuff: '#ffdab9',
peru: '#cd853f',
pink: '#ffc0cb',
plum: '#dda0dd',
powderblue: '#b0e0e6',
purple: '#800080',
red: '#ff0000',
rosybrown: '#bc8f8f',
royalblue: '#4169e1',
saddlebrown: '#8b4513',
salmon: '#fa8072',
sandybrown: '#f4a460',
seagreen: '#2e8b57',
seashell: '#fff5ee',
sienna: '#a0522d',
silver: '#c0c0c0',
skyblue: '#87ceeb',
slateblue: '#6a5acd',
slategray: '#708090',
snow: '#fffafa',
springgreen: '#00ff7f',
steelblue: '#4682b4',
tan: '#d2b48c',
teal: '#008080',
thistle: '#d8bfd8',
tomato: '#ff6347',
turquoise: '#40e0d0',
violet: '#ee82ee',
violetred: '#d02090',
wheat: '#f5deb3',
white: '#ffffff',
whitesmoke: '#f5f5f5',
yellow: '#ffff00',
yellowgreen: '#9acd32'
};
/*
* Returns true if the chart is in series boost mode
* @param chart {Highchart.Chart} - the chart to check
* @returns {Boolean} - true if the chart is in series boost mode
*/
function isChartSeriesBoosting(chart) {
return chart.series.length >= pick(
chart.options.boost && chart.options.boost.seriesThreshold, // docs
10
);
}
/*
* Returns true if the series is in boost mode
* @param series {Highchart.Series} - the series to check
* @returns {boolean} - true if the series is in boost mode
*/
function isSeriesBoosting(series) {
function patientMax() {
var args = Array.prototype.slice.call(arguments),
r = -Number.MAX_VALUE;
each(args, function(t) {
if (typeof t !== 'undefined' && typeof t.length !== 'undefined') {
//r = r < t.length ? t.length : r;
if (t.length > 0) {
r = t.length;
return true;
}
}
});
return r;
}
return isChartSeriesBoosting(series.chart) ||
patientMax(
series.processedXData,
series.options.data,
series.points
) >= (series.options.boostThreshold || Number.MAX_VALUE);
}
////////////////////////////////////////////////////////////////////////////////
// START OF WEBGL ABSTRACTIONS
/*
* A static shader mimicing axis translation functions found in parts/Axis
* @param gl {WebGLContext} - the context in which the shader is active
*/
function GLShader(gl) {
var vertShade = [
/* eslint-disable */
'#version 100',
'precision highp float;',
'attribute vec4 aVertexPosition;',
'attribute vec4 aColor;',
'varying highp vec2 position;',
'varying highp vec4 vColor;',
'uniform mat4 uPMatrix;',
'uniform float pSize;',
'uniform float translatedThreshold;',
'uniform bool hasThreshold;',
'uniform bool skipTranslation;',
'uniform float xAxisTrans;',
'uniform float xAxisMin;',
'uniform float xAxisMinPad;',
'uniform float xAxisPointRange;',
'uniform float xAxisLen;',
'uniform bool xAxisPostTranslate;',
'uniform float xAxisOrdinalSlope;',
'uniform float xAxisOrdinalOffset;',
'uniform float xAxisPos;',
'uniform bool xAxisCVSCoord;',
'uniform float yAxisTrans;',
'uniform float yAxisMin;',
'uniform float yAxisMinPad;',
'uniform float yAxisPointRange;',
'uniform float yAxisLen;',
'uniform bool yAxisPostTranslate;',
'uniform float yAxisOrdinalSlope;',
'uniform float yAxisOrdinalOffset;',
'uniform float yAxisPos;',
'uniform bool yAxisCVSCoord;',
'uniform bool isBubble;',
'uniform bool bubbleSizeByArea;',
'uniform float bubbleZMin;',
'uniform float bubbleZMax;',
'uniform float bubbleZThreshold;',
'uniform float bubbleMinSize;',
'uniform float bubbleMaxSize;',
'uniform bool bubbleSizeAbs;',
'uniform bool isInverted;',
'float bubbleRadius(){',
'float value = aVertexPosition.w;',
'float zMax = bubbleZMax;',
'float zMin = bubbleZMin;',
'float radius = 0.0;',
'float pos = 0.0;',
'float zRange = zMax - zMin;',
'if (bubbleSizeAbs){',
'value = value - bubbleZThreshold;',
'zMax = max(zMax - bubbleZThreshold, zMin - bubbleZThreshold);',
'zMin = 0.0;',
'}',
'if (value < zMin){',
'radius = bubbleZMin / 2.0 - 1.0;',
'} else {',
'pos = zRange > 0.0 ? (value - zMin) / zRange : 0.5;',
'if (bubbleSizeByArea && pos > 0.0){',
'pos = sqrt(pos);',
'}',
'radius = ceil(bubbleMinSize + pos * (bubbleMaxSize - bubbleMinSize)) / 2.0;',
'}',
'return radius * 2.0;',
'}',
'float translate(float val,',
'float pointPlacement,',
'float localA,',
'float localMin,',
'float minPixelPadding,',
'float pointRange,',
'float len,',
'bool cvsCoord',
'){',
'float sign = 1.0;',
'float cvsOffset = 0.0;',
'if (cvsCoord) {',
'sign *= -1.0;',
'cvsOffset = len;',
'}',
'return sign * (val - localMin) * localA + cvsOffset + ',
'(sign * minPixelPadding);', //' + localA * pointPlacement * pointRange;',
'}',
'float xToPixels(float value){',
'if (skipTranslation){',
'return value;// + xAxisPos;',
'}',
'return translate(value, 0.0, xAxisTrans, xAxisMin, xAxisMinPad, xAxisPointRange, xAxisLen, xAxisCVSCoord);// + xAxisPos;',
'}',
'float yToPixels(float value, float checkTreshold){',
'float v;',
'if (skipTranslation){',
'v = value;// + yAxisPos;',
'} else {',
'v = translate(value, 0.0, yAxisTrans, yAxisMin, yAxisMinPad, yAxisPointRange, yAxisLen, yAxisCVSCoord);// + yAxisPos;',
'}',
'if (checkTreshold > 0.0 && hasThreshold) {',
'v = min(v, translatedThreshold);',
'}',
'return v;',
'}',
'void main(void) {',
'if (isBubble){',
'gl_PointSize = bubbleRadius();',
'} else {',
'gl_PointSize = pSize;',
'}',
//'gl_PointSize = 10.0;',
'vColor = aColor;',
'if (isInverted) {',
'gl_Position = uPMatrix * vec4(xToPixels(aVertexPosition.y) + yAxisPos, yToPixels(aVertexPosition.x, aVertexPosition.z) + xAxisPos, 0.0, 1.0);',
'} else {',
'gl_Position = uPMatrix * vec4(xToPixels(aVertexPosition.x) + xAxisPos, yToPixels(aVertexPosition.y, aVertexPosition.z) + yAxisPos, 0.0, 1.0);',
'}',
//'gl_Position = uPMatrix * vec4(aVertexPosition.x, aVertexPosition.y, 0.0, 1.0);',
'}'
/* eslint-enable */
].join('\n'),
//Fragment shader source
fragShade = [
/* eslint-disable */
'precision highp float;',
'uniform vec4 fillColor;',
'varying highp vec2 position;',
'varying highp vec4 vColor;',
'uniform sampler2D uSampler;',
'uniform bool isCircle;',
'uniform bool hasColor;',
// 'vec4 toColor(float value, vec2 point) {',
// 'return vec4(0.0, 0.0, 0.0, 0.0);',
// '}',
'void main(void) {',
'vec4 col = fillColor;',
'if (hasColor) {',
'col = vColor;',
'}',
'if (isCircle) {',
'gl_FragColor = col * texture2D(uSampler, gl_PointCoord.st);',
'} else {',
'gl_FragColor = col;',
'}',
'}'
/* eslint-enable */
].join('\n'),
uLocations = {},
//The shader program
shaderProgram,
//Uniform handle to the perspective matrix
pUniform,
//Uniform for point size
psUniform,
//Uniform for fill color
fillColorUniform,
//Uniform for isBubble
isBubbleUniform,
//Uniform for bubble abs sizing
bubbleSizeAbsUniform,
bubbleSizeAreaUniform,
//Skip translation uniform
skipTranslationUniform,
//Set to 1 if circle
isCircleUniform,
//Uniform for invertion
isInverted,
//Texture uniform
uSamplerUniform;
/* String to shader program
* @param {string} str - the program source
* @param {string} type - the program type: either `vertex` or `fragment`
* @returns {bool|shader}
*/
function stringToProgram(str, type) {
var t = type === 'vertex' ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER,
shader = gl.createShader(t);
gl.shaderSource(shader, str);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
//console.error('shader error:', gl.getShaderInfoLog(shader));
return false;
}
return shader;
}
/*
* Create the shader.
* Loads the shader program statically defined above
*/
function createShader() {
var v = stringToProgram(vertShade, 'vertex'),
f = stringToProgram(fragShade, 'fragment');
if (!v || !f) {
shaderProgram = false;
//console.error('error creating shader program');
return false;
}
function uloc(n) {
return gl.getUniformLocation(shaderProgram, n);
}
shaderProgram = gl.createProgram();
gl.attachShader(shaderProgram, v);
gl.attachShader(shaderProgram, f);
gl.linkProgram(shaderProgram);
gl.useProgram(shaderProgram);
gl.bindAttribLocation(shaderProgram, 0, 'aVertexPosition');
pUniform = uloc('uPMatrix');
psUniform = uloc('pSize');
fillColorUniform = uloc('fillColor');
isBubbleUniform = uloc('isBubble');
bubbleSizeAbsUniform = uloc('bubbleSizeAbs');
bubbleSizeAreaUniform = uloc('bubbleSizeByArea');
uSamplerUniform = uloc('uSampler');
skipTranslationUniform = uloc('skipTranslation');
isCircleUniform = uloc('isCircle');
isInverted = uloc('isInverted');
return true;
}
/*
* Destroy the shader
*/
function destroy() {
if (gl && shaderProgram) {
gl.deleteProgram(shaderProgram);
}
}
/*
* Bind the shader.
* This makes the shader the active one until another one is bound,
* or until 0 is bound.
*/
function bind() {
gl.useProgram(shaderProgram);
}
/*
* Set a uniform value.
* This uses a hash map to cache uniform locations.
* @param name {string} - the name of the uniform to set
* @param val {float} - the value to set
*/
function setUniform(name, val) {
var u = uLocations[name] = uLocations[name] ||
gl.getUniformLocation(shaderProgram, name);
gl.uniform1f(u, val);
}
/*
* Set the active texture
* @param texture - the texture
*/
function setTexture() {
gl.uniform1i(uSamplerUniform, 0);
}
/*
* Set if inversion state
* @flag is the state
*/
function setInverted(flag) {
gl.uniform1i(isInverted, flag);
}
////////////////////////////////////////////////////////////////////////////
/*
* Enable/disable circle drawing
*/
function setDrawAsCircle(flag) {
gl.uniform1i(isCircleUniform, flag ? 1 : 0);
}
/*
* Flush
*/
function reset() {
gl.uniform1i(isBubbleUniform, 0);
gl.uniform1i(isCircleUniform, 0);
}
/*
* Set bubble uniforms
* @param series {Highcharts.Series} - the series to use
*/
function setBubbleUniforms(series, zCalcMin, zCalcMax) {
var seriesOptions = series.options,
zMin = Number.MAX_VALUE,
zMax = -Number.MAX_VALUE;
if (series.type === 'bubble') {
zMin = pick(seriesOptions.zMin, Math.min(
zMin,
Math.max(
zCalcMin,
seriesOptions.displayNegative === false ?
seriesOptions.zThreshold : -Number.MAX_VALUE
)
));
zMax = pick(seriesOptions.zMax, Math.max(zMax, zCalcMax));
gl.uniform1i(isBubbleUniform, 1);
gl.uniform1i(isCircleUniform, 1);
gl.uniform1i(bubbleSizeAreaUniform, series.options.sizeBy !== 'width');
gl.uniform1i(bubbleSizeAbsUniform, series.options.sizeByAbsoluteValue);
setUniform('bubbleZMin', zMin);
setUniform('bubbleZMax', zMax);
setUniform('bubbleZThreshold', series.options.zThreshold);
setUniform('bubbleMinSize', series.minPxSize);
setUniform('bubbleMaxSize', series.maxPxSize);
}
}
/*
* Set the Color uniform.
* @param color {Array<float>} - an array with RGBA values
*/
function setColor(color) {
gl.uniform4f(
fillColorUniform,
color[0] / 255.0,
color[1] / 255.0,
color[2] / 255.0,
color[3]
);
}
/*
* Set skip translation
*/
function setSkipTranslation(flag) {
gl.uniform1i(skipTranslationUniform, flag === true ? 1 : 0);
}
/*
* Set the perspective matrix
* @param m {Matrix4x4} - the matrix
*/
function setPMatrix(m) {
gl.uniformMatrix4fv(pUniform, false, m);
}
/*
* Set the point size.
* @param p {float} - point size
*/
function setPointSize(p) {
gl.uniform1f(psUniform, p);
}
/*
* Get the shader program handle
* @returns {GLInt} - the handle for the program
*/
function getProgram() {
return shaderProgram;
}
if (gl) {
createShader();
}
return {
psUniform: function() {
return psUniform;
},
pUniform: function() {
return pUniform;
},
fillColorUniform: function() {
return fillColorUniform;
},
setBubbleUniforms: setBubbleUniforms,
bind: bind,
program: getProgram,
create: createShader,
setUniform: setUniform,
setPMatrix: setPMatrix,
setColor: setColor,
setPointSize: setPointSize,
setSkipTranslation: setSkipTranslation,
setTexture: setTexture,
setDrawAsCircle: setDrawAsCircle,
reset: reset,
setInverted: setInverted,
destroy: destroy
};
}
/*
* Vertex Buffer abstraction
* A vertex buffer is a set of vertices which are passed to the GPU
* in a single call.
* @param gl {WebGLContext} - the context in which to create the buffer
* @param shader {GLShader} - the shader to use
*/
function GLVertexBuffer(gl, shader, dataComponents /*, type */ ) {
var buffer = false,
vertAttribute = false,
components = dataComponents || 2,
preAllocated = false,
iterator = 0,
data;
// type = type || 'float';
function destroy() {
if (buffer) {
gl.deleteBuffer(buffer);
}
}
/*
* Build the buffer
* @param dataIn {Array<float>} - a 0 padded array of indices
* @param attrib {String} - the name of the Attribute to bind the buffer to
* @param dataComponents {Integer} - the number of components per. indice
*/
function build(dataIn, attrib, dataComponents) {
data = dataIn || [];
if ((!data || data.length === 0) && !preAllocated) {
//console.error('trying to render empty vbuffer');
buffer = false;
return false;
}
components = dataComponents || components;
if (buffer) {
gl.deleteBuffer(buffer);
}
buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(
gl.ARRAY_BUFFER,
preAllocated || new Float32Array(data),
gl.STATIC_DRAW
);
// gl.bindAttribLocation(shader.program(), 0, 'aVertexPosition');
vertAttribute = gl.getAttribLocation(shader.program(), attrib);
gl.enableVertexAttribArray(vertAttribute);
return true;
}
/*
* Bind the buffer
*/
function bind() {
if (!buffer) {
return false;
}
// gl.bindAttribLocation(shader.program(), 0, 'aVertexPosition');
//gl.enableVertexAttribArray(vertAttribute);
//gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.vertexAttribPointer(vertAttribute, components, gl.FLOAT, false, 0, 0);
//gl.enableVertexAttribArray(vertAttribute);
}
/*
* Render the buffer
* @param from {Integer} - the start indice
* @param to {Integer} - the end indice
* @param drawMode {String} - the draw mode
*/
function render(from, to, drawMode) {
var length = preAllocated ? preAllocated.length : data.length;
if (!buffer) {
return false;
}
if (!length) {
return false;
}
if (!from || from > length || from < 0) {
from = 0;
}
if (!to || to > length) {
to = length;
}
drawMode = drawMode || 'points';
gl.drawArrays(
gl[drawMode.toUpperCase()],
from / components,
(to - from) / components
);
return true;
}
function push(x, y, a, b) {
if (preAllocated) { // && iterator <= preAllocated.length - 4) {
preAllocated[++iterator] = x;
preAllocated[++iterator] = y;
preAllocated[++iterator] = a;
preAllocated[++iterator] = b;
}
}
/*
* Note about pre-allocated buffers:
* - This is slower for charts with many series
*/
function allocate(size) {
size *= 4;
iterator = -1;
//if (!preAllocated || (preAllocated && preAllocated.length !== size)) {
preAllocated = new Float32Array(size);
//}
}
////////////////////////////////////////////////////////////////////////////
return {
destroy: destroy,
bind: bind,
data: data,
build: build,
render: render,
allocate: allocate,
push: push
};
}
/* Main renderer. Used to render series.
* Notes to self:
* - May be able to build a point map by rendering to a separate canvas
* and encoding values in the color data.
* - Need to figure out a way to transform the data quicker
*/
function GLRenderer(postRenderCallback) {
var // Shader
shader = false,
// Vertex buffers - keyed on shader attribute name
vbuffer = false,
// Opengl context
gl = false,
// Width of our viewport in pixels
width = 0,
// Height of our viewport in pixels
height = 0,
// The data to render - array of coordinates
data = false,
// The marker data
markerData = false,
// Is the texture ready?
textureIsReady = false,
// Exports
exports = {},
// Is it inited?
isInited = false,
// The series stack
series = [],
// Texture for circles
circleTexture = doc.createElement('canvas'),
// Context for circle texture
circleCtx = circleTexture.getContext('2d'),
// Handle for the circle texture
circleTextureHandle,
// Things to draw as "rectangles" (i.e lines)
asBar = {
'column': true,
'area': true
},
asCircle = {
'scatter': true,
'bubble': true
},
//Render settings
settings = {
pointSize: 1,
lineWidth: 3,
fillColor: '#AA00AA',
useAlpha: true,
usePreallocated: false,
useGPUTranslations: false,
timeRendering: false,
timeSeriesProcessing: false,
timeSetup: false
};
////////////////////////////////////////////////////////////////////////////
function setOptions(options) {
merge(true, settings, options);
}
function seriesPointCount(series) {
var isStacked,
xData,
s;
if (isSeriesBoosting(series)) {
isStacked = !!series.options.stacking;
xData = series.xData || series.options.xData || series.processedXData;
s = (isStacked ? series.data : (xData || series.options.data)).length;
if (series.type === 'treemap') {
s *= 12;
} else if (series.type === 'heatmap') {
s *= 6;
} else if (asBar[series.type]) {
s *= 2;
}
return s;
}
return 0;
}
/* Allocate a float buffer to fit all series */
function allocateBuffer(chart) {
var s = 0;
if (!settings.usePreallocated) {
return;
}
each(chart.series, function(series) {
if (isSeriesBoosting(series)) {
s += seriesPointCount(series);
}
});
vbuffer.allocate(s);
}
function allocateBufferForSingleSeries(series) {
var s = 0;
if (!settings.usePreallocated) {
return;
}
if (isSeriesBoosting(series)) {
s = seriesPointCount(series);
}
vbuffer.allocate(s);
}
/*
* Returns an orthographic perspective matrix
* @param {number} width - the width of the viewport in pixels
* @param {number} height - the height of the viewport in pixels
*/
function orthoMatrix(width, height) {
var near = 0,
far = 1;
return [
2 / width, 0, 0, 0,
0, -(2 / height), 0, 0,
0, 0, -2 / (far - near), 0, -1, 1, -(far + near) / (far - near), 1
];
}
/*
* Clear the depth and color buffer
*/
function clear() {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
}
/*
* Get the WebGL context
* @returns {WebGLContext} - the context
*/
function getGL() {
return gl;
}
/*
* Push data for a single series
* This calculates additional vertices and transforms the data to be
* aligned correctly in memory
*/
function pushSeriesData(series, inst) {
var isRange = series.pointArrayMap &&
series.pointArrayMap.join(',') === 'low,high',
chart = series.chart,
options = series.options,
isStacked = !!options.stacking,
rawData = options.data,
xExtremes = series.xAxis.getExtremes(),
xMin = xExtremes.min,
xMax = xExtremes.max,
yExtremes = series.yAxis.getExtremes(),
yMin = yExtremes.min,
yMax = yExtremes.max,
xData = series.xData || options.xData || series.processedXData,
yData = series.yData || options.yData || series.processedYData,
zData = series.zData || options.zData || series.processedZData,
yAxis = series.yAxis,
xAxis = series.xAxis,
useRaw = !xData || xData.length === 0,
// threshold = options.threshold,
// yBottom = chart.yAxis[0].getThreshold(threshold),
// hasThreshold = isNumber(threshold),
// colorByPoint = series.options.colorByPoint,
// This is required for color by point, so make sure this is
// uncommented if enabling that
// colorIndex = 0,
// Required for color axis support
// caxis,
// connectNulls = options.connectNulls,
// For some reason eslint doesn't pick up that this is actually used
maxVal, //eslint-disable-line no-unused-vars
points = series.points || false,
lastX = false,
minVal,
color,
scolor,
sdata = isStacked ? series.data : (xData || rawData);
if (options.boostData && options.boostData.length > 0) {
return;
}
series.closestPointRangePx = Number.MAX_VALUE;
// Push color to color buffer - need to do this per. vertex
function pushColor(color) {
if (color) {
inst.colorData.push(color[0]);
inst.colorData.push(color[1]);
inst.colorData.push(color[2]);
inst.colorData.push(color[3]);
}
}
//Push a vertice to the data buffer
function vertice(x, y, checkTreshold, pointSize, color) {
pushColor(color);
if (settings.usePreallocated) {
vbuffer.push(x, y, checkTreshold ? 1 : 0, pointSize || 1);
} else {
data.push(x);
data.push(y);
data.push(checkTreshold ? 1 : 0);
data.push(pointSize || 1);
}
}
// Push a rectangle to the data buffer
function pushRect(x, y, w, h, color) {
pushColor(color);
vertice(x + w, y);
pushColor(color);
vertice(x, y);
pushColor(color);
vertice(x, y + h);
pushColor(color);
vertice(x, y + h);
pushColor(color);
vertice(x + w, y + h);
pushColor(color);
vertice(x + w, y);
}
// Special case for point shapes
if (points && points.length > 0) {
// If we're doing points, we assume that the points are already
// translated, so we skip the shader translation.
inst.skipTranslation = true;
// Force triangle draw mode
inst.drawMode = 'triangles';
// We don't have a z component in the shader, so we need to sort.
if (points[0].node && points[0].node.levelDynamic) {
points.sort(function(a, b) {
if (a.node) {
if (a.node.levelDynamic > b.node.levelDynamic) {
return 1;
} else if (a.node.levelDynamic < b.node.levelDynamic) {
return -1;
}
}
return 0;
});
}
each(points, function(point) {
var plotY = point.plotY,
shapeArgs,
swidth,
pointAttr;
if (plotY !== undefined && !isNaN(plotY) && point.y !== null) {
shapeArgs = point.shapeArgs;
pointAttr = (point.pointAttr && point.pointAttr['']) ||
point.series.pointAttribs(point);
swidth = pointAttr['stroke-width'];
// Handle point colors
color = H.color(pointAttr.fill).rgba;
color[0] /= 255.0;
color[1] /= 255.0;
color[2] /= 255.0;
// So there are two ways of doing this. Either we can
// create a rectangle of two triangles, or we can do a
// point and use point size. Latter is faster, but
// only supports squares. So we're doing triangles.
// We could also use one color per. vertice to get
// better color interpolation.
// If there's stroking, we do an additional rect
//if (pointAttr.stroke !== 'none' && swidth && swidth > 0) {
if (series.type === 'treemap') {
swidth = swidth || 1;
scolor = H.color(pointAttr.stroke).rgba;
scolor[0] /= 255.0;
scolor[1] /= 255.0;
scolor[2] /= 255.0;
pushRect(
shapeArgs.x,
shapeArgs.y,
shapeArgs.width,
shapeArgs.height,
scolor
);
swidth /= 2;
}
// } else {
// swidth = 0;
// }
pushRect(
shapeArgs.x + swidth,
shapeArgs.y + swidth,
shapeArgs.width - (swidth * 2),
shapeArgs.height - (swidth * 2),
color
);
}
});
return;
}
// Extract color axis
// each(chart.axes || [], function (a) {
// if (H.ColorAxis && a instanceof H.ColorAxis) {
// caxis = a;
// }
// });
each(sdata, function(d, i) {
var x,
y,
z,
px = false,
nx = false,
// This is in fact used.
low, //eslint-disable-line no-unused-vars
chartDestroyed = typeof chart.index === 'undefined',
nextInside = false,
prevInside = false,
pcolor = false,
drawAsBar = asBar[series.type],
isXInside = false,
isYInside = true;
if (chartDestroyed) {
return false;
}
// Uncomment this to enable color by point.
// This currently left disabled as the charts look really ugly
// when enabled and there's a lot of points.
// Leaving in for the future (tm).
// if (colorByPoint) {
// colorIndex = ++colorIndex % series.chart.options.colors.length;
// pcolor = toRGBAFast(series.chart.options.colors[colorIndex]);
// pcolor[0] /= 255.0;
// pcolor[1] /= 255.0;
// pcolor[2] /= 255.0;
// }
if (useRaw) {
x = d[0];
y = d[1];
if (sdata[i + 1]) {
nx = sdata[i + 1][0];
}
if (sdata[i - 1]) {
px = sdata[i - 1][0];
}
if (d.length >= 3) {
z = d[2];
if (d[2] > inst.zMax) {
inst.zMax = d[2];
}
if (d[2] < inst.zMin) {
inst.zMin = d[2];
}
}
} else {
x = d;
y = yData[i];
if (sdata[i + 1]) {
nx = sdata[i + 1];
}
if (sdata[i - 1]) {
px = sdata[i - 1];
}
if (zData && zData.length) {
z = zData[i];
if (zData[i] > inst.zMax) {
inst.zMax = zData[i];
}
if (zData[i] < inst.zMin) {
inst.zMin = zData[i];
}
}
}
if (nx && nx >= xMin && nx <= xMax) {
nextInside = true;
}
if (px && px >= xMin && px <= xMax) {
prevInside = true;
}
if (isRange) {
if (useRaw) {
y = d.slice(1, 3);
}
low = y[0];
y = y[1];
} else if (isStacked) {
x = d.x;
y = d.stackY;
low = y - d.y;
}
if (!series.requireSorting) {
isYInside = y >= yMin && y <= yMax;
}
if ((!y || !isYInside)) {
return;
}
if (x >= xMin && x <= xMax) {
isXInside = true;
}
if (!isXInside && !nextInside && !prevInside) {
return;
}
// Skip translations - temporary floating point fix
if (!settings.useGPUTranslations) {
inst.skipTranslation = true;
x = xAxis.toPixels(x, true);
y = yAxis.toPixels(y, true);
}
if (drawAsBar) {
maxVal = y;
minVal = 0;
if (y < 0) {
minVal = y;
y = 0;
}
if (!settings.useGPUTranslations) {
minVal = yAxis.toPixels(minVal, true);
}
// Need to add an extra point here
vertice(x, minVal, 0, 0, pcolor);
}
// No markers on out of bounds things.
// Out of bound things are shown if and only if the next
// or previous point is inside the rect.
if (inst.hasMarkers) { // && isXInside) {
// x = H.correctFloat(
// Math.min(Math.max(-1e5, xAxis.translate(
// x,
// 0,
// 0,
// 0,
// 1,
// 0.5,
// false
// )), 1e5)
// );
if (lastX !== false) {
series.closestPointRangePx = Math.min(
series.closestPointRangePx,
Math.abs(x - lastX)
);
}
}
vertice(
x,
y,
0,
series.type === 'bubble' ? (z || 1) : 2,
pcolor
);
// Uncomment this to support color axis.
// if (caxis) {
// color = H.color(caxis.toColor(y)).rgba;
// inst.colorData.push(color[0] / 255.0);
// inst.colorData.push(color[1] / 255.0);
// inst.colorData.push(color[2] / 255.0);
// inst.colorData.push(color[3]);
// }
lastX = x;
//return true;
});
}
/*
* Push a series to the renderer
* If we render the series immediatly, we don't have to loop later
* @param s {Highchart.Series} - the series to push
*/
function pushSeries(s) {
if (series.length > 0) {
series[series.length - 1].to = data.length;
if (series[series.length - 1].hasMarkers) {
series[series.length - 1].markerTo = markerData.length;
}
}
if (settings.timeSeriesProcessing) {
console.time('building ' + s.type + ' series'); //eslint-disable-line no-console
}
series.push({
from: data.length,
markerFrom: markerData.length,
// Push RGBA values to this array to use per. point coloring.
// It should be 0-padded, so each component should be pushed in
// succession.
colorData: [],
series: s,
zMin: Number.MAX_VALUE,
zMax: -Number.MAX_VALUE,
hasMarkers: s.options.marker ? s.options.marker.enabled !== false : false,
showMarksers: true,
drawMode: ({
'area': 'lines',
'arearange': 'lines',
'areaspline': 'line_strip',
'column': 'lines',
'line': 'line_strip',
'scatter': 'points',
'heatmap': 'triangles',
'treemap': 'triangles',
'bubble': 'points'
})[s.type] || 'line_strip'
});
// Add the series data to our buffer(s)
pushSeriesData(s, series[series.length - 1]);
if (settings.timeSeriesProcessing) {
console.timeEnd('building ' + s.type + ' series'); //eslint-disable-line no-console
}
}
/*
* Flush the renderer.
* This removes pushed series and vertices.
* Should be called after clearing and before rendering
*/
function flush() {
series = [];
exports.data = data = [];
markerData = [];
}
/*
* Pass x-axis to shader
* @param axis {Highcharts.Axis} - the x-axis
*/
function setXAxis(axis) {
if (!shader) {
return;
}
shader.setUniform('xAxisTrans', axis.transA);
shader.setUniform('xAxisMin', axis.min);
shader.setUniform('xAxisMinPad', axis.minPixelPadding);
shader.setUniform('xAxisPointRange', axis.pointRange);
shader.setUniform('xAxisLen', axis.len);
shader.setUniform('xAxisPos', axis.pos);
shader.setUniform('xAxisCVSCoord', !axis.horiz);
}
/*
* Pass y-axis to shader
* @param axis {Highcharts.Axis} - the y-axis
*/
function setYAxis(axis) {
if (!shader) {
return;
}
shader.setUniform('yAxisTrans', axis.transA);
shader.setUniform('yAxisMin', axis.min);
shader.setUniform('yAxisMinPad', axis.minPixelPadding);
shader.setUniform('yAxisPointRange', axis.pointRange);
shader.setUniform('yAxisLen', axis.len);
shader.setUniform('yAxisPos', axis.pos);
shader.setUniform('yAxisCVSCoord', !axis.horiz);
}
/*
* Set the translation threshold
* @param has {boolean} - has threshold flag
* @param translation {Float} - the threshold
*/
function setThreshold(has, translation) {
shader.setUniform('hasThreshold', has);
shader.setUniform('translatedThreshold', translation);
}
/*
* Render the data
* This renders all pushed series.
*/
function render(chart) {
if (chart) {
if (!chart.chartHeight || !chart.chartWidth) {
//chart.setChartSize();
}
width = chart.chartWidth || 800;
height = chart.chartHeight || 400;
} else {
return false;
}
if (!gl || !width || !height) {
return false;
}
if (settings.timeRendering) {
console.time('gl rendering'); //eslint-disable-line no-console
}
shader.bind();
gl.viewport(0, 0, width, height);
shader.setPMatrix(orthoMatrix(width, height));
gl.lineWidth(settings.lineWidth);
vbuffer.build(exports.data, 'aVertexPosition', 4);
vbuffer.bind();
if (textureIsReady) {
gl.bindTexture(gl.TEXTURE_2D, circleTextureHandle);
shader.setTexture(circleTextureHandle);
}
shader.setInverted(chart.options.chart ? chart.options.chart.inverted : false);
// Render the series
each(series, function(s, si) {
var options = s.series.options,
threshold = options.threshold,
hasThreshold = isNumber(threshold),
yBottom = s.series.yAxis.getThreshold(threshold),
translatedThreshold = yBottom,
cbuffer,
showMarkers = pick(
options.marker ? options.marker.enabled : null,
s.series.xAxis.isRadial ? true : null,
s.series.closestPointRangePx >
2 * ((
options.marker ?
options.marker.radius :
10
) || 10)
),
fillColor = s.series.fillOpacity ?
new Color(s.series.color).setOpacity(
pick(options.fillOpacity, 0.85)
).get() :
s.series.color,
color;
vbuffer.bind();
if (options.colorByPoint) {
fillColor = s.series.chart.options.colors[si];
}
color = H.color(fillColor).rgba;
if (!settings.useAlpha) {
color[3] = 1.0;
}
//Blending
if (options.boostBlending === 'add') { // docs
gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
gl.blendEquation(gl.FUNC_ADD);
} else if (options.boostBlending === 'mult') {
gl.blendFunc(gl.DST_COLOR, gl.ZERO);
} else if (options.boostBlending === 'darken') {
gl.blendFunc(gl.ONE, gl.ONE);
gl.blendEquation(gl.FUNC_MIN);
} else {
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); //, gl.ONE, gl.ZERO);
gl.blendEquation(gl.FUNC_ADD);
}
shader.reset();
// If there are entries in the colorData buffer, build and bind it.
if (s.colorData.length > 0) {
shader.setUniform('hasColor', 1.0);
cbuffer = GLVertexBuffer(gl, shader); //eslint-disable-line new-cap
cbuffer.build(s.colorData, 'aColor', 4);
cbuffer.bind();
}
// Set series specific uniforms
shader.setColor(color);
setXAxis(s.series.xAxis);
setYAxis(s.series.yAxis);
setThreshold(hasThreshold, translatedThreshold);
if (s.drawMode === 'points') {
if (options.marker && options.marker.radius) {
shader.setPointSize(options.marker.radius * 2.0);
} else {
shader.setPointSize(1);
}
}
// If set to true, the toPixels translations in the shader
// is skipped, i.e it's assumed that the value is a pixel coord.
shader.setSkipTranslation(s.skipTranslation);
if (s.series.type === 'bubble') {
shader.setBubbleUniforms(s.series, s.zMin, s.zMax);
}
shader.setDrawAsCircle((asCircle[s.series.type] && textureIsReady) || false);
// Do the actual rendering
vbuffer.render(s.from, s.to, s.drawMode);
if (s.hasMarkers && showMarkers) {
if (options.marker && options.marker.radius) {
shader.setPointSize(options.marker.radius * 2.0);
} else {
shader.setPointSize(10);
}
shader.setDrawAsCircle(true);
vbuffer.render(s.from, s.to, 'POINTS');
}
});
vbuffer.destroy();
if (settings.timeRendering) {
console.timeEnd('gl rendering'); //eslint-disable-line no-console
}
flush();
if (postRenderCallback) {
postRenderCallback();
}
}
/*
* Render the data when ready
*/
function renderWhenReady(chart) {
clear();
if (chart.renderer.forExport) {
return render(chart);
}
if (isInited) {
render(chart);
} else {
setTimeout(function() {
renderWhenReady(chart);
}, 1);
}
}
/*
* Set the viewport size in pixels
* Creates an orthographic perspective matrix and applies it.
* @param w {Integer} - the width of the viewport
* @param h {Integer} - the height of the viewport
*/
function setSize(w, h) {
// Skip if there's no change
if (width === w && h === h) {
return;
}
width = w;
height = h;
shader.bind();
shader.setPMatrix(orthoMatrix(width, height));
}
/*
* Init OpenGL
* @param canvas {HTMLCanvas} - the canvas to render to
*/
function init(canvas, noFlush) {
var i = 0,
activeContext,
contexts = [
'webgl',
'experimental-webgl',
'moz-webgl',
'webkit-3d'
];
isInited = false;
if (!canvas) {
return false;
}
if (settings.timeSetup) {
console.time('gl setup'); //eslint-disable-line no-console
}
for (; i < contexts.length; i++) {
gl = canvas.getContext(contexts[i]);
if (gl) {
activeContext = contexts[i];
break;
}
}
if (gl) {
if (!noFlush) {
flush();
}
} else {
return false;
}
gl.enable(gl.BLEND);
// gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
gl.disable(gl.DEPTH_TEST);
gl.depthMask(gl.FALSE);
shader = GLShader(gl); //eslint-disable-line new-cap
vbuffer = GLVertexBuffer(gl, shader); //eslint-disable-line new-cap
textureIsReady = false;
// Set up the circle texture used for bubbles
circleTextureHandle = gl.createTexture();
// Draw the circle
circleTexture.width = 512;
circleTexture.height = 512;
circleCtx.fillStyle = '#FFF';
circleCtx.beginPath();
circleCtx.arc(256, 256, 256, 0, 2 * Math.PI);
circleCtx.fill();
try {
gl.bindTexture(gl.TEXTURE_2D, circleTextureHandle);
gl.texImage2D(
gl.TEXTURE_2D,
0,
gl.RGBA,
gl.RGBA,
gl.UNSIGNED_BYTE,
circleTexture
);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
textureIsReady = true;
} catch (e) {}
isInited = true;
if (settings.timeSetup) {
console.timeEnd('gl setup'); //eslint-disable-line no-console
}
return true;
}
/*
* Check if we have a valid OGL context
* @returns {Boolean} - true if the context is valid
*/
function valid() {
return gl !== false;
}
/*
* Check if the renderer has been initialized
* @returns {Boolean} - true if it has, false if not
*/
function inited() {
return isInited;
}
function destroy() {
vbuffer.destroy();
shader.destroy();
if (gl) {
//gl.deleteTexture(circleTextureHandle);
}
}
////////////////////////////////////////////////////////////////////////////
exports = {
allocateBufferForSingleSeries: allocateBufferForSingleSeries,
pushSeries: pushSeries,
setSize: setSize,
inited: inited,
setThreshold: setThreshold,
init: init,
render: renderWhenReady,
settings: settings,
valid: valid,
clear: clear,
flush: flush,
setXAxis: setXAxis,
setYAxis: setYAxis,
data: data,
gl: getGL,
allocateBuffer: allocateBuffer,
destroy: destroy,
setOptions: setOptions
};
return exports;
}
// END OF WEBGL ABSTRACTIONS
////////////////////////////////////////////////////////////////////////////////
/*
* Create a canvas + context and attach it to the target
* @param target {Highcharts.Chart|Highcharts.Series} - the canvas target
* @param chart {Highcharts.Chart} - the chart
*/
function createAndAttachRenderer(chart, series) {
var width = chart.chartWidth,
height = chart.chartHeight,
target = chart,
targetGroup = chart.seriesGroup || series.group,
swapXY = function(proceed, x, y, a, b, c, d) {
proceed.call(series, y, x, a, b, c, d);
};
if (isChartSeriesBoosting(chart)) {
target = chart;
} else {
target = series;
}
if (target.ogl) {
//target.ogl.destroy();
}
if (!target.image) {
target.canvas = doc.createElement('canvas');
target.image = chart.renderer.image(
'',
0,
0,
width,
height
).add(targetGroup);
target.boostClipRect = chart.renderer.clipRect(
chart.plotLeft,
chart.plotTop,
chart.plotWidth,
chart.chartHeight
);
target.image.clip(target.boostClipRect);
if (target.inverted) {
each(['moveTo', 'lineTo', 'rect', 'arc'], function(fn) {
wrap(false, fn, swapXY);
});
}
if (target instanceof H.Chart) {
target.markerGroup = target.renderer.g().add(targetGroup);
target.markerGroup.translate(series.xAxis.pos, series.yAxis.pos);
}
}
target.canvas.width = width;
target.canvas.height = height;
target.image.attr({
x: 0,
y: 0,
width: width,
height: height,
style: 'pointer-events: none'
});
target.boostClipRect.attr({
x: chart.plotLeft,
y: chart.plotTop,
width: chart.plotWidth,
height: chart.chartHeight
});
if (!target.ogl) {
target.ogl = GLRenderer(function() { // eslint-disable-line new-cap
target.image.attr({
href: target.canvas.toDataURL('image/png')
});
}); //eslint-disable-line new-cap
target.ogl.init(target.canvas);
// target.ogl.clear();
target.ogl.setOptions(chart.options.boost || {});
if (target instanceof H.Chart) {
target.ogl.allocateBuffer(chart);
}
}
target.ogl.setSize(width, height);
return target.ogl;
}
/*
* Performs the actual render if the renderer is
* attached to the series.
* @param renderer {OGLRenderer} - the renderer
* @param series {Highcharts.Series} - the series
*/
function renderIfNotSeriesBoosting(renderer, series, chart) {
if (renderer &&
series.image &&
series.canvas &&
!isChartSeriesBoosting(chart || series.chart)
) {
renderer.render(chart || series.chart);
}
}
function allocateIfNotSeriesBoosting(renderer, series) {
if (renderer &&
series.image &&
series.canvas &&
!isChartSeriesBoosting(series.chart)
) {
renderer.allocateBufferForSingleSeries(series);
}
}
/*
* An "async" foreach loop.
* Uses a setTimeout to keep the loop from blocking the UI thread
* @param arr {Array} - the array to loop through
* @param fn {Function} - the callback to call for each item
* @param finalFunc {Function} - the callback to call when done
* @param chunkSize {Number} - the number of iterations per. timeout
* @param i {Number} - the current index
* @param noTimeout {Boolean} - set to true to skip timeouts
*/
function eachAsync(arr, fn, finalFunc, chunkSize, i, noTimeout) {
i = i || 0;
chunkSize = chunkSize || CHUNK_SIZE;
var threshold = i + chunkSize,
proceed = true;
while (proceed && i < threshold && i < arr.length) {
proceed = fn(arr[i], i);
++i;
}
if (proceed) {
if (i < arr.length) {
if (noTimeout) {
eachAsync(arr, fn, finalFunc, chunkSize, i, noTimeout);
} else if (win.requestAnimationFrame) {
//If available, do requestAnimationFrame - shaves off a few ms
win.requestAnimationFrame(function() {
eachAsync(arr, fn, finalFunc, chunkSize, i);
});
} else {
setTimeout(function() {
eachAsync(arr, fn, finalFunc, chunkSize, i);
});
}
} else if (finalFunc) {
finalFunc();
}
}
}
////////////////////////////////////////////////////////////////////////////////
// Following is the parts of the boost that's common between OGL/Legacy
/**
* Return a full Point object based on the index.
* The boost module uses stripped point objects for performance reasons.
* @param {Number} boostPoint A stripped-down point object
* @returns {Object} A Point object as per http://api.highcharts.com/highcharts#Point
*/
Series.prototype.getPoint = function(boostPoint) {
var point = boostPoint,
xData = this.xData || this.options.xData || this.processedXData || false;
if (boostPoint && !(boostPoint instanceof this.pointClass)) {
point = (new this.pointClass()).init( // eslint-disable-line new-cap
this,
this.options.data[boostPoint.i],
xData ? xData[boostPoint.i] : undefined
);
point.category = point.x;
point.dist = boostPoint.dist;
point.distX = boostPoint.distX;
point.plotX = boostPoint.plotX;
point.plotY = boostPoint.plotY;
point.index = boostPoint.i;
}
return point;
};
/**
* Return a point instance from the k-d-tree
*/
wrap(Series.prototype, 'searchPoint', function(proceed) {
return this.getPoint(
proceed.apply(this, [].slice.call(arguments, 1))
);
});
/**
* Extend series.destroy to also remove the fake k-d-tree points (#5137).
* Normally this is handled by Series.destroy that calls Point.destroy,
* but the fake search points are not registered like that.
*/
wrap(Series.prototype, 'destroy', function(proceed) {
var series = this,
chart = series.chart;
if (chart.markerGroup === series.markerGroup) {
series.markerGroup = null;
}
if (chart.hoverPoints) {
chart.hoverPoints = grep(chart.hoverPoints, function(point) {
return point.series === series;
});
}
if (chart.hoverPoint && chart.hoverPoint.series === series) {
chart.hoverPoint = null;
}
proceed.call(this);
});
/**
* Do not compute extremes when min and max are set.
* If we use this in the core, we can add the hook
* to hasExtremes to the methods directly.
*/
wrap(Series.prototype, 'getExtremes', function(proceed) {
if (!isSeriesBoosting(this) || (!this.hasExtremes || !this.hasExtremes())) {
return proceed.apply(this, Array.prototype.slice.call(arguments, 1));
}
});
// Set default options
each([
'area',
'arearange',
'column',
'line',
'scatter',
'heatmap',
'bubble',
'treemap',
'heatmap'
],
function(type) {
if (plotOptions[type]) {
plotOptions[type].boostThreshold = 5000;
plotOptions[type].boostData = [];
}
}
);
/**
* Override a bunch of methods the same way. If the number of points is
* below the threshold, run the original method. If not, check for a
* canvas version or do nothing.
*
* Note that we're not overriding any of these for heatmaps.
*/
each([
'translate',
'generatePoints',
'drawTracker',
'drawPoints',
'render'
], function(method) {
function branch(proceed) {
var letItPass = this.options.stacking &&
(method === 'translate' || method === 'generatePoints');
if (!isSeriesBoosting(this) ||
letItPass ||
this.type === 'heatmap' ||
this.type === 'treemap'
) {
// Clear image
if (method === 'render' && this.image && !isChartSeriesBoosting(this.chart)) {
this.image.attr({
href: ''
});
this.animate = null; // We're zooming in, don't run animation
}
proceed.call(this);
// If a canvas version of the method exists, like renderCanvas(), run
} else if (this[method + 'Canvas']) {
this[method + 'Canvas']();
}
}
wrap(Series.prototype, method, branch);
// A special case for some types - their translate method is already wrapped
if (method === 'translate') {
if (seriesTypes.column) {
wrap(seriesTypes.column.prototype, method, branch);
}
if (seriesTypes.arearange) {
wrap(seriesTypes.arearange.prototype, method, branch);
}
if (seriesTypes.treemap) {
wrap(seriesTypes.treemap.prototype, method, branch);
}
}
});
/*
* Returns true if the current browser supports webgl
*/
function hasWebGLSupport() {
var i = 0,
canvas,
contexts = ['webgl', 'experimental-webgl', 'moz-webgl', 'webkit-3d'],
context = false;
if (typeof win.WebGLRenderingContext !== 'undefined') {
canvas = doc.createElement('canvas');
for (; i < contexts.length; i++) {
try {
context = canvas.getContext(contexts[i]);
if (typeof context !== 'undefined' && context !== null) {
return true;
}
} catch (e) {
}
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
// We're wrapped in a closure, so just return if there's no webgl support
if (!hasWebGLSupport()) {
if (typeof H.initCanvasBoost !== 'undefined') {
// Fallback to canvas boost
H.initCanvasBoost();
} else {
H.error(26);
}
//eslint-disable
return;
//eslint-enable
}
////////////////////////////////////////////////////////////////////////////////
// GL-SPECIFIC WRAPPINGS FOLLOWS
/** If the series is a heatmap or treemap, or if the series is not boosting
* do the default behaviour. Otherwise, process if the series has no
* extremes.
*/
wrap(Series.prototype, 'processData', function(proceed) {
// If this is a heatmap, do default behaviour
if (!isSeriesBoosting(this) ||
this.type === 'heatmap' ||
this.type === 'treemap') {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
}
if (!this.hasExtremes || !this.hasExtremes(true)) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
}
});
H.extend(Series.prototype, {
pointRange: 0,
directTouch: false,
allowDG: false, // No data grouping, let boost handle large data
hasExtremes: function(checkX) {
var options = this.options,
data = options.data,
xAxis = this.xAxis && this.xAxis.options,
yAxis = this.yAxis && this.yAxis.options;
return data.length > (options.boostThreshold || Number.MAX_VALUE) &&
isNumber(yAxis.min) && isNumber(yAxis.max) &&
(!checkX || (isNumber(xAxis.min) && isNumber(xAxis.max)));
},
/**
* If implemented in the core, parts of this can probably be
* shared with other similar methods in Highcharts.
*/
destroyGraphics: function() {
var series = this,
points = this.points,
point,
i;
if (points) {
for (i = 0; i < points.length; i = i + 1) {
point = points[i];
if (point && point.graphic) {
point.graphic = point.graphic.destroy();
}
}
}
each(['graph', 'area', 'tracker'], function(prop) {
if (series[prop]) {
series[prop] = series[prop].destroy();
}
});
},
renderCanvas: function() {
var series = this,
options = series.options || {},
renderer = false,
chart = series.chart,
xAxis = this.xAxis,
yAxis = this.yAxis,
//ctx,
//c = 0,
xData = options.xData || series.processedXData,
yData = options.yData || series.processedYData,
rawData = options.data,
xExtremes = xAxis.getExtremes(),
xMin = xExtremes.min,
xMax = xExtremes.max,
yExtremes = yAxis.getExtremes(),
yMin = yExtremes.min,
yMax = yExtremes.max,
pointTaken = {},
lastClientX,
sampling = !!series.sampling,
points,
// r = options.marker && options.marker.radius,
// cvsDrawPoint = this.cvsDrawPoint,
// cvsLineTo = options.lineWidth ? this.cvsLineTo : false,
// cvsMarker = r <= 1 ? this.cvsMarkerSquare : this.cvsMarkerCircle,
enableMouseTracking = options.enableMouseTracking !== false,
// lastPoint,
threshold = options.threshold,
yBottom = yAxis.getThreshold(threshold),
hasThreshold = isNumber(threshold),
// translatedThreshold = yBottom,
// doFill = this.fill,
isRange = series.pointArrayMap &&
series.pointArrayMap.join(',') === 'low,high',
isStacked = !!options.stacking,
cropStart = series.cropStart || 0,
requireSorting = series.requireSorting,
wasNull,
connectNulls = options.connectNulls,
useRaw = !xData,
minVal,
maxVal,
minI,
maxI,
// fillColor = series.fillOpacity ?
// new Color(series.color).setOpacity(
// pick(options.fillOpacity, 0.75)
// ).get() : series.color,
addKDPoint = function(clientX, plotY, i) {
//Shaves off about 60ms compared to repeated concatination
index = clientX + ',' + plotY;
// The k-d tree requires series points.
// Reduce the amount of points, since the time to build the
// tree increases exponentially.
if (enableMouseTracking && !pointTaken[index]) {
pointTaken[index] = true;
if (chart.inverted) {
clientX = xAxis.len - clientX;
plotY = yAxis.len - plotY;
}
points.push({
clientX: clientX,
plotX: clientX,
plotY: plotY,
i: cropStart + i
});
}
};
// Get or create the renderer
renderer = createAndAttachRenderer(chart, series);
if (!this.visible) {
if (!isChartSeriesBoosting(chart) && renderer) {
renderer.clear();
this.image.attr({
href: ''
});
}
return;
}
// If we are zooming out from SVG mode, destroy the graphics
if (this.points || this.graph) {
this.destroyGraphics();
}
// If we're rendering per. series we should create the marker groups
// as usual.
if (!isChartSeriesBoosting(chart)) {
this.markerGroup = series.plotGroup(
'markerGroup',
'markers',
true,
1,
chart.seriesGroup
);
} else {
//Use a single group for the markers
this.markerGroup = chart.markerGroup;
}
points = this.points = [];
// Do not start building while drawing
series.buildKDTree = noop;
if (renderer) {
allocateIfNotSeriesBoosting(renderer, this);
renderer.pushSeries(series);
// Perform the actual renderer if we're on series level
renderIfNotSeriesBoosting(renderer, this, chart);
//console.log(series, chart);
}
/* This builds the KD-tree */
function processPoint(d, i) {
var x,
y,
clientX,
plotY,
isNull,
low,
chartDestroyed = typeof chart.index === 'undefined',
isYInside = true;
if (!chartDestroyed) {
if (useRaw) {
x = d[0];
y = d[1];
} else {
x = d;
y = yData[i];
}
// Resolve low and high for range series
if (isRange) {
if (useRaw) {
y = d.slice(1, 3);
}
low = y[0];
y = y[1];
} else if (isStacked) {
x = d.x;
y = d.stackY;
low = y - d.y;
}
isNull = y === null;
// Optimize for scatter zooming
if (!requireSorting) {
isYInside = y >= yMin && y <= yMax;
}
if (!isNull && x >= xMin && x <= xMax && isYInside) {
// We use ceil to allow the KD tree to work with sub pixels,
// which can be used in boost to space pixels
clientX = Math.ceil(xAxis.toPixels(x, true));
if (sampling) {
if (minI === undefined || clientX === lastClientX) {
if (!isRange) {
low = y;
}
if (maxI === undefined || y > maxVal) {
maxVal = y;
maxI = i;
}
if (minI === undefined || low < minVal) {
minVal = low;
minI = i;
}
}
if (clientX !== lastClientX) { // Add points and reset
if (minI !== undefined) { // then maxI is also a number
plotY = yAxis.toPixels(maxVal, true);
yBottom = yAxis.toPixels(minVal, true);
addKDPoint(clientX, plotY, maxI);
if (yBottom !== plotY) {
addKDPoint(clientX, yBottom, minI);
}
}
minI = maxI = undefined;
lastClientX = clientX;
}
} else {
plotY = Math.ceil(yAxis.toPixels(y, true));
addKDPoint(clientX, plotY, i);
}
}
wasNull = isNull && !connectNulls;
}
return !chartDestroyed;
}
function doneProcessing() {
fireEvent(series, 'renderedCanvas');
// Pass tests in Pointer.
// Replace this with a single property, and replace when zooming in
// below boostThreshold.
series.directTouch = false;
series.options.stickyTracking = true;
delete series.buildKDTree; // Go back to prototype, ready to build
series.buildKDTree();
}
// Loop over the points to build the k-d tree
eachAsync(
isStacked ? series.data : (xData || rawData),
processPoint,
doneProcessing,
chart.renderer.forExport ? Number.MAX_VALUE : undefined
);
}
});
/* Used for treemap|heatmap.drawPoints */
function pointDrawHandler(proceed) {
if (!isSeriesBoosting(this)) {
return proceed.call(this);
}
//Make sure we have a valid OGL context
var renderer = createAndAttachRenderer(this.chart, this);
if (renderer) {
allocateIfNotSeriesBoosting(renderer, this);
renderer.pushSeries(this);
}
renderIfNotSeriesBoosting(renderer, this);
}
/*
* We need to handle heatmaps separatly, since we can't perform the size/color
* calculations in the shader easily.
*
* This likely needs future optimization.
*
*/
each(['heatmap', 'treemap'],
function(t) {
if (seriesTypes[t]) {
wrap(seriesTypes[t].prototype, 'drawPoints', pointDrawHandler);
seriesTypes[t].prototype.directTouch = false; // Use k-d-tree
}
}
);
if (seriesTypes.bubble) {
// By default, the bubble series does not use the KD-tree, so force it to.
delete seriesTypes.bubble.prototype.buildKDTree;
seriesTypes.bubble.prototype.directTouch = false;
// Needed for markers to work correctly
wrap(seriesTypes.bubble.prototype, 'markerAttribs', function(proceed) {
if (isSeriesBoosting(this)) {
return false;
}
return proceed.apply(this, [].slice.call(arguments, 1));
});
}
seriesTypes.scatter.prototype.fill = true;
extend(seriesTypes.area.prototype, {
fill: true,
fillOpacity: true,
sampling: true
});
extend(seriesTypes.column.prototype, {
fill: true,
sampling: true
});
wrap(Series.prototype, 'setVisible', function(proceed, vis) {
proceed.call(this, vis, false);
if (this.visible === false && this.ogl && this.canvas && this.image) {
this.ogl.clear();
this.image.attr({
href: ''
});
} else {
this.chart.redraw();
}
});
/**
* Take care of the canvas blitting
*/
H.Chart.prototype.callbacks.push(function(chart) {
/* Convert chart-level canvas to image */
function canvasToSVG() {
if (chart.ogl && isChartSeriesBoosting(chart)) {
chart.ogl.render(chart);
}
}
/* Clear chart-level canvas */
function preRender() {
if (chart.canvas && chart.ogl && isChartSeriesBoosting(chart)) {
// Allocate
chart.ogl.allocateBuffer(chart);
}
//see #6518
if (chart.markerGroup) {
chart.markerGroup.translate(
chart.xAxis[0].pos,
chart.yAxis[0].pos
);
}
}
addEvent(chart, 'predraw', preRender);
addEvent(chart, 'render', canvasToSVG);
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
(c) 2009-2017 Torstein Honsi
License: www.highcharts.com/license
*/
(function(k){"object"===typeof module&&module.exports?module.exports=k:k(Highcharts)})(function(k){(function(f){function k(){return Array.prototype.slice.call(arguments,1)}function v(c){c.apply(this);this.drawBreaks(this.xAxis,["x"]);this.drawBreaks(this.yAxis,q(this.pointArrayMap,["y"]))}var q=f.pick,r=f.wrap,u=f.each,y=f.extend,z=f.isArray,w=f.fireEvent,t=f.Axis,A=f.Series;y(t.prototype,{isInBreak:function(c,e){var g=c.repeat||Infinity,a=c.from,b=c.to-c.from;e=e>=a?(e-a)%g:g-(a-e)%g;return c.inclusive?
e<=b:e<b&&0!==e},isInAnyBreak:function(c,e){var g=this.options.breaks,a=g&&g.length,b,d,m;if(a){for(;a--;)this.isInBreak(g[a],c)&&(b=!0,d||(d=q(g[a].showPoints,this.isXAxis?!1:!0)));m=b&&e?b&&!d:b}return m}});r(t.prototype,"setTickPositions",function(c){c.apply(this,Array.prototype.slice.call(arguments,1));if(this.options.breaks){var e=this.tickPositions,g=this.tickPositions.info,a=[],b;for(b=0;b<e.length;b++)this.isInAnyBreak(e[b])||a.push(e[b]);this.tickPositions=a;this.tickPositions.info=g}});
r(t.prototype,"init",function(c,e,g){var a=this;g.breaks&&g.breaks.length&&(g.ordinal=!1);c.call(this,e,g);c=this.options.breaks;a.isBroken=z(c)&&!!c.length;a.isBroken&&(a.val2lin=function(b){var d=b,m,c;for(c=0;c<a.breakArray.length;c++)if(m=a.breakArray[c],m.to<=b)d-=m.len;else if(m.from>=b)break;else if(a.isInBreak(m,b)){d-=b-m.from;break}return d},a.lin2val=function(b){var d,c;for(c=0;c<a.breakArray.length&&!(d=a.breakArray[c],d.from>=b);c++)d.to<b?b+=d.len:a.isInBreak(d,b)&&(b+=d.len);return b},
a.setExtremes=function(a,d,c,g,e){for(;this.isInAnyBreak(a);)a-=this.closestPointRange;for(;this.isInAnyBreak(d);)d-=this.closestPointRange;t.prototype.setExtremes.call(this,a,d,c,g,e)},a.setAxisTranslation=function(b){t.prototype.setAxisTranslation.call(this,b);var d=a.options.breaks;b=[];var c=[],g=0,e,h,n=a.userMin||a.min,f=a.userMax||a.max,k=q(a.pointRangePadding,0),l,p;for(p in d)h=d[p],e=h.repeat||Infinity,a.isInBreak(h,n)&&(n+=h.to%e-n%e),a.isInBreak(h,f)&&(f-=f%e-h.from%e);for(p in d){h=d[p];
l=h.from;for(e=h.repeat||Infinity;l-e>n;)l-=e;for(;l<n;)l+=e;for(;l<f;l+=e)b.push({value:l,move:"in"}),b.push({value:l+(h.to-h.from),move:"out",size:h.breakSize})}b.sort(function(a,b){return a.value===b.value?("in"===a.move?0:1)-("in"===b.move?0:1):a.value-b.value});d=0;l=n;for(p in b)h=b[p],d+="in"===h.move?1:-1,1===d&&"in"===h.move&&(l=h.value),0===d&&(c.push({from:l,to:h.value,len:h.value-l-(h.size||0)}),g+=h.value-l-(h.size||0));a.breakArray=c;a.unitLength=f-n-g+k;w(a,"afterBreaks");a.transA=
a.options.staticScale?a.options.staticScale:(f-a.min+k)/a.unitLength*a.transA;k&&(a.minPixelPadding=a.transA*a.minPointOffset);a.min=n;a.max=f})});r(A.prototype,"generatePoints",function(c){c.apply(this,k(arguments));var e=this.xAxis,g=this.yAxis,a=this.points,b,d=a.length,f=this.options.connectNulls,x;if(e&&g&&(e.options.breaks||g.options.breaks))for(;d--;)b=a[d],x=null===b.y&&!1===f,x||!e.isInAnyBreak(b.x,!0)&&!g.isInAnyBreak(b.y,!0)||(a.splice(d,1),this.data[d]&&this.data[d].destroyElements())});
f.Series.prototype.drawBreaks=function(c,e){var g=this,a=g.points,b,d,f,k;c&&u(e,function(e){b=c.breakArray||[];d=c.isXAxis?c.min:q(g.options.threshold,c.min);u(a,function(a){k=q(a["stack"+e.toUpperCase()],a[e]);u(b,function(b){f=!1;if(d<b.from&&k>b.to||d>b.from&&k<b.from)f="pointBreak";else if(d<b.from&&k>b.from&&k<b.to||d>b.from&&k>b.to&&k<b.from)f="pointInBreak";f&&w(c,f,{point:a,brk:b})})})})};r(f.seriesTypes.column.prototype,"drawPoints",v);r(f.Series.prototype,"drawPoints",v)})(k)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var pick = H.pick,
wrap = H.wrap,
each = H.each,
extend = H.extend,
isArray = H.isArray,
fireEvent = H.fireEvent,
Axis = H.Axis,
Series = H.Series;
function stripArguments() {
return Array.prototype.slice.call(arguments, 1);
}
extend(Axis.prototype, {
isInBreak: function(brk, val) {
var ret,
repeat = brk.repeat || Infinity,
from = brk.from,
length = brk.to - brk.from,
test = (val >= from ? (val - from) % repeat : repeat - ((from - val) % repeat));
if (!brk.inclusive) {
ret = test < length && test !== 0;
} else {
ret = test <= length;
}
return ret;
},
isInAnyBreak: function(val, testKeep) {
var breaks = this.options.breaks,
i = breaks && breaks.length,
inbrk,
keep,
ret;
if (i) {
while (i--) {
if (this.isInBreak(breaks[i], val)) {
inbrk = true;
if (!keep) {
keep = pick(breaks[i].showPoints, this.isXAxis ? false : true);
}
}
}
if (inbrk && testKeep) {
ret = inbrk && !keep;
} else {
ret = inbrk;
}
}
return ret;
}
});
wrap(Axis.prototype, 'setTickPositions', function(proceed) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
if (this.options.breaks) {
var axis = this,
tickPositions = this.tickPositions,
info = this.tickPositions.info,
newPositions = [],
i;
for (i = 0; i < tickPositions.length; i++) {
if (!axis.isInAnyBreak(tickPositions[i])) {
newPositions.push(tickPositions[i]);
}
}
this.tickPositions = newPositions;
this.tickPositions.info = info;
}
});
wrap(Axis.prototype, 'init', function(proceed, chart, userOptions) {
var axis = this,
breaks;
// Force Axis to be not-ordinal when breaks are defined
if (userOptions.breaks && userOptions.breaks.length) {
userOptions.ordinal = false;
}
proceed.call(this, chart, userOptions);
breaks = this.options.breaks;
axis.isBroken = (isArray(breaks) && !!breaks.length);
if (axis.isBroken) {
axis.val2lin = function(val) {
var nval = val,
brk,
i;
for (i = 0; i < axis.breakArray.length; i++) {
brk = axis.breakArray[i];
if (brk.to <= val) {
nval -= brk.len;
} else if (brk.from >= val) {
break;
} else if (axis.isInBreak(brk, val)) {
nval -= (val - brk.from);
break;
}
}
return nval;
};
axis.lin2val = function(val) {
var nval = val,
brk,
i;
for (i = 0; i < axis.breakArray.length; i++) {
brk = axis.breakArray[i];
if (brk.from >= nval) {
break;
} else if (brk.to < nval) {
nval += brk.len;
} else if (axis.isInBreak(brk, nval)) {
nval += brk.len;
}
}
return nval;
};
axis.setExtremes = function(newMin, newMax, redraw, animation, eventArguments) {
// If trying to set extremes inside a break, extend it to before and after the break ( #3857 )
while (this.isInAnyBreak(newMin)) {
newMin -= this.closestPointRange;
}
while (this.isInAnyBreak(newMax)) {
newMax -= this.closestPointRange;
}
Axis.prototype.setExtremes.call(this, newMin, newMax, redraw, animation, eventArguments);
};
axis.setAxisTranslation = function(saveOld) {
Axis.prototype.setAxisTranslation.call(this, saveOld);
var breaks = axis.options.breaks,
breakArrayT = [], // Temporary one
breakArray = [],
length = 0,
inBrk,
repeat,
brk,
min = axis.userMin || axis.min,
max = axis.userMax || axis.max,
pointRangePadding = pick(axis.pointRangePadding, 0),
start,
i,
j;
// Min & max check (#4247)
for (i in breaks) {
brk = breaks[i];
repeat = brk.repeat || Infinity;
if (axis.isInBreak(brk, min)) {
min += (brk.to % repeat) - (min % repeat);
}
if (axis.isInBreak(brk, max)) {
max -= (max % repeat) - (brk.from % repeat);
}
}
// Construct an array holding all breaks in the axis
for (i in breaks) {
brk = breaks[i];
start = brk.from;
repeat = brk.repeat || Infinity;
while (start - repeat > min) {
start -= repeat;
}
while (start < min) {
start += repeat;
}
for (j = start; j < max; j += repeat) {
breakArrayT.push({
value: j,
move: 'in'
});
breakArrayT.push({
value: j + (brk.to - brk.from),
move: 'out',
size: brk.breakSize
});
}
}
breakArrayT.sort(function(a, b) {
var ret;
if (a.value === b.value) {
ret = (a.move === 'in' ? 0 : 1) - (b.move === 'in' ? 0 : 1);
} else {
ret = a.value - b.value;
}
return ret;
});
// Simplify the breaks
inBrk = 0;
start = min;
for (i in breakArrayT) {
brk = breakArrayT[i];
inBrk += (brk.move === 'in' ? 1 : -1);
if (inBrk === 1 && brk.move === 'in') {
start = brk.value;
}
if (inBrk === 0) {
breakArray.push({
from: start,
to: brk.value,
len: brk.value - start - (brk.size || 0)
});
length += brk.value - start - (brk.size || 0);
}
}
axis.breakArray = breakArray;
// Used with staticScale, and below, the actual axis length when
// breaks are substracted.
axis.unitLength = max - min - length + pointRangePadding;
fireEvent(axis, 'afterBreaks');
if (axis.options.staticScale) {
axis.transA = axis.options.staticScale;
} else {
axis.transA *= (max - axis.min + pointRangePadding) /
axis.unitLength;
}
if (pointRangePadding) {
axis.minPixelPadding = axis.transA * axis.minPointOffset;
}
axis.min = min;
axis.max = max;
};
}
});
wrap(Series.prototype, 'generatePoints', function(proceed) {
proceed.apply(this, stripArguments(arguments));
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis,
points = series.points,
point,
i = points.length,
connectNulls = series.options.connectNulls,
nullGap;
if (xAxis && yAxis && (xAxis.options.breaks || yAxis.options.breaks)) {
while (i--) {
point = points[i];
nullGap = point.y === null && connectNulls === false; // respect nulls inside the break (#4275)
if (!nullGap && (xAxis.isInAnyBreak(point.x, true) || yAxis.isInAnyBreak(point.y, true))) {
points.splice(i, 1);
if (this.data[i]) {
this.data[i].destroyElements(); // removes the graphics for this point if they exist
}
}
}
}
});
function drawPointsWrapped(proceed) {
proceed.apply(this);
this.drawBreaks(this.xAxis, ['x']);
this.drawBreaks(this.yAxis, pick(this.pointArrayMap, ['y']));
}
H.Series.prototype.drawBreaks = function(axis, keys) {
var series = this,
points = series.points,
breaks,
threshold,
eventName,
y;
if (!axis) {
return; // #5950
}
each(keys, function(key) {
breaks = axis.breakArray || [];
threshold = axis.isXAxis ? axis.min : pick(series.options.threshold, axis.min);
each(points, function(point) {
y = pick(point['stack' + key.toUpperCase()], point[key]);
each(breaks, function(brk) {
eventName = false;
if ((threshold < brk.from && y > brk.to) || (threshold > brk.from && y < brk.from)) {
eventName = 'pointBreak';
} else if ((threshold < brk.from && y > brk.from && y < brk.to) || (threshold > brk.from && y > brk.to && y < brk.from)) { // point falls inside the break
eventName = 'pointInBreak';
}
if (eventName) {
fireEvent(axis, eventName, {
point: point,
brk: brk
});
}
});
});
});
};
wrap(H.seriesTypes.column.prototype, 'drawPoints', drawPointsWrapped);
wrap(H.Series.prototype, 'drawPoints', drawPointsWrapped);
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | 1 2 1 1 | /* A class to parse color values @author Stoyan Stefanov <sstoo@gmail.com> @link http://www.phpied.com/rgb-color-parser-in-javascript/ Use it if you like it canvg.js - Javascript SVG parser and renderer on Canvas MIT Licensed Gabe Lerner (gabelerner@gmail.com) http://code.google.com/p/canvg/ Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/ Highcharts JS v4.2.7 (2016-09-21) CanVGRenderer Extension module (c) 2011-2016 Torstein Honsi, Erik Olsson License: www.highcharts.com/license */ function RGBColor(m){this.ok=!1;m.charAt(0)=="#"&&(m=m.substr(1,6));var m=m.replace(/ /g,""),m=m.toLowerCase(),a={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b", darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff", gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa", lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080", oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd", slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},c;for(c in a)m==c&&(m=a[c]);var d=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(b){return[parseInt(b[1]),parseInt(b[2]),parseInt(b[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/, example:["#00ff00","336699"],process:function(b){return[parseInt(b[1],16),parseInt(b[2],16),parseInt(b[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(b){return[parseInt(b[1]+b[1],16),parseInt(b[2]+b[2],16),parseInt(b[3]+b[3],16)]}}];for(c=0;c<d.length;c++){var b=d[c].process,k=d[c].re.exec(m);if(k)channels=b(k),this.r=channels[0],this.g=channels[1],this.b=channels[2],this.ok=!0}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r;this.g=this.g<0||isNaN(this.g)?0: this.g>255?255:this.g;this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b;this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"};this.toHex=function(){var b=this.r.toString(16),a=this.g.toString(16),d=this.b.toString(16);b.length==1&&(b="0"+b);a.length==1&&(a="0"+a);d.length==1&&(d="0"+d);return"#"+b+a+d};this.getHelpXML=function(){for(var b=[],c=0;c<d.length;c++)for(var k=d[c].example,h=0;h<k.length;h++)b[b.length]=k[h];for(var j in a)b[b.length]=j;k=document.createElement("ul"); k.setAttribute("id","rgbcolor-examples");for(c=0;c<b.length;c++)try{var l=document.createElement("li"),o=new RGBColor(b[c]),n=document.createElement("div");n.style.cssText="margin: 3px; border: 1px solid black; background:"+o.toHex()+"; color:"+o.toHex();n.appendChild(document.createTextNode("test"));var q=document.createTextNode(" "+b[c]+" -> "+o.toRGB()+" -> "+o.toHex());l.appendChild(n);l.appendChild(q);k.appendChild(l)}catch(p){}return k}} if(!window.console)window.console={},window.console.log=function(){},window.console.dir=function(){};if(!Array.prototype.indexOf)Array.prototype.indexOf=function(m){for(var a=0;a<this.length;a++)if(this[a]==m)return a;return-1}; (function(){function m(){var a={FRAMERATE:30,MAX_VIRTUAL_PIXELS:3E4};a.init=function(c){a.Definitions={};a.Styles={};a.Animations=[];a.Images=[];a.ctx=c;a.ViewPort=new function(){this.viewPorts=[];this.Clear=function(){this.viewPorts=[]};this.SetCurrent=function(a,b){this.viewPorts.push({width:a,height:b})};this.RemoveCurrent=function(){this.viewPorts.pop()};this.Current=function(){return this.viewPorts[this.viewPorts.length-1]};this.width=function(){return this.Current().width};this.height=function(){return this.Current().height}; this.ComputeSize=function(a){return a!=null&&typeof a=="number"?a:a=="x"?this.width():a=="y"?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}};a.init();a.ImagesLoaded=function(){for(var c=0;c<a.Images.length;c++)if(!a.Images[c].loaded)return!1;return!0};a.trim=function(a){return a.replace(/^\s+|\s+$/g,"")};a.compressSpaces=function(a){return a?a.replace(/[\s\r\t\n]+/gm," "):""};a.ajax=function(a){var d;return(d=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"))? (d.open("GET",a,!1),d.send(null),d.responseText):null};a.parseXml=function(a){if(window.DOMParser)return(new DOMParser).parseFromString(a,"text/xml");else{var a=a.replace(/<!DOCTYPE svg[^>]*>/,""),d=new ActiveXObject("Microsoft.XMLDOM");d.async="false";d.loadXML(a);return d}};a.Property=function(c,d){this.name=c;this.value=d;this.hasValue=function(){return this.value!=null&&this.value!==""};this.numValue=function(){if(!this.hasValue())return 0;var b=parseFloat(this.value);(this.value+"").match(/%$/)&& (b/=100);return b};this.valueOrDefault=function(b){return this.hasValue()?this.value:b};this.numValueOrDefault=function(b){return this.hasValue()?this.numValue():b};var b=this;this.Color={addOpacity:function(d){var c=b.value;if(d!=null&&d!=""){var f=new RGBColor(b.value);f.ok&&(c="rgba("+f.r+", "+f.g+", "+f.b+", "+d+")")}return new a.Property(b.name,c)}};this.Definition={getDefinition:function(){var d=b.value.replace(/^(url\()?#([^\)]+)\)?$/,"$2");return a.Definitions[d]},isUrl:function(){return b.value.indexOf("url(")== 0},getFillStyle:function(b){var d=this.getDefinition();return d!=null&&d.createGradient?d.createGradient(a.ctx,b):d!=null&&d.createPattern?d.createPattern(a.ctx,b):null}};this.Length={DPI:function(){return 96},EM:function(b){var d=12,c=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);c.hasValue()&&(d=c.Length.toPixels(b));return d},toPixels:function(d){if(!b.hasValue())return 0;var c=b.value+"";return c.match(/em$/)?b.numValue()*this.EM(d):c.match(/ex$/)?b.numValue()*this.EM(d)/2:c.match(/px$/)? b.numValue():c.match(/pt$/)?b.numValue()*1.25:c.match(/pc$/)?b.numValue()*15:c.match(/cm$/)?b.numValue()*this.DPI(d)/2.54:c.match(/mm$/)?b.numValue()*this.DPI(d)/25.4:c.match(/in$/)?b.numValue()*this.DPI(d):c.match(/%$/)?b.numValue()*a.ViewPort.ComputeSize(d):b.numValue()}};this.Time={toMilliseconds:function(){if(!b.hasValue())return 0;var a=b.value+"";if(a.match(/s$/))return b.numValue()*1E3;a.match(/ms$/);return b.numValue()}};this.Angle={toRadians:function(){if(!b.hasValue())return 0;var a=b.value+ "";return a.match(/deg$/)?b.numValue()*(Math.PI/180):a.match(/grad$/)?b.numValue()*(Math.PI/200):a.match(/rad$/)?b.numValue():b.numValue()*(Math.PI/180)}}};a.Font=new function(){this.Styles=["normal","italic","oblique","inherit"];this.Variants=["normal","small-caps","inherit"];this.Weights="normal,bold,bolder,lighter,100,200,300,400,500,600,700,800,900,inherit".split(",");this.CreateFont=function(d,b,c,e,f,g){g=g!=null?this.Parse(g):this.CreateFont("","","","","",a.ctx.font);return{fontFamily:f|| g.fontFamily,fontSize:e||g.fontSize,fontStyle:d||g.fontStyle,fontWeight:c||g.fontWeight,fontVariant:b||g.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var c=this;this.Parse=function(d){for(var b={},d=a.trim(a.compressSpaces(d||"")).split(" "),k=!1,e=!1,f=!1,g=!1,h="",j=0;j<d.length;j++)if(!e&&c.Styles.indexOf(d[j])!=-1){if(d[j]!="inherit")b.fontStyle=d[j];e=!0}else if(!g&&c.Variants.indexOf(d[j])!=-1){if(d[j]!="inherit")b.fontVariant= d[j];e=g=!0}else if(!f&&c.Weights.indexOf(d[j])!=-1){if(d[j]!="inherit")b.fontWeight=d[j];e=g=f=!0}else if(k)d[j]!="inherit"&&(h+=d[j]);else{if(d[j]!="inherit")b.fontSize=d[j].split("/")[0];e=g=f=k=!0}if(h!="")b.fontFamily=h;return b}};a.ToNumberArray=function(c){for(var c=a.trim(a.compressSpaces((c||"").replace(/,/g," "))).split(" "),d=0;d<c.length;d++)c[d]=parseFloat(c[d]);return c};a.Point=function(a,d){this.x=a;this.y=d;this.angleTo=function(b){return Math.atan2(b.y-this.y,b.x-this.x)};this.applyTransform= function(b){var a=this.x*b[1]+this.y*b[3]+b[5];this.x=this.x*b[0]+this.y*b[2]+b[4];this.y=a}};a.CreatePoint=function(c){c=a.ToNumberArray(c);return new a.Point(c[0],c[1])};a.CreatePath=function(c){for(var c=a.ToNumberArray(c),d=[],b=0;b<c.length;b+=2)d.push(new a.Point(c[b],c[b+1]));return d};a.BoundingBox=function(a,d,b,k){this.y2=this.x2=this.y1=this.x1=Number.NaN;this.x=function(){return this.x1};this.y=function(){return this.y1};this.width=function(){return this.x2-this.x1};this.height=function(){return this.y2- this.y1};this.addPoint=function(b,a){if(b!=null){if(isNaN(this.x1)||isNaN(this.x2))this.x2=this.x1=b;if(b<this.x1)this.x1=b;if(b>this.x2)this.x2=b}if(a!=null){if(isNaN(this.y1)||isNaN(this.y2))this.y2=this.y1=a;if(a<this.y1)this.y1=a;if(a>this.y2)this.y2=a}};this.addX=function(b){this.addPoint(b,null)};this.addY=function(b){this.addPoint(null,b)};this.addBoundingBox=function(b){this.addPoint(b.x1,b.y1);this.addPoint(b.x2,b.y2)};this.addQuadraticCurve=function(b,a,d,c,k,l){d=b+2/3*(d-b);c=a+2/3*(c- a);this.addBezierCurve(b,a,d,d+1/3*(k-b),c,c+1/3*(l-a),k,l)};this.addBezierCurve=function(b,a,d,c,k,l,o,n){var q=[b,a],p=[d,c],t=[k,l],m=[o,n];this.addPoint(q[0],q[1]);this.addPoint(m[0],m[1]);for(i=0;i<=1;i++)b=function(b){return Math.pow(1-b,3)*q[i]+3*Math.pow(1-b,2)*b*p[i]+3*(1-b)*Math.pow(b,2)*t[i]+Math.pow(b,3)*m[i]},a=6*q[i]-12*p[i]+6*t[i],d=-3*q[i]+9*p[i]-9*t[i]+3*m[i],c=3*p[i]-3*q[i],d==0?a!=0&&(a=-c/a,0<a&&a<1&&(i==0&&this.addX(b(a)),i==1&&this.addY(b(a)))):(c=Math.pow(a,2)-4*c*d,c<0||(k= (-a+Math.sqrt(c))/(2*d),0<k&&k<1&&(i==0&&this.addX(b(k)),i==1&&this.addY(b(k))),a=(-a-Math.sqrt(c))/(2*d),0<a&&a<1&&(i==0&&this.addX(b(a)),i==1&&this.addY(b(a)))))};this.isPointInBox=function(b,a){return this.x1<=b&&b<=this.x2&&this.y1<=a&&a<=this.y2};this.addPoint(a,d);this.addPoint(b,k)};a.Transform=function(c){var d=this;this.Type={};this.Type.translate=function(b){this.p=a.CreatePoint(b);this.apply=function(b){b.translate(this.p.x||0,this.p.y||0)};this.applyToPoint=function(b){b.applyTransform([1, 0,0,1,this.p.x||0,this.p.y||0])}};this.Type.rotate=function(b){b=a.ToNumberArray(b);this.angle=new a.Property("angle",b[0]);this.cx=b[1]||0;this.cy=b[2]||0;this.apply=function(b){b.translate(this.cx,this.cy);b.rotate(this.angle.Angle.toRadians());b.translate(-this.cx,-this.cy)};this.applyToPoint=function(b){var a=this.angle.Angle.toRadians();b.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]);b.applyTransform([Math.cos(a),Math.sin(a),-Math.sin(a),Math.cos(a),0,0]);b.applyTransform([1,0,0,1,-this.p.x|| 0,-this.p.y||0])}};this.Type.scale=function(b){this.p=a.CreatePoint(b);this.apply=function(b){b.scale(this.p.x||1,this.p.y||this.p.x||1)};this.applyToPoint=function(b){b.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}};this.Type.matrix=function(b){this.m=a.ToNumberArray(b);this.apply=function(b){b.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])};this.applyToPoint=function(b){b.applyTransform(this.m)}};this.Type.SkewBase=function(b){this.base=d.Type.matrix;this.base(b);this.angle= new a.Property("angle",b)};this.Type.SkewBase.prototype=new this.Type.matrix;this.Type.skewX=function(b){this.base=d.Type.SkewBase;this.base(b);this.m=[1,0,Math.tan(this.angle.Angle.toRadians()),1,0,0]};this.Type.skewX.prototype=new this.Type.SkewBase;this.Type.skewY=function(b){this.base=d.Type.SkewBase;this.base(b);this.m=[1,Math.tan(this.angle.Angle.toRadians()),0,1,0,0]};this.Type.skewY.prototype=new this.Type.SkewBase;this.transforms=[];this.apply=function(b){for(var a=0;a<this.transforms.length;a++)this.transforms[a].apply(b)}; this.applyToPoint=function(b){for(var a=0;a<this.transforms.length;a++)this.transforms[a].applyToPoint(b)};for(var c=a.trim(a.compressSpaces(c)).split(/\s(?=[a-z])/),b=0;b<c.length;b++){var k=c[b].split("(")[0],e=c[b].split("(")[1].replace(")","");this.transforms.push(new this.Type[k](e))}};a.AspectRatio=function(c,d,b,k,e,f,g,h,j,l){var d=a.compressSpaces(d),d=d.replace(/^defer\s/,""),o=d.split(" ")[0]||"xMidYMid",d=d.split(" ")[1]||"meet",n=b/k,q=e/f,p=Math.min(n,q),m=Math.max(n,q);d=="meet"&&(k*= p,f*=p);d=="slice"&&(k*=m,f*=m);j=new a.Property("refX",j);l=new a.Property("refY",l);j.hasValue()&&l.hasValue()?c.translate(-p*j.Length.toPixels("x"),-p*l.Length.toPixels("y")):(o.match(/^xMid/)&&(d=="meet"&&p==q||d=="slice"&&m==q)&&c.translate(b/2-k/2,0),o.match(/YMid$/)&&(d=="meet"&&p==n||d=="slice"&&m==n)&&c.translate(0,e/2-f/2),o.match(/^xMax/)&&(d=="meet"&&p==q||d=="slice"&&m==q)&&c.translate(b-k,0),o.match(/YMax$/)&&(d=="meet"&&p==n||d=="slice"&&m==n)&&c.translate(0,e-f));o=="none"?c.scale(n, q):d=="meet"?c.scale(p,p):d=="slice"&&c.scale(m,m);c.translate(g==null?0:-g,h==null?0:-h)};a.Element={};a.Element.ElementBase=function(c){this.attributes={};this.styles={};this.children=[];this.attribute=function(b,d){var c=this.attributes[b];if(c!=null)return c;c=new a.Property(b,"");d==!0&&(this.attributes[b]=c);return c};this.style=function(b,d){var c=this.styles[b];if(c!=null)return c;c=this.attribute(b);if(c!=null&&c.hasValue())return c;c=this.parent;if(c!=null&&(c=c.style(b),c!=null&&c.hasValue()))return c; c=new a.Property(b,"");d==!0&&(this.styles[b]=c);return c};this.render=function(b){if(this.style("display").value!="none"&&this.attribute("visibility").value!="hidden"){b.save();this.setContext(b);if(this.attribute("mask").hasValue()){var a=this.attribute("mask").Definition.getDefinition();a!=null&&a.apply(b,this)}else this.style("filter").hasValue()?(a=this.style("filter").Definition.getDefinition(),a!=null&&a.apply(b,this)):this.renderChildren(b);this.clearContext(b);b.restore()}};this.setContext= function(){};this.clearContext=function(){};this.renderChildren=function(b){for(var a=0;a<this.children.length;a++)this.children[a].render(b)};this.addChild=function(b,d){var c=b;d&&(c=a.CreateElement(b));c.parent=this;this.children.push(c)};if(c!=null&&c.nodeType==1){for(var d=0;d<c.childNodes.length;d++){var b=c.childNodes[d];b.nodeType==1&&this.addChild(b,!0)}for(d=0;d<c.attributes.length;d++)b=c.attributes[d],this.attributes[b.nodeName]=new a.Property(b.nodeName,b.nodeValue);b=a.Styles[c.nodeName]; if(b!=null)for(var k in b)this.styles[k]=b[k];if(this.attribute("class").hasValue())for(var d=a.compressSpaces(this.attribute("class").value).split(" "),e=0;e<d.length;e++){b=a.Styles["."+d[e]];if(b!=null)for(k in b)this.styles[k]=b[k];b=a.Styles[c.nodeName+"."+d[e]];if(b!=null)for(k in b)this.styles[k]=b[k]}if(this.attribute("style").hasValue()){b=this.attribute("style").value.split(";");for(d=0;d<b.length;d++)a.trim(b[d])!=""&&(c=b[d].split(":"),k=a.trim(c[0]),c=a.trim(c[1]),this.styles[k]=new a.Property(k, c))}this.attribute("id").hasValue()&&a.Definitions[this.attribute("id").value]==null&&(a.Definitions[this.attribute("id").value]=this)}};a.Element.RenderedElementBase=function(c){this.base=a.Element.ElementBase;this.base(c);this.setContext=function(d){if(this.style("fill").Definition.isUrl()){var b=this.style("fill").Definition.getFillStyle(this);if(b!=null)d.fillStyle=b}else if(this.style("fill").hasValue())b=this.style("fill"),this.style("fill-opacity").hasValue()&&(b=b.Color.addOpacity(this.style("fill-opacity").value)), d.fillStyle=b.value=="none"?"rgba(0,0,0,0)":b.value;if(this.style("stroke").Definition.isUrl()){if(b=this.style("stroke").Definition.getFillStyle(this),b!=null)d.strokeStyle=b}else if(this.style("stroke").hasValue())b=this.style("stroke"),this.style("stroke-opacity").hasValue()&&(b=b.Color.addOpacity(this.style("stroke-opacity").value)),d.strokeStyle=b.value=="none"?"rgba(0,0,0,0)":b.value;if(this.style("stroke-width").hasValue())d.lineWidth=this.style("stroke-width").Length.toPixels();if(this.style("stroke-linecap").hasValue())d.lineCap= this.style("stroke-linecap").value;if(this.style("stroke-linejoin").hasValue())d.lineJoin=this.style("stroke-linejoin").value;if(this.style("stroke-miterlimit").hasValue())d.miterLimit=this.style("stroke-miterlimit").value;if(typeof d.font!="undefined")d.font=a.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,this.style("font-weight").value,this.style("font-size").hasValue()?this.style("font-size").Length.toPixels()+"px":"",this.style("font-family").value).toString(); this.attribute("transform").hasValue()&&(new a.Transform(this.attribute("transform").value)).apply(d);this.attribute("clip-path").hasValue()&&(b=this.attribute("clip-path").Definition.getDefinition(),b!=null&&b.apply(d));if(this.style("opacity").hasValue())d.globalAlpha=this.style("opacity").numValue()}};a.Element.RenderedElementBase.prototype=new a.Element.ElementBase;a.Element.PathElementBase=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.path=function(d){d!=null&&d.beginPath(); return new a.BoundingBox};this.renderChildren=function(d){this.path(d);a.Mouse.checkPath(this,d);d.fillStyle!=""&&d.fill();d.strokeStyle!=""&&d.stroke();var b=this.getMarkers();if(b!=null){if(this.style("marker-start").Definition.isUrl()){var c=this.style("marker-start").Definition.getDefinition();c.render(d,b[0][0],b[0][1])}if(this.style("marker-mid").Definition.isUrl())for(var c=this.style("marker-mid").Definition.getDefinition(),e=1;e<b.length-1;e++)c.render(d,b[e][0],b[e][1]);this.style("marker-end").Definition.isUrl()&& (c=this.style("marker-end").Definition.getDefinition(),c.render(d,b[b.length-1][0],b[b.length-1][1]))}};this.getBoundingBox=function(){return this.path()};this.getMarkers=function(){return null}};a.Element.PathElementBase.prototype=new a.Element.RenderedElementBase;a.Element.svg=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseClearContext=this.clearContext;this.clearContext=function(d){this.baseClearContext(d);a.ViewPort.RemoveCurrent()};this.baseSetContext=this.setContext; this.setContext=function(d){d.strokeStyle="rgba(0,0,0,0)";d.lineCap="butt";d.lineJoin="miter";d.miterLimit=4;this.baseSetContext(d);this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&d.translate(this.attribute("x").Length.toPixels("x"),this.attribute("y").Length.toPixels("y"));var b=a.ViewPort.width(),c=a.ViewPort.height();if(typeof this.root=="undefined"&&this.attribute("width").hasValue()&&this.attribute("height").hasValue()){var b=this.attribute("width").Length.toPixels("x"),c=this.attribute("height").Length.toPixels("y"), e=0,f=0;this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()&&(e=-this.attribute("refX").Length.toPixels("x"),f=-this.attribute("refY").Length.toPixels("y"));d.beginPath();d.moveTo(e,f);d.lineTo(b,f);d.lineTo(b,c);d.lineTo(e,c);d.closePath();d.clip()}a.ViewPort.SetCurrent(b,c);if(this.attribute("viewBox").hasValue()){var e=a.ToNumberArray(this.attribute("viewBox").value),f=e[0],g=e[1],b=e[2],c=e[3];a.AspectRatio(d,this.attribute("preserveAspectRatio").value,a.ViewPort.width(),b,a.ViewPort.height(), c,f,g,this.attribute("refX").value,this.attribute("refY").value);a.ViewPort.RemoveCurrent();a.ViewPort.SetCurrent(e[2],e[3])}}};a.Element.svg.prototype=new a.Element.RenderedElementBase;a.Element.rect=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(d){var b=this.attribute("x").Length.toPixels("x"),c=this.attribute("y").Length.toPixels("y"),e=this.attribute("width").Length.toPixels("x"),f=this.attribute("height").Length.toPixels("y"),g=this.attribute("rx").Length.toPixels("x"), h=this.attribute("ry").Length.toPixels("y");this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&(h=g);this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(g=h);d!=null&&(d.beginPath(),d.moveTo(b+g,c),d.lineTo(b+e-g,c),d.quadraticCurveTo(b+e,c,b+e,c+h),d.lineTo(b+e,c+f-h),d.quadraticCurveTo(b+e,c+f,b+e-g,c+f),d.lineTo(b+g,c+f),d.quadraticCurveTo(b,c+f,b,c+f-h),d.lineTo(b,c+h),d.quadraticCurveTo(b,c,b+g,c),d.closePath());return new a.BoundingBox(b,c,b+e,c+f)}};a.Element.rect.prototype= new a.Element.PathElementBase;a.Element.circle=function(c){this.base=a.Element.PathElementBase;this.base(c);this.path=function(d){var b=this.attribute("cx").Length.toPixels("x"),c=this.attribute("cy").Length.toPixels("y"),e=this.attribute("r").Length.toPixels();d!=null&&(d.beginPath(),d.arc(b,c,e,0,Math.PI*2,!0),d.closePath());return new a.BoundingBox(b-e,c-e,b+e,c+e)}};a.Element.circle.prototype=new a.Element.PathElementBase;a.Element.ellipse=function(c){this.base=a.Element.PathElementBase;this.base(c); this.path=function(d){var b=4*((Math.sqrt(2)-1)/3),c=this.attribute("rx").Length.toPixels("x"),e=this.attribute("ry").Length.toPixels("y"),f=this.attribute("cx").Length.toPixels("x"),g=this.attribute("cy").Length.toPixels("y");d!=null&&(d.beginPath(),d.moveTo(f,g-e),d.bezierCurveTo(f+b*c,g-e,f+c,g-b*e,f+c,g),d.bezierCurveTo(f+c,g+b*e,f+b*c,g+e,f,g+e),d.bezierCurveTo(f-b*c,g+e,f-c,g+b*e,f-c,g),d.bezierCurveTo(f-c,g-b*e,f-b*c,g-e,f,g-e),d.closePath());return new a.BoundingBox(f-c,g-e,f+c,g+e)}};a.Element.ellipse.prototype= new a.Element.PathElementBase;a.Element.line=function(c){this.base=a.Element.PathElementBase;this.base(c);this.getPoints=function(){return[new a.Point(this.attribute("x1").Length.toPixels("x"),this.attribute("y1").Length.toPixels("y")),new a.Point(this.attribute("x2").Length.toPixels("x"),this.attribute("y2").Length.toPixels("y"))]};this.path=function(d){var b=this.getPoints();d!=null&&(d.beginPath(),d.moveTo(b[0].x,b[0].y),d.lineTo(b[1].x,b[1].y));return new a.BoundingBox(b[0].x,b[0].y,b[1].x,b[1].y)}; this.getMarkers=function(){var a=this.getPoints(),b=a[0].angleTo(a[1]);return[[a[0],b],[a[1],b]]}};a.Element.line.prototype=new a.Element.PathElementBase;a.Element.polyline=function(c){this.base=a.Element.PathElementBase;this.base(c);this.points=a.CreatePath(this.attribute("points").value);this.path=function(d){var b=new a.BoundingBox(this.points[0].x,this.points[0].y);d!=null&&(d.beginPath(),d.moveTo(this.points[0].x,this.points[0].y));for(var c=1;c<this.points.length;c++)b.addPoint(this.points[c].x, this.points[c].y),d!=null&&d.lineTo(this.points[c].x,this.points[c].y);return b};this.getMarkers=function(){for(var a=[],b=0;b<this.points.length-1;b++)a.push([this.points[b],this.points[b].angleTo(this.points[b+1])]);a.push([this.points[this.points.length-1],a[a.length-1][1]]);return a}};a.Element.polyline.prototype=new a.Element.PathElementBase;a.Element.polygon=function(c){this.base=a.Element.polyline;this.base(c);this.basePath=this.path;this.path=function(a){var b=this.basePath(a);a!=null&&(a.lineTo(this.points[0].x, this.points[0].y),a.closePath());return b}};a.Element.polygon.prototype=new a.Element.polyline;a.Element.path=function(c){this.base=a.Element.PathElementBase;this.base(c);c=this.attribute("d").value;c=c.replace(/,/gm," ");c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2");c=c.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");c=c.replace(/([0-9])([+\-])/gm, "$1 $2");c=c.replace(/(\.[0-9]*)(\.)/gm,"$1 $2");c=c.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 ");c=a.compressSpaces(c);c=a.trim(c);this.PathParser=new function(d){this.tokens=d.split(" ");this.reset=function(){this.i=-1;this.previousCommand=this.command="";this.start=new a.Point(0,0);this.control=new a.Point(0,0);this.current=new a.Point(0,0);this.points=[];this.angles=[]};this.isEnd=function(){return this.i>=this.tokens.length-1};this.isCommandOrEnd=function(){return this.isEnd()? !0:this.tokens[this.i+1].match(/^[A-Za-z]$/)!=null};this.isRelativeCommand=function(){return this.command==this.command.toLowerCase()};this.getToken=function(){this.i+=1;return this.tokens[this.i]};this.getScalar=function(){return parseFloat(this.getToken())};this.nextCommand=function(){this.previousCommand=this.command;this.command=this.getToken()};this.getPoint=function(){return this.makeAbsolute(new a.Point(this.getScalar(),this.getScalar()))};this.getAsControlPoint=function(){var b=this.getPoint(); return this.control=b};this.getAsCurrentPoint=function(){var b=this.getPoint();return this.current=b};this.getReflectedControlPoint=function(){return this.previousCommand.toLowerCase()!="c"&&this.previousCommand.toLowerCase()!="s"?this.current:new a.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)};this.makeAbsolute=function(b){if(this.isRelativeCommand())b.x=this.current.x+b.x,b.y=this.current.y+b.y;return b};this.addMarker=function(b,a,d){d!=null&&this.angles.length>0&&this.angles[this.angles.length- 1]==null&&(this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(d));this.addMarkerAngle(b,a==null?null:a.angleTo(b))};this.addMarkerAngle=function(b,a){this.points.push(b);this.angles.push(a)};this.getMarkerPoints=function(){return this.points};this.getMarkerAngles=function(){for(var b=0;b<this.angles.length;b++)if(this.angles[b]==null)for(var a=b+1;a<this.angles.length;a++)if(this.angles[a]!=null){this.angles[b]=this.angles[a];break}return this.angles}}(c);this.path=function(d){var b= this.PathParser;b.reset();var c=new a.BoundingBox;for(d!=null&&d.beginPath();!b.isEnd();)switch(b.nextCommand(),b.command.toUpperCase()){case "M":var e=b.getAsCurrentPoint();b.addMarker(e);c.addPoint(e.x,e.y);d!=null&&d.moveTo(e.x,e.y);for(b.start=b.current;!b.isCommandOrEnd();)e=b.getAsCurrentPoint(),b.addMarker(e,b.start),c.addPoint(e.x,e.y),d!=null&&d.lineTo(e.x,e.y);break;case "L":for(;!b.isCommandOrEnd();){var f=b.current,e=b.getAsCurrentPoint();b.addMarker(e,f);c.addPoint(e.x,e.y);d!=null&& d.lineTo(e.x,e.y)}break;case "H":for(;!b.isCommandOrEnd();)e=new a.Point((b.isRelativeCommand()?b.current.x:0)+b.getScalar(),b.current.y),b.addMarker(e,b.current),b.current=e,c.addPoint(b.current.x,b.current.y),d!=null&&d.lineTo(b.current.x,b.current.y);break;case "V":for(;!b.isCommandOrEnd();)e=new a.Point(b.current.x,(b.isRelativeCommand()?b.current.y:0)+b.getScalar()),b.addMarker(e,b.current),b.current=e,c.addPoint(b.current.x,b.current.y),d!=null&&d.lineTo(b.current.x,b.current.y);break;case "C":for(;!b.isCommandOrEnd();){var g= b.current,f=b.getPoint(),h=b.getAsControlPoint(),e=b.getAsCurrentPoint();b.addMarker(e,h,f);c.addBezierCurve(g.x,g.y,f.x,f.y,h.x,h.y,e.x,e.y);d!=null&&d.bezierCurveTo(f.x,f.y,h.x,h.y,e.x,e.y)}break;case "S":for(;!b.isCommandOrEnd();)g=b.current,f=b.getReflectedControlPoint(),h=b.getAsControlPoint(),e=b.getAsCurrentPoint(),b.addMarker(e,h,f),c.addBezierCurve(g.x,g.y,f.x,f.y,h.x,h.y,e.x,e.y),d!=null&&d.bezierCurveTo(f.x,f.y,h.x,h.y,e.x,e.y);break;case "Q":for(;!b.isCommandOrEnd();)g=b.current,h=b.getAsControlPoint(), e=b.getAsCurrentPoint(),b.addMarker(e,h,h),c.addQuadraticCurve(g.x,g.y,h.x,h.y,e.x,e.y),d!=null&&d.quadraticCurveTo(h.x,h.y,e.x,e.y);break;case "T":for(;!b.isCommandOrEnd();)g=b.current,h=b.getReflectedControlPoint(),b.control=h,e=b.getAsCurrentPoint(),b.addMarker(e,h,h),c.addQuadraticCurve(g.x,g.y,h.x,h.y,e.x,e.y),d!=null&&d.quadraticCurveTo(h.x,h.y,e.x,e.y);break;case "A":for(;!b.isCommandOrEnd();){var g=b.current,j=b.getScalar(),l=b.getScalar(),f=b.getScalar()*(Math.PI/180),o=b.getScalar(),h=b.getScalar(), e=b.getAsCurrentPoint(),n=new a.Point(Math.cos(f)*(g.x-e.x)/2+Math.sin(f)*(g.y-e.y)/2,-Math.sin(f)*(g.x-e.x)/2+Math.cos(f)*(g.y-e.y)/2),q=Math.pow(n.x,2)/Math.pow(j,2)+Math.pow(n.y,2)/Math.pow(l,2);q>1&&(j*=Math.sqrt(q),l*=Math.sqrt(q));o=(o==h?-1:1)*Math.sqrt((Math.pow(j,2)*Math.pow(l,2)-Math.pow(j,2)*Math.pow(n.y,2)-Math.pow(l,2)*Math.pow(n.x,2))/(Math.pow(j,2)*Math.pow(n.y,2)+Math.pow(l,2)*Math.pow(n.x,2)));isNaN(o)&&(o=0);var p=new a.Point(o*j*n.y/l,o*-l*n.x/j),g=new a.Point((g.x+e.x)/2+Math.cos(f)* p.x-Math.sin(f)*p.y,(g.y+e.y)/2+Math.sin(f)*p.x+Math.cos(f)*p.y),m=function(b,a){return(b[0]*a[0]+b[1]*a[1])/(Math.sqrt(Math.pow(b[0],2)+Math.pow(b[1],2))*Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)))},s=function(b,a){return(b[0]*a[1]<b[1]*a[0]?-1:1)*Math.acos(m(b,a))},o=s([1,0],[(n.x-p.x)/j,(n.y-p.y)/l]),q=[(n.x-p.x)/j,(n.y-p.y)/l],p=[(-n.x-p.x)/j,(-n.y-p.y)/l],n=s(q,p);if(m(q,p)<=-1)n=Math.PI;m(q,p)>=1&&(n=0);h==0&&n>0&&(n-=2*Math.PI);h==1&&n<0&&(n+=2*Math.PI);q=new a.Point(g.x-j*Math.cos((o+n)/ 2),g.y-l*Math.sin((o+n)/2));b.addMarkerAngle(q,(o+n)/2+(h==0?1:-1)*Math.PI/2);b.addMarkerAngle(e,n+(h==0?1:-1)*Math.PI/2);c.addPoint(e.x,e.y);d!=null&&(m=j>l?j:l,e=j>l?1:j/l,j=j>l?l/j:1,d.translate(g.x,g.y),d.rotate(f),d.scale(e,j),d.arc(0,0,m,o,o+n,1-h),d.scale(1/e,1/j),d.rotate(-f),d.translate(-g.x,-g.y))}break;case "Z":d!=null&&d.closePath(),b.current=b.start}return c};this.getMarkers=function(){for(var a=this.PathParser.getMarkerPoints(),b=this.PathParser.getMarkerAngles(),c=[],e=0;e<a.length;e++)c.push([a[e], b[e]]);return c}};a.Element.path.prototype=new a.Element.PathElementBase;a.Element.pattern=function(c){this.base=a.Element.ElementBase;this.base(c);this.createPattern=function(d){var b=new a.Element.svg;b.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);b.attributes.x=new a.Property("x",this.attribute("x").value);b.attributes.y=new a.Property("y",this.attribute("y").value);b.attributes.width=new a.Property("width",this.attribute("width").value);b.attributes.height=new a.Property("height", this.attribute("height").value);b.children=this.children;var c=document.createElement("canvas");c.width=this.attribute("width").Length.toPixels("x");c.height=this.attribute("height").Length.toPixels("y");b.render(c.getContext("2d"));return d.createPattern(c,"repeat")}};a.Element.pattern.prototype=new a.Element.ElementBase;a.Element.marker=function(c){this.base=a.Element.ElementBase;this.base(c);this.baseRender=this.render;this.render=function(d,b,c){d.translate(b.x,b.y);this.attribute("orient").valueOrDefault("auto")== "auto"&&d.rotate(c);this.attribute("markerUnits").valueOrDefault("strokeWidth")=="strokeWidth"&&d.scale(d.lineWidth,d.lineWidth);d.save();var e=new a.Element.svg;e.attributes.viewBox=new a.Property("viewBox",this.attribute("viewBox").value);e.attributes.refX=new a.Property("refX",this.attribute("refX").value);e.attributes.refY=new a.Property("refY",this.attribute("refY").value);e.attributes.width=new a.Property("width",this.attribute("markerWidth").value);e.attributes.height=new a.Property("height", this.attribute("markerHeight").value);e.attributes.fill=new a.Property("fill",this.attribute("fill").valueOrDefault("black"));e.attributes.stroke=new a.Property("stroke",this.attribute("stroke").valueOrDefault("none"));e.children=this.children;e.render(d);d.restore();this.attribute("markerUnits").valueOrDefault("strokeWidth")=="strokeWidth"&&d.scale(1/d.lineWidth,1/d.lineWidth);this.attribute("orient").valueOrDefault("auto")=="auto"&&d.rotate(-c);d.translate(-b.x,-b.y)}};a.Element.marker.prototype= new a.Element.ElementBase;a.Element.defs=function(c){this.base=a.Element.ElementBase;this.base(c);this.render=function(){}};a.Element.defs.prototype=new a.Element.ElementBase;a.Element.GradientBase=function(c){this.base=a.Element.ElementBase;this.base(c);this.gradientUnits=this.attribute("gradientUnits").valueOrDefault("objectBoundingBox");this.stops=[];for(c=0;c<this.children.length;c++)this.stops.push(this.children[c]);this.getGradient=function(){};this.createGradient=function(d,b){var c=this;this.attribute("xlink:href").hasValue()&& (c=this.attribute("xlink:href").Definition.getDefinition());for(var e=this.getGradient(d,b),f=0;f<c.stops.length;f++)e.addColorStop(c.stops[f].offset,c.stops[f].color);if(this.attribute("gradientTransform").hasValue()){c=a.ViewPort.viewPorts[0];f=new a.Element.rect;f.attributes.x=new a.Property("x",-a.MAX_VIRTUAL_PIXELS/3);f.attributes.y=new a.Property("y",-a.MAX_VIRTUAL_PIXELS/3);f.attributes.width=new a.Property("width",a.MAX_VIRTUAL_PIXELS);f.attributes.height=new a.Property("height",a.MAX_VIRTUAL_PIXELS); var g=new a.Element.g;g.attributes.transform=new a.Property("transform",this.attribute("gradientTransform").value);g.children=[f];f=new a.Element.svg;f.attributes.x=new a.Property("x",0);f.attributes.y=new a.Property("y",0);f.attributes.width=new a.Property("width",c.width);f.attributes.height=new a.Property("height",c.height);f.children=[g];g=document.createElement("canvas");g.width=c.width;g.height=c.height;c=g.getContext("2d");c.fillStyle=e;f.render(c);return c.createPattern(g,"no-repeat")}return e}}; a.Element.GradientBase.prototype=new a.Element.ElementBase;a.Element.linearGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.getGradient=function(a,b){var c=b.getBoundingBox(),e=this.gradientUnits=="objectBoundingBox"?c.x()+c.width()*this.attribute("x1").numValue():this.attribute("x1").Length.toPixels("x"),f=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("y1").numValue():this.attribute("y1").Length.toPixels("y"),g=this.gradientUnits=="objectBoundingBox"? c.x()+c.width()*this.attribute("x2").numValue():this.attribute("x2").Length.toPixels("x"),c=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("y2").numValue():this.attribute("y2").Length.toPixels("y");return a.createLinearGradient(e,f,g,c)}};a.Element.linearGradient.prototype=new a.Element.GradientBase;a.Element.radialGradient=function(c){this.base=a.Element.GradientBase;this.base(c);this.getGradient=function(a,b){var c=b.getBoundingBox(),e=this.gradientUnits=="objectBoundingBox"? c.x()+c.width()*this.attribute("cx").numValue():this.attribute("cx").Length.toPixels("x"),f=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("cy").numValue():this.attribute("cy").Length.toPixels("y"),g=e,h=f;this.attribute("fx").hasValue()&&(g=this.gradientUnits=="objectBoundingBox"?c.x()+c.width()*this.attribute("fx").numValue():this.attribute("fx").Length.toPixels("x"));this.attribute("fy").hasValue()&&(h=this.gradientUnits=="objectBoundingBox"?c.y()+c.height()*this.attribute("fy").numValue(): this.attribute("fy").Length.toPixels("y"));c=this.gradientUnits=="objectBoundingBox"?(c.width()+c.height())/2*this.attribute("r").numValue():this.attribute("r").Length.toPixels();return a.createRadialGradient(g,h,0,e,f,c)}};a.Element.radialGradient.prototype=new a.Element.GradientBase;a.Element.stop=function(c){this.base=a.Element.ElementBase;this.base(c);this.offset=this.attribute("offset").numValue();c=this.style("stop-color");this.style("stop-opacity").hasValue()&&(c=c.Color.addOpacity(this.style("stop-opacity").value)); this.color=c.value};a.Element.stop.prototype=new a.Element.ElementBase;a.Element.AnimateBase=function(c){this.base=a.Element.ElementBase;this.base(c);a.Animations.push(this);this.duration=0;this.begin=this.attribute("begin").Time.toMilliseconds();this.maxDuration=this.begin+this.attribute("dur").Time.toMilliseconds();this.getProperty=function(){var a=this.attribute("attributeType").value,b=this.attribute("attributeName").value;return a=="CSS"?this.parent.style(b,!0):this.parent.attribute(b,!0)};this.initialValue= null;this.removed=!1;this.calcValue=function(){return""};this.update=function(a){if(this.initialValue==null)this.initialValue=this.getProperty().value;if(this.duration>this.maxDuration)if(this.attribute("repeatCount").value=="indefinite")this.duration=0;else return this.attribute("fill").valueOrDefault("remove")=="remove"&&!this.removed?(this.removed=!0,this.getProperty().value=this.initialValue,!0):!1;this.duration+=a;a=!1;if(this.begin<this.duration)a=this.calcValue(),this.attribute("type").hasValue()&& (a=this.attribute("type").value+"("+a+")"),this.getProperty().value=a,a=!0;return a};this.progress=function(){return(this.duration-this.begin)/(this.maxDuration-this.begin)}};a.Element.AnimateBase.prototype=new a.Element.ElementBase;a.Element.animate=function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=this.attribute("from").numValue(),b=this.attribute("to").numValue();return a+(b-a)*this.progress()}};a.Element.animate.prototype=new a.Element.AnimateBase;a.Element.animateColor= function(c){this.base=a.Element.AnimateBase;this.base(c);this.calcValue=function(){var a=new RGBColor(this.attribute("from").value),b=new RGBColor(this.attribute("to").value);if(a.ok&&b.ok){var c=a.r+(b.r-a.r)*this.progress(),e=a.g+(b.g-a.g)*this.progress(),a=a.b+(b.b-a.b)*this.progress();return"rgb("+parseInt(c,10)+","+parseInt(e,10)+","+parseInt(a,10)+")"}return this.attribute("from").value}};a.Element.animateColor.prototype=new a.Element.AnimateBase;a.Element.animateTransform=function(c){this.base= a.Element.animate;this.base(c)};a.Element.animateTransform.prototype=new a.Element.animate;a.Element.font=function(c){this.base=a.Element.ElementBase;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.isArabic=this.isRTL=!1;this.missingGlyph=this.fontFace=null;this.glyphs=[];for(c=0;c<this.children.length;c++){var d=this.children[c];if(d.type=="font-face")this.fontFace=d,d.style("font-family").hasValue()&&(a.Definitions[d.style("font-family").value]=this);else if(d.type=="missing-glyph")this.missingGlyph= d;else if(d.type=="glyph")d.arabicForm!=""?(this.isArabic=this.isRTL=!0,typeof this.glyphs[d.unicode]=="undefined"&&(this.glyphs[d.unicode]=[]),this.glyphs[d.unicode][d.arabicForm]=d):this.glyphs[d.unicode]=d}};a.Element.font.prototype=new a.Element.ElementBase;a.Element.fontface=function(c){this.base=a.Element.ElementBase;this.base(c);this.ascent=this.attribute("ascent").value;this.descent=this.attribute("descent").value;this.unitsPerEm=this.attribute("units-per-em").numValue()};a.Element.fontface.prototype= new a.Element.ElementBase;a.Element.missingglyph=function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=0};a.Element.missingglyph.prototype=new a.Element.path;a.Element.glyph=function(c){this.base=a.Element.path;this.base(c);this.horizAdvX=this.attribute("horiz-adv-x").numValue();this.unicode=this.attribute("unicode").value;this.arabicForm=this.attribute("arabic-form").value};a.Element.glyph.prototype=new a.Element.path;a.Element.text=function(c){this.base=a.Element.RenderedElementBase; this.base(c);if(c!=null){this.children=[];for(var d=0;d<c.childNodes.length;d++){var b=c.childNodes[d];b.nodeType==1?this.addChild(b,!0):b.nodeType==3&&this.addChild(new a.Element.tspan(b),!1)}}this.baseSetContext=this.setContext;this.setContext=function(b){this.baseSetContext(b);if(this.style("dominant-baseline").hasValue())b.textBaseline=this.style("dominant-baseline").value;if(this.style("alignment-baseline").hasValue())b.textBaseline=this.style("alignment-baseline").value};this.renderChildren= function(b){for(var a=this.style("text-anchor").valueOrDefault("start"),c=this.attribute("x").Length.toPixels("x"),d=this.attribute("y").Length.toPixels("y"),h=0;h<this.children.length;h++){var j=this.children[h];j.attribute("x").hasValue()?j.x=j.attribute("x").Length.toPixels("x"):(j.attribute("dx").hasValue()&&(c+=j.attribute("dx").Length.toPixels("x")),j.x=c);c=j.measureText?j.measureText(b):0;if(a!="start"&&(h==0||j.attribute("x").hasValue())){for(var l=c,o=h+1;o<this.children.length;o++){var n= this.children[o];if(n.attribute("x").hasValue())break;l+=n.measureText?n.measureText(b):0}j.x-=a=="end"?l:l/2}c=j.x+c;j.attribute("y").hasValue()?j.y=j.attribute("y").Length.toPixels("y"):(j.attribute("dy").hasValue()&&(d+=j.attribute("dy").Length.toPixels("y")),j.y=d);d=j.y;j.render(b)}}};a.Element.text.prototype=new a.Element.RenderedElementBase;a.Element.TextElementBase=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getGlyph=function(a,b,c){var e=b[c],f=null;if(a.isArabic){var g= "isolated";if((c==0||b[c-1]==" ")&&c<b.length-2&&b[c+1]!=" ")g="terminal";c>0&&b[c-1]!=" "&&c<b.length-2&&b[c+1]!=" "&&(g="medial");if(c>0&&b[c-1]!=" "&&(c==b.length-1||b[c+1]==" "))g="initial";typeof a.glyphs[e]!="undefined"&&(f=a.glyphs[e][g],f==null&&a.glyphs[e].type=="glyph"&&(f=a.glyphs[e]))}else f=a.glyphs[e];if(f==null)f=a.missingGlyph;return f};this.renderChildren=function(c){var b=this.parent.style("font-family").Definition.getDefinition();if(b!=null){var k=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize), e=this.parent.style("font-style").valueOrDefault(a.Font.Parse(a.ctx.font).fontStyle),f=this.getText();b.isRTL&&(f=f.split("").reverse().join(""));for(var g=a.ToNumberArray(this.parent.attribute("dx").value),h=0;h<f.length;h++){var j=this.getGlyph(b,f,h),l=k/b.fontFace.unitsPerEm;c.translate(this.x,this.y);c.scale(l,-l);var o=c.lineWidth;c.lineWidth=c.lineWidth*b.fontFace.unitsPerEm/k;e=="italic"&&c.transform(1,0,0.4,1,0,0);j.render(c);e=="italic"&&c.transform(1,0,-0.4,1,0,0);c.lineWidth=o;c.scale(1/ l,-1/l);c.translate(-this.x,-this.y);this.x+=k*(j.horizAdvX||b.horizAdvX)/b.fontFace.unitsPerEm;typeof g[h]!="undefined"&&!isNaN(g[h])&&(this.x+=g[h])}}else c.strokeStyle!=""&&c.strokeText(a.compressSpaces(this.getText()),this.x,this.y),c.fillStyle!=""&&c.fillText(a.compressSpaces(this.getText()),this.x,this.y)};this.getText=function(){};this.measureText=function(c){var b=this.parent.style("font-family").Definition.getDefinition();if(b!=null){var c=this.parent.style("font-size").numValueOrDefault(a.Font.Parse(a.ctx.font).fontSize), k=0,e=this.getText();b.isRTL&&(e=e.split("").reverse().join(""));for(var f=a.ToNumberArray(this.parent.attribute("dx").value),g=0;g<e.length;g++){var h=this.getGlyph(b,e,g);k+=(h.horizAdvX||b.horizAdvX)*c/b.fontFace.unitsPerEm;typeof f[g]!="undefined"&&!isNaN(f[g])&&(k+=f[g])}return k}b=a.compressSpaces(this.getText());if(!c.measureText)return b.length*10;c.save();this.setContext(c);b=c.measureText(b).width;c.restore();return b}};a.Element.TextElementBase.prototype=new a.Element.RenderedElementBase; a.Element.tspan=function(c){this.base=a.Element.TextElementBase;this.base(c);this.text=c.nodeType==3?c.nodeValue:c.childNodes.length>0?c.childNodes[0].nodeValue:c.text;this.getText=function(){return this.text}};a.Element.tspan.prototype=new a.Element.TextElementBase;a.Element.tref=function(c){this.base=a.Element.TextElementBase;this.base(c);this.getText=function(){var a=this.attribute("xlink:href").Definition.getDefinition();if(a!=null)return a.children[0].getText()}};a.Element.tref.prototype=new a.Element.TextElementBase; a.Element.a=function(c){this.base=a.Element.TextElementBase;this.base(c);this.hasText=!0;for(var d=0;d<c.childNodes.length;d++)if(c.childNodes[d].nodeType!=3)this.hasText=!1;this.text=this.hasText?c.childNodes[0].nodeValue:"";this.getText=function(){return this.text};this.baseRenderChildren=this.renderChildren;this.renderChildren=function(b){if(this.hasText){this.baseRenderChildren(b);var c=new a.Property("fontSize",a.Font.Parse(a.ctx.font).fontSize);a.Mouse.checkBoundingBox(this,new a.BoundingBox(this.x, this.y-c.Length.toPixels("y"),this.x+this.measureText(b),this.y))}else c=new a.Element.g,c.children=this.children,c.parent=this,c.render(b)};this.onclick=function(){window.open(this.attribute("xlink:href").value)};this.onmousemove=function(){a.ctx.canvas.style.cursor="pointer"}};a.Element.a.prototype=new a.Element.TextElementBase;a.Element.image=function(c){this.base=a.Element.RenderedElementBase;this.base(c);a.Images.push(this);this.img=document.createElement("img");this.loaded=!1;var d=this;this.img.onload= function(){d.loaded=!0};this.img.src=this.attribute("xlink:href").value;this.renderChildren=function(b){var c=this.attribute("x").Length.toPixels("x"),d=this.attribute("y").Length.toPixels("y"),f=this.attribute("width").Length.toPixels("x"),g=this.attribute("height").Length.toPixels("y");f==0||g==0||(b.save(),b.translate(c,d),a.AspectRatio(b,this.attribute("preserveAspectRatio").value,f,this.img.width,g,this.img.height,0,0),b.drawImage(this.img,0,0),b.restore())}};a.Element.image.prototype=new a.Element.RenderedElementBase; a.Element.g=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.getBoundingBox=function(){for(var c=new a.BoundingBox,b=0;b<this.children.length;b++)c.addBoundingBox(this.children[b].getBoundingBox());return c}};a.Element.g.prototype=new a.Element.RenderedElementBase;a.Element.symbol=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseSetContext=this.setContext;this.setContext=function(c){this.baseSetContext(c);if(this.attribute("viewBox").hasValue()){var b= a.ToNumberArray(this.attribute("viewBox").value),k=b[0],e=b[1];width=b[2];height=b[3];a.AspectRatio(c,this.attribute("preserveAspectRatio").value,this.attribute("width").Length.toPixels("x"),width,this.attribute("height").Length.toPixels("y"),height,k,e);a.ViewPort.SetCurrent(b[2],b[3])}}};a.Element.symbol.prototype=new a.Element.RenderedElementBase;a.Element.style=function(c){this.base=a.Element.ElementBase;this.base(c);for(var c=c.childNodes[0].nodeValue+(c.childNodes.length>1?c.childNodes[1].nodeValue: ""),c=c.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,""),c=a.compressSpaces(c),c=c.split("}"),d=0;d<c.length;d++)if(a.trim(c[d])!="")for(var b=c[d].split("{"),k=b[0].split(","),b=b[1].split(";"),e=0;e<k.length;e++){var f=a.trim(k[e]);if(f!=""){for(var g={},h=0;h<b.length;h++){var j=b[h].indexOf(":"),l=b[h].substr(0,j),j=b[h].substr(j+1,b[h].length-j);l!=null&&j!=null&&(g[a.trim(l)]=new a.Property(a.trim(l),a.trim(j)))}a.Styles[f]=g;if(f=="@font-face"){f=g["font-family"].value.replace(/"/g, "");g=g.src.value.split(",");for(h=0;h<g.length;h++)if(g[h].indexOf('format("svg")')>0){l=g[h].indexOf("url");j=g[h].indexOf(")",l);l=g[h].substr(l+5,j-l-6);l=a.parseXml(a.ajax(l)).getElementsByTagName("font");for(j=0;j<l.length;j++){var o=a.CreateElement(l[j]);a.Definitions[f]=o}}}}}};a.Element.style.prototype=new a.Element.ElementBase;a.Element.use=function(c){this.base=a.Element.RenderedElementBase;this.base(c);this.baseSetContext=this.setContext;this.setContext=function(a){this.baseSetContext(a); this.attribute("x").hasValue()&&a.translate(this.attribute("x").Length.toPixels("x"),0);this.attribute("y").hasValue()&&a.translate(0,this.attribute("y").Length.toPixels("y"))};this.getDefinition=function(){var a=this.attribute("xlink:href").Definition.getDefinition();if(this.attribute("width").hasValue())a.attribute("width",!0).value=this.attribute("width").value;if(this.attribute("height").hasValue())a.attribute("height",!0).value=this.attribute("height").value;return a};this.path=function(a){var b= this.getDefinition();b!=null&&b.path(a)};this.renderChildren=function(a){var b=this.getDefinition();b!=null&&b.render(a)}};a.Element.use.prototype=new a.Element.RenderedElementBase;a.Element.mask=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,b){var c=this.attribute("x").Length.toPixels("x"),e=this.attribute("y").Length.toPixels("y"),f=this.attribute("width").Length.toPixels("x"),g=this.attribute("height").Length.toPixels("y"),h=b.attribute("mask").value;b.attribute("mask").value= "";var j=document.createElement("canvas");j.width=c+f;j.height=e+g;var l=j.getContext("2d");this.renderChildren(l);var o=document.createElement("canvas");o.width=c+f;o.height=e+g;var n=o.getContext("2d");b.render(n);n.globalCompositeOperation="destination-in";n.fillStyle=l.createPattern(j,"no-repeat");n.fillRect(0,0,c+f,e+g);a.fillStyle=n.createPattern(o,"no-repeat");a.fillRect(0,0,c+f,e+g);b.attribute("mask").value=h};this.render=function(){}};a.Element.mask.prototype=new a.Element.ElementBase;a.Element.clipPath= function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a){for(var b=0;b<this.children.length;b++)this.children[b].path&&(this.children[b].path(a),a.clip())};this.render=function(){}};a.Element.clipPath.prototype=new a.Element.ElementBase;a.Element.filter=function(c){this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,b){var c=b.getBoundingBox(),e=this.attribute("x").Length.toPixels("x"),f=this.attribute("y").Length.toPixels("y");if(e==0||f==0)e=c.x1,f=c.y1;var g= this.attribute("width").Length.toPixels("x"),h=this.attribute("height").Length.toPixels("y");if(g==0||h==0)g=c.width(),h=c.height();c=b.style("filter").value;b.style("filter").value="";var j=0.2*g,l=0.2*h,o=document.createElement("canvas");o.width=g+2*j;o.height=h+2*l;var n=o.getContext("2d");n.translate(-e+j,-f+l);b.render(n);for(var q=0;q<this.children.length;q++)this.children[q].apply(n,0,0,g+2*j,h+2*l);a.drawImage(o,0,0,g+2*j,h+2*l,e-j,f-l,g+2*j,h+2*l);b.style("filter",!0).value=c};this.render= function(){}};a.Element.filter.prototype=new a.Element.ElementBase;a.Element.feGaussianBlur=function(c){function d(a,c,d,f,g){for(var h=0;h<g;h++)for(var j=0;j<f;j++)for(var l=a[h*f*4+j*4+3]/255,o=0;o<4;o++){for(var n=d[0]*(l==0?255:a[h*f*4+j*4+o])*(l==0||o==3?1:l),q=1;q<d.length;q++){var p=Math.max(j-q,0),m=a[h*f*4+p*4+3]/255,p=Math.min(j+q,f-1),p=a[h*f*4+p*4+3]/255,s=d[q],r;m==0?r=255:(r=Math.max(j-q,0),r=a[h*f*4+r*4+o]);m=r*(m==0||o==3?1:m);p==0?r=255:(r=Math.min(j+q,f-1),r=a[h*f*4+r*4+o]);n+= s*(m+r*(p==0||o==3?1:p))}c[j*g*4+h*4+o]=n}}this.base=a.Element.ElementBase;this.base(c);this.apply=function(a,c,e,f,g){var e=this.attribute("stdDeviation").numValue(),c=a.getImageData(0,0,f,g),e=Math.max(e,0.01),h=Math.ceil(e*4)+1;mask=[];for(var j=0;j<h;j++)mask[j]=Math.exp(-0.5*(j/e)*(j/e));e=mask;h=0;for(j=1;j<e.length;j++)h+=Math.abs(e[j]);h=2*h+Math.abs(e[0]);for(j=0;j<e.length;j++)e[j]/=h;tmp=[];d(c.data,tmp,e,f,g);d(tmp,c.data,e,g,f);a.clearRect(0,0,f,g);a.putImageData(c,0,0)}};a.Element.filter.prototype= new a.Element.feGaussianBlur;a.Element.title=function(){};a.Element.title.prototype=new a.Element.ElementBase;a.Element.desc=function(){};a.Element.desc.prototype=new a.Element.ElementBase;a.Element.MISSING=function(a){console.log("ERROR: Element '"+a.nodeName+"' not yet implemented.")};a.Element.MISSING.prototype=new a.Element.ElementBase;a.CreateElement=function(c){var d=c.nodeName.replace(/^[^:]+:/,""),d=d.replace(/\-/g,""),b=null,b=typeof a.Element[d]!="undefined"?new a.Element[d](c):new a.Element.MISSING(c); b.type=c.nodeName;return b};a.load=function(c,d){a.loadXml(c,a.ajax(d))};a.loadXml=function(c,d){a.loadXmlDoc(c,a.parseXml(d))};a.loadXmlDoc=function(c,d){a.init(c);var b=function(a){for(var b=c.canvas;b;)a.x-=b.offsetLeft,a.y-=b.offsetTop,b=b.offsetParent;window.scrollX&&(a.x+=window.scrollX);window.scrollY&&(a.y+=window.scrollY);return a};if(a.opts.ignoreMouse!=!0)c.canvas.onclick=function(c){c=b(new a.Point(c!=null?c.clientX:event.clientX,c!=null?c.clientY:event.clientY));a.Mouse.onclick(c.x,c.y)}, c.canvas.onmousemove=function(c){c=b(new a.Point(c!=null?c.clientX:event.clientX,c!=null?c.clientY:event.clientY));a.Mouse.onmousemove(c.x,c.y)};var k=a.CreateElement(d.documentElement),e=k.root=!0,f=function(){a.ViewPort.Clear();c.canvas.parentNode&&a.ViewPort.SetCurrent(c.canvas.parentNode.clientWidth,c.canvas.parentNode.clientHeight);if(a.opts.ignoreDimensions!=!0){if(k.style("width").hasValue())c.canvas.width=k.style("width").Length.toPixels("x"),c.canvas.style.width=c.canvas.width+"px";if(k.style("height").hasValue())c.canvas.height= k.style("height").Length.toPixels("y"),c.canvas.style.height=c.canvas.height+"px"}var b=c.canvas.clientWidth||c.canvas.width,d=c.canvas.clientHeight||c.canvas.height;a.ViewPort.SetCurrent(b,d);if(a.opts!=null&&a.opts.offsetX!=null)k.attribute("x",!0).value=a.opts.offsetX;if(a.opts!=null&&a.opts.offsetY!=null)k.attribute("y",!0).value=a.opts.offsetY;if(a.opts!=null&&a.opts.scaleWidth!=null&&a.opts.scaleHeight!=null){var f=1,g=1;k.attribute("width").hasValue()&&(f=k.attribute("width").Length.toPixels("x")/ a.opts.scaleWidth);k.attribute("height").hasValue()&&(g=k.attribute("height").Length.toPixels("y")/a.opts.scaleHeight);k.attribute("width",!0).value=a.opts.scaleWidth;k.attribute("height",!0).value=a.opts.scaleHeight;k.attribute("viewBox",!0).value="0 0 "+b*f+" "+d*g;k.attribute("preserveAspectRatio",!0).value="none"}a.opts.ignoreClear!=!0&&c.clearRect(0,0,b,d);k.render(c);e&&(e=!1,a.opts!=null&&typeof a.opts.renderCallback=="function"&&a.opts.renderCallback())},g=!0;a.ImagesLoaded()&&(g=!1,f()); a.intervalID=setInterval(function(){var b=!1;g&&a.ImagesLoaded()&&(g=!1,b=!0);a.opts.ignoreMouse!=!0&&(b|=a.Mouse.hasEvents());if(a.opts.ignoreAnimation!=!0)for(var c=0;c<a.Animations.length;c++)b|=a.Animations[c].update(1E3/a.FRAMERATE);a.opts!=null&&typeof a.opts.forceRedraw=="function"&&a.opts.forceRedraw()==!0&&(b=!0);b&&(f(),a.Mouse.runEvents())},1E3/a.FRAMERATE)};a.stop=function(){a.intervalID&&clearInterval(a.intervalID)};a.Mouse=new function(){this.events=[];this.hasEvents=function(){return this.events.length!= 0};this.onclick=function(a,d){this.events.push({type:"onclick",x:a,y:d,run:function(a){if(a.onclick)a.onclick()}})};this.onmousemove=function(a,d){this.events.push({type:"onmousemove",x:a,y:d,run:function(a){if(a.onmousemove)a.onmousemove()}})};this.eventElements=[];this.checkPath=function(a,d){for(var b=0;b<this.events.length;b++){var k=this.events[b];d.isPointInPath&&d.isPointInPath(k.x,k.y)&&(this.eventElements[b]=a)}};this.checkBoundingBox=function(a,d){for(var b=0;b<this.events.length;b++){var k= this.events[b];d.isPointInBox(k.x,k.y)&&(this.eventElements[b]=a)}};this.runEvents=function(){a.ctx.canvas.style.cursor="";for(var c=0;c<this.events.length;c++)for(var d=this.events[c],b=this.eventElements[c];b;)d.run(b),b=b.parent;this.events=[];this.eventElements=[]}};return a}this.canvg=function(a,c,d){if(a==null&&c==null&&d==null)for(var c=document.getElementsByTagName("svg"),b=0;b<c.length;b++){a=c[b];d=document.createElement("canvas");d.width=a.clientWidth;d.height=a.clientHeight;a.parentNode.insertBefore(d, a);a.parentNode.removeChild(a);var k=document.createElement("div");k.appendChild(a);canvg(d,k.innerHTML)}else d=d||{},typeof a=="string"&&(a=document.getElementById(a)),a.svg==null?(b=m(),a.svg=b):(b=a.svg,b.stop()),b.opts=d,a=a.getContext("2d"),typeof c.documentElement!="undefined"?b.loadXmlDoc(a,c):c.substr(0,1)=="<"?b.loadXml(a,c):b.load(a,c)}})(); if(CanvasRenderingContext2D)CanvasRenderingContext2D.prototype.drawSvg=function(m,a,c,d,b){canvg(this.canvas,m,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:a,offsetY:c,scaleWidth:d,scaleHeight:b})}; (function(m){var a=m.win,c=m.css,d=m.CanVGRenderer,b=m.SVGRenderer,k=m.extend,e=m.merge,f=m.addEvent,g=m.createElement,h=m.discardElement;k(d.prototype,b.prototype);k(d.prototype,{create:function(a,b,c,d){this.setContainer(b,c,d);this.configure(a)},setContainer:function(a,b,c){var d=a.style,e=a.parentNode,f=d.left,d=d.top,h=a.offsetWidth,k=a.offsetHeight,m={visibility:"hidden",position:"absolute"};this.init(a,b,c);this.canvas=g("canvas",{width:h,height:k},{position:"relative",left:f,top:d},a);this.ttLine= g("div",null,m,e);this.ttDiv=g("div",null,m,e);this.ttTimer=void 0;this.hiddenSvg=a=g("div",{width:h,height:k},{visibility:"hidden",left:f,top:d},e);a.appendChild(this.box)},configure:function(a){var b=this,d=a.options.tooltip,g=d.borderWidth,h=b.ttDiv,k=d.style,m=b.ttLine,s=parseInt(k.padding,10),k=e(k,{padding:s+"px","background-color":d.backgroundColor,"border-style":"solid","border-width":g+"px","border-radius":d.borderRadius+"px"});d.shadow&&(k=e(k,{"box-shadow":"1px 1px 3px gray","-webkit-box-shadow":"1px 1px 3px gray"})); c(h,k);c(m,{"border-left":"1px solid darkgray"});f(a,"tooltipRefresh",function(d){var e=a.container,f=e.offsetLeft,e=e.offsetTop,g;h.innerHTML=d.text;g=a.tooltip.getPosition(h.offsetWidth,h.offsetHeight,{plotX:d.x,plotY:d.y});c(h,{visibility:"visible",left:g.x+"px",top:g.y+"px","border-color":d.borderColor});c(m,{visibility:"visible",left:f+d.x+"px",top:e+a.plotTop+"px",height:a.plotHeight+"px"});b.ttTimer!==void 0&&clearTimeout(b.ttTimer);b.ttTimer=setTimeout(function(){c(h,{visibility:"hidden"}); c(m,{visibility:"hidden"})},3E3)})},destroy:function(){h(this.canvas);this.ttTimer!==void 0&&clearTimeout(this.ttTimer);h(this.ttLine);h(this.ttDiv);h(this.hiddenSvg);return b.prototype.destroy.apply(this)},color:function(a,c,d){a&&a.linearGradient&&(a=a.stops[a.stops.length-1][1]);return b.prototype.color.call(this,a,c,d)},draw:function(){a.canvg(this.canvas,this.hiddenSvg.innerHTML)}})})(Highcharts); |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 | 1 2 1 1 1 1 1 1 1 | /** * @license A class to parse color values * @author Stoyan Stefanov <sstoo@gmail.com> * @link http://www.phpied.com/rgb-color-parser-in-javascript/ * Use it if you like it * */ function RGBColor(color_string) { this.ok = false; // strip any leading # if (color_string.charAt(0) == '#') { // remove # if any color_string = color_string.substr(1,6); } color_string = color_string.replace(/ /g,''); color_string = color_string.toLowerCase(); // before getting into regexps, try simple matches // and overwrite the input var simple_colors = { aliceblue: 'f0f8ff', antiquewhite: 'faebd7', aqua: '00ffff', aquamarine: '7fffd4', azure: 'f0ffff', beige: 'f5f5dc', bisque: 'ffe4c4', black: '000000', blanchedalmond: 'ffebcd', blue: '0000ff', blueviolet: '8a2be2', brown: 'a52a2a', burlywood: 'deb887', cadetblue: '5f9ea0', chartreuse: '7fff00', chocolate: 'd2691e', coral: 'ff7f50', cornflowerblue: '6495ed', cornsilk: 'fff8dc', crimson: 'dc143c', cyan: '00ffff', darkblue: '00008b', darkcyan: '008b8b', darkgoldenrod: 'b8860b', darkgray: 'a9a9a9', darkgreen: '006400', darkkhaki: 'bdb76b', darkmagenta: '8b008b', darkolivegreen: '556b2f', darkorange: 'ff8c00', darkorchid: '9932cc', darkred: '8b0000', darksalmon: 'e9967a', darkseagreen: '8fbc8f', darkslateblue: '483d8b', darkslategray: '2f4f4f', darkturquoise: '00ced1', darkviolet: '9400d3', deeppink: 'ff1493', deepskyblue: '00bfff', dimgray: '696969', dodgerblue: '1e90ff', feldspar: 'd19275', firebrick: 'b22222', floralwhite: 'fffaf0', forestgreen: '228b22', fuchsia: 'ff00ff', gainsboro: 'dcdcdc', ghostwhite: 'f8f8ff', gold: 'ffd700', goldenrod: 'daa520', gray: '808080', green: '008000', greenyellow: 'adff2f', honeydew: 'f0fff0', hotpink: 'ff69b4', indianred : 'cd5c5c', indigo : '4b0082', ivory: 'fffff0', khaki: 'f0e68c', lavender: 'e6e6fa', lavenderblush: 'fff0f5', lawngreen: '7cfc00', lemonchiffon: 'fffacd', lightblue: 'add8e6', lightcoral: 'f08080', lightcyan: 'e0ffff', lightgoldenrodyellow: 'fafad2', lightgrey: 'd3d3d3', lightgreen: '90ee90', lightpink: 'ffb6c1', lightsalmon: 'ffa07a', lightseagreen: '20b2aa', lightskyblue: '87cefa', lightslateblue: '8470ff', lightslategray: '778899', lightsteelblue: 'b0c4de', lightyellow: 'ffffe0', lime: '00ff00', limegreen: '32cd32', linen: 'faf0e6', magenta: 'ff00ff', maroon: '800000', mediumaquamarine: '66cdaa', mediumblue: '0000cd', mediumorchid: 'ba55d3', mediumpurple: '9370d8', mediumseagreen: '3cb371', mediumslateblue: '7b68ee', mediumspringgreen: '00fa9a', mediumturquoise: '48d1cc', mediumvioletred: 'c71585', midnightblue: '191970', mintcream: 'f5fffa', mistyrose: 'ffe4e1', moccasin: 'ffe4b5', navajowhite: 'ffdead', navy: '000080', oldlace: 'fdf5e6', olive: '808000', olivedrab: '6b8e23', orange: 'ffa500', orangered: 'ff4500', orchid: 'da70d6', palegoldenrod: 'eee8aa', palegreen: '98fb98', paleturquoise: 'afeeee', palevioletred: 'd87093', papayawhip: 'ffefd5', peachpuff: 'ffdab9', peru: 'cd853f', pink: 'ffc0cb', plum: 'dda0dd', powderblue: 'b0e0e6', purple: '800080', red: 'ff0000', rosybrown: 'bc8f8f', royalblue: '4169e1', saddlebrown: '8b4513', salmon: 'fa8072', sandybrown: 'f4a460', seagreen: '2e8b57', seashell: 'fff5ee', sienna: 'a0522d', silver: 'c0c0c0', skyblue: '87ceeb', slateblue: '6a5acd', slategray: '708090', snow: 'fffafa', springgreen: '00ff7f', steelblue: '4682b4', tan: 'd2b48c', teal: '008080', thistle: 'd8bfd8', tomato: 'ff6347', turquoise: '40e0d0', violet: 'ee82ee', violetred: 'd02090', wheat: 'f5deb3', white: 'ffffff', whitesmoke: 'f5f5f5', yellow: 'ffff00', yellowgreen: '9acd32' }; for (var key in simple_colors) { if (color_string == key) { color_string = simple_colors[key]; } } // emd of simple type-in colors // array of color definition objects var color_defs = [ { re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/, example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'], process: function (bits){ return [ parseInt(bits[1]), parseInt(bits[2]), parseInt(bits[3]) ]; } }, { re: /^(\w{2})(\w{2})(\w{2})$/, example: ['#00ff00', '336699'], process: function (bits){ return [ parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16) ]; } }, { re: /^(\w{1})(\w{1})(\w{1})$/, example: ['#fb0', 'f0f'], process: function (bits){ return [ parseInt(bits[1] + bits[1], 16), parseInt(bits[2] + bits[2], 16), parseInt(bits[3] + bits[3], 16) ]; } } ]; // search through the definitions to find a match for (var i = 0; i < color_defs.length; i++) { var re = color_defs[i].re; var processor = color_defs[i].process; var bits = re.exec(color_string); if (bits) { channels = processor(bits); this.r = channels[0]; this.g = channels[1]; this.b = channels[2]; this.ok = true; } } // validate/cleanup values this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r); this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g); this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b); // some getters this.toRGB = function () { return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')'; } this.toHex = function () { var r = this.r.toString(16); var g = this.g.toString(16); var b = this.b.toString(16); if (r.length == 1) r = '0' + r; if (g.length == 1) g = '0' + g; if (b.length == 1) b = '0' + b; return '#' + r + g + b; } // help this.getHelpXML = function () { var examples = new Array(); // add regexps for (var i = 0; i < color_defs.length; i++) { var example = color_defs[i].example; for (var j = 0; j < example.length; j++) { examples[examples.length] = example[j]; } } // add type-in colors for (var sc in simple_colors) { examples[examples.length] = sc; } var xml = document.createElement('ul'); xml.setAttribute('id', 'rgbcolor-examples'); for (var i = 0; i < examples.length; i++) { try { var list_item = document.createElement('li'); var list_color = new RGBColor(examples[i]); var example_div = document.createElement('div'); example_div.style.cssText = 'margin: 3px; ' + 'border: 1px solid black; ' + 'background:' + list_color.toHex() + '; ' + 'color:' + list_color.toHex() ; example_div.appendChild(document.createTextNode('test')); var list_item_value = document.createTextNode( ' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex() ); list_item.appendChild(example_div); list_item.appendChild(list_item_value); xml.appendChild(list_item); } catch(e){} } return xml; } } /** * @license canvg.js - Javascript SVG parser and renderer on Canvas * MIT Licensed * Gabe Lerner (gabelerner@gmail.com) * http://code.google.com/p/canvg/ * * Requires: rgbcolor.js - http://www.phpied.com/rgb-color-parser-in-javascript/ * */ if(!window.console) { window.console = {}; window.console.log = function(str) {}; window.console.dir = function(str) {}; } if(!Array.prototype.indexOf){ Array.prototype.indexOf = function(obj){ for(var i=0; i<this.length; i++){ if(this[i]==obj){ return i; } } return -1; } } (function(){ // canvg(target, s) // empty parameters: replace all 'svg' elements on page with 'canvas' elements // target: canvas element or the id of a canvas element // s: svg string, url to svg file, or xml document // opts: optional hash of options // ignoreMouse: true => ignore mouse events // ignoreAnimation: true => ignore animations // ignoreDimensions: true => does not try to resize canvas // ignoreClear: true => does not clear canvas // offsetX: int => draws at a x offset // offsetY: int => draws at a y offset // scaleWidth: int => scales horizontally to width // scaleHeight: int => scales vertically to height // renderCallback: function => will call the function after the first render is completed // forceRedraw: function => will call the function on every frame, if it returns true, will redraw this.canvg = function (target, s, opts) { // no parameters if (target == null && s == null && opts == null) { var svgTags = document.getElementsByTagName('svg'); for (var i=0; i<svgTags.length; i++) { var svgTag = svgTags[i]; var c = document.createElement('canvas'); c.width = svgTag.clientWidth; c.height = svgTag.clientHeight; svgTag.parentNode.insertBefore(c, svgTag); svgTag.parentNode.removeChild(svgTag); var div = document.createElement('div'); div.appendChild(svgTag); canvg(c, div.innerHTML); } return; } opts = opts || {}; if (typeof target == 'string') { target = document.getElementById(target); } // reuse class per canvas var svg; if (target.svg == null) { svg = build(); target.svg = svg; } else { svg = target.svg; svg.stop(); } svg.opts = opts; var ctx = target.getContext('2d'); if (typeof(s.documentElement) != 'undefined') { // load from xml doc svg.loadXmlDoc(ctx, s); } else if (s.substr(0,1) == '<') { // load from xml string svg.loadXml(ctx, s); } else { // load from url svg.load(ctx, s); } } function build() { var svg = { }; svg.FRAMERATE = 30; svg.MAX_VIRTUAL_PIXELS = 30000; // globals svg.init = function(ctx) { svg.Definitions = {}; svg.Styles = {}; svg.Animations = []; svg.Images = []; svg.ctx = ctx; svg.ViewPort = new (function () { this.viewPorts = []; this.Clear = function() { this.viewPorts = []; } this.SetCurrent = function(width, height) { this.viewPorts.push({ width: width, height: height }); } this.RemoveCurrent = function() { this.viewPorts.pop(); } this.Current = function() { return this.viewPorts[this.viewPorts.length - 1]; } this.width = function() { return this.Current().width; } this.height = function() { return this.Current().height; } this.ComputeSize = function(d) { if (d != null && typeof(d) == 'number') return d; if (d == 'x') return this.width(); if (d == 'y') return this.height(); return Math.sqrt(Math.pow(this.width(), 2) + Math.pow(this.height(), 2)) / Math.sqrt(2); } }); } svg.init(); // images loaded svg.ImagesLoaded = function() { for (var i=0; i<svg.Images.length; i++) { if (!svg.Images[i].loaded) return false; } return true; } // trim svg.trim = function(s) { return s.replace(/^\s+|\s+$/g, ''); } // compress spaces svg.compressSpaces = function(s) { return s ? s.replace(/[\s\r\t\n]+/gm,' ') : ''; } // ajax svg.ajax = function(url) { var AJAX; if(window.XMLHttpRequest){AJAX=new XMLHttpRequest();} else{AJAX=new ActiveXObject('Microsoft.XMLHTTP');} if(AJAX){ AJAX.open('GET',url,false); AJAX.send(null); return AJAX.responseText; } return null; } // parse xml svg.parseXml = function(xml) { if (window.DOMParser) { var parser = new DOMParser(); return parser.parseFromString(xml, 'text/xml'); } else { xml = xml.replace(/<!DOCTYPE svg[^>]*>/, ''); var xmlDoc = new ActiveXObject('Microsoft.XMLDOM'); xmlDoc.async = 'false'; xmlDoc.loadXML(xml); return xmlDoc; } } svg.Property = function(name, value) { this.name = name; this.value = value; this.hasValue = function() { return (this.value != null && this.value !== ''); } // return the numerical value of the property this.numValue = function() { if (!this.hasValue()) return 0; var n = parseFloat(this.value); if ((this.value + '').match(/%$/)) { n = n / 100.0; } return n; } this.valueOrDefault = function(def) { if (this.hasValue()) return this.value; return def; } this.numValueOrDefault = function(def) { if (this.hasValue()) return this.numValue(); return def; } /* EXTENSIONS */ var that = this; // color extensions this.Color = { // augment the current color value with the opacity addOpacity: function(opacity) { var newValue = that.value; if (opacity != null && opacity != '') { var color = new RGBColor(that.value); if (color.ok) { newValue = 'rgba(' + color.r + ', ' + color.g + ', ' + color.b + ', ' + opacity + ')'; } } return new svg.Property(that.name, newValue); } } // definition extensions this.Definition = { // get the definition from the definitions table getDefinition: function() { var name = that.value.replace(/^(url\()?#([^\)]+)\)?$/, '$2'); return svg.Definitions[name]; }, isUrl: function() { return that.value.indexOf('url(') == 0 }, getFillStyle: function(e) { var def = this.getDefinition(); // gradient if (def != null && def.createGradient) { return def.createGradient(svg.ctx, e); } // pattern if (def != null && def.createPattern) { return def.createPattern(svg.ctx, e); } return null; } } // length extensions this.Length = { DPI: function(viewPort) { return 96.0; // TODO: compute? }, EM: function(viewPort) { var em = 12; var fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize); if (fontSize.hasValue()) em = fontSize.Length.toPixels(viewPort); return em; }, // get the length as pixels toPixels: function(viewPort) { if (!that.hasValue()) return 0; var s = that.value+''; if (s.match(/em$/)) return that.numValue() * this.EM(viewPort); if (s.match(/ex$/)) return that.numValue() * this.EM(viewPort) / 2.0; if (s.match(/px$/)) return that.numValue(); if (s.match(/pt$/)) return that.numValue() * 1.25; if (s.match(/pc$/)) return that.numValue() * 15; if (s.match(/cm$/)) return that.numValue() * this.DPI(viewPort) / 2.54; if (s.match(/mm$/)) return that.numValue() * this.DPI(viewPort) / 25.4; if (s.match(/in$/)) return that.numValue() * this.DPI(viewPort); if (s.match(/%$/)) return that.numValue() * svg.ViewPort.ComputeSize(viewPort); return that.numValue(); } } // time extensions this.Time = { // get the time as milliseconds toMilliseconds: function() { if (!that.hasValue()) return 0; var s = that.value+''; if (s.match(/s$/)) return that.numValue() * 1000; if (s.match(/ms$/)) return that.numValue(); return that.numValue(); } } // angle extensions this.Angle = { // get the angle as radians toRadians: function() { if (!that.hasValue()) return 0; var s = that.value+''; if (s.match(/deg$/)) return that.numValue() * (Math.PI / 180.0); if (s.match(/grad$/)) return that.numValue() * (Math.PI / 200.0); if (s.match(/rad$/)) return that.numValue(); return that.numValue() * (Math.PI / 180.0); } } } // fonts svg.Font = new (function() { this.Styles = ['normal','italic','oblique','inherit']; this.Variants = ['normal','small-caps','inherit']; this.Weights = ['normal','bold','bolder','lighter','100','200','300','400','500','600','700','800','900','inherit']; this.CreateFont = function(fontStyle, fontVariant, fontWeight, fontSize, fontFamily, inherit) { var f = inherit != null ? this.Parse(inherit) : this.CreateFont('', '', '', '', '', svg.ctx.font); return { fontFamily: fontFamily || f.fontFamily, fontSize: fontSize || f.fontSize, fontStyle: fontStyle || f.fontStyle, fontWeight: fontWeight || f.fontWeight, fontVariant: fontVariant || f.fontVariant, toString: function () { return [this.fontStyle, this.fontVariant, this.fontWeight, this.fontSize, this.fontFamily].join(' ') } } } var that = this; this.Parse = function(s) { var f = {}; var d = svg.trim(svg.compressSpaces(s || '')).split(' '); var set = { fontSize: false, fontStyle: false, fontWeight: false, fontVariant: false } var ff = ''; for (var i=0; i<d.length; i++) { if (!set.fontStyle && that.Styles.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontStyle = d[i]; set.fontStyle = true; } else if (!set.fontVariant && that.Variants.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontVariant = d[i]; set.fontStyle = set.fontVariant = true; } else if (!set.fontWeight && that.Weights.indexOf(d[i]) != -1) { if (d[i] != 'inherit') f.fontWeight = d[i]; set.fontStyle = set.fontVariant = set.fontWeight = true; } else if (!set.fontSize) { if (d[i] != 'inherit') f.fontSize = d[i].split('/')[0]; set.fontStyle = set.fontVariant = set.fontWeight = set.fontSize = true; } else { if (d[i] != 'inherit') ff += d[i]; } } if (ff != '') f.fontFamily = ff; return f; } }); // points and paths svg.ToNumberArray = function(s) { var a = svg.trim(svg.compressSpaces((s || '').replace(/,/g, ' '))).split(' '); for (var i=0; i<a.length; i++) { a[i] = parseFloat(a[i]); } return a; } svg.Point = function(x, y) { this.x = x; this.y = y; this.angleTo = function(p) { return Math.atan2(p.y - this.y, p.x - this.x); } this.applyTransform = function(v) { var xp = this.x * v[0] + this.y * v[2] + v[4]; var yp = this.x * v[1] + this.y * v[3] + v[5]; this.x = xp; this.y = yp; } } svg.CreatePoint = function(s) { var a = svg.ToNumberArray(s); return new svg.Point(a[0], a[1]); } svg.CreatePath = function(s) { var a = svg.ToNumberArray(s); var path = []; for (var i=0; i<a.length; i+=2) { path.push(new svg.Point(a[i], a[i+1])); } return path; } // bounding box svg.BoundingBox = function(x1, y1, x2, y2) { // pass in initial points if you want this.x1 = Number.NaN; this.y1 = Number.NaN; this.x2 = Number.NaN; this.y2 = Number.NaN; this.x = function() { return this.x1; } this.y = function() { return this.y1; } this.width = function() { return this.x2 - this.x1; } this.height = function() { return this.y2 - this.y1; } this.addPoint = function(x, y) { if (x != null) { if (isNaN(this.x1) || isNaN(this.x2)) { this.x1 = x; this.x2 = x; } if (x < this.x1) this.x1 = x; if (x > this.x2) this.x2 = x; } if (y != null) { if (isNaN(this.y1) || isNaN(this.y2)) { this.y1 = y; this.y2 = y; } if (y < this.y1) this.y1 = y; if (y > this.y2) this.y2 = y; } } this.addX = function(x) { this.addPoint(x, null); } this.addY = function(y) { this.addPoint(null, y); } this.addBoundingBox = function(bb) { this.addPoint(bb.x1, bb.y1); this.addPoint(bb.x2, bb.y2); } this.addQuadraticCurve = function(p0x, p0y, p1x, p1y, p2x, p2y) { var cp1x = p0x + 2/3 * (p1x - p0x); // CP1 = QP0 + 2/3 *(QP1-QP0) var cp1y = p0y + 2/3 * (p1y - p0y); // CP1 = QP0 + 2/3 *(QP1-QP0) var cp2x = cp1x + 1/3 * (p2x - p0x); // CP2 = CP1 + 1/3 *(QP2-QP0) var cp2y = cp1y + 1/3 * (p2y - p0y); // CP2 = CP1 + 1/3 *(QP2-QP0) this.addBezierCurve(p0x, p0y, cp1x, cp2x, cp1y, cp2y, p2x, p2y); } this.addBezierCurve = function(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) { // from http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html var p0 = [p0x, p0y], p1 = [p1x, p1y], p2 = [p2x, p2y], p3 = [p3x, p3y]; this.addPoint(p0[0], p0[1]); this.addPoint(p3[0], p3[1]); for (i=0; i<=1; i++) { var f = function(t) { return Math.pow(1-t, 3) * p0[i] + 3 * Math.pow(1-t, 2) * t * p1[i] + 3 * (1-t) * Math.pow(t, 2) * p2[i] + Math.pow(t, 3) * p3[i]; } var b = 6 * p0[i] - 12 * p1[i] + 6 * p2[i]; var a = -3 * p0[i] + 9 * p1[i] - 9 * p2[i] + 3 * p3[i]; var c = 3 * p1[i] - 3 * p0[i]; if (a == 0) { if (b == 0) continue; var t = -c / b; if (0 < t && t < 1) { if (i == 0) this.addX(f(t)); if (i == 1) this.addY(f(t)); } continue; } var b2ac = Math.pow(b, 2) - 4 * c * a; if (b2ac < 0) continue; var t1 = (-b + Math.sqrt(b2ac)) / (2 * a); if (0 < t1 && t1 < 1) { if (i == 0) this.addX(f(t1)); if (i == 1) this.addY(f(t1)); } var t2 = (-b - Math.sqrt(b2ac)) / (2 * a); if (0 < t2 && t2 < 1) { if (i == 0) this.addX(f(t2)); if (i == 1) this.addY(f(t2)); } } } this.isPointInBox = function(x, y) { return (this.x1 <= x && x <= this.x2 && this.y1 <= y && y <= this.y2); } this.addPoint(x1, y1); this.addPoint(x2, y2); } // transforms svg.Transform = function(v) { var that = this; this.Type = {} // translate this.Type.translate = function(s) { this.p = svg.CreatePoint(s); this.apply = function(ctx) { ctx.translate(this.p.x || 0.0, this.p.y || 0.0); } this.applyToPoint = function(p) { p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]); } } // rotate this.Type.rotate = function(s) { var a = svg.ToNumberArray(s); this.angle = new svg.Property('angle', a[0]); this.cx = a[1] || 0; this.cy = a[2] || 0; this.apply = function(ctx) { ctx.translate(this.cx, this.cy); ctx.rotate(this.angle.Angle.toRadians()); ctx.translate(-this.cx, -this.cy); } this.applyToPoint = function(p) { var a = this.angle.Angle.toRadians(); p.applyTransform([1, 0, 0, 1, this.p.x || 0.0, this.p.y || 0.0]); p.applyTransform([Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0]); p.applyTransform([1, 0, 0, 1, -this.p.x || 0.0, -this.p.y || 0.0]); } } this.Type.scale = function(s) { this.p = svg.CreatePoint(s); this.apply = function(ctx) { ctx.scale(this.p.x || 1.0, this.p.y || this.p.x || 1.0); } this.applyToPoint = function(p) { p.applyTransform([this.p.x || 0.0, 0, 0, this.p.y || 0.0, 0, 0]); } } this.Type.matrix = function(s) { this.m = svg.ToNumberArray(s); this.apply = function(ctx) { ctx.transform(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5]); } this.applyToPoint = function(p) { p.applyTransform(this.m); } } this.Type.SkewBase = function(s) { this.base = that.Type.matrix; this.base(s); this.angle = new svg.Property('angle', s); } this.Type.SkewBase.prototype = new this.Type.matrix; this.Type.skewX = function(s) { this.base = that.Type.SkewBase; this.base(s); this.m = [1, 0, Math.tan(this.angle.Angle.toRadians()), 1, 0, 0]; } this.Type.skewX.prototype = new this.Type.SkewBase; this.Type.skewY = function(s) { this.base = that.Type.SkewBase; this.base(s); this.m = [1, Math.tan(this.angle.Angle.toRadians()), 0, 1, 0, 0]; } this.Type.skewY.prototype = new this.Type.SkewBase; this.transforms = []; this.apply = function(ctx) { for (var i=0; i<this.transforms.length; i++) { this.transforms[i].apply(ctx); } } this.applyToPoint = function(p) { for (var i=0; i<this.transforms.length; i++) { this.transforms[i].applyToPoint(p); } } var data = svg.trim(svg.compressSpaces(v)).split(/\s(?=[a-z])/); for (var i=0; i<data.length; i++) { var type = data[i].split('(')[0]; var s = data[i].split('(')[1].replace(')',''); var transform = new this.Type[type](s); this.transforms.push(transform); } } // aspect ratio svg.AspectRatio = function(ctx, aspectRatio, width, desiredWidth, height, desiredHeight, minX, minY, refX, refY) { // aspect ratio - http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute aspectRatio = svg.compressSpaces(aspectRatio); aspectRatio = aspectRatio.replace(/^defer\s/,''); // ignore defer var align = aspectRatio.split(' ')[0] || 'xMidYMid'; var meetOrSlice = aspectRatio.split(' ')[1] || 'meet'; // calculate scale var scaleX = width / desiredWidth; var scaleY = height / desiredHeight; var scaleMin = Math.min(scaleX, scaleY); var scaleMax = Math.max(scaleX, scaleY); if (meetOrSlice == 'meet') { desiredWidth *= scaleMin; desiredHeight *= scaleMin; } if (meetOrSlice == 'slice') { desiredWidth *= scaleMax; desiredHeight *= scaleMax; } refX = new svg.Property('refX', refX); refY = new svg.Property('refY', refY); if (refX.hasValue() && refY.hasValue()) { ctx.translate(-scaleMin * refX.Length.toPixels('x'), -scaleMin * refY.Length.toPixels('y')); } else { // align if (align.match(/^xMid/) && ((meetOrSlice == 'meet' && scaleMin == scaleY) || (meetOrSlice == 'slice' && scaleMax == scaleY))) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0); if (align.match(/YMid$/) && ((meetOrSlice == 'meet' && scaleMin == scaleX) || (meetOrSlice == 'slice' && scaleMax == scaleX))) ctx.translate(0, height / 2.0 - desiredHeight / 2.0); if (align.match(/^xMax/) && ((meetOrSlice == 'meet' && scaleMin == scaleY) || (meetOrSlice == 'slice' && scaleMax == scaleY))) ctx.translate(width - desiredWidth, 0); if (align.match(/YMax$/) && ((meetOrSlice == 'meet' && scaleMin == scaleX) || (meetOrSlice == 'slice' && scaleMax == scaleX))) ctx.translate(0, height - desiredHeight); } // scale if (align == 'none') ctx.scale(scaleX, scaleY); else if (meetOrSlice == 'meet') ctx.scale(scaleMin, scaleMin); else if (meetOrSlice == 'slice') ctx.scale(scaleMax, scaleMax); // translate ctx.translate(minX == null ? 0 : -minX, minY == null ? 0 : -minY); } // elements svg.Element = {} svg.Element.ElementBase = function(node) { this.attributes = {}; this.styles = {}; this.children = []; // get or create attribute this.attribute = function(name, createIfNotExists) { var a = this.attributes[name]; if (a != null) return a; a = new svg.Property(name, ''); if (createIfNotExists == true) this.attributes[name] = a; return a; } // get or create style, crawls up node tree this.style = function(name, createIfNotExists) { var s = this.styles[name]; if (s != null) return s; var a = this.attribute(name); if (a != null && a.hasValue()) { return a; } var p = this.parent; if (p != null) { var ps = p.style(name); if (ps != null && ps.hasValue()) { return ps; } } s = new svg.Property(name, ''); if (createIfNotExists == true) this.styles[name] = s; return s; } // base render this.render = function(ctx) { // don't render display=none if (this.style('display').value == 'none') return; // don't render visibility=hidden if (this.attribute('visibility').value == 'hidden') return; ctx.save(); this.setContext(ctx); // mask if (this.attribute('mask').hasValue()) { var mask = this.attribute('mask').Definition.getDefinition(); if (mask != null) mask.apply(ctx, this); } else if (this.style('filter').hasValue()) { var filter = this.style('filter').Definition.getDefinition(); if (filter != null) filter.apply(ctx, this); } else this.renderChildren(ctx); this.clearContext(ctx); ctx.restore(); } // base set context this.setContext = function(ctx) { // OVERRIDE ME! } // base clear context this.clearContext = function(ctx) { // OVERRIDE ME! } // base render children this.renderChildren = function(ctx) { for (var i=0; i<this.children.length; i++) { this.children[i].render(ctx); } } this.addChild = function(childNode, create) { var child = childNode; if (create) child = svg.CreateElement(childNode); child.parent = this; this.children.push(child); } if (node != null && node.nodeType == 1) { //ELEMENT_NODE // add children for (var i=0; i<node.childNodes.length; i++) { var childNode = node.childNodes[i]; if (childNode.nodeType == 1) this.addChild(childNode, true); //ELEMENT_NODE } // add attributes for (var i=0; i<node.attributes.length; i++) { var attribute = node.attributes[i]; this.attributes[attribute.nodeName] = new svg.Property(attribute.nodeName, attribute.nodeValue); } // add tag styles var styles = svg.Styles[node.nodeName]; if (styles != null) { for (var name in styles) { this.styles[name] = styles[name]; } } // add class styles if (this.attribute('class').hasValue()) { var classes = svg.compressSpaces(this.attribute('class').value).split(' '); for (var j=0; j<classes.length; j++) { styles = svg.Styles['.'+classes[j]]; if (styles != null) { for (var name in styles) { this.styles[name] = styles[name]; } } styles = svg.Styles[node.nodeName+'.'+classes[j]]; if (styles != null) { for (var name in styles) { this.styles[name] = styles[name]; } } } } // add inline styles if (this.attribute('style').hasValue()) { var styles = this.attribute('style').value.split(';'); for (var i=0; i<styles.length; i++) { if (svg.trim(styles[i]) != '') { var style = styles[i].split(':'); var name = svg.trim(style[0]); var value = svg.trim(style[1]); this.styles[name] = new svg.Property(name, value); } } } // add id if (this.attribute('id').hasValue()) { if (svg.Definitions[this.attribute('id').value] == null) { svg.Definitions[this.attribute('id').value] = this; } } } } svg.Element.RenderedElementBase = function(node) { this.base = svg.Element.ElementBase; this.base(node); this.setContext = function(ctx) { // fill if (this.style('fill').Definition.isUrl()) { var fs = this.style('fill').Definition.getFillStyle(this); if (fs != null) ctx.fillStyle = fs; } else if (this.style('fill').hasValue()) { var fillStyle = this.style('fill'); if (this.style('fill-opacity').hasValue()) fillStyle = fillStyle.Color.addOpacity(this.style('fill-opacity').value); ctx.fillStyle = (fillStyle.value == 'none' ? 'rgba(0,0,0,0)' : fillStyle.value); } // stroke if (this.style('stroke').Definition.isUrl()) { var fs = this.style('stroke').Definition.getFillStyle(this); if (fs != null) ctx.strokeStyle = fs; } else if (this.style('stroke').hasValue()) { var strokeStyle = this.style('stroke'); if (this.style('stroke-opacity').hasValue()) strokeStyle = strokeStyle.Color.addOpacity(this.style('stroke-opacity').value); ctx.strokeStyle = (strokeStyle.value == 'none' ? 'rgba(0,0,0,0)' : strokeStyle.value); } if (this.style('stroke-width').hasValue()) ctx.lineWidth = this.style('stroke-width').Length.toPixels(); if (this.style('stroke-linecap').hasValue()) ctx.lineCap = this.style('stroke-linecap').value; if (this.style('stroke-linejoin').hasValue()) ctx.lineJoin = this.style('stroke-linejoin').value; if (this.style('stroke-miterlimit').hasValue()) ctx.miterLimit = this.style('stroke-miterlimit').value; // font if (typeof(ctx.font) != 'undefined') { ctx.font = svg.Font.CreateFont( this.style('font-style').value, this.style('font-variant').value, this.style('font-weight').value, this.style('font-size').hasValue() ? this.style('font-size').Length.toPixels() + 'px' : '', this.style('font-family').value).toString(); } // transform if (this.attribute('transform').hasValue()) { var transform = new svg.Transform(this.attribute('transform').value); transform.apply(ctx); } // clip if (this.attribute('clip-path').hasValue()) { var clip = this.attribute('clip-path').Definition.getDefinition(); if (clip != null) clip.apply(ctx); } // opacity if (this.style('opacity').hasValue()) { ctx.globalAlpha = this.style('opacity').numValue(); } } } svg.Element.RenderedElementBase.prototype = new svg.Element.ElementBase; svg.Element.PathElementBase = function(node) { this.base = svg.Element.RenderedElementBase; this.base(node); this.path = function(ctx) { if (ctx != null) ctx.beginPath(); return new svg.BoundingBox(); } this.renderChildren = function(ctx) { this.path(ctx); svg.Mouse.checkPath(this, ctx); if (ctx.fillStyle != '') ctx.fill(); if (ctx.strokeStyle != '') ctx.stroke(); var markers = this.getMarkers(); if (markers != null) { if (this.style('marker-start').Definition.isUrl()) { var marker = this.style('marker-start').Definition.getDefinition(); marker.render(ctx, markers[0][0], markers[0][1]); } if (this.style('marker-mid').Definition.isUrl()) { var marker = this.style('marker-mid').Definition.getDefinition(); for (var i=1;i<markers.length-1;i++) { marker.render(ctx, markers[i][0], markers[i][1]); } } if (this.style('marker-end').Definition.isUrl()) { var marker = this.style('marker-end').Definition.getDefinition(); marker.render(ctx, markers[markers.length-1][0], markers[markers.length-1][1]); } } } this.getBoundingBox = function() { return this.path(); } this.getMarkers = function() { return null; } } svg.Element.PathElementBase.prototype = new svg.Element.RenderedElementBase; // svg element svg.Element.svg = function(node) { this.base = svg.Element.RenderedElementBase; this.base(node); this.baseClearContext = this.clearContext; this.clearContext = function(ctx) { this.baseClearContext(ctx); svg.ViewPort.RemoveCurrent(); } this.baseSetContext = this.setContext; this.setContext = function(ctx) { // initial values ctx.strokeStyle = 'rgba(0,0,0,0)'; ctx.lineCap = 'butt'; ctx.lineJoin = 'miter'; ctx.miterLimit = 4; this.baseSetContext(ctx); // create new view port if (this.attribute('x').hasValue() && this.attribute('y').hasValue()) { ctx.translate(this.attribute('x').Length.toPixels('x'), this.attribute('y').Length.toPixels('y')); } var width = svg.ViewPort.width(); var height = svg.ViewPort.height(); if (typeof(this.root) == 'undefined' && this.attribute('width').hasValue() && this.attribute('height').hasValue()) { width = this.attribute('width').Length.toPixels('x'); height = this.attribute('height').Length.toPixels('y'); var x = 0; var y = 0; if (this.attribute('refX').hasValue() && this.attribute('refY').hasValue()) { x = -this.attribute('refX').Length.toPixels('x'); y = -this.attribute('refY').Length.toPixels('y'); } ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(width, y); ctx.lineTo(width, height); ctx.lineTo(x, height); ctx.closePath(); ctx.clip(); } svg.ViewPort.SetCurrent(width, height); // viewbox if (this.attribute('viewBox').hasValue()) { var viewBox = svg.ToNumberArray(this.attribute('viewBox').value); var minX = viewBox[0]; var minY = viewBox[1]; width = viewBox[2]; height = viewBox[3]; svg.AspectRatio(ctx, this.attribute('preserveAspectRatio').value, svg.ViewPort.width(), width, svg.ViewPort.height(), height, minX, minY, this.attribute('refX').value, this.attribute('refY').value); svg.ViewPort.RemoveCurrent(); svg.ViewPort.SetCurrent(viewBox[2], viewBox[3]); } } } svg.Element.svg.prototype = new svg.Element.RenderedElementBase; // rect element svg.Element.rect = function(node) { this.base = svg.Element.PathElementBase; this.base(node); this.path = function(ctx) { var x = this.attribute('x').Length.toPixels('x'); var y = this.attribute('y').Length.toPixels('y'); var width = this.attribute('width').Length.toPixels('x'); var height = this.attribute('height').Length.toPixels('y'); var rx = this.attribute('rx').Length.toPixels('x'); var ry = this.attribute('ry').Length.toPixels('y'); if (this.attribute('rx').hasValue() && !this.attribute('ry').hasValue()) ry = rx; if (this.attribute('ry').hasValue() && !this.attribute('rx').hasValue()) rx = ry; if (ctx != null) { ctx.beginPath(); ctx.moveTo(x + rx, y); ctx.lineTo(x + width - rx, y); ctx.quadraticCurveTo(x + width, y, x + width, y + ry) ctx.lineTo(x + width, y + height - ry); ctx.quadraticCurveTo(x + width, y + height, x + width - rx, y + height) ctx.lineTo(x + rx, y + height); ctx.quadraticCurveTo(x, y + height, x, y + height - ry) ctx.lineTo(x, y + ry); ctx.quadraticCurveTo(x, y, x + rx, y) ctx.closePath(); } return new svg.BoundingBox(x, y, x + width, y + height); } } svg.Element.rect.prototype = new svg.Element.PathElementBase; // circle element svg.Element.circle = function(node) { this.base = svg.Element.PathElementBase; this.base(node); this.path = function(ctx) { var cx = this.attribute('cx').Length.toPixels('x'); var cy = this.attribute('cy').Length.toPixels('y'); var r = this.attribute('r').Length.toPixels(); if (ctx != null) { ctx.beginPath(); ctx.arc(cx, cy, r, 0, Math.PI * 2, true); ctx.closePath(); } return new svg.BoundingBox(cx - r, cy - r, cx + r, cy + r); } } svg.Element.circle.prototype = new svg.Element.PathElementBase; // ellipse element svg.Element.ellipse = function(node) { this.base = svg.Element.PathElementBase; this.base(node); this.path = function(ctx) { var KAPPA = 4 * ((Math.sqrt(2) - 1) / 3); var rx = this.attribute('rx').Length.toPixels('x'); var ry = this.attribute('ry').Length.toPixels('y'); var cx = this.attribute('cx').Length.toPixels('x'); var cy = this.attribute('cy').Length.toPixels('y'); if (ctx != null) { ctx.beginPath(); ctx.moveTo(cx, cy - ry); ctx.bezierCurveTo(cx + (KAPPA * rx), cy - ry, cx + rx, cy - (KAPPA * ry), cx + rx, cy); ctx.bezierCurveTo(cx + rx, cy + (KAPPA * ry), cx + (KAPPA * rx), cy + ry, cx, cy + ry); ctx.bezierCurveTo(cx - (KAPPA * rx), cy + ry, cx - rx, cy + (KAPPA * ry), cx - rx, cy); ctx.bezierCurveTo(cx - rx, cy - (KAPPA * ry), cx - (KAPPA * rx), cy - ry, cx, cy - ry); ctx.closePath(); } return new svg.BoundingBox(cx - rx, cy - ry, cx + rx, cy + ry); } } svg.Element.ellipse.prototype = new svg.Element.PathElementBase; // line element svg.Element.line = function(node) { this.base = svg.Element.PathElementBase; this.base(node); this.getPoints = function() { return [ new svg.Point(this.attribute('x1').Length.toPixels('x'), this.attribute('y1').Length.toPixels('y')), new svg.Point(this.attribute('x2').Length.toPixels('x'), this.attribute('y2').Length.toPixels('y'))]; } this.path = function(ctx) { var points = this.getPoints(); if (ctx != null) { ctx.beginPath(); ctx.moveTo(points[0].x, points[0].y); ctx.lineTo(points[1].x, points[1].y); } return new svg.BoundingBox(points[0].x, points[0].y, points[1].x, points[1].y); } this.getMarkers = function() { var points = this.getPoints(); var a = points[0].angleTo(points[1]); return [[points[0], a], [points[1], a]]; } } svg.Element.line.prototype = new svg.Element.PathElementBase; // polyline element svg.Element.polyline = function(node) { this.base = svg.Element.PathElementBase; this.base(node); this.points = svg.CreatePath(this.attribute('points').value); this.path = function(ctx) { var bb = new svg.BoundingBox(this.points[0].x, this.points[0].y); if (ctx != null) { ctx.beginPath(); ctx.moveTo(this.points[0].x, this.points[0].y); } for (var i=1; i<this.points.length; i++) { bb.addPoint(this.points[i].x, this.points[i].y); if (ctx != null) ctx.lineTo(this.points[i].x, this.points[i].y); } return bb; } this.getMarkers = function() { var markers = []; for (var i=0; i<this.points.length - 1; i++) { markers.push([this.points[i], this.points[i].angleTo(this.points[i+1])]); } markers.push([this.points[this.points.length-1], markers[markers.length-1][1]]); return markers; } } svg.Element.polyline.prototype = new svg.Element.PathElementBase; // polygon element svg.Element.polygon = function(node) { this.base = svg.Element.polyline; this.base(node); this.basePath = this.path; this.path = function(ctx) { var bb = this.basePath(ctx); if (ctx != null) { ctx.lineTo(this.points[0].x, this.points[0].y); ctx.closePath(); } return bb; } } svg.Element.polygon.prototype = new svg.Element.polyline; // path element svg.Element.path = function(node) { this.base = svg.Element.PathElementBase; this.base(node); var d = this.attribute('d').value; // TODO: convert to real lexer based on http://www.w3.org/TR/SVG11/paths.html#PathDataBNF d = d.replace(/,/gm,' '); // get rid of all commas d = d.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,'$1 $2'); // separate commands from commands d = d.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,'$1 $2'); // separate commands from commands d = d.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,'$1 $2'); // separate commands from points d = d.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,'$1 $2'); // separate commands from points d = d.replace(/([0-9])([+\-])/gm,'$1 $2'); // separate digits when no comma d = d.replace(/(\.[0-9]*)(\.)/gm,'$1 $2'); // separate digits when no comma d = d.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,'$1 $3 $4 '); // shorthand elliptical arc path syntax d = svg.compressSpaces(d); // compress multiple spaces d = svg.trim(d); this.PathParser = new (function(d) { this.tokens = d.split(' '); this.reset = function() { this.i = -1; this.command = ''; this.previousCommand = ''; this.start = new svg.Point(0, 0); this.control = new svg.Point(0, 0); this.current = new svg.Point(0, 0); this.points = []; this.angles = []; } this.isEnd = function() { return this.i >= this.tokens.length - 1; } this.isCommandOrEnd = function() { if (this.isEnd()) return true; return this.tokens[this.i + 1].match(/^[A-Za-z]$/) != null; } this.isRelativeCommand = function() { return this.command == this.command.toLowerCase(); } this.getToken = function() { this.i = this.i + 1; return this.tokens[this.i]; } this.getScalar = function() { return parseFloat(this.getToken()); } this.nextCommand = function() { this.previousCommand = this.command; this.command = this.getToken(); } this.getPoint = function() { var p = new svg.Point(this.getScalar(), this.getScalar()); return this.makeAbsolute(p); } this.getAsControlPoint = function() { var p = this.getPoint(); this.control = p; return p; } this.getAsCurrentPoint = function() { var p = this.getPoint(); this.current = p; return p; } this.getReflectedControlPoint = function() { if (this.previousCommand.toLowerCase() != 'c' && this.previousCommand.toLowerCase() != 's') { return this.current; } // reflect point var p = new svg.Point(2 * this.current.x - this.control.x, 2 * this.current.y - this.control.y); return p; } this.makeAbsolute = function(p) { if (this.isRelativeCommand()) { p.x = this.current.x + p.x; p.y = this.current.y + p.y; } return p; } this.addMarker = function(p, from, priorTo) { // if the last angle isn't filled in because we didn't have this point yet ... if (priorTo != null && this.angles.length > 0 && this.angles[this.angles.length-1] == null) { this.angles[this.angles.length-1] = this.points[this.points.length-1].angleTo(priorTo); } this.addMarkerAngle(p, from == null ? null : from.angleTo(p)); } this.addMarkerAngle = function(p, a) { this.points.push(p); this.angles.push(a); } this.getMarkerPoints = function() { return this.points; } this.getMarkerAngles = function() { for (var i=0; i<this.angles.length; i++) { if (this.angles[i] == null) { for (var j=i+1; j<this.angles.length; j++) { if (this.angles[j] != null) { this.angles[i] = this.angles[j]; break; } } } } return this.angles; } })(d); this.path = function(ctx) { var pp = this.PathParser; pp.reset(); var bb = new svg.BoundingBox(); if (ctx != null) ctx.beginPath(); while (!pp.isEnd()) { pp.nextCommand(); switch (pp.command.toUpperCase()) { case 'M': var p = pp.getAsCurrentPoint(); pp.addMarker(p); bb.addPoint(p.x, p.y); if (ctx != null) ctx.moveTo(p.x, p.y); pp.start = pp.current; while (!pp.isCommandOrEnd()) { var p = pp.getAsCurrentPoint(); pp.addMarker(p, pp.start); bb.addPoint(p.x, p.y); if (ctx != null) ctx.lineTo(p.x, p.y); } break; case 'L': while (!pp.isCommandOrEnd()) { var c = pp.current; var p = pp.getAsCurrentPoint(); pp.addMarker(p, c); bb.addPoint(p.x, p.y); if (ctx != null) ctx.lineTo(p.x, p.y); } break; case 'H': while (!pp.isCommandOrEnd()) { var newP = new svg.Point((pp.isRelativeCommand() ? pp.current.x : 0) + pp.getScalar(), pp.current.y); pp.addMarker(newP, pp.current); pp.current = newP; bb.addPoint(pp.current.x, pp.current.y); if (ctx != null) ctx.lineTo(pp.current.x, pp.current.y); } break; case 'V': while (!pp.isCommandOrEnd()) { var newP = new svg.Point(pp.current.x, (pp.isRelativeCommand() ? pp.current.y : 0) + pp.getScalar()); pp.addMarker(newP, pp.current); pp.current = newP; bb.addPoint(pp.current.x, pp.current.y); if (ctx != null) ctx.lineTo(pp.current.x, pp.current.y); } break; case 'C': while (!pp.isCommandOrEnd()) { var curr = pp.current; var p1 = pp.getPoint(); var cntrl = pp.getAsControlPoint(); var cp = pp.getAsCurrentPoint(); pp.addMarker(cp, cntrl, p1); bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y); if (ctx != null) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y); } break; case 'S': while (!pp.isCommandOrEnd()) { var curr = pp.current; var p1 = pp.getReflectedControlPoint(); var cntrl = pp.getAsControlPoint(); var cp = pp.getAsCurrentPoint(); pp.addMarker(cp, cntrl, p1); bb.addBezierCurve(curr.x, curr.y, p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y); if (ctx != null) ctx.bezierCurveTo(p1.x, p1.y, cntrl.x, cntrl.y, cp.x, cp.y); } break; case 'Q': while (!pp.isCommandOrEnd()) { var curr = pp.current; var cntrl = pp.getAsControlPoint(); var cp = pp.getAsCurrentPoint(); pp.addMarker(cp, cntrl, cntrl); bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y); if (ctx != null) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y); } break; case 'T': while (!pp.isCommandOrEnd()) { var curr = pp.current; var cntrl = pp.getReflectedControlPoint(); pp.control = cntrl; var cp = pp.getAsCurrentPoint(); pp.addMarker(cp, cntrl, cntrl); bb.addQuadraticCurve(curr.x, curr.y, cntrl.x, cntrl.y, cp.x, cp.y); if (ctx != null) ctx.quadraticCurveTo(cntrl.x, cntrl.y, cp.x, cp.y); } break; case 'A': while (!pp.isCommandOrEnd()) { var curr = pp.current; var rx = pp.getScalar(); var ry = pp.getScalar(); var xAxisRotation = pp.getScalar() * (Math.PI / 180.0); var largeArcFlag = pp.getScalar(); var sweepFlag = pp.getScalar(); var cp = pp.getAsCurrentPoint(); // Conversion from endpoint to center parameterization // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes // x1', y1' var currp = new svg.Point( Math.cos(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.sin(xAxisRotation) * (curr.y - cp.y) / 2.0, -Math.sin(xAxisRotation) * (curr.x - cp.x) / 2.0 + Math.cos(xAxisRotation) * (curr.y - cp.y) / 2.0 ); // adjust radii var l = Math.pow(currp.x,2)/Math.pow(rx,2)+Math.pow(currp.y,2)/Math.pow(ry,2); if (l > 1) { rx *= Math.sqrt(l); ry *= Math.sqrt(l); } // cx', cy' var s = (largeArcFlag == sweepFlag ? -1 : 1) * Math.sqrt( ((Math.pow(rx,2)*Math.pow(ry,2))-(Math.pow(rx,2)*Math.pow(currp.y,2))-(Math.pow(ry,2)*Math.pow(currp.x,2))) / (Math.pow(rx,2)*Math.pow(currp.y,2)+Math.pow(ry,2)*Math.pow(currp.x,2)) ); if (isNaN(s)) s = 0; var cpp = new svg.Point(s * rx * currp.y / ry, s * -ry * currp.x / rx); // cx, cy var centp = new svg.Point( (curr.x + cp.x) / 2.0 + Math.cos(xAxisRotation) * cpp.x - Math.sin(xAxisRotation) * cpp.y, (curr.y + cp.y) / 2.0 + Math.sin(xAxisRotation) * cpp.x + Math.cos(xAxisRotation) * cpp.y ); // vector magnitude var m = function(v) { return Math.sqrt(Math.pow(v[0],2) + Math.pow(v[1],2)); } // ratio between two vectors var r = function(u, v) { return (u[0]*v[0]+u[1]*v[1]) / (m(u)*m(v)) } // angle between two vectors var a = function(u, v) { return (u[0]*v[1] < u[1]*v[0] ? -1 : 1) * Math.acos(r(u,v)); } // initial angle var a1 = a([1,0], [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry]); // angle delta var u = [(currp.x-cpp.x)/rx,(currp.y-cpp.y)/ry]; var v = [(-currp.x-cpp.x)/rx,(-currp.y-cpp.y)/ry]; var ad = a(u, v); if (r(u,v) <= -1) ad = Math.PI; if (r(u,v) >= 1) ad = 0; if (sweepFlag == 0 && ad > 0) ad = ad - 2 * Math.PI; if (sweepFlag == 1 && ad < 0) ad = ad + 2 * Math.PI; // for markers var halfWay = new svg.Point( centp.x - rx * Math.cos((a1 + ad) / 2), centp.y - ry * Math.sin((a1 + ad) / 2) ); pp.addMarkerAngle(halfWay, (a1 + ad) / 2 + (sweepFlag == 0 ? 1 : -1) * Math.PI / 2); pp.addMarkerAngle(cp, ad + (sweepFlag == 0 ? 1 : -1) * Math.PI / 2); bb.addPoint(cp.x, cp.y); // TODO: this is too naive, make it better if (ctx != null) { var r = rx > ry ? rx : ry; var sx = rx > ry ? 1 : rx / ry; var sy = rx > ry ? ry / rx : 1; ctx.translate(centp.x, centp.y); ctx.rotate(xAxisRotation); ctx.scale(sx, sy); ctx.arc(0, 0, r, a1, a1 + ad, 1 - sweepFlag); ctx.scale(1/sx, 1/sy); ctx.rotate(-xAxisRotation); ctx.translate(-centp.x, -centp.y); } } break; case 'Z': if (ctx != null) ctx.closePath(); pp.current = pp.start; } } return bb; } this.getMarkers = function() { var points = this.PathParser.getMarkerPoints(); var angles = this.PathParser.getMarkerAngles(); var markers = []; for (var i=0; i<points.length; i++) { markers.push([points[i], angles[i]]); } return markers; } } svg.Element.path.prototype = new svg.Element.PathElementBase; // pattern element svg.Element.pattern = function(node) { this.base = svg.Element.ElementBase; this.base(node); this.createPattern = function(ctx, element) { // render me using a temporary svg element var tempSvg = new svg.Element.svg(); tempSvg.attributes['viewBox'] = new svg.Property('viewBox', this.attribute('viewBox').value); tempSvg.attributes['x'] = new svg.Property('x', this.attribute('x').value); tempSvg.attributes['y'] = new svg.Property('y', this.attribute('y').value); tempSvg.attributes['width'] = new svg.Property('width', this.attribute('width').value); tempSvg.attributes['height'] = new svg.Property('height', this.attribute('height').value); tempSvg.children = this.children; var c = document.createElement('canvas'); c.width = this.attribute('width').Length.toPixels('x'); c.height = this.attribute('height').Length.toPixels('y'); tempSvg.render(c.getContext('2d')); return ctx.createPattern(c, 'repeat'); } } svg.Element.pattern.prototype = new svg.Element.ElementBase; // marker element svg.Element.marker = function(node) { this.base = svg.Element.ElementBase; this.base(node); this.baseRender = this.render; this.render = function(ctx, point, angle) { ctx.translate(point.x, point.y); if (this.attribute('orient').valueOrDefault('auto') == 'auto') ctx.rotate(angle); if (this.attribute('markerUnits').valueOrDefault('strokeWidth') == 'strokeWidth') ctx.scale(ctx.lineWidth, ctx.lineWidth); ctx.save(); // render me using a temporary svg element var tempSvg = new svg.Element.svg(); tempSvg.attributes['viewBox'] = new svg.Property('viewBox', this.attribute('viewBox').value); tempSvg.attributes['refX'] = new svg.Property('refX', this.attribute('refX').value); tempSvg.attributes['refY'] = new svg.Property('refY', this.attribute('refY').value); tempSvg.attributes['width'] = new svg.Property('width', this.attribute('markerWidth').value); tempSvg.attributes['height'] = new svg.Property('height', this.attribute('markerHeight').value); tempSvg.attributes['fill'] = new svg.Property('fill', this.attribute('fill').valueOrDefault('black')); tempSvg.attributes['stroke'] = new svg.Property('stroke', this.attribute('stroke').valueOrDefault('none')); tempSvg.children = this.children; tempSvg.render(ctx); ctx.restore(); if (this.attribute('markerUnits').valueOrDefault('strokeWidth') == 'strokeWidth') ctx.scale(1/ctx.lineWidth, 1/ctx.lineWidth); if (this.attribute('orient').valueOrDefault('auto') == 'auto') ctx.rotate(-angle); ctx.translate(-point.x, -point.y); } } svg.Element.marker.prototype = new svg.Element.ElementBase; // definitions element svg.Element.defs = function(node) { this.base = svg.Element.ElementBase; this.base(node); this.render = function(ctx) { // NOOP } } svg.Element.defs.prototype = new svg.Element.ElementBase; // base for gradients svg.Element.GradientBase = function(node) { this.base = svg.Element.ElementBase; this.base(node); this.gradientUnits = this.attribute('gradientUnits').valueOrDefault('objectBoundingBox'); this.stops = []; for (var i=0; i<this.children.length; i++) { var child = this.children[i]; this.stops.push(child); } this.getGradient = function() { // OVERRIDE ME! } this.createGradient = function(ctx, element) { var stopsContainer = this; if (this.attribute('xlink:href').hasValue()) { stopsContainer = this.attribute('xlink:href').Definition.getDefinition(); } var g = this.getGradient(ctx, element); for (var i=0; i<stopsContainer.stops.length; i++) { g.addColorStop(stopsContainer.stops[i].offset, stopsContainer.stops[i].color); } if (this.attribute('gradientTransform').hasValue()) { // render as transformed pattern on temporary canvas var rootView = svg.ViewPort.viewPorts[0]; var rect = new svg.Element.rect(); rect.attributes['x'] = new svg.Property('x', -svg.MAX_VIRTUAL_PIXELS/3.0); rect.attributes['y'] = new svg.Property('y', -svg.MAX_VIRTUAL_PIXELS/3.0); rect.attributes['width'] = new svg.Property('width', svg.MAX_VIRTUAL_PIXELS); rect.attributes['height'] = new svg.Property('height', svg.MAX_VIRTUAL_PIXELS); var group = new svg.Element.g(); group.attributes['transform'] = new svg.Property('transform', this.attribute('gradientTransform').value); group.children = [ rect ]; var tempSvg = new svg.Element.svg(); tempSvg.attributes['x'] = new svg.Property('x', 0); tempSvg.attributes['y'] = new svg.Property('y', 0); tempSvg.attributes['width'] = new svg.Property('width', rootView.width); tempSvg.attributes['height'] = new svg.Property('height', rootView.height); tempSvg.children = [ group ]; var c = document.createElement('canvas'); c.width = rootView.width; c.height = rootView.height; var tempCtx = c.getContext('2d'); tempCtx.fillStyle = g; tempSvg.render(tempCtx); return tempCtx.createPattern(c, 'no-repeat'); } return g; } } svg.Element.GradientBase.prototype = new svg.Element.ElementBase; // linear gradient element svg.Element.linearGradient = function(node) { this.base = svg.Element.GradientBase; this.base(node); this.getGradient = function(ctx, element) { var bb = element.getBoundingBox(); var x1 = (this.gradientUnits == 'objectBoundingBox' ? bb.x() + bb.width() * this.attribute('x1').numValue() : this.attribute('x1').Length.toPixels('x')); var y1 = (this.gradientUnits == 'objectBoundingBox' ? bb.y() + bb.height() * this.attribute('y1').numValue() : this.attribute('y1').Length.toPixels('y')); var x2 = (this.gradientUnits == 'objectBoundingBox' ? bb.x() + bb.width() * this.attribute('x2').numValue() : this.attribute('x2').Length.toPixels('x')); var y2 = (this.gradientUnits == 'objectBoundingBox' ? bb.y() + bb.height() * this.attribute('y2').numValue() : this.attribute('y2').Length.toPixels('y')); return ctx.createLinearGradient(x1, y1, x2, y2); } } svg.Element.linearGradient.prototype = new svg.Element.GradientBase; // radial gradient element svg.Element.radialGradient = function(node) { this.base = svg.Element.GradientBase; this.base(node); this.getGradient = function(ctx, element) { var bb = element.getBoundingBox(); var cx = (this.gradientUnits == 'objectBoundingBox' ? bb.x() + bb.width() * this.attribute('cx').numValue() : this.attribute('cx').Length.toPixels('x')); var cy = (this.gradientUnits == 'objectBoundingBox' ? bb.y() + bb.height() * this.attribute('cy').numValue() : this.attribute('cy').Length.toPixels('y')); var fx = cx; var fy = cy; if (this.attribute('fx').hasValue()) { fx = (this.gradientUnits == 'objectBoundingBox' ? bb.x() + bb.width() * this.attribute('fx').numValue() : this.attribute('fx').Length.toPixels('x')); } if (this.attribute('fy').hasValue()) { fy = (this.gradientUnits == 'objectBoundingBox' ? bb.y() + bb.height() * this.attribute('fy').numValue() : this.attribute('fy').Length.toPixels('y')); } var r = (this.gradientUnits == 'objectBoundingBox' ? (bb.width() + bb.height()) / 2.0 * this.attribute('r').numValue() : this.attribute('r').Length.toPixels()); return ctx.createRadialGradient(fx, fy, 0, cx, cy, r); } } svg.Element.radialGradient.prototype = new svg.Element.GradientBase; // gradient stop element svg.Element.stop = function(node) { this.base = svg.Element.ElementBase; this.base(node); this.offset = this.attribute('offset').numValue(); var stopColor = this.style('stop-color'); if (this.style('stop-opacity').hasValue()) stopColor = stopColor.Color.addOpacity(this.style('stop-opacity').value); this.color = stopColor.value; } svg.Element.stop.prototype = new svg.Element.ElementBase; // animation base element svg.Element.AnimateBase = function(node) { this.base = svg.Element.ElementBase; this.base(node); svg.Animations.push(this); this.duration = 0.0; this.begin = this.attribute('begin').Time.toMilliseconds(); this.maxDuration = this.begin + this.attribute('dur').Time.toMilliseconds(); this.getProperty = function() { var attributeType = this.attribute('attributeType').value; var attributeName = this.attribute('attributeName').value; if (attributeType == 'CSS') { return this.parent.style(attributeName, true); } return this.parent.attribute(attributeName, true); }; this.initialValue = null; this.removed = false; this.calcValue = function() { // OVERRIDE ME! return ''; } this.update = function(delta) { // set initial value if (this.initialValue == null) { this.initialValue = this.getProperty().value; } // if we're past the end time if (this.duration > this.maxDuration) { // loop for indefinitely repeating animations if (this.attribute('repeatCount').value == 'indefinite') { this.duration = 0.0 } else if (this.attribute('fill').valueOrDefault('remove') == 'remove' && !this.removed) { this.removed = true; this.getProperty().value = this.initialValue; return true; } else { return false; // no updates made } } this.duration = this.duration + delta; // if we're past the begin time var updated = false; if (this.begin < this.duration) { var newValue = this.calcValue(); // tween if (this.attribute('type').hasValue()) { // for transform, etc. var type = this.attribute('type').value; newValue = type + '(' + newValue + ')'; } this.getProperty().value = newValue; updated = true; } return updated; } // fraction of duration we've covered this.progress = function() { return ((this.duration - this.begin) / (this.maxDuration - this.begin)); } } svg.Element.AnimateBase.prototype = new svg.Element.ElementBase; // animate element svg.Element.animate = function(node) { this.base = svg.Element.AnimateBase; this.base(node); this.calcValue = function() { var from = this.attribute('from').numValue(); var to = this.attribute('to').numValue(); // tween value linearly return from + (to - from) * this.progress(); }; } svg.Element.animate.prototype = new svg.Element.AnimateBase; // animate color element svg.Element.animateColor = function(node) { this.base = svg.Element.AnimateBase; this.base(node); this.calcValue = function() { var from = new RGBColor(this.attribute('from').value); var to = new RGBColor(this.attribute('to').value); if (from.ok && to.ok) { // tween color linearly var r = from.r + (to.r - from.r) * this.progress(); var g = from.g + (to.g - from.g) * this.progress(); var b = from.b + (to.b - from.b) * this.progress(); return 'rgb('+parseInt(r,10)+','+parseInt(g,10)+','+parseInt(b,10)+')'; } return this.attribute('from').value; }; } svg.Element.animateColor.prototype = new svg.Element.AnimateBase; // animate transform element svg.Element.animateTransform = function(node) { this.base = svg.Element.animate; this.base(node); } svg.Element.animateTransform.prototype = new svg.Element.animate; // font element svg.Element.font = function(node) { this.base = svg.Element.ElementBase; this.base(node); this.horizAdvX = this.attribute('horiz-adv-x').numValue(); this.isRTL = false; this.isArabic = false; this.fontFace = null; this.missingGlyph = null; this.glyphs = []; for (var i=0; i<this.children.length; i++) { var child = this.children[i]; if (child.type == 'font-face') { this.fontFace = child; if (child.style('font-family').hasValue()) { svg.Definitions[child.style('font-family').value] = this; } } else if (child.type == 'missing-glyph') this.missingGlyph = child; else if (child.type == 'glyph') { if (child.arabicForm != '') { this.isRTL = true; this.isArabic = true; if (typeof(this.glyphs[child.unicode]) == 'undefined') this.glyphs[child.unicode] = []; this.glyphs[child.unicode][child.arabicForm] = child; } else { this.glyphs[child.unicode] = child; } } } } svg.Element.font.prototype = new svg.Element.ElementBase; // font-face element svg.Element.fontface = function(node) { this.base = svg.Element.ElementBase; this.base(node); this.ascent = this.attribute('ascent').value; this.descent = this.attribute('descent').value; this.unitsPerEm = this.attribute('units-per-em').numValue(); } svg.Element.fontface.prototype = new svg.Element.ElementBase; // missing-glyph element svg.Element.missingglyph = function(node) { this.base = svg.Element.path; this.base(node); this.horizAdvX = 0; } svg.Element.missingglyph.prototype = new svg.Element.path; // glyph element svg.Element.glyph = function(node) { this.base = svg.Element.path; this.base(node); this.horizAdvX = this.attribute('horiz-adv-x').numValue(); this.unicode = this.attribute('unicode').value; this.arabicForm = this.attribute('arabic-form').value; } svg.Element.glyph.prototype = new svg.Element.path; // text element svg.Element.text = function(node) { this.base = svg.Element.RenderedElementBase; this.base(node); if (node != null) { // add children this.children = []; for (var i=0; i<node.childNodes.length; i++) { var childNode = node.childNodes[i]; if (childNode.nodeType == 1) { // capture tspan and tref nodes this.addChild(childNode, true); } else if (childNode.nodeType == 3) { // capture text this.addChild(new svg.Element.tspan(childNode), false); } } } this.baseSetContext = this.setContext; this.setContext = function(ctx) { this.baseSetContext(ctx); if (this.style('dominant-baseline').hasValue()) ctx.textBaseline = this.style('dominant-baseline').value; if (this.style('alignment-baseline').hasValue()) ctx.textBaseline = this.style('alignment-baseline').value; } this.renderChildren = function(ctx) { var textAnchor = this.style('text-anchor').valueOrDefault('start'); var x = this.attribute('x').Length.toPixels('x'); var y = this.attribute('y').Length.toPixels('y'); for (var i=0; i<this.children.length; i++) { var child = this.children[i]; if (child.attribute('x').hasValue()) { child.x = child.attribute('x').Length.toPixels('x'); } else { if (child.attribute('dx').hasValue()) x += child.attribute('dx').Length.toPixels('x'); child.x = x; } var childLength = child.measureText ? child.measureText(ctx) : 0; if (textAnchor != 'start' && (i==0 || child.attribute('x').hasValue())) { // new group? // loop through rest of children var groupLength = childLength; for (var j=i+1; j<this.children.length; j++) { var childInGroup = this.children[j]; if (childInGroup.attribute('x').hasValue()) break; // new group groupLength += childInGroup.measureText ? childInGroup.measureText(ctx) : 0; } child.x -= (textAnchor == 'end' ? groupLength : groupLength / 2.0); } x = child.x + childLength; if (child.attribute('y').hasValue()) { child.y = child.attribute('y').Length.toPixels('y'); } else { if (child.attribute('dy').hasValue()) y += child.attribute('dy').Length.toPixels('y'); child.y = y; } y = child.y; child.render(ctx); } } } svg.Element.text.prototype = new svg.Element.RenderedElementBase; // text base svg.Element.TextElementBase = function(node) { this.base = svg.Element.RenderedElementBase; this.base(node); this.getGlyph = function(font, text, i) { var c = text[i]; var glyph = null; if (font.isArabic) { var arabicForm = 'isolated'; if ((i==0 || text[i-1]==' ') && i<text.length-2 && text[i+1]!=' ') arabicForm = 'terminal'; if (i>0 && text[i-1]!=' ' && i<text.length-2 && text[i+1]!=' ') arabicForm = 'medial'; if (i>0 && text[i-1]!=' ' && (i == text.length-1 || text[i+1]==' ')) arabicForm = 'initial'; if (typeof(font.glyphs[c]) != 'undefined') { glyph = font.glyphs[c][arabicForm]; if (glyph == null && font.glyphs[c].type == 'glyph') glyph = font.glyphs[c]; } } else { glyph = font.glyphs[c]; } if (glyph == null) glyph = font.missingGlyph; return glyph; } this.renderChildren = function(ctx) { var customFont = this.parent.style('font-family').Definition.getDefinition(); if (customFont != null) { var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize); var fontStyle = this.parent.style('font-style').valueOrDefault(svg.Font.Parse(svg.ctx.font).fontStyle); var text = this.getText(); if (customFont.isRTL) text = text.split("").reverse().join(""); var dx = svg.ToNumberArray(this.parent.attribute('dx').value); for (var i=0; i<text.length; i++) { var glyph = this.getGlyph(customFont, text, i); var scale = fontSize / customFont.fontFace.unitsPerEm; ctx.translate(this.x, this.y); ctx.scale(scale, -scale); var lw = ctx.lineWidth; ctx.lineWidth = ctx.lineWidth * customFont.fontFace.unitsPerEm / fontSize; if (fontStyle == 'italic') ctx.transform(1, 0, .4, 1, 0, 0); glyph.render(ctx); if (fontStyle == 'italic') ctx.transform(1, 0, -.4, 1, 0, 0); ctx.lineWidth = lw; ctx.scale(1/scale, -1/scale); ctx.translate(-this.x, -this.y); this.x += fontSize * (glyph.horizAdvX || customFont.horizAdvX) / customFont.fontFace.unitsPerEm; if (typeof(dx[i]) != 'undefined' && !isNaN(dx[i])) { this.x += dx[i]; } } return; } if (ctx.strokeStyle != '') ctx.strokeText(svg.compressSpaces(this.getText()), this.x, this.y); if (ctx.fillStyle != '') ctx.fillText(svg.compressSpaces(this.getText()), this.x, this.y); } this.getText = function() { // OVERRIDE ME } this.measureText = function(ctx) { var customFont = this.parent.style('font-family').Definition.getDefinition(); if (customFont != null) { var fontSize = this.parent.style('font-size').numValueOrDefault(svg.Font.Parse(svg.ctx.font).fontSize); var measure = 0; var text = this.getText(); if (customFont.isRTL) text = text.split("").reverse().join(""); var dx = svg.ToNumberArray(this.parent.attribute('dx').value); for (var i=0; i<text.length; i++) { var glyph = this.getGlyph(customFont, text, i); measure += (glyph.horizAdvX || customFont.horizAdvX) * fontSize / customFont.fontFace.unitsPerEm; if (typeof(dx[i]) != 'undefined' && !isNaN(dx[i])) { measure += dx[i]; } } return measure; } var textToMeasure = svg.compressSpaces(this.getText()); if (!ctx.measureText) return textToMeasure.length * 10; ctx.save(); this.setContext(ctx); var width = ctx.measureText(textToMeasure).width; ctx.restore(); return width; } } svg.Element.TextElementBase.prototype = new svg.Element.RenderedElementBase; // tspan svg.Element.tspan = function(node) { this.base = svg.Element.TextElementBase; this.base(node); this.text = node.nodeType == 3 ? node.nodeValue : // text node.childNodes.length > 0 ? node.childNodes[0].nodeValue : // element node.text; this.getText = function() { return this.text; } } svg.Element.tspan.prototype = new svg.Element.TextElementBase; // tref svg.Element.tref = function(node) { this.base = svg.Element.TextElementBase; this.base(node); this.getText = function() { var element = this.attribute('xlink:href').Definition.getDefinition(); if (element != null) return element.children[0].getText(); } } svg.Element.tref.prototype = new svg.Element.TextElementBase; // a element svg.Element.a = function(node) { this.base = svg.Element.TextElementBase; this.base(node); this.hasText = true; for (var i=0; i<node.childNodes.length; i++) { if (node.childNodes[i].nodeType != 3) this.hasText = false; } // this might contain text this.text = this.hasText ? node.childNodes[0].nodeValue : ''; this.getText = function() { return this.text; } this.baseRenderChildren = this.renderChildren; this.renderChildren = function(ctx) { if (this.hasText) { // render as text element this.baseRenderChildren(ctx); var fontSize = new svg.Property('fontSize', svg.Font.Parse(svg.ctx.font).fontSize); svg.Mouse.checkBoundingBox(this, new svg.BoundingBox(this.x, this.y - fontSize.Length.toPixels('y'), this.x + this.measureText(ctx), this.y)); } else { // render as temporary group var g = new svg.Element.g(); g.children = this.children; g.parent = this; g.render(ctx); } } this.onclick = function() { window.open(this.attribute('xlink:href').value); } this.onmousemove = function() { svg.ctx.canvas.style.cursor = 'pointer'; } } svg.Element.a.prototype = new svg.Element.TextElementBase; // image element svg.Element.image = function(node) { this.base = svg.Element.RenderedElementBase; this.base(node); svg.Images.push(this); this.img = document.createElement('img'); this.loaded = false; var that = this; this.img.onload = function() { that.loaded = true; } this.img.src = this.attribute('xlink:href').value; this.renderChildren = function(ctx) { var x = this.attribute('x').Length.toPixels('x'); var y = this.attribute('y').Length.toPixels('y'); var width = this.attribute('width').Length.toPixels('x'); var height = this.attribute('height').Length.toPixels('y'); if (width == 0 || height == 0) return; ctx.save(); ctx.translate(x, y); svg.AspectRatio(ctx, this.attribute('preserveAspectRatio').value, width, this.img.width, height, this.img.height, 0, 0); ctx.drawImage(this.img, 0, 0); ctx.restore(); } } svg.Element.image.prototype = new svg.Element.RenderedElementBase; // group element svg.Element.g = function(node) { this.base = svg.Element.RenderedElementBase; this.base(node); this.getBoundingBox = function() { var bb = new svg.BoundingBox(); for (var i=0; i<this.children.length; i++) { bb.addBoundingBox(this.children[i].getBoundingBox()); } return bb; }; } svg.Element.g.prototype = new svg.Element.RenderedElementBase; // symbol element svg.Element.symbol = function(node) { this.base = svg.Element.RenderedElementBase; this.base(node); this.baseSetContext = this.setContext; this.setContext = function(ctx) { this.baseSetContext(ctx); // viewbox if (this.attribute('viewBox').hasValue()) { var viewBox = svg.ToNumberArray(this.attribute('viewBox').value); var minX = viewBox[0]; var minY = viewBox[1]; width = viewBox[2]; height = viewBox[3]; svg.AspectRatio(ctx, this.attribute('preserveAspectRatio').value, this.attribute('width').Length.toPixels('x'), width, this.attribute('height').Length.toPixels('y'), height, minX, minY); svg.ViewPort.SetCurrent(viewBox[2], viewBox[3]); } } } svg.Element.symbol.prototype = new svg.Element.RenderedElementBase; // style element svg.Element.style = function(node) { this.base = svg.Element.ElementBase; this.base(node); // text, or spaces then CDATA var css = node.childNodes[0].nodeValue + (node.childNodes.length > 1 ? node.childNodes[1].nodeValue : ''); css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // remove comments css = svg.compressSpaces(css); // replace whitespace var cssDefs = css.split('}'); for (var i=0; i<cssDefs.length; i++) { if (svg.trim(cssDefs[i]) != '') { var cssDef = cssDefs[i].split('{'); var cssClasses = cssDef[0].split(','); var cssProps = cssDef[1].split(';'); for (var j=0; j<cssClasses.length; j++) { var cssClass = svg.trim(cssClasses[j]); if (cssClass != '') { var props = {}; for (var k=0; k<cssProps.length; k++) { var prop = cssProps[k].indexOf(':'); var name = cssProps[k].substr(0, prop); var value = cssProps[k].substr(prop + 1, cssProps[k].length - prop); if (name != null && value != null) { props[svg.trim(name)] = new svg.Property(svg.trim(name), svg.trim(value)); } } svg.Styles[cssClass] = props; if (cssClass == '@font-face') { var fontFamily = props['font-family'].value.replace(/"/g,''); var srcs = props['src'].value.split(','); for (var s=0; s<srcs.length; s++) { if (srcs[s].indexOf('format("svg")') > 0) { var urlStart = srcs[s].indexOf('url'); var urlEnd = srcs[s].indexOf(')', urlStart); var url = srcs[s].substr(urlStart + 5, urlEnd - urlStart - 6); var doc = svg.parseXml(svg.ajax(url)); var fonts = doc.getElementsByTagName('font'); for (var f=0; f<fonts.length; f++) { var font = svg.CreateElement(fonts[f]); svg.Definitions[fontFamily] = font; } } } } } } } } } svg.Element.style.prototype = new svg.Element.ElementBase; // use element svg.Element.use = function(node) { this.base = svg.Element.RenderedElementBase; this.base(node); this.baseSetContext = this.setContext; this.setContext = function(ctx) { this.baseSetContext(ctx); if (this.attribute('x').hasValue()) ctx.translate(this.attribute('x').Length.toPixels('x'), 0); if (this.attribute('y').hasValue()) ctx.translate(0, this.attribute('y').Length.toPixels('y')); } this.getDefinition = function() { var element = this.attribute('xlink:href').Definition.getDefinition(); if (this.attribute('width').hasValue()) element.attribute('width', true).value = this.attribute('width').value; if (this.attribute('height').hasValue()) element.attribute('height', true).value = this.attribute('height').value; return element; } this.path = function(ctx) { var element = this.getDefinition(); if (element != null) element.path(ctx); } this.renderChildren = function(ctx) { var element = this.getDefinition(); if (element != null) element.render(ctx); } } svg.Element.use.prototype = new svg.Element.RenderedElementBase; // mask element svg.Element.mask = function(node) { this.base = svg.Element.ElementBase; this.base(node); this.apply = function(ctx, element) { // render as temp svg var x = this.attribute('x').Length.toPixels('x'); var y = this.attribute('y').Length.toPixels('y'); var width = this.attribute('width').Length.toPixels('x'); var height = this.attribute('height').Length.toPixels('y'); // temporarily remove mask to avoid recursion var mask = element.attribute('mask').value; element.attribute('mask').value = ''; var cMask = document.createElement('canvas'); cMask.width = x + width; cMask.height = y + height; var maskCtx = cMask.getContext('2d'); this.renderChildren(maskCtx); var c = document.createElement('canvas'); c.width = x + width; c.height = y + height; var tempCtx = c.getContext('2d'); element.render(tempCtx); tempCtx.globalCompositeOperation = 'destination-in'; tempCtx.fillStyle = maskCtx.createPattern(cMask, 'no-repeat'); tempCtx.fillRect(0, 0, x + width, y + height); ctx.fillStyle = tempCtx.createPattern(c, 'no-repeat'); ctx.fillRect(0, 0, x + width, y + height); // reassign mask element.attribute('mask').value = mask; } this.render = function(ctx) { // NO RENDER } } svg.Element.mask.prototype = new svg.Element.ElementBase; // clip element svg.Element.clipPath = function(node) { this.base = svg.Element.ElementBase; this.base(node); this.apply = function(ctx) { for (var i=0; i<this.children.length; i++) { if (this.children[i].path) { this.children[i].path(ctx); ctx.clip(); } } } this.render = function(ctx) { // NO RENDER } } svg.Element.clipPath.prototype = new svg.Element.ElementBase; // filters svg.Element.filter = function(node) { this.base = svg.Element.ElementBase; this.base(node); this.apply = function(ctx, element) { // render as temp svg var bb = element.getBoundingBox(); var x = this.attribute('x').Length.toPixels('x'); var y = this.attribute('y').Length.toPixels('y'); if (x == 0 || y == 0) { x = bb.x1; y = bb.y1; } var width = this.attribute('width').Length.toPixels('x'); var height = this.attribute('height').Length.toPixels('y'); if (width == 0 || height == 0) { width = bb.width(); height = bb.height(); } // temporarily remove filter to avoid recursion var filter = element.style('filter').value; element.style('filter').value = ''; // max filter distance var extraPercent = .20; var px = extraPercent * width; var py = extraPercent * height; var c = document.createElement('canvas'); c.width = width + 2*px; c.height = height + 2*py; var tempCtx = c.getContext('2d'); tempCtx.translate(-x + px, -y + py); element.render(tempCtx); // apply filters for (var i=0; i<this.children.length; i++) { this.children[i].apply(tempCtx, 0, 0, width + 2*px, height + 2*py); } // render on me ctx.drawImage(c, 0, 0, width + 2*px, height + 2*py, x - px, y - py, width + 2*px, height + 2*py); // reassign filter element.style('filter', true).value = filter; } this.render = function(ctx) { // NO RENDER } } svg.Element.filter.prototype = new svg.Element.ElementBase; svg.Element.feGaussianBlur = function(node) { this.base = svg.Element.ElementBase; this.base(node); function make_fgauss(sigma) { sigma = Math.max(sigma, 0.01); var len = Math.ceil(sigma * 4.0) + 1; mask = []; for (var i = 0; i < len; i++) { mask[i] = Math.exp(-0.5 * (i / sigma) * (i / sigma)); } return mask; } function normalize(mask) { var sum = 0; for (var i = 1; i < mask.length; i++) { sum += Math.abs(mask[i]); } sum = 2 * sum + Math.abs(mask[0]); for (var i = 0; i < mask.length; i++) { mask[i] /= sum; } return mask; } function convolve_even(src, dst, mask, width, height) { for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { var a = imGet(src, x, y, width, height, 3)/255; for (var rgba = 0; rgba < 4; rgba++) { var sum = mask[0] * (a==0?255:imGet(src, x, y, width, height, rgba)) * (a==0||rgba==3?1:a); for (var i = 1; i < mask.length; i++) { var a1 = imGet(src, Math.max(x-i,0), y, width, height, 3)/255; var a2 = imGet(src, Math.min(x+i, width-1), y, width, height, 3)/255; sum += mask[i] * ((a1==0?255:imGet(src, Math.max(x-i,0), y, width, height, rgba)) * (a1==0||rgba==3?1:a1) + (a2==0?255:imGet(src, Math.min(x+i, width-1), y, width, height, rgba)) * (a2==0||rgba==3?1:a2)); } imSet(dst, y, x, height, width, rgba, sum); } } } } function imGet(img, x, y, width, height, rgba) { return img[y*width*4 + x*4 + rgba]; } function imSet(img, x, y, width, height, rgba, val) { img[y*width*4 + x*4 + rgba] = val; } function blur(ctx, width, height, sigma) { var srcData = ctx.getImageData(0, 0, width, height); var mask = make_fgauss(sigma); mask = normalize(mask); tmp = []; convolve_even(srcData.data, tmp, mask, width, height); convolve_even(tmp, srcData.data, mask, height, width); ctx.clearRect(0, 0, width, height); ctx.putImageData(srcData, 0, 0); } this.apply = function(ctx, x, y, width, height) { // assuming x==0 && y==0 for now blur(ctx, width, height, this.attribute('stdDeviation').numValue()); } } svg.Element.filter.prototype = new svg.Element.feGaussianBlur; // title element, do nothing svg.Element.title = function(node) { } svg.Element.title.prototype = new svg.Element.ElementBase; // desc element, do nothing svg.Element.desc = function(node) { } svg.Element.desc.prototype = new svg.Element.ElementBase; svg.Element.MISSING = function(node) { console.log('ERROR: Element \'' + node.nodeName + '\' not yet implemented.'); } svg.Element.MISSING.prototype = new svg.Element.ElementBase; // element factory svg.CreateElement = function(node) { var className = node.nodeName.replace(/^[^:]+:/,''); // remove namespace className = className.replace(/\-/g,''); // remove dashes var e = null; if (typeof(svg.Element[className]) != 'undefined') { e = new svg.Element[className](node); } else { e = new svg.Element.MISSING(node); } e.type = node.nodeName; return e; } // load from url svg.load = function(ctx, url) { svg.loadXml(ctx, svg.ajax(url)); } // load from xml svg.loadXml = function(ctx, xml) { svg.loadXmlDoc(ctx, svg.parseXml(xml)); } svg.loadXmlDoc = function(ctx, dom) { svg.init(ctx); var mapXY = function(p) { var e = ctx.canvas; while (e) { p.x -= e.offsetLeft; p.y -= e.offsetTop; e = e.offsetParent; } if (window.scrollX) p.x += window.scrollX; if (window.scrollY) p.y += window.scrollY; return p; } // bind mouse if (svg.opts['ignoreMouse'] != true) { ctx.canvas.onclick = function(e) { var p = mapXY(new svg.Point(e != null ? e.clientX : event.clientX, e != null ? e.clientY : event.clientY)); svg.Mouse.onclick(p.x, p.y); }; ctx.canvas.onmousemove = function(e) { var p = mapXY(new svg.Point(e != null ? e.clientX : event.clientX, e != null ? e.clientY : event.clientY)); svg.Mouse.onmousemove(p.x, p.y); }; } var e = svg.CreateElement(dom.documentElement); e.root = true; // render loop var isFirstRender = true; var draw = function() { svg.ViewPort.Clear(); if (ctx.canvas.parentNode) svg.ViewPort.SetCurrent(ctx.canvas.parentNode.clientWidth, ctx.canvas.parentNode.clientHeight); if (svg.opts['ignoreDimensions'] != true) { // set canvas size if (e.style('width').hasValue()) { ctx.canvas.width = e.style('width').Length.toPixels('x'); ctx.canvas.style.width = ctx.canvas.width + 'px'; } if (e.style('height').hasValue()) { ctx.canvas.height = e.style('height').Length.toPixels('y'); ctx.canvas.style.height = ctx.canvas.height + 'px'; } } var cWidth = ctx.canvas.clientWidth || ctx.canvas.width; var cHeight = ctx.canvas.clientHeight || ctx.canvas.height; svg.ViewPort.SetCurrent(cWidth, cHeight); if (svg.opts != null && svg.opts['offsetX'] != null) e.attribute('x', true).value = svg.opts['offsetX']; if (svg.opts != null && svg.opts['offsetY'] != null) e.attribute('y', true).value = svg.opts['offsetY']; if (svg.opts != null && svg.opts['scaleWidth'] != null && svg.opts['scaleHeight'] != null) { var xRatio = 1, yRatio = 1; if (e.attribute('width').hasValue()) xRatio = e.attribute('width').Length.toPixels('x') / svg.opts['scaleWidth']; if (e.attribute('height').hasValue()) yRatio = e.attribute('height').Length.toPixels('y') / svg.opts['scaleHeight']; e.attribute('width', true).value = svg.opts['scaleWidth']; e.attribute('height', true).value = svg.opts['scaleHeight']; e.attribute('viewBox', true).value = '0 0 ' + (cWidth * xRatio) + ' ' + (cHeight * yRatio); e.attribute('preserveAspectRatio', true).value = 'none'; } // clear and render if (svg.opts['ignoreClear'] != true) { ctx.clearRect(0, 0, cWidth, cHeight); } e.render(ctx); if (isFirstRender) { isFirstRender = false; if (svg.opts != null && typeof(svg.opts['renderCallback']) == 'function') svg.opts['renderCallback'](); } } var waitingForImages = true; if (svg.ImagesLoaded()) { waitingForImages = false; draw(); } svg.intervalID = setInterval(function() { var needUpdate = false; if (waitingForImages && svg.ImagesLoaded()) { waitingForImages = false; needUpdate = true; } // need update from mouse events? if (svg.opts['ignoreMouse'] != true) { needUpdate = needUpdate | svg.Mouse.hasEvents(); } // need update from animations? if (svg.opts['ignoreAnimation'] != true) { for (var i=0; i<svg.Animations.length; i++) { needUpdate = needUpdate | svg.Animations[i].update(1000 / svg.FRAMERATE); } } // need update from redraw? if (svg.opts != null && typeof(svg.opts['forceRedraw']) == 'function') { if (svg.opts['forceRedraw']() == true) needUpdate = true; } // render if needed if (needUpdate) { draw(); svg.Mouse.runEvents(); // run and clear our events } }, 1000 / svg.FRAMERATE); } svg.stop = function() { if (svg.intervalID) { clearInterval(svg.intervalID); } } svg.Mouse = new (function() { this.events = []; this.hasEvents = function() { return this.events.length != 0; } this.onclick = function(x, y) { this.events.push({ type: 'onclick', x: x, y: y, run: function(e) { if (e.onclick) e.onclick(); } }); } this.onmousemove = function(x, y) { this.events.push({ type: 'onmousemove', x: x, y: y, run: function(e) { if (e.onmousemove) e.onmousemove(); } }); } this.eventElements = []; this.checkPath = function(element, ctx) { for (var i=0; i<this.events.length; i++) { var e = this.events[i]; if (ctx.isPointInPath && ctx.isPointInPath(e.x, e.y)) this.eventElements[i] = element; } } this.checkBoundingBox = function(element, bb) { for (var i=0; i<this.events.length; i++) { var e = this.events[i]; if (bb.isPointInBox(e.x, e.y)) this.eventElements[i] = element; } } this.runEvents = function() { svg.ctx.canvas.style.cursor = ''; for (var i=0; i<this.events.length; i++) { var e = this.events[i]; var element = this.eventElements[i]; while (element) { e.run(element); element = element.parent; } } // done running, clear this.events = []; this.eventElements = []; } }); return svg; } })(); if (CanvasRenderingContext2D) { CanvasRenderingContext2D.prototype.drawSvg = function(s, dx, dy, dw, dh) { canvg(this.canvas, s, { ignoreMouse: true, ignoreAnimation: true, ignoreDimensions: true, ignoreClear: true, offsetX: dx, offsetY: dy, scaleWidth: dw, scaleHeight: dh }); } }/** * @license Highcharts JS v4.2.7 (2016-09-21) * CanVGRenderer Extension module * * (c) 2011-2016 Torstein Honsi, Erik Olsson * * License: www.highcharts.com/license */ (function (Highcharts) { var UNDEFINED, win = Highcharts.win, DIV = 'div', ABSOLUTE = 'absolute', RELATIVE = 'relative', HIDDEN = 'hidden', VISIBLE = 'visible', PX = 'px', css = Highcharts.css, CanVGRenderer = Highcharts.CanVGRenderer, SVGRenderer = Highcharts.SVGRenderer, extend = Highcharts.extend, merge = Highcharts.merge, addEvent = Highcharts.addEvent, createElement = Highcharts.createElement, discardElement = Highcharts.discardElement; // Extend CanVG renderer on demand, inherit from SVGRenderer extend(CanVGRenderer.prototype, SVGRenderer.prototype); // Add additional functionality: extend(CanVGRenderer.prototype, { create: function (chart, container, chartWidth, chartHeight) { this.setContainer(container, chartWidth, chartHeight); this.configure(chart); }, setContainer: function (container, chartWidth, chartHeight) { var containerStyle = container.style, containerParent = container.parentNode, containerLeft = containerStyle.left, containerTop = containerStyle.top, containerOffsetWidth = container.offsetWidth, containerOffsetHeight = container.offsetHeight, canvas, initialHiddenStyle = { visibility: HIDDEN, position: ABSOLUTE }; this.init(container, chartWidth, chartHeight); // add the canvas above it canvas = createElement('canvas', { width: containerOffsetWidth, height: containerOffsetHeight }, { position: RELATIVE, left: containerLeft, top: containerTop }, container); this.canvas = canvas; // Create the tooltip line and div, they are placed as siblings to // the container (and as direct childs to the div specified in the html page) this.ttLine = createElement(DIV, null, initialHiddenStyle, containerParent); this.ttDiv = createElement(DIV, null, initialHiddenStyle, containerParent); this.ttTimer = UNDEFINED; // Move away the svg node to a new div inside the container's parent so we can hide it. var hiddenSvg = createElement(DIV, { width: containerOffsetWidth, height: containerOffsetHeight }, { visibility: HIDDEN, left: containerLeft, top: containerTop }, containerParent); this.hiddenSvg = hiddenSvg; hiddenSvg.appendChild(this.box); }, /** * Configures the renderer with the chart. Attach a listener to the event tooltipRefresh. **/ configure: function (chart) { var renderer = this, options = chart.options.tooltip, borderWidth = options.borderWidth, tooltipDiv = renderer.ttDiv, tooltipDivStyle = options.style, tooltipLine = renderer.ttLine, padding = parseInt(tooltipDivStyle.padding, 10); // Add border styling from options to the style tooltipDivStyle = merge(tooltipDivStyle, { padding: padding + PX, 'background-color': options.backgroundColor, 'border-style': 'solid', 'border-width': borderWidth + PX, 'border-radius': options.borderRadius + PX }); // Optionally add shadow if (options.shadow) { tooltipDivStyle = merge(tooltipDivStyle, { 'box-shadow': '1px 1px 3px gray', // w3c '-webkit-box-shadow': '1px 1px 3px gray' // webkit }); } css(tooltipDiv, tooltipDivStyle); // Set simple style on the line css(tooltipLine, { 'border-left': '1px solid darkgray' }); // This event is triggered when a new tooltip should be shown addEvent(chart, 'tooltipRefresh', function (args) { var chartContainer = chart.container, offsetLeft = chartContainer.offsetLeft, offsetTop = chartContainer.offsetTop, position; // Set the content of the tooltip tooltipDiv.innerHTML = args.text; // Compute the best position for the tooltip based on the divs size and container size. position = chart.tooltip.getPosition( tooltipDiv.offsetWidth, tooltipDiv.offsetHeight, { plotX: args.x, plotY: args.y } ); css(tooltipDiv, { visibility: VISIBLE, left: position.x + PX, top: position.y + PX, 'border-color': args.borderColor }); // Position the tooltip line css(tooltipLine, { visibility: VISIBLE, left: offsetLeft + args.x + PX, top: offsetTop + chart.plotTop + PX, height: chart.plotHeight + PX }); // This timeout hides the tooltip after 3 seconds // First clear any existing timer if (renderer.ttTimer !== UNDEFINED) { clearTimeout(renderer.ttTimer); } // Start a new timer that hides tooltip and line renderer.ttTimer = setTimeout(function () { css(tooltipDiv, { visibility: HIDDEN }); css(tooltipLine, { visibility: HIDDEN }); }, 3000); }); }, /** * Extend SVGRenderer.destroy to also destroy the elements added by CanVGRenderer. */ destroy: function () { var renderer = this; // Remove the canvas discardElement(renderer.canvas); // Kill the timer if (renderer.ttTimer !== UNDEFINED) { clearTimeout(renderer.ttTimer); } // Remove the divs for tooltip and line discardElement(renderer.ttLine); discardElement(renderer.ttDiv); discardElement(renderer.hiddenSvg); // Continue with base class return SVGRenderer.prototype.destroy.apply(renderer); }, /** * Take a color and return it if it's a string, do not make it a gradient even if it is a * gradient. Currently canvg cannot render gradients (turns out black), * see: http://code.google.com/p/canvg/issues/detail?id=104 * * @param {Object} color The color or config object */ color: function (color, elem, prop) { if (color && color.linearGradient) { // Pick the end color and forward to base implementation color = color.stops[color.stops.length - 1][1]; } return SVGRenderer.prototype.color.call(this, color, elem, prop); }, /** * Draws the SVG on the canvas or adds a draw invokation to the deferred list. */ draw: function () { var renderer = this; win.canvg(renderer.canvas, renderer.hiddenSvg.innerHTML); } }); }(Highcharts)); |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Data module
(c) 2012-2017 Torstein Honsi
License: www.highcharts.com/license
*/
(function(p){"object"===typeof module&&module.exports?module.exports=p:p(Highcharts)})(function(p){(function(g){var p=g.win.document,m=g.each,z=g.pick,w=g.inArray,x=g.isNumber,A=g.splat,n,u=function(b,a){this.init(b,a)};g.extend(u.prototype,{init:function(b,a){this.options=b;this.chartOptions=a;this.columns=b.columns||this.rowsToColumns(b.rows)||[];this.firstRowAsNames=z(b.firstRowAsNames,!0);this.decimalRegex=b.decimalPoint&&new RegExp("^(-?[0-9]+)"+b.decimalPoint+"([0-9]+)$");this.rawColumns=[];
this.columns.length?this.dataFound():(this.parseCSV(),this.parseTable(),this.parseGoogleSpreadsheet())},getColumnDistribution:function(){var b=this.chartOptions,a=this.options,d=[],f=function(b){return(g.seriesTypes[b||"line"].prototype.pointArrayMap||[0]).length},e=b&&b.chart&&b.chart.type,c=[],k=[],t=0,h;m(b&&b.series||[],function(b){c.push(f(b.type||e))});m(a&&a.seriesMapping||[],function(b){d.push(b.x||0)});0===d.length&&d.push(0);m(a&&a.seriesMapping||[],function(a){var d=new n,r,v=c[t]||f(e),
q=g.seriesTypes[((b&&b.series||[])[t]||{}).type||e||"line"].prototype.pointArrayMap||["y"];d.addColumnReader(a.x,"x");for(r in a)a.hasOwnProperty(r)&&"x"!==r&&d.addColumnReader(a[r],r);for(h=0;h<v;h++)d.hasReader(q[h])||d.addColumnReader(void 0,q[h]);k.push(d);t++});a=g.seriesTypes[e||"line"].prototype.pointArrayMap;void 0===a&&(a=["y"]);this.valueCount={global:f(e),xColumns:d,individual:c,seriesBuilders:k,globalPointArrayMap:a}},dataFound:function(){this.options.switchRowsAndColumns&&(this.columns=
this.rowsToColumns(this.columns));this.getColumnDistribution();this.parseTypes();!1!==this.parsed()&&this.complete()},parseCSV:function(){var b=this,a=this.options,d=a.csv,f=this.columns,e=a.startRow||0,c=a.endRow||Number.MAX_VALUE,k=a.startColumn||0,t=a.endColumn||Number.MAX_VALUE,h,g,y=0;d&&(g=d.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split(a.lineDelimiter||"\n"),h=a.itemDelimiter||(-1!==d.indexOf("\t")?"\t":","),m(g,function(a,d){var g=b.trim(a),r=0===g.indexOf("#");d>=e&&d<=c&&!r&&""!==g&&(a=
a.split(h),m(a,function(b,a){a>=k&&a<=t&&(f[a-k]||(f[a-k]=[]),f[a-k][y]=b)}),y+=1)}),this.dataFound())},parseTable:function(){var b=this.options,a=b.table,d=this.columns,f=b.startRow||0,e=b.endRow||Number.MAX_VALUE,c=b.startColumn||0,k=b.endColumn||Number.MAX_VALUE;a&&("string"===typeof a&&(a=p.getElementById(a)),m(a.getElementsByTagName("tr"),function(b,a){a>=f&&a<=e&&m(b.children,function(b,e){("TD"===b.tagName||"TH"===b.tagName)&&e>=c&&e<=k&&(d[e-c]||(d[e-c]=[]),d[e-c][a-f]=b.innerHTML)})}),this.dataFound())},
parseGoogleSpreadsheet:function(){var b=this,a=this.options,d=a.googleSpreadsheetKey,f=this.columns,e=a.startRow||0,c=a.endRow||Number.MAX_VALUE,k=a.startColumn||0,g=a.endColumn||Number.MAX_VALUE,h,v;d&&jQuery.ajax({dataType:"json",url:"https://spreadsheets.google.com/feeds/cells/"+d+"/"+(a.googleSpreadsheetWorksheet||"od6")+"/public/values?alt\x3djson-in-script\x26callback\x3d?",error:a.error,success:function(a){a=a.feed.entry;var d,t=a.length,q=0,n=0,l;for(l=0;l<t;l++)d=a[l],q=Math.max(q,d.gs$cell.col),
n=Math.max(n,d.gs$cell.row);for(l=0;l<q;l++)l>=k&&l<=g&&(f[l-k]=[],f[l-k].length=Math.min(n,c-e));for(l=0;l<t;l++)d=a[l],h=d.gs$cell.row-1,v=d.gs$cell.col-1,v>=k&&v<=g&&h>=e&&h<=c&&(f[v-k][h-e]=d.content.$t);m(f,function(a){for(l=0;l<a.length;l++)void 0===a[l]&&(a[l]=null)});b.dataFound()}})},trim:function(b,a){"string"===typeof b&&(b=b.replace(/^\s+|\s+$/g,""),a&&/^[0-9\s]+$/.test(b)&&(b=b.replace(/\s/g,"")),this.decimalRegex&&(b=b.replace(this.decimalRegex,"$1.$2")));return b},parseTypes:function(){for(var b=
this.columns,a=b.length;a--;)this.parseColumn(b[a],a)},parseColumn:function(b,a){var d=this.rawColumns,f=this.columns,e=b.length,c,k,g,h,n=this.firstRowAsNames,m=-1!==w(a,this.valueCount.xColumns),r=[],p=this.chartOptions,q,u=(this.options.columnTypes||[])[a],p=m&&(p&&p.xAxis&&"category"===A(p.xAxis)[0].type||"string"===u);for(d[a]||(d[a]=[]);e--;)c=r[e]||b[e],g=this.trim(c),h=this.trim(c,!0),k=parseFloat(h),void 0===d[a][e]&&(d[a][e]=g),p||0===e&&n?b[e]=g:+h===k?(b[e]=k,31536E6<k&&"float"!==u?b.isDatetime=
!0:b.isNumeric=!0,void 0!==b[e+1]&&(q=k>b[e+1])):(k=this.parseDate(c),m&&x(k)&&"float"!==u?(r[e]=c,b[e]=k,b.isDatetime=!0,void 0!==b[e+1]&&(c=k>b[e+1],c!==q&&void 0!==q&&(this.alternativeFormat?(this.dateFormat=this.alternativeFormat,e=b.length,this.alternativeFormat=this.dateFormats[this.dateFormat].alternative):b.unsorted=!0),q=c)):(b[e]=""===g?null:g,0!==e&&(b.isDatetime||b.isNumeric)&&(b.mixed=!0)));m&&b.mixed&&(f[a]=d[a]);if(m&&q&&this.options.sort)for(a=0;a<f.length;a++)f[a].reverse(),n&&f[a].unshift(f[a].pop())},
dateFormats:{"YYYY-mm-dd":{regex:/^([0-9]{4})[\-\/\.]([0-9]{2})[\-\/\.]([0-9]{2})$/,parser:function(b){return Date.UTC(+b[1],b[2]-1,+b[3])}},"dd/mm/YYYY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/,parser:function(b){return Date.UTC(+b[3],b[2]-1,+b[1])},alternative:"mm/dd/YYYY"},"mm/dd/YYYY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/,parser:function(b){return Date.UTC(+b[3],b[1]-1,+b[2])}},"dd/mm/YY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/,
parser:function(b){return Date.UTC(+b[3]+2E3,b[2]-1,+b[1])},alternative:"mm/dd/YY"},"mm/dd/YY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/,parser:function(b){return Date.UTC(+b[3]+2E3,b[1]-1,+b[2])}}},parseDate:function(b){var a=this.options.parseDate,d,f,e=this.options.dateFormat||this.dateFormat,c;if(a)d=a(b);else if("string"===typeof b){if(e)a=this.dateFormats[e],(c=b.match(a.regex))&&(d=a.parser(c));else for(f in this.dateFormats)if(a=this.dateFormats[f],c=b.match(a.regex)){this.dateFormat=
f;this.alternativeFormat=a.alternative;d=a.parser(c);break}c||(c=Date.parse(b),"object"===typeof c&&null!==c&&c.getTime?d=c.getTime()-6E4*c.getTimezoneOffset():x(c)&&(d=c-6E4*(new Date(c)).getTimezoneOffset()))}return d},rowsToColumns:function(b){var a,d,f,e,c;if(b)for(c=[],d=b.length,a=0;a<d;a++)for(e=b[a].length,f=0;f<e;f++)c[f]||(c[f]=[]),c[f][a]=b[a][f];return c},parsed:function(){if(this.options.parsed)return this.options.parsed.call(this,this.columns)},getFreeIndexes:function(b,a){var d,f=[],
e=[],c;for(d=0;d<b;d+=1)f.push(!0);for(b=0;b<a.length;b+=1)for(c=a[b].getReferencedColumnIndexes(),d=0;d<c.length;d+=1)f[c[d]]=!1;for(d=0;d<f.length;d+=1)f[d]&&e.push(d);return e},complete:function(){var b=this.columns,a,d=this.options,f,e,c,k,g=[],h;if(d.complete||d.afterComplete){for(c=0;c<b.length;c++)this.firstRowAsNames&&(b[c].name=b[c].shift());f=[];e=this.getFreeIndexes(b.length,this.valueCount.seriesBuilders);for(c=0;c<this.valueCount.seriesBuilders.length;c++)h=this.valueCount.seriesBuilders[c],
h.populateColumns(e)&&g.push(h);for(;0<e.length;){h=new n;h.addColumnReader(0,"x");c=w(0,e);-1!==c&&e.splice(c,1);for(c=0;c<this.valueCount.global;c++)h.addColumnReader(void 0,this.valueCount.globalPointArrayMap[c]);h.populateColumns(e)&&g.push(h)}0<g.length&&0<g[0].readers.length&&(h=b[g[0].readers[0].columnIndex],void 0!==h&&(h.isDatetime?a="datetime":h.isNumeric||(a="category")));if("category"===a)for(c=0;c<g.length;c++)for(h=g[c],e=0;e<h.readers.length;e++)"x"===h.readers[e].configName&&(h.readers[e].configName=
"name");for(c=0;c<g.length;c++){h=g[c];e=[];for(k=0;k<b[0].length;k++)e[k]=h.read(b,k);f[c]={data:e};h.name&&(f[c].name=h.name);"category"===a&&(f[c].turboThreshold=0)}b={series:f};a&&(b.xAxis={type:a},"category"===a&&(b.xAxis.uniqueNames=!1));d.complete&&d.complete(b);d.afterComplete&&d.afterComplete(b)}}});g.Data=u;g.data=function(b,a){return new u(b,a)};g.wrap(g.Chart.prototype,"init",function(b,a,d){var f=this;a&&a.data?g.data(g.extend(a.data,{afterComplete:function(e){var c,k;if(a.hasOwnProperty("series"))if("object"===
typeof a.series)for(c=Math.max(a.series.length,e.series.length);c--;)k=a.series[c]||{},a.series[c]=g.merge(k,e.series[c]);else delete a.series;a=g.merge(e,a);b.call(f,a,d)}}),a):b.call(f,a,d)});n=function(){this.readers=[];this.pointIsArray=!0};n.prototype.populateColumns=function(b){var a=!0;m(this.readers,function(a){void 0===a.columnIndex&&(a.columnIndex=b.shift())});m(this.readers,function(b){void 0===b.columnIndex&&(a=!1)});return a};n.prototype.read=function(b,a){var d=this.pointIsArray,f=d?
[]:{},e;m(this.readers,function(c){var e=b[c.columnIndex][a];d?f.push(e):f[c.configName]=e});void 0===this.name&&2<=this.readers.length&&(e=this.getReferencedColumnIndexes(),2<=e.length&&(e.shift(),e.sort(),this.name=b[e.shift()].name));return f};n.prototype.addColumnReader=function(b,a){this.readers.push({columnIndex:b,configName:a});"x"!==a&&"y"!==a&&void 0!==a&&(this.pointIsArray=!1)};n.prototype.getReferencedColumnIndexes=function(){var b,a=[],d;for(b=0;b<this.readers.length;b+=1)d=this.readers[b],
void 0!==d.columnIndex&&a.push(d.columnIndex);return a};n.prototype.hasReader=function(b){var a,d;for(a=0;a<this.readers.length;a+=1)if(d=this.readers[a],d.configName===b)return!0}})(p)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Data module
*
* (c) 2012-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(Highcharts) {
/**
* Data module
*
* (c) 2012-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/* global jQuery */
// Utilities
var win = Highcharts.win,
doc = win.document,
each = Highcharts.each,
pick = Highcharts.pick,
inArray = Highcharts.inArray,
isNumber = Highcharts.isNumber,
splat = Highcharts.splat,
SeriesBuilder;
// The Data constructor
var Data = function(dataOptions, chartOptions) {
this.init(dataOptions, chartOptions);
};
// Set the prototype properties
Highcharts.extend(Data.prototype, {
/**
* Initialize the Data object with the given options
*/
init: function(options, chartOptions) {
this.options = options;
this.chartOptions = chartOptions;
this.columns = options.columns || this.rowsToColumns(options.rows) || [];
this.firstRowAsNames = pick(options.firstRowAsNames, true);
this.decimalRegex = options.decimalPoint && new RegExp('^(-?[0-9]+)' + options.decimalPoint + '([0-9]+)$');
// This is a two-dimensional array holding the raw, trimmed string values
// with the same organisation as the columns array. It makes it possible
// for example to revert from interpreted timestamps to string-based
// categories.
this.rawColumns = [];
// No need to parse or interpret anything
if (this.columns.length) {
this.dataFound();
// Parse and interpret
} else {
// Parse a CSV string if options.csv is given
this.parseCSV();
// Parse a HTML table if options.table is given
this.parseTable();
// Parse a Google Spreadsheet
this.parseGoogleSpreadsheet();
}
},
/**
* Get the column distribution. For example, a line series takes a single column for
* Y values. A range series takes two columns for low and high values respectively,
* and an OHLC series takes four columns.
*/
getColumnDistribution: function() {
var chartOptions = this.chartOptions,
options = this.options,
xColumns = [],
getValueCount = function(type) {
return (Highcharts.seriesTypes[type || 'line'].prototype.pointArrayMap || [0]).length;
},
getPointArrayMap = function(type) {
return Highcharts.seriesTypes[type || 'line'].prototype.pointArrayMap;
},
globalType = chartOptions && chartOptions.chart && chartOptions.chart.type,
individualCounts = [],
seriesBuilders = [],
seriesIndex = 0,
i;
each((chartOptions && chartOptions.series) || [], function(series) {
individualCounts.push(getValueCount(series.type || globalType));
});
// Collect the x-column indexes from seriesMapping
each((options && options.seriesMapping) || [], function(mapping) {
xColumns.push(mapping.x || 0);
});
// If there are no defined series with x-columns, use the first column as x column
if (xColumns.length === 0) {
xColumns.push(0);
}
// Loop all seriesMappings and constructs SeriesBuilders from
// the mapping options.
each((options && options.seriesMapping) || [], function(mapping) {
var builder = new SeriesBuilder(),
name,
numberOfValueColumnsNeeded = individualCounts[seriesIndex] || getValueCount(globalType),
seriesArr = (chartOptions && chartOptions.series) || [],
series = seriesArr[seriesIndex] || {},
pointArrayMap = getPointArrayMap(series.type || globalType) || ['y'];
// Add an x reader from the x property or from an undefined column
// if the property is not set. It will then be auto populated later.
builder.addColumnReader(mapping.x, 'x');
// Add all column mappings
for (name in mapping) {
if (mapping.hasOwnProperty(name) && name !== 'x') {
builder.addColumnReader(mapping[name], name);
}
}
// Add missing columns
for (i = 0; i < numberOfValueColumnsNeeded; i++) {
if (!builder.hasReader(pointArrayMap[i])) {
//builder.addNextColumnReader(pointArrayMap[i]);
// Create and add a column reader for the next free column index
builder.addColumnReader(undefined, pointArrayMap[i]);
}
}
seriesBuilders.push(builder);
seriesIndex++;
});
var globalPointArrayMap = getPointArrayMap(globalType);
if (globalPointArrayMap === undefined) {
globalPointArrayMap = ['y'];
}
this.valueCount = {
global: getValueCount(globalType),
xColumns: xColumns,
individual: individualCounts,
seriesBuilders: seriesBuilders,
globalPointArrayMap: globalPointArrayMap
};
},
/**
* When the data is parsed into columns, either by CSV, table, GS or direct input,
* continue with other operations.
*/
dataFound: function() {
if (this.options.switchRowsAndColumns) {
this.columns = this.rowsToColumns(this.columns);
}
// Interpret the info about series and columns
this.getColumnDistribution();
// Interpret the values into right types
this.parseTypes();
// Handle columns if a handleColumns callback is given
if (this.parsed() !== false) {
// Complete if a complete callback is given
this.complete();
}
},
/**
* Parse a CSV input string
*/
parseCSV: function() {
var self = this,
options = this.options,
csv = options.csv,
columns = this.columns,
startRow = options.startRow || 0,
endRow = options.endRow || Number.MAX_VALUE,
startColumn = options.startColumn || 0,
endColumn = options.endColumn || Number.MAX_VALUE,
itemDelimiter,
lines,
activeRowNo = 0;
if (csv) {
lines = csv
.replace(/\r\n/g, '\n') // Unix
.replace(/\r/g, '\n') // Mac
.split(options.lineDelimiter || '\n');
itemDelimiter = options.itemDelimiter || (csv.indexOf('\t') !== -1 ? '\t' : ',');
each(lines, function(line, rowNo) {
var trimmed = self.trim(line),
isComment = trimmed.indexOf('#') === 0,
isBlank = trimmed === '',
items;
if (rowNo >= startRow && rowNo <= endRow && !isComment && !isBlank) {
items = line.split(itemDelimiter);
each(items, function(item, colNo) {
if (colNo >= startColumn && colNo <= endColumn) {
if (!columns[colNo - startColumn]) {
columns[colNo - startColumn] = [];
}
columns[colNo - startColumn][activeRowNo] = item;
}
});
activeRowNo += 1;
}
});
this.dataFound();
}
},
/**
* Parse a HTML table
*/
parseTable: function() {
var options = this.options,
table = options.table,
columns = this.columns,
startRow = options.startRow || 0,
endRow = options.endRow || Number.MAX_VALUE,
startColumn = options.startColumn || 0,
endColumn = options.endColumn || Number.MAX_VALUE;
if (table) {
if (typeof table === 'string') {
table = doc.getElementById(table);
}
each(table.getElementsByTagName('tr'), function(tr, rowNo) {
if (rowNo >= startRow && rowNo <= endRow) {
each(tr.children, function(item, colNo) {
if ((item.tagName === 'TD' || item.tagName === 'TH') && colNo >= startColumn && colNo <= endColumn) {
if (!columns[colNo - startColumn]) {
columns[colNo - startColumn] = [];
}
columns[colNo - startColumn][rowNo - startRow] = item.innerHTML;
}
});
}
});
this.dataFound(); // continue
}
},
/**
*/
parseGoogleSpreadsheet: function() {
var self = this,
options = this.options,
googleSpreadsheetKey = options.googleSpreadsheetKey,
columns = this.columns,
startRow = options.startRow || 0,
endRow = options.endRow || Number.MAX_VALUE,
startColumn = options.startColumn || 0,
endColumn = options.endColumn || Number.MAX_VALUE,
gr, // google row
gc; // google column
if (googleSpreadsheetKey) {
jQuery.ajax({
dataType: 'json',
url: 'https://spreadsheets.google.com/feeds/cells/' +
googleSpreadsheetKey + '/' + (options.googleSpreadsheetWorksheet || 'od6') +
'/public/values?alt=json-in-script&callback=?',
error: options.error,
success: function(json) {
// Prepare the data from the spreadsheat
var cells = json.feed.entry,
cell,
cellCount = cells.length,
colCount = 0,
rowCount = 0,
i;
// First, find the total number of columns and rows that
// are actually filled with data
for (i = 0; i < cellCount; i++) {
cell = cells[i];
colCount = Math.max(colCount, cell.gs$cell.col);
rowCount = Math.max(rowCount, cell.gs$cell.row);
}
// Set up arrays containing the column data
for (i = 0; i < colCount; i++) {
if (i >= startColumn && i <= endColumn) {
// Create new columns with the length of either end-start or rowCount
columns[i - startColumn] = [];
// Setting the length to avoid jslint warning
columns[i - startColumn].length = Math.min(rowCount, endRow - startRow);
}
}
// Loop over the cells and assign the value to the right
// place in the column arrays
for (i = 0; i < cellCount; i++) {
cell = cells[i];
gr = cell.gs$cell.row - 1; // rows start at 1
gc = cell.gs$cell.col - 1; // columns start at 1
// If both row and col falls inside start and end
// set the transposed cell value in the newly created columns
if (gc >= startColumn && gc <= endColumn &&
gr >= startRow && gr <= endRow) {
columns[gc - startColumn][gr - startRow] = cell.content.$t;
}
}
// Insert null for empty spreadsheet cells (#5298)
each(columns, function(column) {
for (i = 0; i < column.length; i++) {
if (column[i] === undefined) {
column[i] = null;
}
}
});
self.dataFound();
}
});
}
},
/**
* Trim a string from whitespace
*/
trim: function(str, inside) {
if (typeof str === 'string') {
str = str.replace(/^\s+|\s+$/g, '');
// Clear white space insdie the string, like thousands separators
if (inside && /^[0-9\s]+$/.test(str)) {
str = str.replace(/\s/g, '');
}
if (this.decimalRegex) {
str = str.replace(this.decimalRegex, '$1.$2');
}
}
return str;
},
/**
* Parse numeric cells in to number types and date types in to true dates.
*/
parseTypes: function() {
var columns = this.columns,
col = columns.length;
while (col--) {
this.parseColumn(columns[col], col);
}
},
/**
* Parse a single column. Set properties like .isDatetime and .isNumeric.
*/
parseColumn: function(column, col) {
var rawColumns = this.rawColumns,
columns = this.columns,
row = column.length,
val,
floatVal,
trimVal,
trimInsideVal,
firstRowAsNames = this.firstRowAsNames,
isXColumn = inArray(col, this.valueCount.xColumns) !== -1,
dateVal,
backup = [],
diff,
chartOptions = this.chartOptions,
descending,
columnTypes = this.options.columnTypes || [],
columnType = columnTypes[col],
forceCategory = isXColumn && ((chartOptions && chartOptions.xAxis && splat(chartOptions.xAxis)[0].type === 'category') || columnType === 'string');
if (!rawColumns[col]) {
rawColumns[col] = [];
}
while (row--) {
val = backup[row] || column[row];
trimVal = this.trim(val);
trimInsideVal = this.trim(val, true);
floatVal = parseFloat(trimInsideVal);
// Set it the first time
if (rawColumns[col][row] === undefined) {
rawColumns[col][row] = trimVal;
}
// Disable number or date parsing by setting the X axis type to category
if (forceCategory || (row === 0 && firstRowAsNames)) {
column[row] = trimVal;
} else if (+trimInsideVal === floatVal) { // is numeric
column[row] = floatVal;
// If the number is greater than milliseconds in a year, assume datetime
if (floatVal > 365 * 24 * 3600 * 1000 && columnType !== 'float') {
column.isDatetime = true;
} else {
column.isNumeric = true;
}
if (column[row + 1] !== undefined) {
descending = floatVal > column[row + 1];
}
// String, continue to determine if it is a date string or really a string
} else {
dateVal = this.parseDate(val);
// Only allow parsing of dates if this column is an x-column
if (isXColumn && isNumber(dateVal) && columnType !== 'float') { // is date
backup[row] = val;
column[row] = dateVal;
column.isDatetime = true;
// Check if the dates are uniformly descending or ascending. If they
// are not, chances are that they are a different time format, so check
// for alternative.
if (column[row + 1] !== undefined) {
diff = dateVal > column[row + 1];
if (diff !== descending && descending !== undefined) {
if (this.alternativeFormat) {
this.dateFormat = this.alternativeFormat;
row = column.length;
this.alternativeFormat = this.dateFormats[this.dateFormat].alternative;
} else {
column.unsorted = true;
}
}
descending = diff;
}
} else { // string
column[row] = trimVal === '' ? null : trimVal;
if (row !== 0 && (column.isDatetime || column.isNumeric)) {
column.mixed = true;
}
}
}
}
// If strings are intermixed with numbers or dates in a parsed column, it is an indication
// that parsing went wrong or the data was not intended to display as numbers or dates and
// parsing is too aggressive. Fall back to categories. Demonstrated in the
// highcharts/demo/column-drilldown sample.
if (isXColumn && column.mixed) {
columns[col] = rawColumns[col];
}
// If the 0 column is date or number and descending, reverse all columns.
if (isXColumn && descending && this.options.sort) {
for (col = 0; col < columns.length; col++) {
columns[col].reverse();
if (firstRowAsNames) {
columns[col].unshift(columns[col].pop());
}
}
}
},
/**
* A collection of available date formats, extendable from the outside to support
* custom date formats.
*/
dateFormats: {
'YYYY-mm-dd': {
regex: /^([0-9]{4})[\-\/\.]([0-9]{2})[\-\/\.]([0-9]{2})$/,
parser: function(match) {
return Date.UTC(+match[1], match[2] - 1, +match[3]);
}
},
'dd/mm/YYYY': {
regex: /^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/,
parser: function(match) {
return Date.UTC(+match[3], match[2] - 1, +match[1]);
},
alternative: 'mm/dd/YYYY' // different format with the same regex
},
'mm/dd/YYYY': {
regex: /^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/,
parser: function(match) {
return Date.UTC(+match[3], match[1] - 1, +match[2]);
}
},
'dd/mm/YY': {
regex: /^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/,
parser: function(match) {
return Date.UTC(+match[3] + 2000, match[2] - 1, +match[1]);
},
alternative: 'mm/dd/YY' // different format with the same regex
},
'mm/dd/YY': {
regex: /^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/,
parser: function(match) {
return Date.UTC(+match[3] + 2000, match[1] - 1, +match[2]);
}
}
},
/**
* Parse a date and return it as a number. Overridable through options.parseDate.
*/
parseDate: function(val) {
var parseDate = this.options.parseDate,
ret,
key,
format,
dateFormat = this.options.dateFormat || this.dateFormat,
match;
if (parseDate) {
ret = parseDate(val);
} else if (typeof val === 'string') {
// Auto-detect the date format the first time
if (!dateFormat) {
for (key in this.dateFormats) {
format = this.dateFormats[key];
match = val.match(format.regex);
if (match) {
this.dateFormat = dateFormat = key;
this.alternativeFormat = format.alternative;
ret = format.parser(match);
break;
}
}
// Next time, use the one previously found
} else {
format = this.dateFormats[dateFormat];
match = val.match(format.regex);
if (match) {
ret = format.parser(match);
}
}
// Fall back to Date.parse
if (!match) {
match = Date.parse(val);
// External tools like Date.js and MooTools extend Date object and
// returns a date.
if (typeof match === 'object' && match !== null && match.getTime) {
ret = match.getTime() - match.getTimezoneOffset() * 60000;
// Timestamp
} else if (isNumber(match)) {
ret = match - (new Date(match)).getTimezoneOffset() * 60000;
}
}
}
return ret;
},
/**
* Reorganize rows into columns
*/
rowsToColumns: function(rows) {
var row,
rowsLength,
col,
colsLength,
columns;
if (rows) {
columns = [];
rowsLength = rows.length;
for (row = 0; row < rowsLength; row++) {
colsLength = rows[row].length;
for (col = 0; col < colsLength; col++) {
if (!columns[col]) {
columns[col] = [];
}
columns[col][row] = rows[row][col];
}
}
}
return columns;
},
/**
* A hook for working directly on the parsed columns
*/
parsed: function() {
if (this.options.parsed) {
return this.options.parsed.call(this, this.columns);
}
},
getFreeIndexes: function(numberOfColumns, seriesBuilders) {
var s,
i,
freeIndexes = [],
freeIndexValues = [],
referencedIndexes;
// Add all columns as free
for (i = 0; i < numberOfColumns; i = i + 1) {
freeIndexes.push(true);
}
// Loop all defined builders and remove their referenced columns
for (s = 0; s < seriesBuilders.length; s = s + 1) {
referencedIndexes = seriesBuilders[s].getReferencedColumnIndexes();
for (i = 0; i < referencedIndexes.length; i = i + 1) {
freeIndexes[referencedIndexes[i]] = false;
}
}
// Collect the values for the free indexes
for (i = 0; i < freeIndexes.length; i = i + 1) {
if (freeIndexes[i]) {
freeIndexValues.push(i);
}
}
return freeIndexValues;
},
/**
* If a complete callback function is provided in the options, interpret the
* columns into a Highcharts options object.
*/
complete: function() {
var columns = this.columns,
xColumns = [],
type,
options = this.options,
series,
data,
i,
j,
r,
seriesIndex,
chartOptions,
allSeriesBuilders = [],
builder,
freeIndexes,
typeCol,
index;
xColumns.length = columns.length;
if (options.complete || options.afterComplete) {
// Get the names and shift the top row
for (i = 0; i < columns.length; i++) {
if (this.firstRowAsNames) {
columns[i].name = columns[i].shift();
}
}
// Use the next columns for series
series = [];
freeIndexes = this.getFreeIndexes(columns.length, this.valueCount.seriesBuilders);
// Populate defined series
for (seriesIndex = 0; seriesIndex < this.valueCount.seriesBuilders.length; seriesIndex++) {
builder = this.valueCount.seriesBuilders[seriesIndex];
// If the builder can be populated with remaining columns, then add it to allBuilders
if (builder.populateColumns(freeIndexes)) {
allSeriesBuilders.push(builder);
}
}
// Populate dynamic series
while (freeIndexes.length > 0) {
builder = new SeriesBuilder();
builder.addColumnReader(0, 'x');
// Mark index as used (not free)
index = inArray(0, freeIndexes);
if (index !== -1) {
freeIndexes.splice(index, 1);
}
for (i = 0; i < this.valueCount.global; i++) {
// Create and add a column reader for the next free column index
builder.addColumnReader(undefined, this.valueCount.globalPointArrayMap[i]);
}
// If the builder can be populated with remaining columns, then add it to allBuilders
if (builder.populateColumns(freeIndexes)) {
allSeriesBuilders.push(builder);
}
}
// Get the data-type from the first series x column
if (allSeriesBuilders.length > 0 && allSeriesBuilders[0].readers.length > 0) {
typeCol = columns[allSeriesBuilders[0].readers[0].columnIndex];
if (typeCol !== undefined) {
if (typeCol.isDatetime) {
type = 'datetime';
} else if (!typeCol.isNumeric) {
type = 'category';
}
}
}
// Axis type is category, then the "x" column should be called "name"
if (type === 'category') {
for (seriesIndex = 0; seriesIndex < allSeriesBuilders.length; seriesIndex++) {
builder = allSeriesBuilders[seriesIndex];
for (r = 0; r < builder.readers.length; r++) {
if (builder.readers[r].configName === 'x') {
builder.readers[r].configName = 'name';
}
}
}
}
// Read data for all builders
for (seriesIndex = 0; seriesIndex < allSeriesBuilders.length; seriesIndex++) {
builder = allSeriesBuilders[seriesIndex];
// Iterate down the cells of each column and add data to the series
data = [];
for (j = 0; j < columns[0].length; j++) {
data[j] = builder.read(columns, j);
}
// Add the series
series[seriesIndex] = {
data: data
};
if (builder.name) {
series[seriesIndex].name = builder.name;
}
if (type === 'category') {
series[seriesIndex].turboThreshold = 0;
}
}
// Do the callback
chartOptions = {
series: series
};
if (type) {
chartOptions.xAxis = {
type: type
};
if (type === 'category') {
chartOptions.xAxis.uniqueNames = false;
}
}
if (options.complete) {
options.complete(chartOptions);
}
// The afterComplete hook is used internally to avoid conflict with the externally
// available complete option.
if (options.afterComplete) {
options.afterComplete(chartOptions);
}
}
}
});
// Register the Data prototype and data function on Highcharts
Highcharts.Data = Data;
Highcharts.data = function(options, chartOptions) {
return new Data(options, chartOptions);
};
// Extend Chart.init so that the Chart constructor accepts a new configuration
// option group, data.
Highcharts.wrap(Highcharts.Chart.prototype, 'init', function(proceed, userOptions, callback) {
var chart = this;
if (userOptions && userOptions.data) {
Highcharts.data(Highcharts.extend(userOptions.data, {
afterComplete: function(dataOptions) {
var i, series;
// Merge series configs
if (userOptions.hasOwnProperty('series')) {
if (typeof userOptions.series === 'object') {
i = Math.max(userOptions.series.length, dataOptions.series.length);
while (i--) {
series = userOptions.series[i] || {};
userOptions.series[i] = Highcharts.merge(series, dataOptions.series[i]);
}
} else { // Allow merging in dataOptions.series (#2856)
delete userOptions.series;
}
}
// Do the merge
userOptions = Highcharts.merge(dataOptions, userOptions);
proceed.call(chart, userOptions, callback);
}
}), userOptions);
} else {
proceed.call(chart, userOptions, callback);
}
});
/**
* Creates a new SeriesBuilder. A SeriesBuilder consists of a number
* of ColumnReaders that reads columns and give them a name.
* Ex: A series builder can be constructed to read column 3 as 'x' and
* column 7 and 8 as 'y1' and 'y2'.
* The output would then be points/rows of the form {x: 11, y1: 22, y2: 33}
*
* The name of the builder is taken from the second column. In the above
* example it would be the column with index 7.
* @constructor
*/
SeriesBuilder = function() {
this.readers = [];
this.pointIsArray = true;
};
/**
* Populates readers with column indexes. A reader can be added without
* a specific index and for those readers the index is taken sequentially
* from the free columns (this is handled by the ColumnCursor instance).
* @returns {boolean}
*/
SeriesBuilder.prototype.populateColumns = function(freeIndexes) {
var builder = this,
enoughColumns = true;
// Loop each reader and give it an index if its missing.
// The freeIndexes.shift() will return undefined if there
// are no more columns.
each(builder.readers, function(reader) {
if (reader.columnIndex === undefined) {
reader.columnIndex = freeIndexes.shift();
}
});
// Now, all readers should have columns mapped. If not
// then return false to signal that this series should
// not be added.
each(builder.readers, function(reader) {
if (reader.columnIndex === undefined) {
enoughColumns = false;
}
});
return enoughColumns;
};
/**
* Reads a row from the dataset and returns a point or array depending
* on the names of the readers.
* @param columns
* @param rowIndex
* @returns {Array | Object}
*/
SeriesBuilder.prototype.read = function(columns, rowIndex) {
var builder = this,
pointIsArray = builder.pointIsArray,
point = pointIsArray ? [] : {},
columnIndexes;
// Loop each reader and ask it to read its value.
// Then, build an array or point based on the readers names.
each(builder.readers, function(reader) {
var value = columns[reader.columnIndex][rowIndex];
if (pointIsArray) {
point.push(value);
} else {
point[reader.configName] = value;
}
});
// The name comes from the first column (excluding the x column)
if (this.name === undefined && builder.readers.length >= 2) {
columnIndexes = builder.getReferencedColumnIndexes();
if (columnIndexes.length >= 2) {
// remove the first one (x col)
columnIndexes.shift();
// Sort the remaining
columnIndexes.sort();
// Now use the lowest index as name column
this.name = columns[columnIndexes.shift()].name;
}
}
return point;
};
/**
* Creates and adds ColumnReader from the given columnIndex and configName.
* ColumnIndex can be undefined and in that case the reader will be given
* an index when columns are populated.
* @param columnIndex {Number | undefined}
* @param configName
*/
SeriesBuilder.prototype.addColumnReader = function(columnIndex, configName) {
this.readers.push({
columnIndex: columnIndex,
configName: configName
});
if (!(configName === 'x' || configName === 'y' || configName === undefined)) {
this.pointIsArray = false;
}
};
/**
* Returns an array of column indexes that the builder will use when
* reading data.
* @returns {Array}
*/
SeriesBuilder.prototype.getReferencedColumnIndexes = function() {
var i,
referencedColumnIndexes = [],
columnReader;
for (i = 0; i < this.readers.length; i = i + 1) {
columnReader = this.readers[i];
if (columnReader.columnIndex !== undefined) {
referencedColumnIndexes.push(columnReader.columnIndex);
}
}
return referencedColumnIndexes;
};
/**
* Returns true if the builder has a reader for the given configName.
* @param configName
* @returns {boolean}
*/
SeriesBuilder.prototype.hasReader = function(configName) {
var i, columnReader;
for (i = 0; i < this.readers.length; i = i + 1) {
columnReader = this.readers[i];
if (columnReader.configName === configName) {
return true;
}
}
// Else return undefined
};
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Highcharts Drilldown module
Author: Torstein Honsi
License: www.highcharts.com/license
*/
(function(n){"object"===typeof module&&module.exports?module.exports=n:n(Highcharts)})(function(n){(function(f){function n(b,a,d){var c;a.rgba.length&&b.rgba.length?(b=b.rgba,a=a.rgba,c=1!==a[3]||1!==b[3],b=(c?"rgba(":"rgb(")+Math.round(a[0]+(b[0]-a[0])*(1-d))+","+Math.round(a[1]+(b[1]-a[1])*(1-d))+","+Math.round(a[2]+(b[2]-a[2])*(1-d))+(c?","+(a[3]+(b[3]-a[3])*(1-d)):"")+")"):b=a.input||"none";return b}var B=f.noop,v=f.color,w=f.defaultOptions,l=f.each,p=f.extend,H=f.format,C=f.pick,x=f.wrap,q=f.Chart,
t=f.seriesTypes,D=t.pie,r=t.column,E=f.Tick,y=f.fireEvent,F=f.inArray,G=1;l(["fill","stroke"],function(b){f.Fx.prototype[b+"Setter"]=function(){this.elem.attr(b,n(v(this.start),v(this.end),this.pos),null,!0)}});p(w.lang,{drillUpText:"\u25c1 Back to {series.name}"});w.drilldown={activeAxisLabelStyle:{cursor:"pointer",color:"#003399",fontWeight:"bold",textDecoration:"underline"},activeDataLabelStyle:{cursor:"pointer",color:"#003399",fontWeight:"bold",textDecoration:"underline"},animation:{duration:500},
drillUpButton:{position:{align:"right",x:-10,y:10}}};f.SVGRenderer.prototype.Element.prototype.fadeIn=function(b){this.attr({opacity:.1,visibility:"inherit"}).animate({opacity:C(this.newOpacity,1)},b||{duration:250})};q.prototype.addSeriesAsDrilldown=function(b,a){this.addSingleSeriesAsDrilldown(b,a);this.applyDrilldown()};q.prototype.addSingleSeriesAsDrilldown=function(b,a){var d=b.series,c=d.xAxis,e=d.yAxis,h,g=[],k=[],u,m,z;z={color:b.color||d.color};this.drilldownLevels||(this.drilldownLevels=
[]);u=d.options._levelNumber||0;(m=this.drilldownLevels[this.drilldownLevels.length-1])&&m.levelNumber!==u&&(m=void 0);a=p(p({_ddSeriesId:G++},z),a);h=F(b,d.points);l(d.chart.series,function(a){a.xAxis!==c||a.isDrilling||(a.options._ddSeriesId=a.options._ddSeriesId||G++,a.options._colorIndex=a.userOptions._colorIndex,a.options._levelNumber=a.options._levelNumber||u,m?(g=m.levelSeries,k=m.levelSeriesOptions):(g.push(a),k.push(a.options)))});b=p({levelNumber:u,seriesOptions:d.options,levelSeriesOptions:k,
levelSeries:g,shapeArgs:b.shapeArgs,bBox:b.graphic?b.graphic.getBBox():{},color:b.isNull?(new f.Color(v)).setOpacity(0).get():v,lowerSeriesOptions:a,pointOptions:d.options.data[h],pointIndex:h,oldExtremes:{xMin:c&&c.userMin,xMax:c&&c.userMax,yMin:e&&e.userMin,yMax:e&&e.userMax}},z);this.drilldownLevels.push(b);a=b.lowerSeries=this.addSeries(a,!1);a.options._levelNumber=u+1;c&&(c.oldPos=c.pos,c.userMin=c.userMax=null,e.userMin=e.userMax=null);d.type===a.type&&(a.animate=a.animateDrilldown||B,a.options.animation=
!0)};q.prototype.applyDrilldown=function(){var b=this.drilldownLevels,a;b&&0<b.length&&(a=b[b.length-1].levelNumber,l(this.drilldownLevels,function(b){b.levelNumber===a&&l(b.levelSeries,function(c){c.options&&c.options._levelNumber===a&&c.remove(!1)})}));this.redraw();this.showDrillUpButton()};q.prototype.getDrilldownBackText=function(){var b=this.drilldownLevels;if(b&&0<b.length)return b=b[b.length-1],b.series=b.seriesOptions,H(this.options.lang.drillUpText,b)};q.prototype.showDrillUpButton=function(){var b=
this,a=this.getDrilldownBackText(),d=b.options.drilldown.drillUpButton,c,e;this.drillUpButton?this.drillUpButton.attr({text:a}).align():(e=(c=d.theme)&&c.states,this.drillUpButton=this.renderer.button(a,null,null,function(){b.drillUp()},c,e&&e.hover,e&&e.select).addClass("highcharts-drillup-button").attr({align:d.position.align,zIndex:7}).add().align(d.position,!1,d.relativeTo||"plotBox"))};q.prototype.drillUp=function(){for(var b=this,a=b.drilldownLevels,d=a[a.length-1].levelNumber,c=a.length,e=
b.series,h,g,k,f,m=function(a){var c;l(e,function(b){b.options._ddSeriesId===a._ddSeriesId&&(c=b)});c=c||b.addSeries(a,!1);c.type===k.type&&c.animateDrillupTo&&(c.animate=c.animateDrillupTo);a===g.seriesOptions&&(f=c)};c--;)if(g=a[c],g.levelNumber===d){a.pop();k=g.lowerSeries;if(!k.chart)for(h=e.length;h--;)if(e[h].options.id===g.lowerSeriesOptions.id&&e[h].options._levelNumber===d+1){k=e[h];break}k.xData=[];l(g.levelSeriesOptions,m);y(b,"drillup",{seriesOptions:g.seriesOptions});f.type===k.type&&
(f.drilldownLevel=g,f.options.animation=b.options.drilldown.animation,k.animateDrillupFrom&&k.chart&&k.animateDrillupFrom(g));f.options._levelNumber=d;k.remove(!1);f.xAxis&&(h=g.oldExtremes,f.xAxis.setExtremes(h.xMin,h.xMax,!1),f.yAxis.setExtremes(h.yMin,h.yMax,!1))}y(b,"drillupall");this.redraw();0===this.drilldownLevels.length?this.drillUpButton=this.drillUpButton.destroy():this.drillUpButton.attr({text:this.getDrilldownBackText()}).align();this.ddDupes.length=[]};r.prototype.supportsDrilldown=
!0;r.prototype.animateDrillupTo=function(b){if(!b){var a=this,d=a.drilldownLevel;l(this.points,function(a){var c=a.dataLabel;a.graphic&&a.graphic.hide();c&&(c.hidden="hidden"===c.attr("visibility"),c.hidden||(c.hide(),a.connector&&a.connector.hide()))});setTimeout(function(){a.points&&l(a.points,function(a,b){b=b===(d&&d.pointIndex)?"show":"fadeIn";var c="show"===b?!0:void 0,e=a.dataLabel;if(a.graphic)a.graphic[b](c);if(e&&!e.hidden&&(e[b](c),a.connector))a.connector[b](c)})},Math.max(this.chart.options.drilldown.animation.duration-
50,0));this.animate=B}};r.prototype.animateDrilldown=function(b){var a=this,d=this.chart.drilldownLevels,c,e=this.chart.options.drilldown.animation,h=this.xAxis;b||(l(d,function(b){a.options._ddSeriesId===b.lowerSeriesOptions._ddSeriesId&&(c=b.shapeArgs,c.fill=b.color)}),c.x+=C(h.oldPos,h.pos)-h.pos,l(this.points,function(b){b.shapeArgs.fill=b.color;b.graphic&&b.graphic.attr(c).animate(p(b.shapeArgs,{fill:b.color||a.color}),e);b.dataLabel&&b.dataLabel.fadeIn(e)}),this.animate=null)};r.prototype.animateDrillupFrom=
function(b){var a=this.chart.options.drilldown.animation,d=this.group,c=this;l(c.trackerGroups,function(a){if(c[a])c[a].on("mouseover")});delete this.group;l(this.points,function(c){var e=c.graphic,g=b.shapeArgs,k=function(){e.destroy();d&&(d=d.destroy())};e&&(delete c.graphic,g.fill=b.color,a?e.animate(g,f.merge(a,{complete:k})):(e.attr(g),k()))})};D&&p(D.prototype,{supportsDrilldown:!0,animateDrillupTo:r.prototype.animateDrillupTo,animateDrillupFrom:r.prototype.animateDrillupFrom,animateDrilldown:function(b){var a=
this.chart.drilldownLevels[this.chart.drilldownLevels.length-1],d=this.chart.options.drilldown.animation,c=a.shapeArgs,e=c.start,h=(c.end-e)/this.points.length;b||(l(this.points,function(b,k){var g=b.shapeArgs;c.fill=a.color;g.fill=b.color;if(b.graphic)b.graphic.attr(f.merge(c,{start:e+k*h,end:e+(k+1)*h}))[d?"animate":"attr"](g,d)}),this.animate=null)}});f.Point.prototype.doDrilldown=function(b,a,d){var c=this.series.chart,e=c.options.drilldown,f=(e.series||[]).length,g;c.ddDupes||(c.ddDupes=[]);
for(;f--&&!g;)e.series[f].id===this.drilldown&&-1===F(this.drilldown,c.ddDupes)&&(g=e.series[f],c.ddDupes.push(this.drilldown));y(c,"drilldown",{point:this,seriesOptions:g,category:a,originalEvent:d,points:void 0!==a&&this.series.xAxis.getDDPoints(a).slice(0)},function(a){var c=a.point.series&&a.point.series.chart,d=a.seriesOptions;c&&d&&(b?c.addSingleSeriesAsDrilldown(a.point,d):c.addSeriesAsDrilldown(a.point,d))})};f.Axis.prototype.drilldownCategory=function(b,a){var d,c,e=this.getDDPoints(b);for(d in e)(c=
e[d])&&c.series&&c.series.visible&&c.doDrilldown&&c.doDrilldown(!0,b,a);this.chart.applyDrilldown()};f.Axis.prototype.getDDPoints=function(b){var a=[];l(this.series,function(d){var c,e=d.xData,f=d.points;for(c=0;c<e.length;c++)if(e[c]===b&&d.options.data[c]&&d.options.data[c].drilldown){a.push(f?f[c]:!0);break}});return a};E.prototype.drillable=function(){var b=this.pos,a=this.label,d=this.axis,c="xAxis"===d.coll&&d.getDDPoints,e=c&&d.getDDPoints(b);c&&(a&&e.length?(a.drillable=!0,a.basicStyles||
(a.basicStyles=f.merge(a.styles)),a.addClass("highcharts-drilldown-axis-label").css(d.chart.options.drilldown.activeAxisLabelStyle).on("click",function(a){d.drilldownCategory(b,a)})):a&&a.drillable&&(a.styles={},a.css(a.basicStyles),a.on("click",null),a.removeClass("highcharts-drilldown-axis-label")))};x(E.prototype,"addLabel",function(b){b.call(this);this.drillable()});x(f.Point.prototype,"init",function(b,a,d,c){var e=b.call(this,a,d,c);c=(b=a.xAxis)&&b.ticks[c];e.drilldown&&f.addEvent(e,"click",
function(b){a.xAxis&&!1===a.chart.options.drilldown.allowPointDrilldown?a.xAxis.drilldownCategory(e.x,b):e.doDrilldown(void 0,void 0,b)});c&&c.drillable();return e});x(f.Series.prototype,"drawDataLabels",function(b){var a=this.chart.options.drilldown.activeDataLabelStyle,d=this.chart.renderer;b.call(this);l(this.points,function(b){var c={};b.drilldown&&b.dataLabel&&("contrast"===a.color&&(c.color=d.getContrast(b.color||this.color)),b.dataLabel.addClass("highcharts-drilldown-data-label"),b.dataLabel.css(a).css(c))},
this)});var A,w=function(b){b.call(this);l(this.points,function(a){a.drilldown&&a.graphic&&(a.graphic.addClass("highcharts-drilldown-point"),a.graphic.css({cursor:"pointer"}))})};for(A in t)t[A].prototype.supportsDrilldown&&x(t[A].prototype,"drawTracker",w)})(n)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Highcharts Drilldown module
*
* Author: Torstein Honsi
* License: www.highcharts.com/license
*
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* Highcharts Drilldown module
*
* Author: Torstein Honsi
* License: www.highcharts.com/license
*
*/
var noop = H.noop,
color = H.color,
defaultOptions = H.defaultOptions,
each = H.each,
extend = H.extend,
format = H.format,
pick = H.pick,
wrap = H.wrap,
Chart = H.Chart,
seriesTypes = H.seriesTypes,
PieSeries = seriesTypes.pie,
ColumnSeries = seriesTypes.column,
Tick = H.Tick,
fireEvent = H.fireEvent,
inArray = H.inArray,
ddSeriesId = 1;
// Utilities
/*
* Return an intermediate color between two colors, according to pos where 0
* is the from color and 1 is the to color. This method is copied from ColorAxis.js
* and should always be kept updated, until we get AMD support.
*/
function tweenColors(from, to, pos) {
// Check for has alpha, because rgba colors perform worse due to lack of
// support in WebKit.
var hasAlpha,
ret;
// Unsupported color, return to-color (#3920)
if (!to.rgba.length || !from.rgba.length) {
ret = to.input || 'none';
// Interpolate
} else {
from = from.rgba;
to = to.rgba;
hasAlpha = (to[3] !== 1 || from[3] !== 1);
ret = (hasAlpha ? 'rgba(' : 'rgb(') +
Math.round(to[0] + (from[0] - to[0]) * (1 - pos)) + ',' +
Math.round(to[1] + (from[1] - to[1]) * (1 - pos)) + ',' +
Math.round(to[2] + (from[2] - to[2]) * (1 - pos)) +
(hasAlpha ? (',' + (to[3] + (from[3] - to[3]) * (1 - pos))) : '') + ')';
}
return ret;
}
/**
* Handle animation of the color attributes directly
*/
each(['fill', 'stroke'], function(prop) {
H.Fx.prototype[prop + 'Setter'] = function() {
this.elem.attr(
prop,
tweenColors(color(this.start), color(this.end), this.pos),
null,
true
);
};
});
// Add language
extend(defaultOptions.lang, {
drillUpText: '◁ Back to {series.name}'
});
defaultOptions.drilldown = {
activeAxisLabelStyle: {
cursor: 'pointer',
color: '#003399',
fontWeight: 'bold',
textDecoration: 'underline'
},
activeDataLabelStyle: {
cursor: 'pointer',
color: '#003399',
fontWeight: 'bold',
textDecoration: 'underline'
},
animation: {
duration: 500
},
drillUpButton: {
position: {
align: 'right',
x: -10,
y: 10
}
// relativeTo: 'plotBox'
// theme
}
};
/**
* A general fadeIn method
*/
H.SVGRenderer.prototype.Element.prototype.fadeIn = function(animation) {
this
.attr({
opacity: 0.1,
visibility: 'inherit'
})
.animate({
opacity: pick(this.newOpacity, 1) // newOpacity used in maps
}, animation || {
duration: 250
});
};
Chart.prototype.addSeriesAsDrilldown = function(point, ddOptions) {
this.addSingleSeriesAsDrilldown(point, ddOptions);
this.applyDrilldown();
};
Chart.prototype.addSingleSeriesAsDrilldown = function(point, ddOptions) {
var oldSeries = point.series,
xAxis = oldSeries.xAxis,
yAxis = oldSeries.yAxis,
newSeries,
pointIndex,
levelSeries = [],
levelSeriesOptions = [],
level,
levelNumber,
last,
colorProp;
colorProp = {
color: point.color || oldSeries.color
};
if (!this.drilldownLevels) {
this.drilldownLevels = [];
}
levelNumber = oldSeries.options._levelNumber || 0;
// See if we can reuse the registered series from last run
last = this.drilldownLevels[this.drilldownLevels.length - 1];
if (last && last.levelNumber !== levelNumber) {
last = undefined;
}
ddOptions = extend(extend({
_ddSeriesId: ddSeriesId++
}, colorProp), ddOptions);
pointIndex = inArray(point, oldSeries.points);
// Record options for all current series
each(oldSeries.chart.series, function(series) {
if (series.xAxis === xAxis && !series.isDrilling) {
series.options._ddSeriesId = series.options._ddSeriesId || ddSeriesId++;
series.options._colorIndex = series.userOptions._colorIndex;
series.options._levelNumber = series.options._levelNumber || levelNumber; // #3182
if (last) {
levelSeries = last.levelSeries;
levelSeriesOptions = last.levelSeriesOptions;
} else {
levelSeries.push(series);
levelSeriesOptions.push(series.options);
}
}
});
// Add a record of properties for each drilldown level
level = extend({
levelNumber: levelNumber,
seriesOptions: oldSeries.options,
levelSeriesOptions: levelSeriesOptions,
levelSeries: levelSeries,
shapeArgs: point.shapeArgs,
bBox: point.graphic ? point.graphic.getBBox() : {}, // no graphic in line series with markers disabled
color: point.isNull ? new H.Color(color).setOpacity(0).get() : color,
lowerSeriesOptions: ddOptions,
pointOptions: oldSeries.options.data[pointIndex],
pointIndex: pointIndex,
oldExtremes: {
xMin: xAxis && xAxis.userMin,
xMax: xAxis && xAxis.userMax,
yMin: yAxis && yAxis.userMin,
yMax: yAxis && yAxis.userMax
}
}, colorProp);
// Push it to the lookup array
this.drilldownLevels.push(level);
newSeries = level.lowerSeries = this.addSeries(ddOptions, false);
newSeries.options._levelNumber = levelNumber + 1;
if (xAxis) {
xAxis.oldPos = xAxis.pos;
xAxis.userMin = xAxis.userMax = null;
yAxis.userMin = yAxis.userMax = null;
}
// Run fancy cross-animation on supported and equal types
if (oldSeries.type === newSeries.type) {
newSeries.animate = newSeries.animateDrilldown || noop;
newSeries.options.animation = true;
}
};
Chart.prototype.applyDrilldown = function() {
var drilldownLevels = this.drilldownLevels,
levelToRemove;
if (drilldownLevels && drilldownLevels.length > 0) { // #3352, async loading
levelToRemove = drilldownLevels[drilldownLevels.length - 1].levelNumber;
each(this.drilldownLevels, function(level) {
if (level.levelNumber === levelToRemove) {
each(level.levelSeries, function(series) {
if (series.options && series.options._levelNumber === levelToRemove) { // Not removed, not added as part of a multi-series drilldown
series.remove(false);
}
});
}
});
}
this.redraw();
this.showDrillUpButton();
};
Chart.prototype.getDrilldownBackText = function() {
var drilldownLevels = this.drilldownLevels,
lastLevel;
if (drilldownLevels && drilldownLevels.length > 0) { // #3352, async loading
lastLevel = drilldownLevels[drilldownLevels.length - 1];
lastLevel.series = lastLevel.seriesOptions;
return format(this.options.lang.drillUpText, lastLevel);
}
};
Chart.prototype.showDrillUpButton = function() {
var chart = this,
backText = this.getDrilldownBackText(),
buttonOptions = chart.options.drilldown.drillUpButton,
attr,
states;
if (!this.drillUpButton) {
attr = buttonOptions.theme;
states = attr && attr.states;
this.drillUpButton = this.renderer.button(
backText,
null,
null,
function() {
chart.drillUp();
},
attr,
states && states.hover,
states && states.select
)
.addClass('highcharts-drillup-button')
.attr({
align: buttonOptions.position.align,
zIndex: 7
})
.add()
.align(buttonOptions.position, false, buttonOptions.relativeTo || 'plotBox');
} else {
this.drillUpButton.attr({
text: backText
})
.align();
}
};
Chart.prototype.drillUp = function() {
var chart = this,
drilldownLevels = chart.drilldownLevels,
levelNumber = drilldownLevels[drilldownLevels.length - 1].levelNumber,
i = drilldownLevels.length,
chartSeries = chart.series,
seriesI,
level,
oldSeries,
newSeries,
oldExtremes,
addSeries = function(seriesOptions) {
var addedSeries;
each(chartSeries, function(series) {
if (series.options._ddSeriesId === seriesOptions._ddSeriesId) {
addedSeries = series;
}
});
addedSeries = addedSeries || chart.addSeries(seriesOptions, false);
if (addedSeries.type === oldSeries.type && addedSeries.animateDrillupTo) {
addedSeries.animate = addedSeries.animateDrillupTo;
}
if (seriesOptions === level.seriesOptions) {
newSeries = addedSeries;
}
};
while (i--) {
level = drilldownLevels[i];
if (level.levelNumber === levelNumber) {
drilldownLevels.pop();
// Get the lower series by reference or id
oldSeries = level.lowerSeries;
if (!oldSeries.chart) { // #2786
seriesI = chartSeries.length; // #2919
while (seriesI--) {
if (chartSeries[seriesI].options.id === level.lowerSeriesOptions.id &&
chartSeries[seriesI].options._levelNumber === levelNumber + 1) { // #3867
oldSeries = chartSeries[seriesI];
break;
}
}
}
oldSeries.xData = []; // Overcome problems with minRange (#2898)
each(level.levelSeriesOptions, addSeries);
fireEvent(chart, 'drillup', {
seriesOptions: level.seriesOptions
});
if (newSeries.type === oldSeries.type) {
newSeries.drilldownLevel = level;
newSeries.options.animation = chart.options.drilldown.animation;
if (oldSeries.animateDrillupFrom && oldSeries.chart) { // #2919
oldSeries.animateDrillupFrom(level);
}
}
newSeries.options._levelNumber = levelNumber;
oldSeries.remove(false);
// Reset the zoom level of the upper series
if (newSeries.xAxis) {
oldExtremes = level.oldExtremes;
newSeries.xAxis.setExtremes(oldExtremes.xMin, oldExtremes.xMax, false);
newSeries.yAxis.setExtremes(oldExtremes.yMin, oldExtremes.yMax, false);
}
}
}
// Fire a once-off event after all series have been drilled up (#5158)
fireEvent(chart, 'drillupall');
this.redraw();
if (this.drilldownLevels.length === 0) {
this.drillUpButton = this.drillUpButton.destroy();
} else {
this.drillUpButton.attr({
text: this.getDrilldownBackText()
})
.align();
}
this.ddDupes.length = []; // #3315
};
ColumnSeries.prototype.supportsDrilldown = true;
/**
* When drilling up, keep the upper series invisible until the lower series has
* moved into place
*/
ColumnSeries.prototype.animateDrillupTo = function(init) {
if (!init) {
var newSeries = this,
level = newSeries.drilldownLevel;
// First hide all items before animating in again
each(this.points, function(point) {
var dataLabel = point.dataLabel;
if (point.graphic) { // #3407
point.graphic.hide();
}
if (dataLabel) {
// The data label is initially hidden, make sure it is not faded
// in (#6127)
dataLabel.hidden = dataLabel.attr('visibility') === 'hidden';
if (!dataLabel.hidden) {
dataLabel.hide();
if (point.connector) {
point.connector.hide();
}
}
}
});
// Do dummy animation on first point to get to complete
setTimeout(function() {
if (newSeries.points) { // May be destroyed in the meantime, #3389
each(newSeries.points, function(point, i) {
// Fade in other points
var verb =
i === (level && level.pointIndex) ? 'show' : 'fadeIn',
inherit = verb === 'show' ? true : undefined,
dataLabel = point.dataLabel;
if (point.graphic) { // #3407
point.graphic[verb](inherit);
}
if (dataLabel && !dataLabel.hidden) { // #6127
dataLabel[verb](inherit);
if (point.connector) {
point.connector[verb](inherit);
}
}
});
}
}, Math.max(this.chart.options.drilldown.animation.duration - 50, 0));
// Reset
this.animate = noop;
}
};
ColumnSeries.prototype.animateDrilldown = function(init) {
var series = this,
drilldownLevels = this.chart.drilldownLevels,
animateFrom,
animationOptions = this.chart.options.drilldown.animation,
xAxis = this.xAxis;
if (!init) {
each(drilldownLevels, function(level) {
if (series.options._ddSeriesId === level.lowerSeriesOptions._ddSeriesId) {
animateFrom = level.shapeArgs;
// Add the point colors to animate from
animateFrom.fill = level.color;
}
});
animateFrom.x += (pick(xAxis.oldPos, xAxis.pos) - xAxis.pos);
each(this.points, function(point) {
var animateTo = point.shapeArgs;
// Add the point colors to animate to
animateTo.fill = point.color;
if (point.graphic) {
point.graphic
.attr(animateFrom)
.animate(
extend(point.shapeArgs, {
fill: point.color || series.color
}),
animationOptions
);
}
if (point.dataLabel) {
point.dataLabel.fadeIn(animationOptions);
}
});
this.animate = null;
}
};
/**
* When drilling up, pull out the individual point graphics from the lower series
* and animate them into the origin point in the upper series.
*/
ColumnSeries.prototype.animateDrillupFrom = function(level) {
var animationOptions = this.chart.options.drilldown.animation,
group = this.group,
series = this;
// Cancel mouse events on the series group (#2787)
each(series.trackerGroups, function(key) {
if (series[key]) { // we don't always have dataLabelsGroup
series[key].on('mouseover');
}
});
delete this.group;
each(this.points, function(point) {
var graphic = point.graphic,
animateTo = level.shapeArgs,
complete = function() {
graphic.destroy();
if (group) {
group = group.destroy();
}
};
if (graphic) {
delete point.graphic;
animateTo.fill = level.color;
if (animationOptions) {
graphic.animate(
animateTo,
H.merge(animationOptions, {
complete: complete
})
);
} else {
graphic.attr(animateTo);
complete();
}
}
});
};
if (PieSeries) {
extend(PieSeries.prototype, {
supportsDrilldown: true,
animateDrillupTo: ColumnSeries.prototype.animateDrillupTo,
animateDrillupFrom: ColumnSeries.prototype.animateDrillupFrom,
animateDrilldown: function(init) {
var level = this.chart.drilldownLevels[this.chart.drilldownLevels.length - 1],
animationOptions = this.chart.options.drilldown.animation,
animateFrom = level.shapeArgs,
start = animateFrom.start,
angle = animateFrom.end - start,
startAngle = angle / this.points.length;
if (!init) {
each(this.points, function(point, i) {
var animateTo = point.shapeArgs;
animateFrom.fill = level.color;
animateTo.fill = point.color;
if (point.graphic) {
point.graphic
.attr(H.merge(animateFrom, {
start: start + i * startAngle,
end: start + (i + 1) * startAngle
}))[animationOptions ? 'animate' : 'attr'](
animateTo,
animationOptions
);
}
});
this.animate = null;
}
}
});
}
H.Point.prototype.doDrilldown = function(_holdRedraw, category, originalEvent) {
var series = this.series,
chart = series.chart,
drilldown = chart.options.drilldown,
i = (drilldown.series || []).length,
seriesOptions;
if (!chart.ddDupes) {
chart.ddDupes = [];
}
while (i-- && !seriesOptions) {
if (drilldown.series[i].id === this.drilldown && inArray(this.drilldown, chart.ddDupes) === -1) {
seriesOptions = drilldown.series[i];
chart.ddDupes.push(this.drilldown);
}
}
// Fire the event. If seriesOptions is undefined, the implementer can check for
// seriesOptions, and call addSeriesAsDrilldown async if necessary.
fireEvent(chart, 'drilldown', {
point: this,
seriesOptions: seriesOptions,
category: category,
originalEvent: originalEvent,
points: category !== undefined && this.series.xAxis.getDDPoints(category).slice(0)
}, function(e) {
var chart = e.point.series && e.point.series.chart,
seriesOptions = e.seriesOptions;
if (chart && seriesOptions) {
if (_holdRedraw) {
chart.addSingleSeriesAsDrilldown(e.point, seriesOptions);
} else {
chart.addSeriesAsDrilldown(e.point, seriesOptions);
}
}
});
};
/**
* Drill down to a given category. This is the same as clicking on an axis label.
*/
H.Axis.prototype.drilldownCategory = function(x, e) {
var key,
point,
ddPointsX = this.getDDPoints(x);
for (key in ddPointsX) {
point = ddPointsX[key];
if (point && point.series && point.series.visible && point.doDrilldown) { // #3197
point.doDrilldown(true, x, e);
}
}
this.chart.applyDrilldown();
};
/**
* Return drillable points for this specific X value
*/
H.Axis.prototype.getDDPoints = function(x) {
var ret = [];
each(this.series, function(series) {
var i,
xData = series.xData,
points = series.points;
for (i = 0; i < xData.length; i++) {
if (xData[i] === x && series.options.data[i] && series.options.data[i].drilldown) {
ret.push(points ? points[i] : true);
break;
}
}
});
return ret;
};
/**
* Make a tick label drillable, or remove drilling on update
*/
Tick.prototype.drillable = function() {
var pos = this.pos,
label = this.label,
axis = this.axis,
isDrillable = axis.coll === 'xAxis' && axis.getDDPoints,
ddPointsX = isDrillable && axis.getDDPoints(pos);
if (isDrillable) {
if (label && ddPointsX.length) {
label.drillable = true;
if (!label.basicStyles) {
label.basicStyles = H.merge(label.styles);
}
label
.addClass('highcharts-drilldown-axis-label')
.css(axis.chart.options.drilldown.activeAxisLabelStyle)
.on('click', function(e) {
axis.drilldownCategory(pos, e);
});
} else if (label && label.drillable) {
label.styles = {}; // reset for full overwrite of styles
label.css(label.basicStyles);
label.on('click', null); // #3806
label.removeClass('highcharts-drilldown-axis-label');
}
}
};
/**
* Always keep the drillability updated (#3951)
*/
wrap(Tick.prototype, 'addLabel', function(proceed) {
proceed.call(this);
this.drillable();
});
/**
* On initialization of each point, identify its label and make it clickable. Also, provide a
* list of points associated to that label.
*/
wrap(H.Point.prototype, 'init', function(proceed, series, options, x) {
var point = proceed.call(this, series, options, x),
xAxis = series.xAxis,
tick = xAxis && xAxis.ticks[x];
if (point.drilldown) {
// Add the click event to the point
H.addEvent(point, 'click', function(e) {
if (series.xAxis && series.chart.options.drilldown.allowPointDrilldown === false) {
series.xAxis.drilldownCategory(point.x, e); // #5822, x changed
} else {
point.doDrilldown(undefined, undefined, e);
}
});
/*wrap(point, 'importEvents', function (proceed) { // wrapping importEvents makes point.click event work
if (!this.hasImportedEvents) {
proceed.call(this);
H.addEvent(this, 'click', function () {
this.doDrilldown();
});
}
});*/
}
// Add or remove click handler and style on the tick label
if (tick) {
tick.drillable();
}
return point;
});
wrap(H.Series.prototype, 'drawDataLabels', function(proceed) {
var css = this.chart.options.drilldown.activeDataLabelStyle,
renderer = this.chart.renderer;
proceed.call(this);
each(this.points, function(point) {
var pointCSS = {};
if (point.drilldown && point.dataLabel) {
if (css.color === 'contrast') {
pointCSS.color = renderer.getContrast(point.color || this.color);
}
point.dataLabel
.addClass('highcharts-drilldown-data-label');
point.dataLabel
.css(css)
.css(pointCSS);
}
}, this);
});
// Mark the trackers with a pointer
var type,
drawTrackerWrapper = function(proceed) {
proceed.call(this);
each(this.points, function(point) {
if (point.drilldown && point.graphic) {
point.graphic.addClass('highcharts-drilldown-point');
point.graphic.css({
cursor: 'pointer'
});
}
});
};
for (type in seriesTypes) {
if (seriesTypes[type].prototype.supportsDrilldown) {
wrap(seriesTypes[type].prototype, 'drawTracker', drawTrackerWrapper);
}
}
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Exporting module
(c) 2010-2017 Torstein Honsi
License: www.highcharts.com/license
*/
(function(k){"object"===typeof module&&module.exports?module.exports=k:k(Highcharts)})(function(k){(function(f){var k=f.defaultOptions,n=f.doc,A=f.Chart,w=f.addEvent,F=f.removeEvent,D=f.fireEvent,q=f.createElement,B=f.discardElement,u=f.css,p=f.merge,C=f.pick,h=f.each,r=f.extend,G=f.isTouchDevice,E=f.win,H=f.Renderer.prototype.symbols;r(k.lang,{printChart:"Print chart",downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",
contextButtonTitle:"Chart context menu"});k.navigation={buttonOptions:{theme:{},symbolSize:14,symbolX:12.5,symbolY:10.5,align:"right",buttonSpacing:3,height:22,verticalAlign:"top",width:24}};p(!0,k.navigation,{menuStyle:{border:"1px solid #999999",background:"#ffffff",padding:"5px 0"},menuItemStyle:{padding:"0.5em 1em",background:"none",color:"#333333",fontSize:G?"14px":"11px",transition:"background 250ms, color 250ms"},menuItemHoverStyle:{background:"#335cad",color:"#ffffff"},buttonOptions:{symbolFill:"#666666",
symbolStroke:"#666666",symbolStrokeWidth:3,theme:{fill:"#ffffff",stroke:"none",padding:5}}});k.exporting={type:"image/png",url:"https://export.highcharts.com/",printMaxWidth:780,scale:2,buttons:{contextButton:{className:"highcharts-contextbutton",menuClassName:"highcharts-contextmenu",symbol:"menu",_titleKey:"contextButtonTitle",menuItems:[{textKey:"printChart",onclick:function(){this.print()}},{separator:!0},{textKey:"downloadPNG",onclick:function(){this.exportChart()}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},
{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"application/pdf"})}},{textKey:"downloadSVG",onclick:function(){this.exportChart({type:"image/svg+xml"})}}]}}};f.post=function(a,b,e){var c;a=q("form",p({method:"post",action:a,enctype:"multipart/form-data"},e),{display:"none"},n.body);for(c in b)q("input",{type:"hidden",name:c,value:b[c]},null,a);a.submit();B(a)};r(A.prototype,{sanitizeSVG:function(a,b){if(b&&b.exporting&&b.exporting.allowHTML){var e=a.match(/<\/svg>(.*?$)/);e&&e[1]&&
(e='\x3cforeignObject x\x3d"0" y\x3d"0" width\x3d"'+b.chart.width+'" height\x3d"'+b.chart.height+'"\x3e\x3cbody xmlns\x3d"http://www.w3.org/1999/xhtml"\x3e'+e[1]+"\x3c/body\x3e\x3c/foreignObject\x3e",a=a.replace("\x3c/svg\x3e",e+"\x3c/svg\x3e"))}a=a.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/url\(("|")(\S+)("|")\)/g,"url($2)").replace(/url\([^#]+#/g,"url(#").replace(/<svg /,'\x3csvg xmlns:xlink\x3d"http://www.w3.org/1999/xlink" ').replace(/ (NS[0-9]+\:)?href=/g,
" xlink:href\x3d").replace(/\n/," ").replace(/<\/svg>.*?$/,"\x3c/svg\x3e").replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g,'$1\x3d"rgb($2)" $1-opacity\x3d"$3"').replace(/ /g,"\u00a0").replace(/­/g,"\u00ad");return a=a.replace(/<IMG /g,"\x3cimage ").replace(/<(\/?)TITLE>/g,"\x3c$1title\x3e").replace(/height=([^" ]+)/g,'height\x3d"$1"').replace(/width=([^" ]+)/g,'width\x3d"$1"').replace(/hc-svg-href="([^"]+)">/g,'xlink:href\x3d"$1"/\x3e').replace(/ id=([^" >]+)/g,' id\x3d"$1"').replace(/class=([^" >]+)/g,
'class\x3d"$1"').replace(/ transform /g," ").replace(/:(path|rect)/g,"$1").replace(/style="([^"]+)"/g,function(a){return a.toLowerCase()})},getChartHTML:function(){return this.container.innerHTML},getSVG:function(a){var b,e,c,v,m,g=p(this.options,a);n.createElementNS||(n.createElementNS=function(a,b){return n.createElement(b)});e=q("div",null,{position:"absolute",top:"-9999em",width:this.chartWidth+"px",height:this.chartHeight+"px"},n.body);c=this.renderTo.style.width;m=this.renderTo.style.height;
c=g.exporting.sourceWidth||g.chart.width||/px$/.test(c)&&parseInt(c,10)||600;m=g.exporting.sourceHeight||g.chart.height||/px$/.test(m)&&parseInt(m,10)||400;r(g.chart,{animation:!1,renderTo:e,forExport:!0,renderer:"SVGRenderer",width:c,height:m});g.exporting.enabled=!1;delete g.data;g.series=[];h(this.series,function(a){v=p(a.userOptions,{animation:!1,enableMouseTracking:!1,showCheckbox:!1,visible:a.visible});v.isInternal||g.series.push(v)});h(this.axes,function(a){a.userOptions.internalKey||(a.userOptions.internalKey=
f.uniqueKey())});b=new f.Chart(g,this.callback);a&&h(["xAxis","yAxis","series"],function(c){var d={};a[c]&&(d[c]=a[c],b.update(d))});h(this.axes,function(a){var c=f.find(b.axes,function(b){return b.options.internalKey===a.userOptions.internalKey}),d=a.getExtremes(),e=d.userMin,d=d.userMax;!c||void 0===e&&void 0===d||c.setExtremes(e,d,!0,!1)});c=b.getChartHTML();c=this.sanitizeSVG(c,g);g=null;b.destroy();B(e);return c},getSVGForExport:function(a,b){var e=this.options.exporting;return this.getSVG(p({chart:{borderRadius:0}},
e.chartOptions,b,{exporting:{sourceWidth:a&&a.sourceWidth||e.sourceWidth,sourceHeight:a&&a.sourceHeight||e.sourceHeight}}))},exportChart:function(a,b){b=this.getSVGForExport(a,b);a=p(this.options.exporting,a);f.post(a.url,{filename:a.filename||"chart",type:a.type,width:a.width||0,scale:a.scale,svg:b},a.formAttributes)},print:function(){var a=this,b=a.container,e=[],c=b.parentNode,f=n.body,m=f.childNodes,g=a.options.exporting.printMaxWidth,d,t;if(!a.isPrinting){a.isPrinting=!0;a.pointer.reset(null,
0);D(a,"beforePrint");if(t=g&&a.chartWidth>g)d=[a.options.chart.width,void 0,!1],a.setSize(g,void 0,!1);h(m,function(a,b){1===a.nodeType&&(e[b]=a.style.display,a.style.display="none")});f.appendChild(b);E.focus();E.print();setTimeout(function(){c.appendChild(b);h(m,function(a,b){1===a.nodeType&&(a.style.display=e[b])});a.isPrinting=!1;t&&a.setSize.apply(a,d);D(a,"afterPrint")},1E3)}},contextMenu:function(a,b,e,c,f,m,g){var d=this,t=d.options.navigation,v=d.chartWidth,k=d.chartHeight,p="cache-"+a,
l=d[p],x=Math.max(f,m),y,z;l||(d[p]=l=q("div",{className:a},{position:"absolute",zIndex:1E3,padding:x+"px"},d.container),y=q("div",{className:"highcharts-menu"},null,l),u(y,r({MozBoxShadow:"3px 3px 10px #888",WebkitBoxShadow:"3px 3px 10px #888",boxShadow:"3px 3px 10px #888"},t.menuStyle)),z=function(){u(l,{display:"none"});g&&g.setState(0);d.openMenu=!1},d.exportEvents.push(w(l,"mouseleave",function(){l.hideTimer=setTimeout(z,500)}),w(l,"mouseenter",function(){clearTimeout(l.hideTimer)}),w(n,"mouseup",
function(b){d.pointer.inClass(b.target,a)||z()})),h(b,function(a){if(a){var b;a.separator?b=q("hr",null,null,y):(b=q("div",{className:"highcharts-menu-item",onclick:function(b){b&&b.stopPropagation();z();a.onclick&&a.onclick.apply(d,arguments)},innerHTML:a.text||d.options.lang[a.textKey]},null,y),b.onmouseover=function(){u(this,t.menuItemHoverStyle)},b.onmouseout=function(){u(this,t.menuItemStyle)},u(b,r({cursor:"pointer"},t.menuItemStyle)));d.exportDivElements.push(b)}}),d.exportDivElements.push(y,
l),d.exportMenuWidth=l.offsetWidth,d.exportMenuHeight=l.offsetHeight);b={display:"block"};e+d.exportMenuWidth>v?b.right=v-e-f-x+"px":b.left=e-x+"px";c+m+d.exportMenuHeight>k&&"top"!==g.alignOptions.verticalAlign?b.bottom=k-c-x+"px":b.top=c+m-x+"px";u(l,b);d.openMenu=!0},addButton:function(a){var b=this,e=b.renderer,c=p(b.options.navigation.buttonOptions,a),f=c.onclick,m=c.menuItems,g,d,k=c.symbolSize||12;b.btnCount||(b.btnCount=0);b.exportDivElements||(b.exportDivElements=[],b.exportSVGElements=[]);
if(!1!==c.enabled){var h=c.theme,n=h.states,q=n&&n.hover,n=n&&n.select,l;delete h.states;f?l=function(a){a.stopPropagation();f.call(b,a)}:m&&(l=function(){b.contextMenu(d.menuClassName,m,d.translateX,d.translateY,d.width,d.height,d);d.setState(2)});c.text&&c.symbol?h.paddingLeft=C(h.paddingLeft,25):c.text||r(h,{width:c.width,height:c.height,padding:0});d=e.button(c.text,0,0,l,h,q,n).addClass(a.className).attr({"stroke-linecap":"round",title:b.options.lang[c._titleKey],zIndex:3});d.menuClassName=a.menuClassName||
"highcharts-menu-"+b.btnCount++;c.symbol&&(g=e.symbol(c.symbol,c.symbolX-k/2,c.symbolY-k/2,k,k).addClass("highcharts-button-symbol").attr({zIndex:1}).add(d),g.attr({stroke:c.symbolStroke,fill:c.symbolFill,"stroke-width":c.symbolStrokeWidth||1}));d.add().align(r(c,{width:d.width,x:C(c.x,b.buttonOffset)}),!0,"spacingBox");b.buttonOffset+=(d.width+c.buttonSpacing)*("right"===c.align?-1:1);b.exportSVGElements.push(d,g)}},destroyExport:function(a){var b=a?a.target:this;a=b.exportSVGElements;var e=b.exportDivElements,
c=b.exportEvents,f;a&&(h(a,function(a,c){a&&(a.onclick=a.ontouchstart=null,f="cache-"+a.menuClassName,b[f]&&delete b[f],b.exportSVGElements[c]=a.destroy())}),a.length=0);e&&(h(e,function(a,c){clearTimeout(a.hideTimer);F(a,"mouseleave");b.exportDivElements[c]=a.onmouseout=a.onmouseover=a.ontouchstart=a.onclick=null;B(a)}),e.length=0);c&&(h(c,function(a){a()}),c.length=0)}});H.menu=function(a,b,e,c){return["M",a,b+2.5,"L",a+e,b+2.5,"M",a,b+c/2+.5,"L",a+e,b+c/2+.5,"M",a,b+c-1.5,"L",a+e,b+c-1.5]};A.prototype.renderExporting=
function(){var a,b=this.options.exporting,e=b.buttons,c=this.isDirtyExporting||!this.exportSVGElements;this.buttonOffset=0;this.isDirtyExporting&&this.destroyExport();if(c&&!1!==b.enabled){this.exportEvents=[];for(a in e)this.addButton(e[a]);this.isDirtyExporting=!1}w(this,"destroy",this.destroyExport)};A.prototype.callbacks.push(function(a){a.renderExporting();w(a,"redraw",a.renderExporting);h(["exporting","navigation"],function(b){a[b]={update:function(e,c){a.isDirtyExporting=!0;p(!0,a.options[b],
e);C(c,!0)&&a.redraw()}}})})})(k)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 | 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Exporting module
*
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* Exporting module
*
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/* eslint indent:0 */
// create shortcuts
var defaultOptions = H.defaultOptions,
doc = H.doc,
Chart = H.Chart,
addEvent = H.addEvent,
removeEvent = H.removeEvent,
fireEvent = H.fireEvent,
createElement = H.createElement,
discardElement = H.discardElement,
css = H.css,
merge = H.merge,
pick = H.pick,
each = H.each,
extend = H.extend,
isTouchDevice = H.isTouchDevice,
win = H.win,
SVGRenderer = H.SVGRenderer;
var symbols = H.Renderer.prototype.symbols;
// Add language
extend(defaultOptions.lang, {
printChart: 'Print chart',
downloadPNG: 'Download PNG image',
downloadJPEG: 'Download JPEG image',
downloadPDF: 'Download PDF document',
downloadSVG: 'Download SVG vector image',
contextButtonTitle: 'Chart context menu'
});
// Buttons and menus are collected in a separate config option set called 'navigation'.
// This can be extended later to add control buttons like zoom and pan right click menus.
defaultOptions.navigation = {
buttonOptions: {
theme: {},
symbolSize: 14,
symbolX: 12.5,
symbolY: 10.5,
align: 'right',
buttonSpacing: 3,
height: 22,
// text: null,
verticalAlign: 'top',
width: 24
}
};
// Presentational attributes
merge(true, defaultOptions.navigation, {
menuStyle: {
border: '1px solid #999999',
background: '#ffffff',
padding: '5px 0'
},
menuItemStyle: {
padding: '0.5em 1em',
background: 'none',
color: '#333333',
fontSize: isTouchDevice ? '14px' : '11px',
transition: 'background 250ms, color 250ms'
},
menuItemHoverStyle: {
background: '#335cad',
color: '#ffffff'
},
buttonOptions: {
symbolFill: '#666666',
symbolStroke: '#666666',
symbolStrokeWidth: 3,
theme: {
fill: '#ffffff', // capture hover
stroke: 'none',
padding: 5
}
}
});
// Add the export related options
defaultOptions.exporting = {
//enabled: true,
//filename: 'chart',
type: 'image/png',
url: 'https://export.highcharts.com/',
//width: undefined,
printMaxWidth: 780,
scale: 2,
buttons: {
contextButton: {
className: 'highcharts-contextbutton',
menuClassName: 'highcharts-contextmenu',
//x: -10,
symbol: 'menu',
_titleKey: 'contextButtonTitle',
menuItems: [{
textKey: 'printChart',
onclick: function() {
this.print();
}
}, {
separator: true
}, {
textKey: 'downloadPNG',
onclick: function() {
this.exportChart();
}
}, {
textKey: 'downloadJPEG',
onclick: function() {
this.exportChart({
type: 'image/jpeg'
});
}
}, {
textKey: 'downloadPDF',
onclick: function() {
this.exportChart({
type: 'application/pdf'
});
}
}, {
textKey: 'downloadSVG',
onclick: function() {
this.exportChart({
type: 'image/svg+xml'
});
}
}
// Enable this block to add "View SVG" to the dropdown menu
/*
,{
text: 'View SVG Image',
onclick: function () {
var div = doc.createElement('div');
div.innerHTML = this.getSVGForExport();
this.renderTo.parentNode.appendChild(div);
}
}, {
text: 'View SVG Source',
onclick: function () {
var pre = doc.createElement('pre');
pre.innerHTML = this.getSVGForExport()
.replace(/</g, '\n<')
.replace(/>/g, '>');
this.renderTo.parentNode.appendChild(pre);
}
}
// */
]
}
}
};
// Add the H.post utility
H.post = function(url, data, formAttributes) {
var name,
form;
// create the form
form = createElement('form', merge({
method: 'post',
action: url,
enctype: 'multipart/form-data'
}, formAttributes), {
display: 'none'
}, doc.body);
// add the data
for (name in data) {
createElement('input', {
type: 'hidden',
name: name,
value: data[name]
}, null, form);
}
// submit
form.submit();
// clean up
discardElement(form);
};
extend(Chart.prototype, {
/**
* A collection of fixes on the produced SVG to account for expando properties,
* browser bugs, VML problems and other. Returns a cleaned SVG.
*/
sanitizeSVG: function(svg, options) {
// Move HTML into a foreignObject
if (options && options.exporting && options.exporting.allowHTML) {
var html = svg.match(/<\/svg>(.*?$)/);
if (html && html[1]) {
html = '<foreignObject x="0" y="0" ' +
'width="' + options.chart.width + '" ' +
'height="' + options.chart.height + '">' +
'<body xmlns="http://www.w3.org/1999/xhtml">' +
html[1] +
'</body>' +
'</foreignObject>';
svg = svg.replace('</svg>', html + '</svg>');
}
}
svg = svg
.replace(/zIndex="[^"]+"/g, '')
.replace(/isShadow="[^"]+"/g, '')
.replace(/symbolName="[^"]+"/g, '')
.replace(/jQuery[0-9]+="[^"]+"/g, '')
.replace(/url\(("|")(\S+)("|")\)/g, 'url($2)')
.replace(/url\([^#]+#/g, 'url(#')
.replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ')
.replace(/ (NS[0-9]+\:)?href=/g, ' xlink:href=') // #3567
.replace(/\n/, ' ')
// Any HTML added to the container after the SVG (#894)
.replace(/<\/svg>.*?$/, '</svg>')
// Batik doesn't support rgba fills and strokes (#3095)
.replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g, '$1="rgb($2)" $1-opacity="$3"')
/* This fails in IE < 8
.replace(/([0-9]+)\.([0-9]+)/g, function(s1, s2, s3) { // round off to save weight
return s2 +'.'+ s3[0];
})*/
// Replace HTML entities, issue #347
.replace(/ /g, '\u00A0') // no-break space
.replace(/­/g, '\u00AD'); // soft hyphen
// IE specific
svg = svg
.replace(/<IMG /g, '<image ')
.replace(/<(\/?)TITLE>/g, '<$1title>')
.replace(/height=([^" ]+)/g, 'height="$1"')
.replace(/width=([^" ]+)/g, 'width="$1"')
.replace(/hc-svg-href="([^"]+)">/g, 'xlink:href="$1"/>')
.replace(/ id=([^" >]+)/g, ' id="$1"') // #4003
.replace(/class=([^" >]+)/g, 'class="$1"')
.replace(/ transform /g, ' ')
.replace(/:(path|rect)/g, '$1')
.replace(/style="([^"]+)"/g, function(s) {
return s.toLowerCase();
});
return svg;
},
/**
* Return innerHTML of chart. Used as hook for plugins.
*/
getChartHTML: function() {
return this.container.innerHTML;
},
/**
* Return an SVG representation of the chart.
*
* @param additionalOptions {Object} Additional chart options for the
* generated SVG representation. For collections like `xAxis`, `yAxis` or
* `series`, the additional options is either merged in to the orininal
* item of the same `id`, or to the first item if a commin id is not
* found.
*/
getSVG: function(additionalOptions) {
var chart = this,
chartCopy,
sandbox,
svg,
seriesOptions,
sourceWidth,
sourceHeight,
cssWidth,
cssHeight,
options = merge(chart.options, additionalOptions); // copy the options and add extra options
// IE compatibility hack for generating SVG content that it doesn't really understand
if (!doc.createElementNS) {
doc.createElementNS = function(ns, tagName) {
return doc.createElement(tagName);
};
}
// create a sandbox where a new chart will be generated
sandbox = createElement('div', null, {
position: 'absolute',
top: '-9999em',
width: chart.chartWidth + 'px',
height: chart.chartHeight + 'px'
}, doc.body);
// get the source size
cssWidth = chart.renderTo.style.width;
cssHeight = chart.renderTo.style.height;
sourceWidth = options.exporting.sourceWidth ||
options.chart.width ||
(/px$/.test(cssWidth) && parseInt(cssWidth, 10)) ||
600;
sourceHeight = options.exporting.sourceHeight ||
options.chart.height ||
(/px$/.test(cssHeight) && parseInt(cssHeight, 10)) ||
400;
// override some options
extend(options.chart, {
animation: false,
renderTo: sandbox,
forExport: true,
renderer: 'SVGRenderer',
width: sourceWidth,
height: sourceHeight
});
options.exporting.enabled = false; // hide buttons in print
delete options.data; // #3004
// prepare for replicating the chart
options.series = [];
each(chart.series, function(serie) {
seriesOptions = merge(serie.userOptions, { // #4912
animation: false, // turn off animation
enableMouseTracking: false,
showCheckbox: false,
visible: serie.visible
});
if (!seriesOptions.isInternal) { // used for the navigator series that has its own option set
options.series.push(seriesOptions);
}
});
// Assign an internal key to ensure a one-to-one mapping (#5924)
each(chart.axes, function(axis) {
if (!axis.userOptions.internalKey) { // #6444
axis.userOptions.internalKey = H.uniqueKey();
}
});
// generate the chart copy
chartCopy = new H.Chart(options, chart.callback);
// Axis options and series options (#2022, #3900, #5982)
if (additionalOptions) {
each(['xAxis', 'yAxis', 'series'], function(coll) {
var collOptions = {};
if (additionalOptions[coll]) {
collOptions[coll] = additionalOptions[coll];
chartCopy.update(collOptions);
}
});
}
// Reflect axis extremes in the export (#5924)
each(chart.axes, function(axis) {
var axisCopy = H.find(chartCopy.axes, function(copy) {
return copy.options.internalKey ===
axis.userOptions.internalKey;
}),
extremes = axis.getExtremes(),
userMin = extremes.userMin,
userMax = extremes.userMax;
if (axisCopy && (userMin !== undefined || userMax !== undefined)) {
axisCopy.setExtremes(userMin, userMax, true, false);
}
});
// Get the SVG from the container's innerHTML
svg = chartCopy.getChartHTML();
svg = chart.sanitizeSVG(svg, options);
// free up memory
options = null;
chartCopy.destroy();
discardElement(sandbox);
return svg;
},
getSVGForExport: function(options, chartOptions) {
var chartExportingOptions = this.options.exporting;
return this.getSVG(merge({
chart: {
borderRadius: 0
}
},
chartExportingOptions.chartOptions,
chartOptions, {
exporting: {
sourceWidth: (options && options.sourceWidth) || chartExportingOptions.sourceWidth,
sourceHeight: (options && options.sourceHeight) || chartExportingOptions.sourceHeight
}
}
));
},
/**
* Submit the SVG representation of the chart to the server
* @param {Object} options Exporting options. Possible members are url, type, width and formAttributes.
* @param {Object} chartOptions Additional chart options for the SVG representation of the chart
*/
exportChart: function(options, chartOptions) {
var svg = this.getSVGForExport(options, chartOptions);
// merge the options
options = merge(this.options.exporting, options);
// do the post
H.post(options.url, {
filename: options.filename || 'chart',
type: options.type,
width: options.width || 0, // IE8 fails to post undefined correctly, so use 0
scale: options.scale,
svg: svg
}, options.formAttributes);
},
/**
* Print the chart
*/
print: function() {
var chart = this,
container = chart.container,
origDisplay = [],
origParent = container.parentNode,
body = doc.body,
childNodes = body.childNodes,
printMaxWidth = chart.options.exporting.printMaxWidth,
resetParams,
handleMaxWidth;
if (chart.isPrinting) { // block the button while in printing mode
return;
}
chart.isPrinting = true;
chart.pointer.reset(null, 0);
fireEvent(chart, 'beforePrint');
// Handle printMaxWidth
handleMaxWidth = printMaxWidth && chart.chartWidth > printMaxWidth;
if (handleMaxWidth) {
resetParams = [chart.options.chart.width, undefined, false];
chart.setSize(printMaxWidth, undefined, false);
}
// hide all body content
each(childNodes, function(node, i) {
if (node.nodeType === 1) {
origDisplay[i] = node.style.display;
node.style.display = 'none';
}
});
// pull out the chart
body.appendChild(container);
// print
win.focus(); // #1510
win.print();
// allow the browser to prepare before reverting
setTimeout(function() {
// put the chart back in
origParent.appendChild(container);
// restore all body content
each(childNodes, function(node, i) {
if (node.nodeType === 1) {
node.style.display = origDisplay[i];
}
});
chart.isPrinting = false;
// Reset printMaxWidth
if (handleMaxWidth) {
chart.setSize.apply(chart, resetParams);
}
fireEvent(chart, 'afterPrint');
}, 1000);
},
/**
* Display a popup menu for choosing the export type
*
* @param {String} className An identifier for the menu
* @param {Array} items A collection with text and onclicks for the items
* @param {Number} x The x position of the opener button
* @param {Number} y The y position of the opener button
* @param {Number} width The width of the opener button
* @param {Number} height The height of the opener button
*/
contextMenu: function(className, items, x, y, width, height, button) {
var chart = this,
navOptions = chart.options.navigation,
chartWidth = chart.chartWidth,
chartHeight = chart.chartHeight,
cacheName = 'cache-' + className,
menu = chart[cacheName],
menuPadding = Math.max(width, height), // for mouse leave detection
innerMenu,
hide,
menuStyle;
// create the menu only the first time
if (!menu) {
// create a HTML element above the SVG
chart[cacheName] = menu = createElement('div', {
className: className
}, {
position: 'absolute',
zIndex: 1000,
padding: menuPadding + 'px'
}, chart.container);
innerMenu = createElement('div', {
className: 'highcharts-menu'
}, null, menu);
// Presentational CSS
css(innerMenu, extend({
MozBoxShadow: '3px 3px 10px #888',
WebkitBoxShadow: '3px 3px 10px #888',
boxShadow: '3px 3px 10px #888'
}, navOptions.menuStyle));
// hide on mouse out
hide = function() {
css(menu, {
display: 'none'
});
if (button) {
button.setState(0);
}
chart.openMenu = false;
};
// Hide the menu some time after mouse leave (#1357)
chart.exportEvents.push(
addEvent(menu, 'mouseleave', function() {
menu.hideTimer = setTimeout(hide, 500);
}),
addEvent(menu, 'mouseenter', function() {
clearTimeout(menu.hideTimer);
}),
// Hide it on clicking or touching outside the menu (#2258, #2335,
// #2407)
addEvent(doc, 'mouseup', function(e) {
if (!chart.pointer.inClass(e.target, className)) {
hide();
}
})
);
// create the items
each(items, function(item) {
if (item) {
var element;
if (item.separator) {
element = createElement('hr', null, null, innerMenu);
} else {
element = createElement('div', {
className: 'highcharts-menu-item',
onclick: function(e) {
if (e) { // IE7
e.stopPropagation();
}
hide();
if (item.onclick) {
item.onclick.apply(chart, arguments);
}
},
innerHTML: item.text || chart.options.lang[item.textKey]
}, null, innerMenu);
element.onmouseover = function() {
css(this, navOptions.menuItemHoverStyle);
};
element.onmouseout = function() {
css(this, navOptions.menuItemStyle);
};
css(element, extend({
cursor: 'pointer'
}, navOptions.menuItemStyle));
}
// Keep references to menu divs to be able to destroy them
chart.exportDivElements.push(element);
}
});
// Keep references to menu and innerMenu div to be able to destroy them
chart.exportDivElements.push(innerMenu, menu);
chart.exportMenuWidth = menu.offsetWidth;
chart.exportMenuHeight = menu.offsetHeight;
}
menuStyle = {
display: 'block'
};
// if outside right, right align it
if (x + chart.exportMenuWidth > chartWidth) {
menuStyle.right = (chartWidth - x - width - menuPadding) + 'px';
} else {
menuStyle.left = (x - menuPadding) + 'px';
}
// if outside bottom, bottom align it
if (y + height + chart.exportMenuHeight > chartHeight && button.alignOptions.verticalAlign !== 'top') {
menuStyle.bottom = (chartHeight - y - menuPadding) + 'px';
} else {
menuStyle.top = (y + height - menuPadding) + 'px';
}
css(menu, menuStyle);
chart.openMenu = true;
},
/**
* Add the export button to the chart
*/
addButton: function(options) {
var chart = this,
renderer = chart.renderer,
btnOptions = merge(chart.options.navigation.buttonOptions, options),
onclick = btnOptions.onclick,
menuItems = btnOptions.menuItems,
symbol,
button,
symbolSize = btnOptions.symbolSize || 12;
if (!chart.btnCount) {
chart.btnCount = 0;
}
// Keeps references to the button elements
if (!chart.exportDivElements) {
chart.exportDivElements = [];
chart.exportSVGElements = [];
}
if (btnOptions.enabled === false) {
return;
}
var attr = btnOptions.theme,
states = attr.states,
hover = states && states.hover,
select = states && states.select,
callback;
delete attr.states;
if (onclick) {
callback = function(e) {
e.stopPropagation();
onclick.call(chart, e);
};
} else if (menuItems) {
callback = function() {
chart.contextMenu(
button.menuClassName,
menuItems,
button.translateX,
button.translateY,
button.width,
button.height,
button
);
button.setState(2);
};
}
if (btnOptions.text && btnOptions.symbol) {
attr.paddingLeft = pick(attr.paddingLeft, 25);
} else if (!btnOptions.text) {
extend(attr, {
width: btnOptions.width,
height: btnOptions.height,
padding: 0
});
}
button = renderer.button(btnOptions.text, 0, 0, callback, attr, hover, select)
.addClass(options.className)
.attr({
'stroke-linecap': 'round',
title: chart.options.lang[btnOptions._titleKey],
zIndex: 3 // #4955
});
button.menuClassName = options.menuClassName || 'highcharts-menu-' + chart.btnCount++;
if (btnOptions.symbol) {
symbol = renderer.symbol(
btnOptions.symbol,
btnOptions.symbolX - (symbolSize / 2),
btnOptions.symbolY - (symbolSize / 2),
symbolSize,
symbolSize
)
.addClass('highcharts-button-symbol')
.attr({
zIndex: 1
}).add(button);
symbol.attr({
stroke: btnOptions.symbolStroke,
fill: btnOptions.symbolFill,
'stroke-width': btnOptions.symbolStrokeWidth || 1
});
}
button.add()
.align(extend(btnOptions, {
width: button.width,
x: pick(btnOptions.x, chart.buttonOffset) // #1654
}), true, 'spacingBox');
chart.buttonOffset += (button.width + btnOptions.buttonSpacing) * (btnOptions.align === 'right' ? -1 : 1);
chart.exportSVGElements.push(button, symbol);
},
/**
* Destroy the buttons.
*/
destroyExport: function(e) {
var chart = e ? e.target : this,
exportSVGElements = chart.exportSVGElements,
exportDivElements = chart.exportDivElements,
exportEvents = chart.exportEvents,
cacheName;
// Destroy the extra buttons added
if (exportSVGElements) {
each(exportSVGElements, function(elem, i) {
// Destroy and null the svg/vml elements
if (elem) { // #1822
elem.onclick = elem.ontouchstart = null;
cacheName = 'cache-' + elem.menuClassName;
if (chart[cacheName]) {
delete chart[cacheName];
}
chart.exportSVGElements[i] = elem.destroy();
}
});
exportSVGElements.length = 0;
}
// Destroy the divs for the menu
if (exportDivElements) {
each(exportDivElements, function(elem, i) {
// Remove the event handler
clearTimeout(elem.hideTimer); // #5427
removeEvent(elem, 'mouseleave');
// Remove inline events
chart.exportDivElements[i] = elem.onmouseout = elem.onmouseover = elem.ontouchstart = elem.onclick = null;
// Destroy the div by moving to garbage bin
discardElement(elem);
});
exportDivElements.length = 0;
}
if (exportEvents) {
each(exportEvents, function(unbind) {
unbind();
});
exportEvents.length = 0;
}
}
});
symbols.menu = function(x, y, width, height) {
var arr = [
'M', x, y + 2.5,
'L', x + width, y + 2.5,
'M', x, y + height / 2 + 0.5,
'L', x + width, y + height / 2 + 0.5,
'M', x, y + height - 1.5,
'L', x + width, y + height - 1.5
];
return arr;
};
// Add the buttons on chart load
Chart.prototype.renderExporting = function() {
var n,
exportingOptions = this.options.exporting,
buttons = exportingOptions.buttons,
isDirty = this.isDirtyExporting || !this.exportSVGElements;
this.buttonOffset = 0;
if (this.isDirtyExporting) {
this.destroyExport();
}
if (isDirty && exportingOptions.enabled !== false) {
this.exportEvents = [];
for (n in buttons) {
this.addButton(buttons[n]);
}
this.isDirtyExporting = false;
}
// Destroy the export elements at chart destroy
addEvent(this, 'destroy', this.destroyExport);
};
Chart.prototype.callbacks.push(function(chart) {
function update(prop, options, redraw) {
chart.isDirtyExporting = true;
merge(true, chart.options[prop], options);
if (pick(redraw, true)) {
chart.redraw();
}
}
chart.renderExporting();
addEvent(chart, 'redraw', chart.renderExporting);
// Add update methods to handle chart.update and chart.exporting.update
// and chart.navigation.update.
each(['exporting', 'navigation'], function(prop) {
chart[prop] = {
update: function(options, redraw) {
update(prop, options, redraw);
}
};
});
// Uncomment this to see a button directly below the chart, for quick
// testing of export
/*
if (!chart.renderer.forExport) {
var button = doc.createElement('button');
button.innerHTML = 'View exported SVG';
chart.renderTo.parentNode.appendChild(button);
button.onclick = function () {
var div = doc.createElement('div');
div.innerHTML = chart.getSVGForExport();
chart.renderTo.parentNode.appendChild(div);
};
}
// */
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Highcharts funnel module
(c) 2010-2017 Torstein Honsi
License: www.highcharts.com/license
*/
(function(c){"object"===typeof module&&module.exports?module.exports=c:c(Highcharts)})(function(c){(function(c){var n=c.seriesType,z=c.seriesTypes,F=c.noop,G=c.each;n("funnel","pie",{animation:!1,center:["50%","50%"],width:"90%",neckWidth:"30%",height:"100%",neckHeight:"25%",reversed:!1,size:!0,dataLabels:{connectorWidth:1},states:{select:{color:"#cccccc",borderColor:"#000000",shadow:!1}}},{animate:F,translate:function(){var b=function(a,b){return/%$/.test(a)?b*parseInt(a,10)/100:parseInt(a,10)},
c=0,e=this.chart,d=this.options,r=d.reversed,H=d.ignoreHiddenPoint,t=e.plotWidth,e=e.plotHeight,p=0,n=d.center,f=b(n[0],t),q=b(n[1],e),z=b(d.width,t),h,v,k=b(d.height,e),w=b(d.neckWidth,t),D=b(d.neckHeight,e),x=q-k/2+k-D,b=this.data,A,B,I="left"===d.dataLabels.position?1:0,C,l,E,u,g,y,m;this.getWidthAt=v=function(a){var b=q-k/2;return a>x||k===D?w:w+(z-w)*(1-(a-b)/(k-D))};this.getX=function(a,b){return f+(b?-1:1)*(v(r?2*q-a:a)/2+d.dataLabels.distance)};this.center=[f,q,k];this.centerX=f;G(b,function(a){H&&
!1===a.visible||(c+=a.y)});G(b,function(a){m=null;B=c?a.y/c:0;l=q-k/2+p*k;g=l+B*k;h=v(l);C=f-h/2;E=C+h;h=v(g);u=f-h/2;y=u+h;l>x?(C=u=f-w/2,E=y=f+w/2):g>x&&(m=g,h=v(x),u=f-h/2,y=u+h,g=x);r&&(l=2*q-l,g=2*q-g,m=m?2*q-m:null);A=["M",C,l,"L",E,l,y,g];m&&A.push(y,m,u,m);A.push(u,g,"Z");a.shapeType="path";a.shapeArgs={d:A};a.percentage=100*B;a.plotX=f;a.plotY=(l+(m||g))/2;a.tooltipPos=[f,a.plotY];a.slice=F;a.half=I;H&&!1===a.visible||(p+=B)})},drawPoints:z.column.prototype.drawPoints,sortByAngle:function(b){b.sort(function(b,
c){return b.plotY-c.plotY})},drawDataLabels:function(){var b=this.data,c=this.options.dataLabels.distance,e,d,r,n=b.length,t,p;for(this.center[2]-=2*c;n--;)r=b[n],d=(e=r.half)?1:-1,p=r.plotY,t=this.getX(p,e),r.labelPos=[0,p,t+(c-5)*d,p,t+c*d,p,e?"right":"left",0];z.pie.prototype.drawDataLabels.call(this)}});n("pyramid","funnel",{neckWidth:"0%",neckHeight:"0%",reversed:!0})})(c)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Highcharts funnel module
*
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(Highcharts) {
/**
* Highcharts funnel module
*
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/* eslint indent:0 */
// create shortcuts
var seriesType = Highcharts.seriesType,
seriesTypes = Highcharts.seriesTypes,
noop = Highcharts.noop,
each = Highcharts.each;
seriesType('funnel', 'pie', {
animation: false,
center: ['50%', '50%'],
width: '90%',
neckWidth: '30%',
height: '100%',
neckHeight: '25%',
reversed: false,
size: true, // to avoid adapting to data label size in Pie.drawDataLabels
// Presentational
dataLabels: {
//position: 'right',
connectorWidth: 1
//connectorColor: null
},
states: {
select: {
color: '#cccccc',
borderColor: '#000000',
shadow: false
}
}
},
// Properties
{
animate: noop,
/**
* Overrides the pie translate method
*/
translate: function() {
var
// Get positions - either an integer or a percentage string must be given
getLength = function(length, relativeTo) {
return (/%$/).test(length) ?
relativeTo * parseInt(length, 10) / 100 :
parseInt(length, 10);
},
sum = 0,
series = this,
chart = series.chart,
options = series.options,
reversed = options.reversed,
ignoreHiddenPoint = options.ignoreHiddenPoint,
plotWidth = chart.plotWidth,
plotHeight = chart.plotHeight,
cumulative = 0, // start at top
center = options.center,
centerX = getLength(center[0], plotWidth),
centerY = getLength(center[1], plotHeight),
width = getLength(options.width, plotWidth),
tempWidth,
getWidthAt,
height = getLength(options.height, plotHeight),
neckWidth = getLength(options.neckWidth, plotWidth),
neckHeight = getLength(options.neckHeight, plotHeight),
neckY = (centerY - height / 2) + height - neckHeight,
data = series.data,
path,
fraction,
half = options.dataLabels.position === 'left' ? 1 : 0,
x1,
y1,
x2,
x3,
y3,
x4,
y5;
// Return the width at a specific y coordinate
series.getWidthAt = getWidthAt = function(y) {
var top = (centerY - height / 2);
return y > neckY || height === neckHeight ?
neckWidth :
neckWidth + (width - neckWidth) * (1 - (y - top) / (height - neckHeight));
};
series.getX = function(y, half) {
return centerX + (half ? -1 : 1) * ((getWidthAt(reversed ? 2 * centerY - y : y) / 2) + options.dataLabels.distance);
};
// Expose
series.center = [centerX, centerY, height];
series.centerX = centerX;
/*
* Individual point coordinate naming:
*
* x1,y1 _________________ x2,y1
* \ /
* \ /
* \ /
* \ /
* \ /
* x3,y3 _________ x4,y3
*
* Additional for the base of the neck:
*
* | |
* | |
* | |
* x3,y5 _________ x4,y5
*/
// get the total sum
each(data, function(point) {
if (!ignoreHiddenPoint || point.visible !== false) {
sum += point.y;
}
});
each(data, function(point) {
// set start and end positions
y5 = null;
fraction = sum ? point.y / sum : 0;
y1 = centerY - height / 2 + cumulative * height;
y3 = y1 + fraction * height;
//tempWidth = neckWidth + (width - neckWidth) * ((height - neckHeight - y1) / (height - neckHeight));
tempWidth = getWidthAt(y1);
x1 = centerX - tempWidth / 2;
x2 = x1 + tempWidth;
tempWidth = getWidthAt(y3);
x3 = centerX - tempWidth / 2;
x4 = x3 + tempWidth;
// the entire point is within the neck
if (y1 > neckY) {
x1 = x3 = centerX - neckWidth / 2;
x2 = x4 = centerX + neckWidth / 2;
// the base of the neck
} else if (y3 > neckY) {
y5 = y3;
tempWidth = getWidthAt(neckY);
x3 = centerX - tempWidth / 2;
x4 = x3 + tempWidth;
y3 = neckY;
}
if (reversed) {
y1 = 2 * centerY - y1;
y3 = 2 * centerY - y3;
y5 = (y5 ? 2 * centerY - y5 : null);
}
// save the path
path = [
'M',
x1, y1,
'L',
x2, y1,
x4, y3
];
if (y5) {
path.push(x4, y5, x3, y5);
}
path.push(x3, y3, 'Z');
// prepare for using shared dr
point.shapeType = 'path';
point.shapeArgs = {
d: path
};
// for tooltips and data labels
point.percentage = fraction * 100;
point.plotX = centerX;
point.plotY = (y1 + (y5 || y3)) / 2;
// Placement of tooltips and data labels
point.tooltipPos = [
centerX,
point.plotY
];
// Slice is a noop on funnel points
point.slice = noop;
// Mimicking pie data label placement logic
point.half = half;
if (!ignoreHiddenPoint || point.visible !== false) {
cumulative += fraction;
}
});
},
/**
* Draw a single point (wedge)
* @param {Object} point The point object
* @param {Object} color The color of the point
* @param {Number} brightness The brightness relative to the color
*/
drawPoints: seriesTypes.column.prototype.drawPoints,
/**
* Funnel items don't have angles (#2289)
*/
sortByAngle: function(points) {
points.sort(function(a, b) {
return a.plotY - b.plotY;
});
},
/**
* Extend the pie data label method
*/
drawDataLabels: function() {
var data = this.data,
labelDistance = this.options.dataLabels.distance,
leftSide,
sign,
point,
i = data.length,
x,
y;
// In the original pie label anticollision logic, the slots are distributed
// from one labelDistance above to one labelDistance below the pie. In funnels
// we don't want this.
this.center[2] -= 2 * labelDistance;
// Set the label position array for each point.
while (i--) {
point = data[i];
leftSide = point.half;
sign = leftSide ? 1 : -1;
y = point.plotY;
x = this.getX(y, leftSide);
// set the anchor point for data labels
point.labelPos = [
0, // first break of connector
y, // a/a
x + (labelDistance - 5) * sign, // second break, right outside point shape
y, // a/a
x + labelDistance * sign, // landing point for connector
y, // a/a
leftSide ? 'right' : 'left', // alignment
0 // center angle
];
}
seriesTypes.pie.prototype.drawDataLabels.call(this);
}
});
/**
* Pyramid series type.
* A pyramid series is a special type of funnel, without neck and reversed by default.
*/
seriesType('pyramid', 'funnel', {
neckWidth: '0%',
neckHeight: '0%',
reversed: true
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Gantt series
(c) 2016 Lars A. V. Cabrera
--- WORK IN PROGRESS ---
License: www.highcharts.com/license
*/
(function(p){"object"===typeof module&&module.exports?module.exports=p:p(Highcharts)})(function(p){(function(h){var p=h.dateFormat,v=h.each,w=h.isObject,r=h.pick,m=h.wrap,q=h.Axis,x=h.Chart,t=h.Tick;q.prototype.isOuterAxis=function(){var a=this,c=-1,b=!0;v(this.chart.axes,function(d,g){d.side===a.side&&(d===a?c=g:0<=c&&g>c&&(b=!1))});return b};t.prototype.getLabelWidth=function(){return this.label.getBBox().width};q.prototype.getMaxLabelLength=function(a){var c=this.tickPositions,b=this.ticks,d=0;
if(!this.maxLabelLength||a)v(c,function(a){(a=b[a])&&a.labelLength>d&&(d=a.labelLength)}),this.maxLabelLength=d;return this.maxLabelLength};q.prototype.addTitle=function(){var a=this.chart.renderer,c=this.axisParent,b=this.horiz,d=this.opposite,g=this.options,e=g.title,f;this.showAxis=f=this.hasData()||r(g.showEmpty,!0);g.title="";this.axisTitle||((g=e.textAlign)||(g=(b?{low:"left",middle:"center",high:"right"}:{low:d?"right":"left",middle:"center",high:d?"left":"right"})[e.align]),this.axisTitle=
a.text(e.text,0,0,e.useHTML).attr({zIndex:7,rotation:e.rotation||0,align:g}).addClass("highcharts-axis-title").css(e.style).add(c),this.axisTitle.isNew=!0);this.axisTitle[f?"show":"hide"](!0)};h.dateFormats={W:function(a){a=new Date(a);var c=0===a.getUTCDay()?7:a.getUTCDay(),b=a.getTime(),d=new Date(a.getUTCFullYear(),0,1,-6);a.setDate(a.getUTCDate()+4-c);return 1+Math.floor(Math.floor((b-d)/864E5)/7)},E:function(a){return p("%a",a,!0).charAt(0)}};m(t.prototype,"addLabel",function(a){var c=this.axis,
b=void 0!==c.options.categories,d=c.tickPositions,d=this.pos!==d[d.length-1];(!c.options.grid||b||d)&&a.apply(this)});m(t.prototype,"getLabelPosition",function(a,c,b,d){var g=a.apply(this,Array.prototype.slice.call(arguments,1)),e=this.axis,f=e.options,k=f.tickInterval||1,n,u;f.grid&&(n=f.labels.style.fontSize,u=e.chart.renderer.fontMetrics(n,d),n=u.b,u=u.h,e.horiz&&void 0===f.categories?(f=e.axisGroup.getBBox().height,k=this.pos+k/2,g.x=e.translate(k)+e.left,k=f/2+u/2-Math.abs(u-n),g.y=0===e.side?
b-k:b+k):(void 0===f.categories&&(k=this.pos+k/2,g.y=e.translate(k)+e.top+n/2),k=this.getLabelWidth()/2-e.maxLabelLength/2,g.x=3===e.side?g.x+k:g.x-k));return g});m(q.prototype,"tickSize",function(a){var c=a.apply(this,Array.prototype.slice.call(arguments,1)),b;this.options.grid&&!this.horiz&&(b=2*Math.abs(this.defaultLeftAxisOptions.labels.x),this.maxLabelLength||(this.maxLabelLength=this.getMaxLabelLength()),b=this.maxLabelLength+b,c[0]=b);return c});m(q.prototype,"getOffset",function(a){var c=
this.chart.axisOffset,b=this.side,d,g,e=this.options,f=e.title,k=f&&f.text&&!1!==f.enabled;this.options.grid&&w(this.options.title)?(g=this.tickSize("tick")[0],c[b]&&g&&(d=c[b]+g),k&&this.addTitle(),a.apply(this,Array.prototype.slice.call(arguments,1)),c[b]=r(d,c[b]),e.title=f):a.apply(this,Array.prototype.slice.call(arguments,1))});m(q.prototype,"renderUnsquish",function(a){this.options.grid&&(this.labelRotation=0,this.options.labels.rotation=0);a.apply(this)});m(q.prototype,"setOptions",function(a,
c){c.grid&&this.horiz&&(c.startOnTick=!0,c.minPadding=0,c.endOnTick=!0);a.apply(this,Array.prototype.slice.call(arguments,1))});m(q.prototype,"render",function(a){var c=this.options,b,d,g,e,f,k,n=this.chart.renderer;if(c.grid){if(b=2*Math.abs(this.defaultLeftAxisOptions.labels.x),b=this.maxLabelLength+b,d=c.lineWidth,this.rightWall&&this.rightWall.destroy(),a.apply(this),a=this.axisGroup.getBBox(),this.horiz&&(this.rightWall=n.path(["M",a.x+this.width+1,a.y,"L",a.x+this.width+1,a.y+a.height]).attr({stroke:c.tickColor||
"#ccd6eb","stroke-width":c.tickWidth||1,zIndex:7,class:"grid-wall"}).add(this.axisGroup)),this.isOuterAxis()&&this.axisLine&&(this.horiz&&(b=a.height-1),d)){a=this.getLinePath(d);f=a.indexOf("M")+1;k=a.indexOf("L")+1;g=a.indexOf("M")+2;e=a.indexOf("L")+2;if(0===this.side||3===this.side)b=-b;this.horiz?(a[g]+=b,a[e]+=b):(a[f]+=b,a[k]+=b);this.axisLineExtra?this.axisLineExtra.animate({d:a}):this.axisLineExtra=n.path(a).attr({stroke:c.lineColor,"stroke-width":d,zIndex:7}).add(this.axisGroup);this.axisLine[this.showAxis?
"show":"hide"](!0)}}else a.apply(this)});m(x.prototype,"render",function(a){var c=25/11,b,d;v(this.axes,function(a){var e=a.options;e.grid&&(d=e.labels.style.fontSize,b=a.chart.renderer.fontMetrics(d),"datetime"===e.type&&(e.units=[["millisecond",[1]],["second",[1]],["minute",[1]],["hour",[1]],["day",[1]],["week",[1]],["month",[1]],["year",null]]),a.horiz?e.tickLength=e.cellHeight||b.h*c:(e.tickWidth=1,e.lineWidth||(e.lineWidth=1)))});a.apply(this)})})(p);(function(h){var p=h.getOptions().plotOptions,
v=h.Color,w=h.seriesTypes.column,r=h.each,m=h.extendClass,q=h.isNumber,x=h.isObject,t=h.merge,a=h.pick,c=h.seriesTypes,b=h.wrap,d=h.Axis,g=h.Point,e=h.Series;p.xrange=t(p.column,{tooltip:{pointFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e {series.name}: \x3cb\x3e{point.yCategory}\x3c/b\x3e\x3cbr/\x3e'}});c.xrange=m(w,{pointClass:m(g,{getLabelConfig:function(){var a=g.prototype.getLabelConfig.call(this);a.x2=this.x2;a.yCategory=this.yCategory=this.series.yAxis.categories&&
this.series.yAxis.categories[this.y];return a}}),type:"xrange",forceDL:!0,parallelArrays:["x","x2","y"],requireSorting:!1,animate:c.line.prototype.animate,getColumnMetrics:function(){function a(){r(c.series,function(a){var b=a.xAxis;a.xAxis=a.yAxis;a.yAxis=b})}var b,c=this.chart;a();this.yAxis.closestPointRange=1;b=w.prototype.getColumnMetrics.call(this);a();return b},cropData:function(a,b,c,d){b=e.prototype.cropData.call(this,this.x2Data,b,c,d);b.xData=a.slice(b.start,b.end);return b},translate:function(){w.prototype.translate.apply(this,
arguments);var b=this.xAxis,c=this.columnMetrics,e=this.options.minPointLength||0;r(this.points,function(d){var f=d.plotX,l=a(d.x2,d.x+(d.len||0)),l=b.toPixels(l,!0),g=l-f,h;e&&(h=e-g,0>h&&(h=0),f-=h/2,l+=h/2);f=Math.max(f,-10);l=Math.min(Math.max(l,-10),b.len+10);l<f&&(l=f);d.shapeArgs={x:f,y:d.plotY+c.offset,width:l-f,height:c.width};d.tooltipPos[0]+=g/2;d.tooltipPos[1]-=c.width/2;if(l=d.partialFill)x(l)&&(l=l.amount),q(l)||(l=0),f=d.shapeArgs,d.partShapeArgs={x:f.x,y:f.y+1,width:f.width*l,height:f.height-
2}})},drawPoints:function(){var a=this,b=this.chart,d=a.options,c=b.renderer,e=b.pointCount<(d.animationLimit||250)?"animate":"attr";r(a.points,function(b){var f=b.graphic,g=b.shapeType,h=b.shapeArgs,k=b.partShapeArgs,l=a.options,n=b.partialFill,m=b.selected&&"select",p=d.stacking&&!d.borderRadius;if(q(b.plotY)&&null!==b.y){if(f){if(b.graphicOriginal[e](t(h)),k)b.graphicOverlay[e](t(k))}else b.graphic=f=c.g("point").attr({"class":b.getClassName()}).add(b.group||a.group),b.graphicOriginal=c[g](h).addClass("highcharts-partfill-original").add(f),
k&&(b.graphicOverlay=c[g](k).addClass("highcharts-partfill-overlay").add(f));b.graphicOriginal.attr(a.pointAttribs(b,m)).shadow(d.shadow,null,p);k&&(x(n)||(n={}),x(l.partialFill)&&(n=t(n,l.partialFill)),f=n.fill||v(a.color).brighten(-.3).get("rgb"),b.graphicOverlay.attr(a.pointAttribs(b,m)).attr("fill",f).attr("stroke-width",0).shadow(d.shadow,null,p))}else f&&(b.graphic=f.destroy())})}});b(d.prototype,"getSeriesExtremes",function(b){var d=this.series,c,e;b.call(this);this.isXAxis&&"xrange"===d.type&&
(c=a(this.dataMax,Number.MIN_VALUE),r(this.series,function(a){r(a.x2Data||[],function(a){a>c&&(c=a,e=!0)})}),e&&(this.dataMax=c))})})(p)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Gantt series
*
* (c) 2016 Lars A. V. Cabrera
*
* --- WORK IN PROGRESS ---
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2016 Highsoft AS
* Authors: Lars A. V. Cabrera
*
* License: www.highcharts.com/license
*/
var dateFormat = H.dateFormat,
each = H.each,
isObject = H.isObject,
pick = H.pick,
wrap = H.wrap,
Axis = H.Axis,
Chart = H.Chart,
Tick = H.Tick;
// Enum for which side the axis is on.
// Maps to axis.side
var axisSide = {
top: 0,
right: 1,
bottom: 2,
left: 3,
0: 'top',
1: 'right',
2: 'bottom',
3: 'left'
};
/**
* Checks if an axis is the outer axis in its dimension. Since
* axes are placed outwards in order, the axis with the highest
* index is the outermost axis.
*
* Example: If there are multiple x-axes at the top of the chart,
* this function returns true if the axis supplied is the last
* of the x-axes.
*
* @return true if the axis is the outermost axis in its dimension;
* false if not
*/
Axis.prototype.isOuterAxis = function() {
var axis = this,
thisIndex = -1,
isOuter = true;
each(this.chart.axes, function(otherAxis, index) {
if (otherAxis.side === axis.side) {
if (otherAxis === axis) {
// Get the index of the axis in question
thisIndex = index;
// Check thisIndex >= 0 in case thisIndex has
// not been found yet
} else if (thisIndex >= 0 && index > thisIndex) {
// There was an axis on the same side with a
// higher index. Exit the loop.
isOuter = false;
return;
}
}
});
// There were either no other axes on the same side,
// or the other axes were not farther from the chart
return isOuter;
};
/**
* Shortcut function to Tick.label.getBBox().width.
*
* @return {number} width - the width of the tick label
*/
Tick.prototype.getLabelWidth = function() {
return this.label.getBBox().width;
};
/**
* Get the maximum label length.
* This function can be used in states where the axis.maxLabelLength has not
* been set.
*
* @param {boolean} force - Optional parameter to force a new calculation, even
* if a value has already been set
* @return {number} maxLabelLength - the maximum label length of the axis
*/
Axis.prototype.getMaxLabelLength = function(force) {
var tickPositions = this.tickPositions,
ticks = this.ticks,
maxLabelLength = 0;
if (!this.maxLabelLength || force) {
each(tickPositions, function(tick) {
tick = ticks[tick];
if (tick && tick.labelLength > maxLabelLength) {
maxLabelLength = tick.labelLength;
}
});
this.maxLabelLength = maxLabelLength;
}
return this.maxLabelLength;
};
/**
* Adds the axis defined in axis.options.title
*/
Axis.prototype.addTitle = function() {
var axis = this,
renderer = axis.chart.renderer,
axisParent = axis.axisParent,
horiz = axis.horiz,
opposite = axis.opposite,
options = axis.options,
axisTitleOptions = options.title,
hasData,
showAxis,
textAlign;
// For reuse in Axis.render
hasData = axis.hasData();
axis.showAxis = showAxis = hasData || pick(options.showEmpty, true);
// Disregard title generation in original Axis.getOffset()
options.title = '';
if (!axis.axisTitle) {
textAlign = axisTitleOptions.textAlign;
if (!textAlign) {
textAlign = (horiz ? {
low: 'left',
middle: 'center',
high: 'right'
} : {
low: opposite ? 'right' : 'left',
middle: 'center',
high: opposite ? 'left' : 'right'
})[axisTitleOptions.align];
}
axis.axisTitle = renderer.text(
axisTitleOptions.text,
0,
0,
axisTitleOptions.useHTML
)
.attr({
zIndex: 7,
rotation: axisTitleOptions.rotation || 0,
align: textAlign
})
.addClass('highcharts-axis-title')
.css(axisTitleOptions.style)
// Add to axisParent instead of axisGroup, to ignore the space
// it takes
.add(axisParent);
axis.axisTitle.isNew = true;
}
// hide or show the title depending on whether showEmpty is set
axis.axisTitle[showAxis ? 'show' : 'hide'](true);
};
/**
* Add custom date formats
*/
H.dateFormats = {
// Week number
W: function(timestamp) {
var date = new Date(timestamp),
day = date.getUTCDay() === 0 ? 7 : date.getUTCDay(),
time = date.getTime(),
startOfYear = new Date(date.getUTCFullYear(), 0, 1, -6),
dayNumber;
date.setDate(date.getUTCDate() + 4 - day);
dayNumber = Math.floor((time - startOfYear) / 86400000);
return 1 + Math.floor(dayNumber / 7);
},
// First letter of the day of the week, e.g. 'M' for 'Monday'.
E: function(timestamp) {
return dateFormat('%a', timestamp, true).charAt(0);
}
};
/**
* Prevents adding the last tick label if the axis is not a category axis.
*
* Since numeric labels are normally placed at starts and ends of a range of
* value, and this module makes the label point at the value, an "extra" label
* would appear.
*
* @param {function} proceed - the original function
*/
wrap(Tick.prototype, 'addLabel', function(proceed) {
var axis = this.axis,
isCategoryAxis = axis.options.categories !== undefined,
tickPositions = axis.tickPositions,
lastTick = tickPositions[tickPositions.length - 1],
isLastTick = this.pos !== lastTick;
if (!axis.options.grid || isCategoryAxis || isLastTick) {
proceed.apply(this);
}
});
/**
* Center tick labels vertically and horizontally between ticks
*
* @param {function} proceed - the original function
*
* @return {object} object - an object containing x and y positions
* for the tick
*/
wrap(Tick.prototype, 'getLabelPosition', function(proceed, x, y, label) {
var retVal = proceed.apply(this, Array.prototype.slice.call(arguments, 1)),
axis = this.axis,
options = axis.options,
tickInterval = options.tickInterval || 1,
newX,
newPos,
axisHeight,
fontSize,
labelMetrics,
lblB,
lblH,
labelCenter;
// Only center tick labels if axis has option grid: true
if (options.grid) {
fontSize = options.labels.style.fontSize;
labelMetrics = axis.chart.renderer.fontMetrics(fontSize, label);
lblB = labelMetrics.b;
lblH = labelMetrics.h;
if (axis.horiz && options.categories === undefined) {
// Center x position
axisHeight = axis.axisGroup.getBBox().height;
newPos = this.pos + tickInterval / 2;
retVal.x = axis.translate(newPos) + axis.left;
labelCenter = (axisHeight / 2) + (lblH / 2) - Math.abs(lblH - lblB);
// Center y position
if (axis.side === axisSide.top) {
retVal.y = y - labelCenter;
} else {
retVal.y = y + labelCenter;
}
} else {
// Center y position
if (options.categories === undefined) {
newPos = this.pos + (tickInterval / 2);
retVal.y = axis.translate(newPos) + axis.top + (lblB / 2);
}
// Center x position
newX = (this.getLabelWidth() / 2) - (axis.maxLabelLength / 2);
if (axis.side === axisSide.left) {
retVal.x += newX;
} else {
retVal.x -= newX;
}
}
}
return retVal;
});
/**
* Draw vertical ticks extra long to create cell floors and roofs.
* Overrides the tickLength for vertical axes.
*
* @param {function} proceed - the original function
* @returns {array} retVal -
*/
wrap(Axis.prototype, 'tickSize', function(proceed) {
var axis = this,
retVal = proceed.apply(axis, Array.prototype.slice.call(arguments, 1)),
labelPadding,
distance;
if (axis.options.grid && !axis.horiz) {
labelPadding = (Math.abs(axis.defaultLeftAxisOptions.labels.x) * 2);
if (!axis.maxLabelLength) {
axis.maxLabelLength = axis.getMaxLabelLength();
}
distance = axis.maxLabelLength + labelPadding;
retVal[0] = distance;
}
return retVal;
});
/**
* Disregards space required by axisTitle, by adding axisTitle to axisParent
* instead of axisGroup, and disregarding margins and offsets related to
* axisTitle.
*
* @param {function} proceed - the original function
*/
wrap(Axis.prototype, 'getOffset', function(proceed) {
var axis = this,
axisOffset = axis.chart.axisOffset,
side = axis.side,
axisHeight,
tickSize,
options = axis.options,
axisTitleOptions = options.title,
addTitle = axisTitleOptions &&
axisTitleOptions.text &&
axisTitleOptions.enabled !== false;
if (axis.options.grid && isObject(axis.options.title)) {
tickSize = axis.tickSize('tick')[0];
if (axisOffset[side] && tickSize) {
axisHeight = axisOffset[side] + tickSize;
}
if (addTitle) {
// Use the custom addTitle() to add it, while preventing making room
// for it
axis.addTitle();
}
proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
axisOffset[side] = pick(axisHeight, axisOffset[side]);
// Put axis options back after original Axis.getOffset() has been called
options.title = axisTitleOptions;
} else {
proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
}
});
/**
* Prevents rotation of labels when squished, as rotating them would not
* help.
*
* @param {function} proceed - the original function
*/
wrap(Axis.prototype, 'renderUnsquish', function(proceed) {
if (this.options.grid) {
this.labelRotation = 0;
this.options.labels.rotation = 0;
}
proceed.apply(this);
});
/**
* Places leftmost tick at the start of the axis, to create a left wall.
*
* @param {function} proceed - the original function
*/
wrap(Axis.prototype, 'setOptions', function(proceed, userOptions) {
var axis = this;
if (userOptions.grid && axis.horiz) {
userOptions.startOnTick = true;
userOptions.minPadding = 0;
userOptions.endOnTick = true;
}
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
});
/**
* Draw an extra line on the far side of the the axisLine,
* creating cell roofs of a grid.
*
* @param {function} proceed - the original function
*/
wrap(Axis.prototype, 'render', function(proceed) {
var axis = this,
options = axis.options,
labelPadding,
distance,
lineWidth,
linePath,
yStartIndex,
yEndIndex,
xStartIndex,
xEndIndex,
renderer = axis.chart.renderer,
axisGroupBox;
if (options.grid) {
labelPadding = (Math.abs(axis.defaultLeftAxisOptions.labels.x) * 2);
distance = axis.maxLabelLength + labelPadding;
lineWidth = options.lineWidth;
// Remove right wall before rendering
if (axis.rightWall) {
axis.rightWall.destroy();
}
// Call original Axis.render() to obtain axis.axisLine and
// axis.axisGroup
proceed.apply(axis);
axisGroupBox = axis.axisGroup.getBBox();
// Add right wall on horizontal axes
if (axis.horiz) {
axis.rightWall = renderer.path([
'M',
axisGroupBox.x + axis.width + 1, // account for left wall
axisGroupBox.y,
'L',
axisGroupBox.x + axis.width + 1, // account for left wall
axisGroupBox.y + axisGroupBox.height
])
.attr({
stroke: options.tickColor || '#ccd6eb',
'stroke-width': options.tickWidth || 1,
zIndex: 7,
class: 'grid-wall'
})
.add(axis.axisGroup);
}
if (axis.isOuterAxis() && axis.axisLine) {
if (axis.horiz) {
// -1 to avoid adding distance each time the chart updates
distance = axisGroupBox.height - 1;
}
if (lineWidth) {
linePath = axis.getLinePath(lineWidth);
xStartIndex = linePath.indexOf('M') + 1;
xEndIndex = linePath.indexOf('L') + 1;
yStartIndex = linePath.indexOf('M') + 2;
yEndIndex = linePath.indexOf('L') + 2;
// Negate distance if top or left axis
if (axis.side === axisSide.top || axis.side === axisSide.left) {
distance = -distance;
}
// If axis is horizontal, reposition line path vertically
if (axis.horiz) {
linePath[yStartIndex] = linePath[yStartIndex] + distance;
linePath[yEndIndex] = linePath[yEndIndex] + distance;
} else {
// If axis is vertical, reposition line path horizontally
linePath[xStartIndex] = linePath[xStartIndex] + distance;
linePath[xEndIndex] = linePath[xEndIndex] + distance;
}
if (!axis.axisLineExtra) {
axis.axisLineExtra = renderer.path(linePath)
.attr({
stroke: options.lineColor,
'stroke-width': lineWidth,
zIndex: 7
})
.add(axis.axisGroup);
} else {
axis.axisLineExtra.animate({
d: linePath
});
}
// show or hide the line depending on options.showEmpty
axis.axisLine[axis.showAxis ? 'show' : 'hide'](true);
}
}
} else {
proceed.apply(axis);
}
});
/**
* Wraps chart rendering with the following customizations:
* 1. Prohibit timespans of multitudes of a time unit
* 2. Draw cell walls on vertical axes
*
* @param {function} proceed - the original function
*/
wrap(Chart.prototype, 'render', function(proceed) {
// 25 is optimal height for default fontSize (11px)
// 25 / 11 ≈ 2.28
var fontSizeToCellHeightRatio = 25 / 11,
fontMetrics,
fontSize;
each(this.axes, function(axis) {
var options = axis.options;
if (options.grid) {
fontSize = options.labels.style.fontSize;
fontMetrics = axis.chart.renderer.fontMetrics(fontSize);
// Prohibit timespans of multitudes of a time unit,
// e.g. two days, three weeks, etc.
if (options.type === 'datetime') {
options.units = [
['millisecond', [1]],
['second', [1]],
['minute', [1]],
['hour', [1]],
['day', [1]],
['week', [1]],
['month', [1]],
['year', null]
];
}
// Make tick marks taller, creating cell walls of a grid.
// Use cellHeight axis option if set
if (axis.horiz) {
options.tickLength = options.cellHeight ||
fontMetrics.h * fontSizeToCellHeightRatio;
} else {
options.tickWidth = 1;
if (!options.lineWidth) {
options.lineWidth = 1;
}
}
}
});
// Call original Chart.render()
proceed.apply(this);
});
}(Highcharts));
(function(H) {
/**
* (c) 2014-2017 Highsoft AS
* Authors: Torstein Honsi, Lars A. V. Cabrera
*
* License: www.highcharts.com/license
*/
var defaultPlotOptions = H.getOptions().plotOptions,
color = H.Color,
columnType = H.seriesTypes.column,
each = H.each,
extendClass = H.extendClass,
isNumber = H.isNumber,
isObject = H.isObject,
merge = H.merge,
pick = H.pick,
seriesTypes = H.seriesTypes,
wrap = H.wrap,
Axis = H.Axis,
Point = H.Point,
Series = H.Series,
pointFormat = '<span style="color:{point.color}">' +
'\u25CF' +
'</span> {series.name}: <b>{point.yCategory}</b><br/>',
xrange = 'xrange';
defaultPlotOptions.xrange = merge(defaultPlotOptions.column, {
tooltip: {
pointFormat: pointFormat
}
});
seriesTypes.xrange = extendClass(columnType, {
pointClass: extendClass(Point, {
// Add x2 and yCategory to the available properties for tooltip formats
getLabelConfig: function() {
var cfg = Point.prototype.getLabelConfig.call(this);
cfg.x2 = this.x2;
cfg.yCategory = this.yCategory = this.series.yAxis.categories && this.series.yAxis.categories[this.y];
return cfg;
}
}),
type: xrange,
forceDL: true,
parallelArrays: ['x', 'x2', 'y'],
requireSorting: false,
animate: seriesTypes.line.prototype.animate,
/**
* Borrow the column series metrics, but with swapped axes. This gives free access
* to features like groupPadding, grouping, pointWidth etc.
*/
getColumnMetrics: function() {
var metrics,
chart = this.chart;
function swapAxes() {
each(chart.series, function(s) {
var xAxis = s.xAxis;
s.xAxis = s.yAxis;
s.yAxis = xAxis;
});
}
swapAxes();
this.yAxis.closestPointRange = 1;
metrics = columnType.prototype.getColumnMetrics.call(this);
swapAxes();
return metrics;
},
/**
* Override cropData to show a point where x is outside visible range
* but x2 is outside.
*/
cropData: function(xData, yData, min, max) {
// Replace xData with x2Data to find the appropriate cropStart
var cropData = Series.prototype.cropData,
crop = cropData.call(this, this.x2Data, yData, min, max);
// Re-insert the cropped xData
crop.xData = xData.slice(crop.start, crop.end);
return crop;
},
translate: function() {
columnType.prototype.translate.apply(this, arguments);
var series = this,
xAxis = series.xAxis,
metrics = series.columnMetrics,
minPointLength = series.options.minPointLength || 0;
each(series.points, function(point) {
var plotX = point.plotX,
posX = pick(point.x2, point.x + (point.len || 0)),
plotX2 = xAxis.toPixels(posX, true),
width = plotX2 - plotX,
widthDifference,
shapeArgs,
partialFill;
if (minPointLength) {
widthDifference = minPointLength - width;
if (widthDifference < 0) {
widthDifference = 0;
}
plotX -= widthDifference / 2;
plotX2 += widthDifference / 2;
}
plotX = Math.max(plotX, -10);
plotX2 = Math.min(Math.max(plotX2, -10), xAxis.len + 10);
if (plotX2 < plotX) { // #6107
plotX2 = plotX;
}
point.shapeArgs = {
x: plotX,
y: point.plotY + metrics.offset,
width: plotX2 - plotX,
height: metrics.width
};
point.tooltipPos[0] += width / 2;
point.tooltipPos[1] -= metrics.width / 2;
// Add a partShapeArgs to the point, based on the shapeArgs property
partialFill = point.partialFill;
if (partialFill) {
// Get the partial fill amount
if (isObject(partialFill)) {
partialFill = partialFill.amount;
}
// If it was not a number, assume 0
if (!isNumber(partialFill)) {
partialFill = 0;
}
shapeArgs = point.shapeArgs;
point.partShapeArgs = {
x: shapeArgs.x,
y: shapeArgs.y + 1,
width: shapeArgs.width * partialFill,
height: shapeArgs.height - 2
};
}
});
},
drawPoints: function() {
var series = this,
chart = this.chart,
options = series.options,
renderer = chart.renderer,
animationLimit = options.animationLimit || 250,
verb = chart.pointCount < animationLimit ? 'animate' : 'attr';
// draw the columns
each(series.points, function(point) {
var plotY = point.plotY,
graphic = point.graphic,
type = point.shapeType,
shapeArgs = point.shapeArgs,
partShapeArgs = point.partShapeArgs,
seriesOpts = series.options,
pfOptions = point.partialFill,
fill,
state = point.selected && 'select',
cutOff = options.stacking && !options.borderRadius;
if (isNumber(plotY) && point.y !== null) {
if (graphic) { // update
point.graphicOriginal[verb](
merge(shapeArgs)
);
if (partShapeArgs) {
point.graphicOverlay[verb](
merge(partShapeArgs)
);
}
} else {
point.graphic = graphic = renderer.g('point')
.attr({
'class': point.getClassName()
})
.add(point.group || series.group);
point.graphicOriginal = renderer[type](shapeArgs)
.addClass('highcharts-partfill-original')
.add(graphic);
if (partShapeArgs) {
point.graphicOverlay = renderer[type](partShapeArgs)
.addClass('highcharts-partfill-overlay')
.add(graphic);
}
}
// Presentational
point.graphicOriginal
.attr(series.pointAttribs(point, state))
.shadow(options.shadow, null, cutOff);
if (partShapeArgs) {
// Ensure pfOptions is an object
if (!isObject(pfOptions)) {
pfOptions = {};
}
if (isObject(seriesOpts.partialFill)) {
pfOptions = merge(pfOptions, seriesOpts.partialFill);
}
fill = pfOptions.fill ||
color(series.color).brighten(-0.3).get('rgb');
point.graphicOverlay
.attr(series.pointAttribs(point, state))
.attr('fill', fill)
.attr('stroke-width', 0)
.shadow(options.shadow, null, cutOff);
}
} else if (graphic) {
point.graphic = graphic.destroy(); // #1269
}
});
}
});
/**
* Max x2 should be considered in xAxis extremes
*/
wrap(Axis.prototype, 'getSeriesExtremes', function(proceed) {
var axis = this,
series = axis.series,
dataMax,
modMax;
proceed.call(this);
if (axis.isXAxis && series.type === xrange) {
dataMax = pick(axis.dataMax, Number.MIN_VALUE);
each(this.series, function(series) {
each(series.x2Data || [], function(val) {
if (val > dataMax) {
dataMax = val;
modMax = true;
}
});
});
if (modMax) {
axis.dataMax = dataMax;
}
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2016 Highsoft AS
* Authors: Lars A. V. Cabrera
*
* License: www.highcharts.com/license
*/
//
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
GridAxis
(c) 2016 Lars A. V. Cabrera
--- WORK IN PROGRESS ---
License: www.highcharts.com/license
*/
(function(n){"object"===typeof module&&module.exports?module.exports=n:n(Highcharts)})(function(n){(function(h){var n=h.dateFormat,p=h.each,t=h.isObject,r=h.pick,l=h.wrap,m=h.Axis,u=h.Chart,q=h.Tick;m.prototype.isOuterAxis=function(){var a=this,c=-1,b=!0;p(this.chart.axes,function(e,f){e.side===a.side&&(e===a?c=f:0<=c&&f>c&&(b=!1))});return b};q.prototype.getLabelWidth=function(){return this.label.getBBox().width};m.prototype.getMaxLabelLength=function(a){var c=this.tickPositions,b=this.ticks,e=0;
if(!this.maxLabelLength||a)p(c,function(a){(a=b[a])&&a.labelLength>e&&(e=a.labelLength)}),this.maxLabelLength=e;return this.maxLabelLength};m.prototype.addTitle=function(){var a=this.chart.renderer,c=this.axisParent,b=this.horiz,e=this.opposite,f=this.options,d=f.title,g;this.showAxis=g=this.hasData()||r(f.showEmpty,!0);f.title="";this.axisTitle||((f=d.textAlign)||(f=(b?{low:"left",middle:"center",high:"right"}:{low:e?"right":"left",middle:"center",high:e?"left":"right"})[d.align]),this.axisTitle=
a.text(d.text,0,0,d.useHTML).attr({zIndex:7,rotation:d.rotation||0,align:f}).addClass("highcharts-axis-title").css(d.style).add(c),this.axisTitle.isNew=!0);this.axisTitle[g?"show":"hide"](!0)};h.dateFormats={W:function(a){a=new Date(a);var c=0===a.getUTCDay()?7:a.getUTCDay(),b=a.getTime(),e=new Date(a.getUTCFullYear(),0,1,-6);a.setDate(a.getUTCDate()+4-c);return 1+Math.floor(Math.floor((b-e)/864E5)/7)},E:function(a){return n("%a",a,!0).charAt(0)}};l(q.prototype,"addLabel",function(a){var c=this.axis,
b=void 0!==c.options.categories,e=c.tickPositions,e=this.pos!==e[e.length-1];(!c.options.grid||b||e)&&a.apply(this)});l(q.prototype,"getLabelPosition",function(a,c,b,e){var f=a.apply(this,Array.prototype.slice.call(arguments,1)),d=this.axis,g=d.options,k=g.tickInterval||1,h,l;g.grid&&(h=g.labels.style.fontSize,l=d.chart.renderer.fontMetrics(h,e),h=l.b,l=l.h,d.horiz&&void 0===g.categories?(g=d.axisGroup.getBBox().height,k=this.pos+k/2,f.x=d.translate(k)+d.left,k=g/2+l/2-Math.abs(l-h),f.y=0===d.side?
b-k:b+k):(void 0===g.categories&&(k=this.pos+k/2,f.y=d.translate(k)+d.top+h/2),k=this.getLabelWidth()/2-d.maxLabelLength/2,f.x=3===d.side?f.x+k:f.x-k));return f});l(m.prototype,"tickSize",function(a){var c=a.apply(this,Array.prototype.slice.call(arguments,1)),b;this.options.grid&&!this.horiz&&(b=2*Math.abs(this.defaultLeftAxisOptions.labels.x),this.maxLabelLength||(this.maxLabelLength=this.getMaxLabelLength()),b=this.maxLabelLength+b,c[0]=b);return c});l(m.prototype,"getOffset",function(a){var c=
this.chart.axisOffset,b=this.side,e,f,d=this.options,g=d.title,k=g&&g.text&&!1!==g.enabled;this.options.grid&&t(this.options.title)?(f=this.tickSize("tick")[0],c[b]&&f&&(e=c[b]+f),k&&this.addTitle(),a.apply(this,Array.prototype.slice.call(arguments,1)),c[b]=r(e,c[b]),d.title=g):a.apply(this,Array.prototype.slice.call(arguments,1))});l(m.prototype,"renderUnsquish",function(a){this.options.grid&&(this.labelRotation=0,this.options.labels.rotation=0);a.apply(this)});l(m.prototype,"setOptions",function(a,
c){c.grid&&this.horiz&&(c.startOnTick=!0,c.minPadding=0,c.endOnTick=!0);a.apply(this,Array.prototype.slice.call(arguments,1))});l(m.prototype,"render",function(a){var c=this.options,b,e,f,d,g,k,h=this.chart.renderer;if(c.grid){if(b=2*Math.abs(this.defaultLeftAxisOptions.labels.x),b=this.maxLabelLength+b,e=c.lineWidth,this.rightWall&&this.rightWall.destroy(),a.apply(this),a=this.axisGroup.getBBox(),this.horiz&&(this.rightWall=h.path(["M",a.x+this.width+1,a.y,"L",a.x+this.width+1,a.y+a.height]).attr({stroke:c.tickColor||
"#ccd6eb","stroke-width":c.tickWidth||1,zIndex:7,class:"grid-wall"}).add(this.axisGroup)),this.isOuterAxis()&&this.axisLine&&(this.horiz&&(b=a.height-1),e)){a=this.getLinePath(e);g=a.indexOf("M")+1;k=a.indexOf("L")+1;f=a.indexOf("M")+2;d=a.indexOf("L")+2;if(0===this.side||3===this.side)b=-b;this.horiz?(a[f]+=b,a[d]+=b):(a[g]+=b,a[k]+=b);this.axisLineExtra?this.axisLineExtra.animate({d:a}):this.axisLineExtra=h.path(a).attr({stroke:c.lineColor,"stroke-width":e,zIndex:7}).add(this.axisGroup);this.axisLine[this.showAxis?
"show":"hide"](!0)}}else a.apply(this)});l(u.prototype,"render",function(a){var c=25/11,b,e;p(this.axes,function(a){var d=a.options;d.grid&&(e=d.labels.style.fontSize,b=a.chart.renderer.fontMetrics(e),"datetime"===d.type&&(d.units=[["millisecond",[1]],["second",[1]],["minute",[1]],["hour",[1]],["day",[1]],["week",[1]],["month",[1]],["year",null]]),a.horiz?d.tickLength=d.cellHeight||b.h*c:(d.tickWidth=1,d.lineWidth||(d.lineWidth=1)))});a.apply(this)})})(n)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* GridAxis
*
* (c) 2016 Lars A. V. Cabrera
*
* --- WORK IN PROGRESS ---
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2016 Highsoft AS
* Authors: Lars A. V. Cabrera
*
* License: www.highcharts.com/license
*/
var dateFormat = H.dateFormat,
each = H.each,
isObject = H.isObject,
pick = H.pick,
wrap = H.wrap,
Axis = H.Axis,
Chart = H.Chart,
Tick = H.Tick;
// Enum for which side the axis is on.
// Maps to axis.side
var axisSide = {
top: 0,
right: 1,
bottom: 2,
left: 3,
0: 'top',
1: 'right',
2: 'bottom',
3: 'left'
};
/**
* Checks if an axis is the outer axis in its dimension. Since
* axes are placed outwards in order, the axis with the highest
* index is the outermost axis.
*
* Example: If there are multiple x-axes at the top of the chart,
* this function returns true if the axis supplied is the last
* of the x-axes.
*
* @return true if the axis is the outermost axis in its dimension;
* false if not
*/
Axis.prototype.isOuterAxis = function() {
var axis = this,
thisIndex = -1,
isOuter = true;
each(this.chart.axes, function(otherAxis, index) {
if (otherAxis.side === axis.side) {
if (otherAxis === axis) {
// Get the index of the axis in question
thisIndex = index;
// Check thisIndex >= 0 in case thisIndex has
// not been found yet
} else if (thisIndex >= 0 && index > thisIndex) {
// There was an axis on the same side with a
// higher index. Exit the loop.
isOuter = false;
return;
}
}
});
// There were either no other axes on the same side,
// or the other axes were not farther from the chart
return isOuter;
};
/**
* Shortcut function to Tick.label.getBBox().width.
*
* @return {number} width - the width of the tick label
*/
Tick.prototype.getLabelWidth = function() {
return this.label.getBBox().width;
};
/**
* Get the maximum label length.
* This function can be used in states where the axis.maxLabelLength has not
* been set.
*
* @param {boolean} force - Optional parameter to force a new calculation, even
* if a value has already been set
* @return {number} maxLabelLength - the maximum label length of the axis
*/
Axis.prototype.getMaxLabelLength = function(force) {
var tickPositions = this.tickPositions,
ticks = this.ticks,
maxLabelLength = 0;
if (!this.maxLabelLength || force) {
each(tickPositions, function(tick) {
tick = ticks[tick];
if (tick && tick.labelLength > maxLabelLength) {
maxLabelLength = tick.labelLength;
}
});
this.maxLabelLength = maxLabelLength;
}
return this.maxLabelLength;
};
/**
* Adds the axis defined in axis.options.title
*/
Axis.prototype.addTitle = function() {
var axis = this,
renderer = axis.chart.renderer,
axisParent = axis.axisParent,
horiz = axis.horiz,
opposite = axis.opposite,
options = axis.options,
axisTitleOptions = options.title,
hasData,
showAxis,
textAlign;
// For reuse in Axis.render
hasData = axis.hasData();
axis.showAxis = showAxis = hasData || pick(options.showEmpty, true);
// Disregard title generation in original Axis.getOffset()
options.title = '';
if (!axis.axisTitle) {
textAlign = axisTitleOptions.textAlign;
if (!textAlign) {
textAlign = (horiz ? {
low: 'left',
middle: 'center',
high: 'right'
} : {
low: opposite ? 'right' : 'left',
middle: 'center',
high: opposite ? 'left' : 'right'
})[axisTitleOptions.align];
}
axis.axisTitle = renderer.text(
axisTitleOptions.text,
0,
0,
axisTitleOptions.useHTML
)
.attr({
zIndex: 7,
rotation: axisTitleOptions.rotation || 0,
align: textAlign
})
.addClass('highcharts-axis-title')
.css(axisTitleOptions.style)
// Add to axisParent instead of axisGroup, to ignore the space
// it takes
.add(axisParent);
axis.axisTitle.isNew = true;
}
// hide or show the title depending on whether showEmpty is set
axis.axisTitle[showAxis ? 'show' : 'hide'](true);
};
/**
* Add custom date formats
*/
H.dateFormats = {
// Week number
W: function(timestamp) {
var date = new Date(timestamp),
day = date.getUTCDay() === 0 ? 7 : date.getUTCDay(),
time = date.getTime(),
startOfYear = new Date(date.getUTCFullYear(), 0, 1, -6),
dayNumber;
date.setDate(date.getUTCDate() + 4 - day);
dayNumber = Math.floor((time - startOfYear) / 86400000);
return 1 + Math.floor(dayNumber / 7);
},
// First letter of the day of the week, e.g. 'M' for 'Monday'.
E: function(timestamp) {
return dateFormat('%a', timestamp, true).charAt(0);
}
};
/**
* Prevents adding the last tick label if the axis is not a category axis.
*
* Since numeric labels are normally placed at starts and ends of a range of
* value, and this module makes the label point at the value, an "extra" label
* would appear.
*
* @param {function} proceed - the original function
*/
wrap(Tick.prototype, 'addLabel', function(proceed) {
var axis = this.axis,
isCategoryAxis = axis.options.categories !== undefined,
tickPositions = axis.tickPositions,
lastTick = tickPositions[tickPositions.length - 1],
isLastTick = this.pos !== lastTick;
if (!axis.options.grid || isCategoryAxis || isLastTick) {
proceed.apply(this);
}
});
/**
* Center tick labels vertically and horizontally between ticks
*
* @param {function} proceed - the original function
*
* @return {object} object - an object containing x and y positions
* for the tick
*/
wrap(Tick.prototype, 'getLabelPosition', function(proceed, x, y, label) {
var retVal = proceed.apply(this, Array.prototype.slice.call(arguments, 1)),
axis = this.axis,
options = axis.options,
tickInterval = options.tickInterval || 1,
newX,
newPos,
axisHeight,
fontSize,
labelMetrics,
lblB,
lblH,
labelCenter;
// Only center tick labels if axis has option grid: true
if (options.grid) {
fontSize = options.labels.style.fontSize;
labelMetrics = axis.chart.renderer.fontMetrics(fontSize, label);
lblB = labelMetrics.b;
lblH = labelMetrics.h;
if (axis.horiz && options.categories === undefined) {
// Center x position
axisHeight = axis.axisGroup.getBBox().height;
newPos = this.pos + tickInterval / 2;
retVal.x = axis.translate(newPos) + axis.left;
labelCenter = (axisHeight / 2) + (lblH / 2) - Math.abs(lblH - lblB);
// Center y position
if (axis.side === axisSide.top) {
retVal.y = y - labelCenter;
} else {
retVal.y = y + labelCenter;
}
} else {
// Center y position
if (options.categories === undefined) {
newPos = this.pos + (tickInterval / 2);
retVal.y = axis.translate(newPos) + axis.top + (lblB / 2);
}
// Center x position
newX = (this.getLabelWidth() / 2) - (axis.maxLabelLength / 2);
if (axis.side === axisSide.left) {
retVal.x += newX;
} else {
retVal.x -= newX;
}
}
}
return retVal;
});
/**
* Draw vertical ticks extra long to create cell floors and roofs.
* Overrides the tickLength for vertical axes.
*
* @param {function} proceed - the original function
* @returns {array} retVal -
*/
wrap(Axis.prototype, 'tickSize', function(proceed) {
var axis = this,
retVal = proceed.apply(axis, Array.prototype.slice.call(arguments, 1)),
labelPadding,
distance;
if (axis.options.grid && !axis.horiz) {
labelPadding = (Math.abs(axis.defaultLeftAxisOptions.labels.x) * 2);
if (!axis.maxLabelLength) {
axis.maxLabelLength = axis.getMaxLabelLength();
}
distance = axis.maxLabelLength + labelPadding;
retVal[0] = distance;
}
return retVal;
});
/**
* Disregards space required by axisTitle, by adding axisTitle to axisParent
* instead of axisGroup, and disregarding margins and offsets related to
* axisTitle.
*
* @param {function} proceed - the original function
*/
wrap(Axis.prototype, 'getOffset', function(proceed) {
var axis = this,
axisOffset = axis.chart.axisOffset,
side = axis.side,
axisHeight,
tickSize,
options = axis.options,
axisTitleOptions = options.title,
addTitle = axisTitleOptions &&
axisTitleOptions.text &&
axisTitleOptions.enabled !== false;
if (axis.options.grid && isObject(axis.options.title)) {
tickSize = axis.tickSize('tick')[0];
if (axisOffset[side] && tickSize) {
axisHeight = axisOffset[side] + tickSize;
}
if (addTitle) {
// Use the custom addTitle() to add it, while preventing making room
// for it
axis.addTitle();
}
proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
axisOffset[side] = pick(axisHeight, axisOffset[side]);
// Put axis options back after original Axis.getOffset() has been called
options.title = axisTitleOptions;
} else {
proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
}
});
/**
* Prevents rotation of labels when squished, as rotating them would not
* help.
*
* @param {function} proceed - the original function
*/
wrap(Axis.prototype, 'renderUnsquish', function(proceed) {
if (this.options.grid) {
this.labelRotation = 0;
this.options.labels.rotation = 0;
}
proceed.apply(this);
});
/**
* Places leftmost tick at the start of the axis, to create a left wall.
*
* @param {function} proceed - the original function
*/
wrap(Axis.prototype, 'setOptions', function(proceed, userOptions) {
var axis = this;
if (userOptions.grid && axis.horiz) {
userOptions.startOnTick = true;
userOptions.minPadding = 0;
userOptions.endOnTick = true;
}
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
});
/**
* Draw an extra line on the far side of the the axisLine,
* creating cell roofs of a grid.
*
* @param {function} proceed - the original function
*/
wrap(Axis.prototype, 'render', function(proceed) {
var axis = this,
options = axis.options,
labelPadding,
distance,
lineWidth,
linePath,
yStartIndex,
yEndIndex,
xStartIndex,
xEndIndex,
renderer = axis.chart.renderer,
axisGroupBox;
if (options.grid) {
labelPadding = (Math.abs(axis.defaultLeftAxisOptions.labels.x) * 2);
distance = axis.maxLabelLength + labelPadding;
lineWidth = options.lineWidth;
// Remove right wall before rendering
if (axis.rightWall) {
axis.rightWall.destroy();
}
// Call original Axis.render() to obtain axis.axisLine and
// axis.axisGroup
proceed.apply(axis);
axisGroupBox = axis.axisGroup.getBBox();
// Add right wall on horizontal axes
if (axis.horiz) {
axis.rightWall = renderer.path([
'M',
axisGroupBox.x + axis.width + 1, // account for left wall
axisGroupBox.y,
'L',
axisGroupBox.x + axis.width + 1, // account for left wall
axisGroupBox.y + axisGroupBox.height
])
.attr({
stroke: options.tickColor || '#ccd6eb',
'stroke-width': options.tickWidth || 1,
zIndex: 7,
class: 'grid-wall'
})
.add(axis.axisGroup);
}
if (axis.isOuterAxis() && axis.axisLine) {
if (axis.horiz) {
// -1 to avoid adding distance each time the chart updates
distance = axisGroupBox.height - 1;
}
if (lineWidth) {
linePath = axis.getLinePath(lineWidth);
xStartIndex = linePath.indexOf('M') + 1;
xEndIndex = linePath.indexOf('L') + 1;
yStartIndex = linePath.indexOf('M') + 2;
yEndIndex = linePath.indexOf('L') + 2;
// Negate distance if top or left axis
if (axis.side === axisSide.top || axis.side === axisSide.left) {
distance = -distance;
}
// If axis is horizontal, reposition line path vertically
if (axis.horiz) {
linePath[yStartIndex] = linePath[yStartIndex] + distance;
linePath[yEndIndex] = linePath[yEndIndex] + distance;
} else {
// If axis is vertical, reposition line path horizontally
linePath[xStartIndex] = linePath[xStartIndex] + distance;
linePath[xEndIndex] = linePath[xEndIndex] + distance;
}
if (!axis.axisLineExtra) {
axis.axisLineExtra = renderer.path(linePath)
.attr({
stroke: options.lineColor,
'stroke-width': lineWidth,
zIndex: 7
})
.add(axis.axisGroup);
} else {
axis.axisLineExtra.animate({
d: linePath
});
}
// show or hide the line depending on options.showEmpty
axis.axisLine[axis.showAxis ? 'show' : 'hide'](true);
}
}
} else {
proceed.apply(axis);
}
});
/**
* Wraps chart rendering with the following customizations:
* 1. Prohibit timespans of multitudes of a time unit
* 2. Draw cell walls on vertical axes
*
* @param {function} proceed - the original function
*/
wrap(Chart.prototype, 'render', function(proceed) {
// 25 is optimal height for default fontSize (11px)
// 25 / 11 ≈ 2.28
var fontSizeToCellHeightRatio = 25 / 11,
fontMetrics,
fontSize;
each(this.axes, function(axis) {
var options = axis.options;
if (options.grid) {
fontSize = options.labels.style.fontSize;
fontMetrics = axis.chart.renderer.fontMetrics(fontSize);
// Prohibit timespans of multitudes of a time unit,
// e.g. two days, three weeks, etc.
if (options.type === 'datetime') {
options.units = [
['millisecond', [1]],
['second', [1]],
['minute', [1]],
['hour', [1]],
['day', [1]],
['week', [1]],
['month', [1]],
['year', null]
];
}
// Make tick marks taller, creating cell walls of a grid.
// Use cellHeight axis option if set
if (axis.horiz) {
options.tickLength = options.cellHeight ||
fontMetrics.h * fontSizeToCellHeightRatio;
} else {
options.tickWidth = 1;
if (!options.lineWidth) {
options.lineWidth = 1;
}
}
}
});
// Call original Chart.render()
proceed.apply(this);
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
(c) 2009-2017 Torstein Honsi
License: www.highcharts.com/license
*/
(function(n){"object"===typeof module&&module.exports?module.exports=n:n(Highcharts)})(function(n){(function(c){var k=c.Axis,r=c.Chart,m=c.color,l,e=c.each,v=c.extend,w=c.isNumber,p=c.Legend,f=c.LegendSymbolMixin,x=c.noop,q=c.merge,u=c.pick,t=c.wrap;l=c.ColorAxis=function(){this.init.apply(this,arguments)};v(l.prototype,k.prototype);v(l.prototype,{defaultColorAxisOptions:{lineWidth:0,minPadding:0,maxPadding:0,gridLineWidth:1,tickPixelInterval:72,startOnTick:!0,endOnTick:!0,offset:0,marker:{animation:{duration:50},
width:.01,color:"#999999"},labels:{overflow:"justify",rotation:0},minColor:"#e6ebf5",maxColor:"#003399",tickLength:5,showInLegend:!0},keepProps:["legendGroup","legendItemHeight","legendItemWidth","legendItem","legendSymbol"].concat(k.prototype.keepProps),init:function(a,b){var d="vertical"!==a.options.legend.layout,g;this.coll="colorAxis";g=q(this.defaultColorAxisOptions,{side:d?2:1,reversed:!d},b,{opposite:!d,showEmpty:!1,title:null});k.prototype.init.call(this,a,g);b.dataClasses&&this.initDataClasses(b);
this.initStops(b);this.horiz=d;this.zoomEnabled=!1;this.defaultLegendLength=200},tweenColors:function(a,b,d){var g;b.rgba.length&&a.rgba.length?(a=a.rgba,b=b.rgba,g=1!==b[3]||1!==a[3],a=(g?"rgba(":"rgb(")+Math.round(b[0]+(a[0]-b[0])*(1-d))+","+Math.round(b[1]+(a[1]-b[1])*(1-d))+","+Math.round(b[2]+(a[2]-b[2])*(1-d))+(g?","+(b[3]+(a[3]-b[3])*(1-d)):"")+")"):a=b.input||"none";return a},initDataClasses:function(a){var b=this,d=this.chart,g,h=0,c=d.options.chart.colorCount,y=this.options,f=a.dataClasses.length;
this.dataClasses=g=[];this.legendItems=[];e(a.dataClasses,function(a,e){a=q(a);g.push(a);a.color||("category"===y.dataClassColor?(e=d.options.colors,c=e.length,a.color=e[h],a.colorIndex=h,h++,h===c&&(h=0)):a.color=b.tweenColors(m(y.minColor),m(y.maxColor),2>f?.5:e/(f-1)))})},initStops:function(a){this.stops=a.stops||[[0,this.options.minColor],[1,this.options.maxColor]];e(this.stops,function(a){a.color=m(a[1])})},setOptions:function(a){k.prototype.setOptions.call(this,a);this.options.crosshair=this.options.marker},
setAxisSize:function(){var a=this.legendSymbol,b=this.chart,d=b.options.legend||{},g,h;a?(this.left=d=a.attr("x"),this.top=g=a.attr("y"),this.width=h=a.attr("width"),this.height=a=a.attr("height"),this.right=b.chartWidth-d-h,this.bottom=b.chartHeight-g-a,this.len=this.horiz?h:a,this.pos=this.horiz?d:g):this.len=(this.horiz?d.symbolWidth:d.symbolHeight)||this.defaultLegendLength},toColor:function(a,b){var d=this.stops,g,h,c=this.dataClasses,e,f;if(c)for(f=c.length;f--;){if(e=c[f],g=e.from,d=e.to,(void 0===
g||a>=g)&&(void 0===d||a<=d)){h=e.color;b&&(b.dataClass=f,b.colorIndex=e.colorIndex);break}}else{this.isLog&&(a=this.val2lin(a));a=1-(this.max-a)/(this.max-this.min||1);for(f=d.length;f--&&!(a>d[f][0]););g=d[f]||d[f+1];d=d[f+1]||g;a=1-(d[0]-a)/(d[0]-g[0]||1);h=this.tweenColors(g.color,d.color,a)}return h},getOffset:function(){var a=this.legendGroup,b=this.chart.axisOffset[this.side];a&&(this.axisParent=a,k.prototype.getOffset.call(this),this.added||(this.added=!0,this.labelLeft=0,this.labelRight=
this.width),this.chart.axisOffset[this.side]=b)},setLegendColor:function(){var a,b=this.options,d=this.reversed;a=d?1:0;d=d?0:1;a=this.horiz?[a,0,d,0]:[0,d,0,a];this.legendColor={linearGradient:{x1:a[0],y1:a[1],x2:a[2],y2:a[3]},stops:b.stops||[[0,b.minColor],[1,b.maxColor]]}},drawLegendSymbol:function(a,b){var d=a.padding,g=a.options,h=this.horiz,c=u(g.symbolWidth,h?this.defaultLegendLength:12),f=u(g.symbolHeight,h?12:this.defaultLegendLength),e=u(g.labelPadding,h?16:30),g=u(g.itemDistance,10);this.setLegendColor();
b.legendSymbol=this.chart.renderer.rect(0,a.baseline-11,c,f).attr({zIndex:1}).add(b.legendGroup);this.legendItemWidth=c+d+(h?g:e);this.legendItemHeight=f+d+(h?e:0)},setState:x,visible:!0,setVisible:x,getSeriesExtremes:function(){var a=this.series,b=a.length;this.dataMin=Infinity;for(this.dataMax=-Infinity;b--;)void 0!==a[b].valueMin&&(this.dataMin=Math.min(this.dataMin,a[b].valueMin),this.dataMax=Math.max(this.dataMax,a[b].valueMax))},drawCrosshair:function(a,b){var d=b&&b.plotX,c=b&&b.plotY,h,f=
this.pos,e=this.len;b&&(h=this.toPixels(b[b.series.colorKey]),h<f?h=f-2:h>f+e&&(h=f+e+2),b.plotX=h,b.plotY=this.len-h,k.prototype.drawCrosshair.call(this,a,b),b.plotX=d,b.plotY=c,this.cross&&(this.cross.addClass("highcharts-coloraxis-marker").add(this.legendGroup),this.cross.attr({fill:this.crosshair.color})))},getPlotLinePath:function(a,b,d,c,h){return w(h)?this.horiz?["M",h-4,this.top-6,"L",h+4,this.top-6,h,this.top,"Z"]:["M",this.left,h,"L",this.left-6,h+6,this.left-6,h-6,"Z"]:k.prototype.getPlotLinePath.call(this,
a,b,d,c)},update:function(a,b){var d=this.chart,c=d.legend;e(this.series,function(a){a.isDirtyData=!0});a.dataClasses&&c.allItems&&(e(c.allItems,function(a){a.isDataClass&&a.legendGroup.destroy()}),d.isDirtyLegend=!0);d.options[this.coll]=q(this.userOptions,a);k.prototype.update.call(this,a,b);this.legendItem&&(this.setLegendColor(),c.colorizeItem(this,!0))},getDataClassLegendSymbols:function(){var a=this,b=this.chart,d=this.legendItems,g=b.options.legend,h=g.valueDecimals,t=g.valueSuffix||"",k;d.length||
e(this.dataClasses,function(g,p){var l=!0,q=g.from,m=g.to;k="";void 0===q?k="\x3c ":void 0===m&&(k="\x3e ");void 0!==q&&(k+=c.numberFormat(q,h)+t);void 0!==q&&void 0!==m&&(k+=" - ");void 0!==m&&(k+=c.numberFormat(m,h)+t);d.push(v({chart:b,name:k,options:{},drawLegendSymbol:f.drawRectangle,visible:!0,setState:x,isDataClass:!0,setVisible:function(){l=this.visible=!l;e(a.series,function(a){e(a.points,function(a){a.dataClass===p&&a.setVisible(l)})});b.legend.colorizeItem(this,l)}},g))});return d},name:""});
e(["fill","stroke"],function(a){c.Fx.prototype[a+"Setter"]=function(){this.elem.attr(a,l.prototype.tweenColors(m(this.start),m(this.end),this.pos),null,!0)}});t(r.prototype,"getAxes",function(a){var b=this.options.colorAxis;a.call(this);this.colorAxis=[];b&&new l(this,b)});t(p.prototype,"getAllItems",function(a){var b=[],d=this.chart.colorAxis[0];d&&d.options&&(d.options.showInLegend&&(d.options.dataClasses?b=b.concat(d.getDataClassLegendSymbols()):b.push(d)),e(d.series,function(a){a.options.showInLegend=
!1}));return b.concat(a.call(this))});t(p.prototype,"colorizeItem",function(a,b,d){a.call(this,b,d);d&&b.legendColor&&b.legendSymbol.attr({fill:b.legendColor})})})(n);(function(c){var k=c.defined,r=c.each,m=c.noop,l=c.seriesTypes;c.colorPointMixin={isValid:function(){return null!==this.value},setVisible:function(c){var e=this,k=c?"show":"hide";r(["graphic","dataLabel"],function(c){if(e[c])e[c][k]()})},setState:function(e){c.Point.prototype.setState.call(this,e);this.graphic&&this.graphic.attr({zIndex:"hover"===
e?1:0})}};c.colorSeriesMixin={pointArrayMap:["value"],axisTypes:["xAxis","yAxis","colorAxis"],optionalAxis:"colorAxis",trackerGroups:["group","markerGroup","dataLabelsGroup"],getSymbol:m,parallelArrays:["x","y","value"],colorKey:"value",pointAttribs:l.column.prototype.pointAttribs,translateColors:function(){var c=this,k=this.options.nullColor,l=this.colorAxis,m=this.colorKey;r(this.data,function(f){var e=f[m];if(e=f.options.color||(f.isNull?k:l&&void 0!==e?l.toColor(e,f):f.color||c.color))f.color=
e})},colorAttribs:function(c){var e={};k(c.color)&&(e[this.colorProp||"fill"]=c.color);return e}}})(n);(function(c){var k=c.colorPointMixin,r=c.each,m=c.merge,l=c.noop,e=c.pick,n=c.Series,w=c.seriesType,p=c.seriesTypes;w("heatmap","scatter",{animation:!1,borderWidth:0,nullColor:"#f7f7f7",dataLabels:{formatter:function(){return this.point.value},inside:!0,verticalAlign:"middle",crop:!1,overflow:!1,padding:0},marker:null,pointRange:null,tooltip:{pointFormat:"{point.x}, {point.y}: {point.value}\x3cbr/\x3e"},
states:{normal:{animation:!0},hover:{halo:!1,brightness:.2}}},m(c.colorSeriesMixin,{pointArrayMap:["y","value"],hasPointSpecificOptions:!0,supportsDrilldown:!0,getExtremesFromAll:!0,directTouch:!0,init:function(){var c;p.scatter.prototype.init.apply(this,arguments);c=this.options;c.pointRange=e(c.pointRange,c.colsize||1);this.yAxis.axisPointRange=c.rowsize||1},translate:function(){var c=this.options,e=this.xAxis,k=this.yAxis,l=function(c,a,b){return Math.min(Math.max(a,c),b)};this.generatePoints();
r(this.points,function(f){var a=(c.colsize||1)/2,b=(c.rowsize||1)/2,d=l(Math.round(e.len-e.translate(f.x-a,0,1,0,1)),-e.len,2*e.len),a=l(Math.round(e.len-e.translate(f.x+a,0,1,0,1)),-e.len,2*e.len),g=l(Math.round(k.translate(f.y-b,0,1,0,1)),-k.len,2*k.len),b=l(Math.round(k.translate(f.y+b,0,1,0,1)),-k.len,2*k.len);f.plotX=f.clientX=(d+a)/2;f.plotY=(g+b)/2;f.shapeType="rect";f.shapeArgs={x:Math.min(d,a),y:Math.min(g,b),width:Math.abs(a-d),height:Math.abs(b-g)}});this.translateColors()},drawPoints:function(){p.column.prototype.drawPoints.call(this);
r(this.points,function(c){c.graphic.attr(this.colorAttribs(c))},this)},animate:l,getBox:l,drawLegendSymbol:c.LegendSymbolMixin.drawRectangle,alignDataLabel:p.column.prototype.alignDataLabel,getExtremes:function(){n.prototype.getExtremes.call(this,this.valueData);this.valueMin=this.dataMin;this.valueMax=this.dataMax;n.prototype.getExtremes.call(this)}}),k)})(n)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
Chart = H.Chart,
color = H.color,
ColorAxis,
each = H.each,
extend = H.extend,
isNumber = H.isNumber,
Legend = H.Legend,
LegendSymbolMixin = H.LegendSymbolMixin,
noop = H.noop,
merge = H.merge,
pick = H.pick,
wrap = H.wrap;
/**
* The ColorAxis object for inclusion in gradient legends
*/
ColorAxis = H.ColorAxis = function() {
this.init.apply(this, arguments);
};
extend(ColorAxis.prototype, Axis.prototype);
extend(ColorAxis.prototype, {
defaultColorAxisOptions: {
lineWidth: 0,
minPadding: 0,
maxPadding: 0,
gridLineWidth: 1,
tickPixelInterval: 72,
startOnTick: true,
endOnTick: true,
offset: 0,
marker: {
animation: {
duration: 50
},
width: 0.01,
color: '#999999'
},
labels: {
overflow: 'justify',
rotation: 0
},
minColor: '#e6ebf5',
maxColor: '#003399',
tickLength: 5,
showInLegend: true
},
// Properties to preserve after destroy, for Axis.update (#5881, #6025)
keepProps: [
'legendGroup',
'legendItemHeight',
'legendItemWidth',
'legendItem',
'legendSymbol'
].concat(Axis.prototype.keepProps),
/**
* Initialize the color axis
*/
init: function(chart, userOptions) {
var horiz = chart.options.legend.layout !== 'vertical',
options;
this.coll = 'colorAxis';
// Build the options
options = merge(this.defaultColorAxisOptions, {
side: horiz ? 2 : 1,
reversed: !horiz
}, userOptions, {
opposite: !horiz,
showEmpty: false,
title: null
});
Axis.prototype.init.call(this, chart, options);
// Base init() pushes it to the xAxis array, now pop it again
//chart[this.isXAxis ? 'xAxis' : 'yAxis'].pop();
// Prepare data classes
if (userOptions.dataClasses) {
this.initDataClasses(userOptions);
}
this.initStops(userOptions);
// Override original axis properties
this.horiz = horiz;
this.zoomEnabled = false;
// Add default values
this.defaultLegendLength = 200;
},
/*
* Return an intermediate color between two colors, according to pos where 0
* is the from color and 1 is the to color.
* NOTE: Changes here should be copied
* to the same function in drilldown.src.js and solid-gauge-src.js.
*/
tweenColors: function(from, to, pos) {
// Check for has alpha, because rgba colors perform worse due to lack of
// support in WebKit.
var hasAlpha,
ret;
// Unsupported color, return to-color (#3920)
if (!to.rgba.length || !from.rgba.length) {
ret = to.input || 'none';
// Interpolate
} else {
from = from.rgba;
to = to.rgba;
hasAlpha = (to[3] !== 1 || from[3] !== 1);
ret = (hasAlpha ? 'rgba(' : 'rgb(') +
Math.round(to[0] + (from[0] - to[0]) * (1 - pos)) + ',' +
Math.round(to[1] + (from[1] - to[1]) * (1 - pos)) + ',' +
Math.round(to[2] + (from[2] - to[2]) * (1 - pos)) +
(hasAlpha ? (',' + (to[3] + (from[3] - to[3]) * (1 - pos))) : '') + ')';
}
return ret;
},
initDataClasses: function(userOptions) {
var axis = this,
chart = this.chart,
dataClasses,
colorCounter = 0,
colorCount = chart.options.chart.colorCount,
options = this.options,
len = userOptions.dataClasses.length;
this.dataClasses = dataClasses = [];
this.legendItems = [];
each(userOptions.dataClasses, function(dataClass, i) {
var colors;
dataClass = merge(dataClass);
dataClasses.push(dataClass);
if (!dataClass.color) {
if (options.dataClassColor === 'category') {
colors = chart.options.colors;
colorCount = colors.length;
dataClass.color = colors[colorCounter];
dataClass.colorIndex = colorCounter;
// increase and loop back to zero
colorCounter++;
if (colorCounter === colorCount) {
colorCounter = 0;
}
} else {
dataClass.color = axis.tweenColors(
color(options.minColor),
color(options.maxColor),
len < 2 ? 0.5 : i / (len - 1) // #3219
);
}
}
});
},
initStops: function(userOptions) {
this.stops = userOptions.stops || [
[0, this.options.minColor],
[1, this.options.maxColor]
];
each(this.stops, function(stop) {
stop.color = color(stop[1]);
});
},
/**
* Extend the setOptions method to process extreme colors and color
* stops.
*/
setOptions: function(userOptions) {
Axis.prototype.setOptions.call(this, userOptions);
this.options.crosshair = this.options.marker;
},
setAxisSize: function() {
var symbol = this.legendSymbol,
chart = this.chart,
legendOptions = chart.options.legend || {},
x,
y,
width,
height;
if (symbol) {
this.left = x = symbol.attr('x');
this.top = y = symbol.attr('y');
this.width = width = symbol.attr('width');
this.height = height = symbol.attr('height');
this.right = chart.chartWidth - x - width;
this.bottom = chart.chartHeight - y - height;
this.len = this.horiz ? width : height;
this.pos = this.horiz ? x : y;
} else {
// Fake length for disabled legend to avoid tick issues and such (#5205)
this.len = (this.horiz ? legendOptions.symbolWidth : legendOptions.symbolHeight) || this.defaultLegendLength;
}
},
/**
* Translate from a value to a color
*/
toColor: function(value, point) {
var pos,
stops = this.stops,
from,
to,
color,
dataClasses = this.dataClasses,
dataClass,
i;
if (dataClasses) {
i = dataClasses.length;
while (i--) {
dataClass = dataClasses[i];
from = dataClass.from;
to = dataClass.to;
if ((from === undefined || value >= from) && (to === undefined || value <= to)) {
color = dataClass.color;
if (point) {
point.dataClass = i;
point.colorIndex = dataClass.colorIndex;
}
break;
}
}
} else {
if (this.isLog) {
value = this.val2lin(value);
}
pos = 1 - ((this.max - value) / ((this.max - this.min) || 1));
i = stops.length;
while (i--) {
if (pos > stops[i][0]) {
break;
}
}
from = stops[i] || stops[i + 1];
to = stops[i + 1] || from;
// The position within the gradient
pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1);
color = this.tweenColors(
from.color,
to.color,
pos
);
}
return color;
},
/**
* Override the getOffset method to add the whole axis groups inside the legend.
*/
getOffset: function() {
var group = this.legendGroup,
sideOffset = this.chart.axisOffset[this.side];
if (group) {
// Hook for the getOffset method to add groups to this parent group
this.axisParent = group;
// Call the base
Axis.prototype.getOffset.call(this);
// First time only
if (!this.added) {
this.added = true;
this.labelLeft = 0;
this.labelRight = this.width;
}
// Reset it to avoid color axis reserving space
this.chart.axisOffset[this.side] = sideOffset;
}
},
/**
* Create the color gradient
*/
setLegendColor: function() {
var grad,
horiz = this.horiz,
options = this.options,
reversed = this.reversed,
one = reversed ? 1 : 0,
zero = reversed ? 0 : 1;
grad = horiz ? [one, 0, zero, 0] : [0, zero, 0, one]; // #3190
this.legendColor = {
linearGradient: {
x1: grad[0],
y1: grad[1],
x2: grad[2],
y2: grad[3]
},
stops: options.stops || [
[0, options.minColor],
[1, options.maxColor]
]
};
},
/**
* The color axis appears inside the legend and has its own legend symbol
*/
drawLegendSymbol: function(legend, item) {
var padding = legend.padding,
legendOptions = legend.options,
horiz = this.horiz,
width = pick(legendOptions.symbolWidth, horiz ? this.defaultLegendLength : 12),
height = pick(legendOptions.symbolHeight, horiz ? 12 : this.defaultLegendLength),
labelPadding = pick(legendOptions.labelPadding, horiz ? 16 : 30),
itemDistance = pick(legendOptions.itemDistance, 10);
this.setLegendColor();
// Create the gradient
item.legendSymbol = this.chart.renderer.rect(
0,
legend.baseline - 11,
width,
height
).attr({
zIndex: 1
}).add(item.legendGroup);
// Set how much space this legend item takes up
this.legendItemWidth = width + padding + (horiz ? itemDistance : labelPadding);
this.legendItemHeight = height + padding + (horiz ? labelPadding : 0);
},
/**
* Fool the legend
*/
setState: noop,
visible: true,
setVisible: noop,
getSeriesExtremes: function() {
var series = this.series,
i = series.length;
this.dataMin = Infinity;
this.dataMax = -Infinity;
while (i--) {
if (series[i].valueMin !== undefined) {
this.dataMin = Math.min(this.dataMin, series[i].valueMin);
this.dataMax = Math.max(this.dataMax, series[i].valueMax);
}
}
},
drawCrosshair: function(e, point) {
var plotX = point && point.plotX,
plotY = point && point.plotY,
crossPos,
axisPos = this.pos,
axisLen = this.len;
if (point) {
crossPos = this.toPixels(point[point.series.colorKey]);
if (crossPos < axisPos) {
crossPos = axisPos - 2;
} else if (crossPos > axisPos + axisLen) {
crossPos = axisPos + axisLen + 2;
}
point.plotX = crossPos;
point.plotY = this.len - crossPos;
Axis.prototype.drawCrosshair.call(this, e, point);
point.plotX = plotX;
point.plotY = plotY;
if (this.cross) {
this.cross
.addClass('highcharts-coloraxis-marker')
.add(this.legendGroup);
this.cross.attr({
fill: this.crosshair.color
});
}
}
},
getPlotLinePath: function(a, b, c, d, pos) {
return isNumber(pos) ? // crosshairs only // #3969 pos can be 0 !!
(this.horiz ? ['M', pos - 4, this.top - 6, 'L', pos + 4, this.top - 6, pos, this.top, 'Z'] : ['M', this.left, pos, 'L', this.left - 6, pos + 6, this.left - 6, pos - 6, 'Z']) :
Axis.prototype.getPlotLinePath.call(this, a, b, c, d);
},
update: function(newOptions, redraw) {
var chart = this.chart,
legend = chart.legend;
each(this.series, function(series) {
series.isDirtyData = true; // Needed for Axis.update when choropleth colors change
});
// When updating data classes, destroy old items and make sure new ones are created (#3207)
if (newOptions.dataClasses && legend.allItems) {
each(legend.allItems, function(item) {
if (item.isDataClass) {
item.legendGroup.destroy();
}
});
chart.isDirtyLegend = true;
}
// Keep the options structure updated for export. Unlike xAxis and yAxis, the colorAxis is
// not an array. (#3207)
chart.options[this.coll] = merge(this.userOptions, newOptions);
Axis.prototype.update.call(this, newOptions, redraw);
if (this.legendItem) {
this.setLegendColor();
legend.colorizeItem(this, true);
}
},
/**
* Get the legend item symbols for data classes
*/
getDataClassLegendSymbols: function() {
var axis = this,
chart = this.chart,
legendItems = this.legendItems,
legendOptions = chart.options.legend,
valueDecimals = legendOptions.valueDecimals,
valueSuffix = legendOptions.valueSuffix || '',
name;
if (!legendItems.length) {
each(this.dataClasses, function(dataClass, i) {
var vis = true,
from = dataClass.from,
to = dataClass.to;
// Assemble the default name. This can be overridden by legend.options.labelFormatter
name = '';
if (from === undefined) {
name = '< ';
} else if (to === undefined) {
name = '> ';
}
if (from !== undefined) {
name += H.numberFormat(from, valueDecimals) + valueSuffix;
}
if (from !== undefined && to !== undefined) {
name += ' - ';
}
if (to !== undefined) {
name += H.numberFormat(to, valueDecimals) + valueSuffix;
}
// Add a mock object to the legend items
legendItems.push(extend({
chart: chart,
name: name,
options: {},
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
visible: true,
setState: noop,
isDataClass: true,
setVisible: function() {
vis = this.visible = !vis;
each(axis.series, function(series) {
each(series.points, function(point) {
if (point.dataClass === i) {
point.setVisible(vis);
}
});
});
chart.legend.colorizeItem(this, vis);
}
}, dataClass));
});
}
return legendItems;
},
name: '' // Prevents 'undefined' in legend in IE8
});
/**
* Handle animation of the color attributes directly
*/
each(['fill', 'stroke'], function(prop) {
H.Fx.prototype[prop + 'Setter'] = function() {
this.elem.attr(
prop,
ColorAxis.prototype.tweenColors(
color(this.start),
color(this.end),
this.pos
),
null,
true
);
};
});
/**
* Extend the chart getAxes method to also get the color axis
*/
wrap(Chart.prototype, 'getAxes', function(proceed) {
var options = this.options,
colorAxisOptions = options.colorAxis;
proceed.call(this);
this.colorAxis = [];
if (colorAxisOptions) {
new ColorAxis(this, colorAxisOptions); // eslint-disable-line no-new
}
});
/**
* Wrap the legend getAllItems method to add the color axis. This also removes the
* axis' own series to prevent them from showing up individually.
*/
wrap(Legend.prototype, 'getAllItems', function(proceed) {
var allItems = [],
colorAxis = this.chart.colorAxis[0];
if (colorAxis && colorAxis.options) {
if (colorAxis.options.showInLegend) {
// Data classes
if (colorAxis.options.dataClasses) {
allItems = allItems.concat(colorAxis.getDataClassLegendSymbols());
// Gradient legend
} else {
// Add this axis on top
allItems.push(colorAxis);
}
}
// Don't add the color axis' series
each(colorAxis.series, function(series) {
series.options.showInLegend = false;
});
}
return allItems.concat(proceed.call(this));
});
wrap(Legend.prototype, 'colorizeItem', function(proceed, item, visible) {
proceed.call(this, item, visible);
if (visible && item.legendColor) {
item.legendSymbol.attr({
fill: item.legendColor
});
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var defined = H.defined,
each = H.each,
noop = H.noop,
seriesTypes = H.seriesTypes;
/**
* Mixin for maps and heatmaps
*/
H.colorPointMixin = {
/**
* Color points have a value option that determines whether or not it is a null point
*/
isValid: function() {
return this.value !== null;
},
/**
* Set the visibility of a single point
*/
setVisible: function(vis) {
var point = this,
method = vis ? 'show' : 'hide';
// Show and hide associated elements
each(['graphic', 'dataLabel'], function(key) {
if (point[key]) {
point[key][method]();
}
});
},
setState: function(state) {
H.Point.prototype.setState.call(this, state);
if (this.graphic) {
this.graphic.attr({
zIndex: state === 'hover' ? 1 : 0
});
}
}
};
H.colorSeriesMixin = {
pointArrayMap: ['value'],
axisTypes: ['xAxis', 'yAxis', 'colorAxis'],
optionalAxis: 'colorAxis',
trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
getSymbol: noop,
parallelArrays: ['x', 'y', 'value'],
colorKey: 'value',
pointAttribs: seriesTypes.column.prototype.pointAttribs,
/**
* In choropleth maps, the color is a result of the value, so this needs translation too
*/
translateColors: function() {
var series = this,
nullColor = this.options.nullColor,
colorAxis = this.colorAxis,
colorKey = this.colorKey;
each(this.data, function(point) {
var value = point[colorKey],
color;
color = point.options.color ||
(point.isNull ? nullColor : (colorAxis && value !== undefined) ? colorAxis.toColor(value, point) : point.color || series.color);
if (color) {
point.color = color;
}
});
},
/**
* Get the color attibutes to apply on the graphic
*/
colorAttribs: function(point) {
var ret = {};
if (defined(point.color)) {
ret[this.colorProp || 'fill'] = point.color;
}
return ret;
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var colorPointMixin = H.colorPointMixin,
colorSeriesMixin = H.colorSeriesMixin,
each = H.each,
LegendSymbolMixin = H.LegendSymbolMixin,
merge = H.merge,
noop = H.noop,
pick = H.pick,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
// The Heatmap series type
seriesType('heatmap', 'scatter', {
animation: false,
borderWidth: 0,
nullColor: '#f7f7f7',
dataLabels: {
formatter: function() { // #2945
return this.point.value;
},
inside: true,
verticalAlign: 'middle',
crop: false,
overflow: false,
padding: 0 // #3837
},
marker: null,
pointRange: null, // dynamically set to colsize by default
tooltip: {
pointFormat: '{point.x}, {point.y}: {point.value}<br/>'
},
states: {
normal: {
animation: true
},
hover: {
halo: false, // #3406, halo is not required on heatmaps
brightness: 0.2
}
}
}, merge(colorSeriesMixin, {
pointArrayMap: ['y', 'value'],
hasPointSpecificOptions: true,
supportsDrilldown: true,
getExtremesFromAll: true,
directTouch: true,
/**
* Override the init method to add point ranges on both axes.
*/
init: function() {
var options;
seriesTypes.scatter.prototype.init.apply(this, arguments);
options = this.options;
options.pointRange = pick(options.pointRange, options.colsize || 1); // #3758, prevent resetting in setData
this.yAxis.axisPointRange = options.rowsize || 1; // general point range
},
translate: function() {
var series = this,
options = series.options,
xAxis = series.xAxis,
yAxis = series.yAxis,
between = function(x, a, b) {
return Math.min(Math.max(a, x), b);
};
series.generatePoints();
each(series.points, function(point) {
var xPad = (options.colsize || 1) / 2,
yPad = (options.rowsize || 1) / 2,
x1 = between(Math.round(xAxis.len - xAxis.translate(point.x - xPad, 0, 1, 0, 1)), -xAxis.len, 2 * xAxis.len),
x2 = between(Math.round(xAxis.len - xAxis.translate(point.x + xPad, 0, 1, 0, 1)), -xAxis.len, 2 * xAxis.len),
y1 = between(Math.round(yAxis.translate(point.y - yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len),
y2 = between(Math.round(yAxis.translate(point.y + yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len);
// Set plotX and plotY for use in K-D-Tree and more
point.plotX = point.clientX = (x1 + x2) / 2;
point.plotY = (y1 + y2) / 2;
point.shapeType = 'rect';
point.shapeArgs = {
x: Math.min(x1, x2),
y: Math.min(y1, y2),
width: Math.abs(x2 - x1),
height: Math.abs(y2 - y1)
};
});
series.translateColors();
},
drawPoints: function() {
seriesTypes.column.prototype.drawPoints.call(this);
each(this.points, function(point) {
point.graphic.attr(this.colorAttribs(point));
}, this);
},
animate: noop,
getBox: noop,
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
getExtremes: function() {
// Get the extremes from the value data
Series.prototype.getExtremes.call(this, this.valueData);
this.valueMin = this.dataMin;
this.valueMax = this.dataMax;
// Get the extremes from the y data
Series.prototype.getExtremes.call(this);
}
}), colorPointMixin);
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | 1 1 1 1 | /*
Highmaps JS v5.0.10 (2017-03-31)
Highmaps as a plugin for Highcharts 4.1.x or Highstock 2.1.x (x being the patch version of this file)
(c) 2011-2017 Torstein Honsi
License: www.highcharts.com/license
*/
(function(y){"object"===typeof module&&module.exports?module.exports=y:y(Highcharts)})(function(y){(function(a){var m=a.Axis,p=a.each,l=a.pick;a=a.wrap;a(m.prototype,"getSeriesExtremes",function(a){var e=this.isXAxis,w,m,v=[],d;e&&p(this.series,function(b,a){b.useMapGeometry&&(v[a]=b.xData,b.xData=[])});a.call(this);e&&(w=l(this.dataMin,Number.MAX_VALUE),m=l(this.dataMax,-Number.MAX_VALUE),p(this.series,function(b,a){b.useMapGeometry&&(w=Math.min(w,l(b.minX,w)),m=Math.max(m,l(b.maxX,w)),b.xData=v[a],
d=!0)}),d&&(this.dataMin=w,this.dataMax=m))});a(m.prototype,"setAxisTranslation",function(a){var q=this.chart,e=q.plotWidth/q.plotHeight,q=q.xAxis[0],l;a.call(this);"yAxis"===this.coll&&void 0!==q.transA&&p(this.series,function(a){a.preserveAspectRatio&&(l=!0)});if(l&&(this.transA=q.transA=Math.min(this.transA,q.transA),a=e/((q.max-q.min)/(this.max-this.min)),a=1>a?this:q,e=(a.max-a.min)*a.transA,a.pixelPadding=a.len-e,a.minPixelPadding=a.pixelPadding/2,e=a.fixTo)){e=e[1]-a.toValue(e[0],!0);e*=a.transA;
if(Math.abs(e)>a.minPixelPadding||a.min===a.dataMin&&a.max===a.dataMax)e=0;a.minPixelPadding-=e}});a(m.prototype,"render",function(a){a.call(this);this.fixTo=null})})(y);(function(a){var m=a.Axis,p=a.Chart,l=a.color,e,q=a.each,w=a.extend,x=a.isNumber,v=a.Legend,d=a.LegendSymbolMixin,b=a.noop,c=a.merge,g=a.pick,t=a.wrap;e=a.ColorAxis=function(){this.init.apply(this,arguments)};w(e.prototype,m.prototype);w(e.prototype,{defaultColorAxisOptions:{lineWidth:0,minPadding:0,maxPadding:0,gridLineWidth:1,tickPixelInterval:72,
startOnTick:!0,endOnTick:!0,offset:0,marker:{animation:{duration:50},width:.01,color:"#999999"},labels:{overflow:"justify",rotation:0},minColor:"#e6ebf5",maxColor:"#003399",tickLength:5,showInLegend:!0},keepProps:["legendGroup","legendItemHeight","legendItemWidth","legendItem","legendSymbol"].concat(m.prototype.keepProps),init:function(a,f){var b="vertical"!==a.options.legend.layout,k;this.coll="colorAxis";k=c(this.defaultColorAxisOptions,{side:b?2:1,reversed:!b},f,{opposite:!b,showEmpty:!1,title:null});
m.prototype.init.call(this,a,k);f.dataClasses&&this.initDataClasses(f);this.initStops(f);this.horiz=b;this.zoomEnabled=!1;this.defaultLegendLength=200},tweenColors:function(a,f,b){var k;f.rgba.length&&a.rgba.length?(a=a.rgba,f=f.rgba,k=1!==f[3]||1!==a[3],a=(k?"rgba(":"rgb(")+Math.round(f[0]+(a[0]-f[0])*(1-b))+","+Math.round(f[1]+(a[1]-f[1])*(1-b))+","+Math.round(f[2]+(a[2]-f[2])*(1-b))+(k?","+(f[3]+(a[3]-f[3])*(1-b)):"")+")"):a=f.input||"none";return a},initDataClasses:function(a){var b=this,k=this.chart,
r,h=0,u=k.options.chart.colorCount,g=this.options,d=a.dataClasses.length;this.dataClasses=r=[];this.legendItems=[];q(a.dataClasses,function(a,f){a=c(a);r.push(a);a.color||("category"===g.dataClassColor?(f=k.options.colors,u=f.length,a.color=f[h],a.colorIndex=h,h++,h===u&&(h=0)):a.color=b.tweenColors(l(g.minColor),l(g.maxColor),2>d?.5:f/(d-1)))})},initStops:function(a){this.stops=a.stops||[[0,this.options.minColor],[1,this.options.maxColor]];q(this.stops,function(a){a.color=l(a[1])})},setOptions:function(a){m.prototype.setOptions.call(this,
a);this.options.crosshair=this.options.marker},setAxisSize:function(){var a=this.legendSymbol,b=this.chart,n=b.options.legend||{},c,h;a?(this.left=n=a.attr("x"),this.top=c=a.attr("y"),this.width=h=a.attr("width"),this.height=a=a.attr("height"),this.right=b.chartWidth-n-h,this.bottom=b.chartHeight-c-a,this.len=this.horiz?h:a,this.pos=this.horiz?n:c):this.len=(this.horiz?n.symbolWidth:n.symbolHeight)||this.defaultLegendLength},toColor:function(a,b){var f=this.stops,k,h,c=this.dataClasses,g,d;if(c)for(d=
c.length;d--;){if(g=c[d],k=g.from,f=g.to,(void 0===k||a>=k)&&(void 0===f||a<=f)){h=g.color;b&&(b.dataClass=d,b.colorIndex=g.colorIndex);break}}else{this.isLog&&(a=this.val2lin(a));a=1-(this.max-a)/(this.max-this.min||1);for(d=f.length;d--&&!(a>f[d][0]););k=f[d]||f[d+1];f=f[d+1]||k;a=1-(f[0]-a)/(f[0]-k[0]||1);h=this.tweenColors(k.color,f.color,a)}return h},getOffset:function(){var a=this.legendGroup,b=this.chart.axisOffset[this.side];a&&(this.axisParent=a,m.prototype.getOffset.call(this),this.added||
(this.added=!0,this.labelLeft=0,this.labelRight=this.width),this.chart.axisOffset[this.side]=b)},setLegendColor:function(){var a,b=this.options,n=this.reversed;a=n?1:0;n=n?0:1;a=this.horiz?[a,0,n,0]:[0,n,0,a];this.legendColor={linearGradient:{x1:a[0],y1:a[1],x2:a[2],y2:a[3]},stops:b.stops||[[0,b.minColor],[1,b.maxColor]]}},drawLegendSymbol:function(a,b){var f=a.padding,k=a.options,h=this.horiz,c=g(k.symbolWidth,h?this.defaultLegendLength:12),d=g(k.symbolHeight,h?12:this.defaultLegendLength),e=g(k.labelPadding,
h?16:30),k=g(k.itemDistance,10);this.setLegendColor();b.legendSymbol=this.chart.renderer.rect(0,a.baseline-11,c,d).attr({zIndex:1}).add(b.legendGroup);this.legendItemWidth=c+f+(h?k:e);this.legendItemHeight=d+f+(h?e:0)},setState:b,visible:!0,setVisible:b,getSeriesExtremes:function(){var a=this.series,b=a.length;this.dataMin=Infinity;for(this.dataMax=-Infinity;b--;)void 0!==a[b].valueMin&&(this.dataMin=Math.min(this.dataMin,a[b].valueMin),this.dataMax=Math.max(this.dataMax,a[b].valueMax))},drawCrosshair:function(a,
b){var f=b&&b.plotX,c=b&&b.plotY,h,k=this.pos,d=this.len;b&&(h=this.toPixels(b[b.series.colorKey]),h<k?h=k-2:h>k+d&&(h=k+d+2),b.plotX=h,b.plotY=this.len-h,m.prototype.drawCrosshair.call(this,a,b),b.plotX=f,b.plotY=c,this.cross&&(this.cross.addClass("highcharts-coloraxis-marker").add(this.legendGroup),this.cross.attr({fill:this.crosshair.color})))},getPlotLinePath:function(a,b,c,d,h){return x(h)?this.horiz?["M",h-4,this.top-6,"L",h+4,this.top-6,h,this.top,"Z"]:["M",this.left,h,"L",this.left-6,h+6,
this.left-6,h-6,"Z"]:m.prototype.getPlotLinePath.call(this,a,b,c,d)},update:function(a,b){var f=this.chart,k=f.legend;q(this.series,function(a){a.isDirtyData=!0});a.dataClasses&&k.allItems&&(q(k.allItems,function(a){a.isDataClass&&a.legendGroup.destroy()}),f.isDirtyLegend=!0);f.options[this.coll]=c(this.userOptions,a);m.prototype.update.call(this,a,b);this.legendItem&&(this.setLegendColor(),k.colorizeItem(this,!0))},getDataClassLegendSymbols:function(){var c=this,f=this.chart,n=this.legendItems,g=
f.options.legend,h=g.valueDecimals,e=g.valueSuffix||"",t;n.length||q(this.dataClasses,function(k,g){var u=!0,r=k.from,z=k.to;t="";void 0===r?t="\x3c ":void 0===z&&(t="\x3e ");void 0!==r&&(t+=a.numberFormat(r,h)+e);void 0!==r&&void 0!==z&&(t+=" - ");void 0!==z&&(t+=a.numberFormat(z,h)+e);n.push(w({chart:f,name:t,options:{},drawLegendSymbol:d.drawRectangle,visible:!0,setState:b,isDataClass:!0,setVisible:function(){u=this.visible=!u;q(c.series,function(a){q(a.points,function(a){a.dataClass===g&&a.setVisible(u)})});
f.legend.colorizeItem(this,u)}},k))});return n},name:""});q(["fill","stroke"],function(b){a.Fx.prototype[b+"Setter"]=function(){this.elem.attr(b,e.prototype.tweenColors(l(this.start),l(this.end),this.pos),null,!0)}});t(p.prototype,"getAxes",function(a){var b=this.options.colorAxis;a.call(this);this.colorAxis=[];b&&new e(this,b)});t(v.prototype,"getAllItems",function(a){var b=[],c=this.chart.colorAxis[0];c&&c.options&&(c.options.showInLegend&&(c.options.dataClasses?b=b.concat(c.getDataClassLegendSymbols()):
b.push(c)),q(c.series,function(a){a.options.showInLegend=!1}));return b.concat(a.call(this))});t(v.prototype,"colorizeItem",function(a,b,c){a.call(this,b,c);c&&b.legendColor&&b.legendSymbol.attr({fill:b.legendColor})})})(y);(function(a){var m=a.defined,p=a.each,l=a.noop,e=a.seriesTypes;a.colorPointMixin={isValid:function(){return null!==this.value},setVisible:function(a){var e=this,q=a?"show":"hide";p(["graphic","dataLabel"],function(a){if(e[a])e[a][q]()})},setState:function(e){a.Point.prototype.setState.call(this,
e);this.graphic&&this.graphic.attr({zIndex:"hover"===e?1:0})}};a.colorSeriesMixin={pointArrayMap:["value"],axisTypes:["xAxis","yAxis","colorAxis"],optionalAxis:"colorAxis",trackerGroups:["group","markerGroup","dataLabelsGroup"],getSymbol:l,parallelArrays:["x","y","value"],colorKey:"value",pointAttribs:e.column.prototype.pointAttribs,translateColors:function(){var a=this,e=this.options.nullColor,l=this.colorAxis,m=this.colorKey;p(this.data,function(d){var b=d[m];if(b=d.options.color||(d.isNull?e:l&&
void 0!==b?l.toColor(b,d):d.color||a.color))d.color=b})},colorAttribs:function(a){var e={};m(a.color)&&(e[this.colorProp||"fill"]=a.color);return e}}})(y);(function(a){function m(a){a&&(a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)}function p(a){this.init(a)}var l=a.addEvent,e=a.Chart,q=a.doc,w=a.each,x=a.extend,v=a.merge,d=a.pick;a=a.wrap;p.prototype.init=function(a){this.chart=a;a.mapNavButtons=[]};p.prototype.update=function(a){var b=this.chart,
g=b.options.mapNavigation,e,k,f,n,r,h=function(a){this.handler.call(b,a);m(a)},u=b.mapNavButtons;a&&(g=b.options.mapNavigation=v(b.options.mapNavigation,a));for(;u.length;)u.pop().destroy();if(d(g.enableButtons,g.enabled)&&!b.renderer.forExport)for(e in a=g.buttons,a)a.hasOwnProperty(e)&&(f=v(g.buttonOptions,a[e]),k=f.theme,k.style=v(f.theme.style,f.style),r=(n=k.states)&&n.hover,n=n&&n.select,k=b.renderer.button(f.text,0,0,h,k,r,n,0,"zoomIn"===e?"topbutton":"bottombutton").addClass("highcharts-map-navigation").attr({width:f.width,
height:f.height,title:b.options.lang[e],padding:f.padding,zIndex:5}).add(),k.handler=f.onclick,k.align(x(f,{width:k.width,height:2*k.height}),null,f.alignTo),l(k.element,"dblclick",m),u.push(k));this.updateEvents(g)};p.prototype.updateEvents=function(a){var b=this.chart;d(a.enableDoubleClickZoom,a.enabled)||a.enableDoubleClickZoomTo?this.unbindDblClick=this.unbindDblClick||l(b.container,"dblclick",function(a){b.pointer.onContainerDblClick(a)}):this.unbindDblClick&&(this.unbindDblClick=this.unbindDblClick());
d(a.enableMouseWheelZoom,a.enabled)?this.unbindMouseWheel=this.unbindMouseWheel||l(b.container,void 0===q.onmousewheel?"DOMMouseScroll":"mousewheel",function(a){b.pointer.onContainerMouseWheel(a);m(a);return!1}):this.unbindMouseWheel&&(this.unbindMouseWheel=this.unbindMouseWheel())};x(e.prototype,{fitToBox:function(a,c){w([["x","width"],["y","height"]],function(b){var d=b[0];b=b[1];a[d]+a[b]>c[d]+c[b]&&(a[b]>c[b]?(a[b]=c[b],a[d]=c[d]):a[d]=c[d]+c[b]-a[b]);a[b]>c[b]&&(a[b]=c[b]);a[d]<c[d]&&(a[d]=c[d])});
return a},mapZoom:function(a,c,e,q,k){var b=this.xAxis[0],n=b.max-b.min,g=d(c,b.min+n/2),h=n*a,n=this.yAxis[0],u=n.max-n.min,z=d(e,n.min+u/2),u=u*a,g=this.fitToBox({x:g-h*(q?(q-b.pos)/b.len:.5),y:z-u*(k?(k-n.pos)/n.len:.5),width:h,height:u},{x:b.dataMin,y:n.dataMin,width:b.dataMax-b.dataMin,height:n.dataMax-n.dataMin}),h=g.x<=b.dataMin&&g.width>=b.dataMax-b.dataMin&&g.y<=n.dataMin&&g.height>=n.dataMax-n.dataMin;q&&(b.fixTo=[q-b.pos,c]);k&&(n.fixTo=[k-n.pos,e]);void 0===a||h?(b.setExtremes(void 0,
void 0,!1),n.setExtremes(void 0,void 0,!1)):(b.setExtremes(g.x,g.x+g.width,!1),n.setExtremes(g.y,g.y+g.height,!1));this.redraw()}});a(e.prototype,"render",function(a){this.mapNavigation=new p(this);this.mapNavigation.update();a.call(this)})})(y);(function(a){var m=a.extend,p=a.pick,l=a.Pointer;a=a.wrap;m(l.prototype,{onContainerDblClick:function(a){var e=this.chart;a=this.normalize(a);e.options.mapNavigation.enableDoubleClickZoomTo?e.pointer.inClass(a.target,"highcharts-tracker")&&e.hoverPoint&&e.hoverPoint.zoomTo():
e.isInsidePlot(a.chartX-e.plotLeft,a.chartY-e.plotTop)&&e.mapZoom(.5,e.xAxis[0].toValue(a.chartX),e.yAxis[0].toValue(a.chartY),a.chartX,a.chartY)},onContainerMouseWheel:function(a){var e=this.chart,l;a=this.normalize(a);l=a.detail||-(a.wheelDelta/120);e.isInsidePlot(a.chartX-e.plotLeft,a.chartY-e.plotTop)&&e.mapZoom(Math.pow(e.options.mapNavigation.mouseWheelSensitivity,l),e.xAxis[0].toValue(a.chartX),e.yAxis[0].toValue(a.chartY),a.chartX,a.chartY)}});a(l.prototype,"zoomOption",function(a){var e=
this.chart.options.mapNavigation;p(e.enableTouchZoom,e.enabled)&&(this.chart.options.chart.pinchType="xy");a.apply(this,[].slice.call(arguments,1))});a(l.prototype,"pinchTranslate",function(a,l,m,p,v,d,b){a.call(this,l,m,p,v,d,b);"map"===this.chart.options.chart.type&&this.hasZoom&&(a=p.scaleX>p.scaleY,this.pinchTranslateDirection(!a,l,m,p,v,d,b,a?p.scaleX:p.scaleY))})})(y);(function(a){var m=a.color,p=a.ColorAxis,l=a.colorPointMixin,e=a.each,q=a.extend,w=a.isNumber,x=a.map,v=a.merge,d=a.noop,b=a.pick,
c=a.isArray,g=a.Point,t=a.Series,k=a.seriesType,f=a.seriesTypes,n=a.splat,r=void 0!==a.doc.documentElement.style.vectorEffect;k("map","scatter",{allAreas:!0,animation:!1,nullColor:"#f7f7f7",borderColor:"#cccccc",borderWidth:1,marker:null,stickyTracking:!1,joinBy:"hc-key",dataLabels:{formatter:function(){return this.point.value},inside:!0,verticalAlign:"middle",crop:!1,overflow:!1,padding:0},turboThreshold:0,tooltip:{followPointer:!0,pointFormat:"{point.name}: {point.value}\x3cbr/\x3e"},states:{normal:{animation:!0},
hover:{brightness:.2,halo:null},select:{color:"#cccccc"}}},v(a.colorSeriesMixin,{type:"map",supportsDrilldown:!0,getExtremesFromAll:!0,useMapGeometry:!0,forceDL:!0,searchPoint:d,directTouch:!0,preserveAspectRatio:!0,pointArrayMap:["value"],getBox:function(h){var c=Number.MAX_VALUE,f=-c,d=c,k=-c,n=c,g=c,l=this.xAxis,t=this.yAxis,r;e(h||[],function(h){if(h.path){"string"===typeof h.path&&(h.path=a.splitPath(h.path));var e=h.path||[],u=e.length,l=!1,t=-c,z=c,q=-c,m=c,p=h.properties;if(!h._foundBox){for(;u--;)w(e[u])&&
(l?(t=Math.max(t,e[u]),z=Math.min(z,e[u])):(q=Math.max(q,e[u]),m=Math.min(m,e[u])),l=!l);h._midX=z+(t-z)*(h.middleX||p&&p["hc-middle-x"]||.5);h._midY=m+(q-m)*(h.middleY||p&&p["hc-middle-y"]||.5);h._maxX=t;h._minX=z;h._maxY=q;h._minY=m;h.labelrank=b(h.labelrank,(t-z)*(q-m));h._foundBox=!0}f=Math.max(f,h._maxX);d=Math.min(d,h._minX);k=Math.max(k,h._maxY);n=Math.min(n,h._minY);g=Math.min(h._maxX-h._minX,h._maxY-h._minY,g);r=!0}});r&&(this.minY=Math.min(n,b(this.minY,c)),this.maxY=Math.max(k,b(this.maxY,
-c)),this.minX=Math.min(d,b(this.minX,c)),this.maxX=Math.max(f,b(this.maxX,-c)),l&&void 0===l.options.minRange&&(l.minRange=Math.min(5*g,(this.maxX-this.minX)/5,l.minRange||c)),t&&void 0===t.options.minRange&&(t.minRange=Math.min(5*g,(this.maxY-this.minY)/5,t.minRange||c)))},getExtremes:function(){t.prototype.getExtremes.call(this,this.valueData);this.chart.hasRendered&&this.isDirtyData&&this.getBox(this.options.data);this.valueMin=this.dataMin;this.valueMax=this.dataMax;this.dataMin=this.minY;this.dataMax=
this.maxY},translatePath:function(a){var b=!1,h=this.xAxis,c=this.yAxis,f=h.min,d=h.transA,h=h.minPixelPadding,k=c.min,e=c.transA,c=c.minPixelPadding,n,g=[];if(a)for(n=a.length;n--;)w(a[n])?(g[n]=b?(a[n]-f)*d+h:(a[n]-k)*e+c,b=!b):g[n]=a[n];return g},setData:function(b,f,d,k){var h=this.options,g=this.chart.options.chart,l=g&&g.map,u=h.mapData,r=h.joinBy,z=null===r,q=h.keys||this.pointArrayMap,m=[],p={},A,B=this.chart.mapTransforms;!u&&l&&(u="string"===typeof l?a.maps[l]:l);z&&(r="_i");r=this.joinBy=
n(r);r[1]||(r[1]=r[0]);b&&e(b,function(a,f){var d=0;if(w(a))b[f]={value:a};else if(c(a)){b[f]={};!h.keys&&a.length>q.length&&"string"===typeof a[0]&&(b[f]["hc-key"]=a[0],++d);for(var k=0;k<q.length;++k,++d)q[k]&&(b[f][q[k]]=a[d])}z&&(b[f]._i=f)});this.getBox(b);if(this.chart.mapTransforms=B=g&&g.mapTransforms||u&&u["hc-transform"]||B)for(A in B)B.hasOwnProperty(A)&&A.rotation&&(A.cosAngle=Math.cos(A.rotation),A.sinAngle=Math.sin(A.rotation));if(u){"FeatureCollection"===u.type&&(this.mapTitle=u.title,
u=a.geojson(u,this.type,this));this.mapData=u;this.mapMap={};for(A=0;A<u.length;A++)g=u[A],l=g.properties,g._i=A,r[0]&&l&&l[r[0]]&&(g[r[0]]=l[r[0]]),p[g[r[0]]]=g;this.mapMap=p;b&&r[1]&&e(b,function(a){p[a[r[1]]]&&m.push(p[a[r[1]]])});h.allAreas?(this.getBox(u),b=b||[],r[1]&&e(b,function(a){m.push(a[r[1]])}),m="|"+x(m,function(a){return a&&a[r[0]]}).join("|")+"|",e(u,function(a){r[0]&&-1!==m.indexOf("|"+a[r[0]]+"|")||(b.push(v(a,{value:null})),k=!1)})):this.getBox(m)}t.prototype.setData.call(this,
b,f,d,k)},drawGraph:d,drawDataLabels:d,doFullTranslate:function(){return this.isDirtyData||this.chart.isResizing||this.chart.renderer.isVML||!this.baseTrans},translate:function(){var a=this,b=a.xAxis,c=a.yAxis,f=a.doFullTranslate();a.generatePoints();e(a.data,function(h){h.plotX=b.toPixels(h._midX,!0);h.plotY=c.toPixels(h._midY,!0);f&&(h.shapeType="path",h.shapeArgs={d:a.translatePath(h.path)})});a.translateColors()},pointAttribs:function(a,b){b=f.column.prototype.pointAttribs.call(this,a,b);a.isFading&&
delete b.fill;r?b["vector-effect"]="non-scaling-stroke":b["stroke-width"]="inherit";return b},drawPoints:function(){var a=this,b=a.xAxis,c=a.yAxis,d=a.group,k=a.chart,g=k.renderer,n,l,t,m,q=this.baseTrans,p,w,v,x,y;a.transformGroup||(a.transformGroup=g.g().attr({scaleX:1,scaleY:1}).add(d),a.transformGroup.survive=!0);a.doFullTranslate()?(k.hasRendered&&e(a.points,function(b){b.shapeArgs&&(b.shapeArgs.fill=a.pointAttribs(b,b.state).fill)}),a.group=a.transformGroup,f.column.prototype.drawPoints.apply(a),
a.group=d,e(a.points,function(a){a.graphic&&(a.name&&a.graphic.addClass("highcharts-name-"+a.name.replace(/ /g,"-").toLowerCase()),a.properties&&a.properties["hc-key"]&&a.graphic.addClass("highcharts-key-"+a.properties["hc-key"].toLowerCase()))}),this.baseTrans={originX:b.min-b.minPixelPadding/b.transA,originY:c.min-c.minPixelPadding/c.transA+(c.reversed?0:c.len/c.transA),transAX:b.transA,transAY:c.transA},this.transformGroup.animate({translateX:0,translateY:0,scaleX:1,scaleY:1})):(n=b.transA/q.transAX,
l=c.transA/q.transAY,t=b.toPixels(q.originX,!0),m=c.toPixels(q.originY,!0),.99<n&&1.01>n&&.99<l&&1.01>l&&(l=n=1,t=Math.round(t),m=Math.round(m)),p=this.transformGroup,k.renderer.globalAnimation?(w=p.attr("translateX"),v=p.attr("translateY"),x=p.attr("scaleX"),y=p.attr("scaleY"),p.attr({animator:0}).animate({animator:1},{step:function(a,b){p.attr({translateX:w+(t-w)*b.pos,translateY:v+(m-v)*b.pos,scaleX:x+(n-x)*b.pos,scaleY:y+(l-y)*b.pos})}})):p.attr({translateX:t,translateY:m,scaleX:n,scaleY:l}));
r||a.group.element.setAttribute("stroke-width",a.options[a.pointAttrToOptions&&a.pointAttrToOptions["stroke-width"]||"borderWidth"]/(n||1));this.drawMapDataLabels()},drawMapDataLabels:function(){t.prototype.drawDataLabels.call(this);this.dataLabelsGroup&&this.dataLabelsGroup.clip(this.chart.clipRect)},render:function(){var a=this,b=t.prototype.render;a.chart.renderer.isVML&&3E3<a.data.length?setTimeout(function(){b.call(a)}):b.call(a)},animate:function(a){var b=this.options.animation,c=this.group,
h=this.xAxis,f=this.yAxis,k=h.pos,d=f.pos;this.chart.renderer.isSVG&&(!0===b&&(b={duration:1E3}),a?c.attr({translateX:k+h.len/2,translateY:d+f.len/2,scaleX:.001,scaleY:.001}):(c.animate({translateX:k,translateY:d,scaleX:1,scaleY:1},b),this.animate=null))},animateDrilldown:function(a){var b=this.chart.plotBox,c=this.chart.drilldownLevels[this.chart.drilldownLevels.length-1],h=c.bBox,f=this.chart.options.drilldown.animation;a||(a=Math.min(h.width/b.width,h.height/b.height),c.shapeArgs={scaleX:a,scaleY:a,
translateX:h.x,translateY:h.y},e(this.points,function(a){a.graphic&&a.graphic.attr(c.shapeArgs).animate({scaleX:1,scaleY:1,translateX:0,translateY:0},f)}),this.animate=null)},drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,animateDrillupFrom:function(a){f.column.prototype.animateDrillupFrom.call(this,a)},animateDrillupTo:function(a){f.column.prototype.animateDrillupTo.call(this,a)}}),q({applyOptions:function(a,b){a=g.prototype.applyOptions.call(this,a,b);b=this.series;var c=b.joinBy;b.mapData&&
((c=void 0!==a[c[1]]&&b.mapMap[a[c[1]]])?(b.xyFromShape&&(a.x=c._midX,a.y=c._midY),q(a,c)):a.value=a.value||null);return a},onMouseOver:function(a){clearTimeout(this.colorInterval);if(null!==this.value)g.prototype.onMouseOver.call(this,a);else this.series.onMouseOut(a)},onMouseOut:function(){var a=this,b=+new Date,c=m(this.series.pointAttribs(a).fill),f=m(this.series.pointAttribs(a,"hover").fill),k=a.series.options.states.normal.animation,d=k&&(k.duration||500);d&&4===c.rgba.length&&4===f.rgba.length&&
"select"!==a.state&&(clearTimeout(a.colorInterval),a.colorInterval=setInterval(function(){var k=(new Date-b)/d,h=a.graphic;1<k&&(k=1);h&&h.attr("fill",p.prototype.tweenColors.call(0,f,c,k));1<=k&&clearTimeout(a.colorInterval)},13),a.isFading=!0);g.prototype.onMouseOut.call(a);a.isFading=null},zoomTo:function(){var a=this.series;a.xAxis.setExtremes(this._minX,this._maxX,!1);a.yAxis.setExtremes(this._minY,this._maxY,!1);a.chart.redraw()}},l))})(y);(function(a){var m=a.seriesType,p=a.seriesTypes;m("mapline",
"map",{lineWidth:1,fillColor:"none"},{type:"mapline",colorProp:"stroke",pointAttrToOptions:{stroke:"color","stroke-width":"lineWidth"},pointAttribs:function(a,e){a=p.map.prototype.pointAttribs.call(this,a,e);a.fill=this.options.fillColor;return a},drawLegendSymbol:p.line.prototype.drawLegendSymbol})})(y);(function(a){var m=a.merge,p=a.Point;a=a.seriesType;a("mappoint","scatter",{dataLabels:{enabled:!0,formatter:function(){return this.point.name},crop:!1,defer:!1,overflow:!1,style:{color:"#000000"}}},
{type:"mappoint",forceDL:!0},{applyOptions:function(a,e){a=void 0!==a.lat&&void 0!==a.lon?m(a,this.series.chart.fromLatLonToPoint(a)):a;return p.prototype.applyOptions.call(this,a,e)}})})(y);(function(a){var m=a.arrayMax,p=a.arrayMin,l=a.Axis,e=a.color,q=a.each,w=a.isNumber,x=a.noop,v=a.pick,d=a.pInt,b=a.Point,c=a.Series,g=a.seriesType,t=a.seriesTypes;g("bubble","scatter",{dataLabels:{formatter:function(){return this.point.z},inside:!0,verticalAlign:"middle"},marker:{lineColor:null,lineWidth:1,radius:null,
states:{hover:{radiusPlus:0}},symbol:"circle"},minSize:8,maxSize:"20%",softThreshold:!1,states:{hover:{halo:{size:5}}},tooltip:{pointFormat:"({point.x}, {point.y}), Size: {point.z}"},turboThreshold:0,zThreshold:0,zoneAxis:"z"},{pointArrayMap:["y","z"],parallelArrays:["x","y","z"],trackerGroups:["markerGroup","dataLabelsGroup"],bubblePadding:!0,zoneAxis:"z",directTouch:!0,pointAttribs:function(a,b){var f=v(this.options.marker.fillOpacity,.5);a=c.prototype.pointAttribs.call(this,a,b);1!==f&&(a.fill=
e(a.fill).setOpacity(f).get("rgba"));return a},getRadii:function(a,b,c,d){var f,k,g,n=this.zData,e=[],r=this.options,t="width"!==r.sizeBy,l=r.zThreshold,m=b-a;k=0;for(f=n.length;k<f;k++)g=n[k],r.sizeByAbsoluteValue&&null!==g&&(g=Math.abs(g-l),b=Math.max(b-l,Math.abs(a-l)),a=0),null===g?g=null:g<a?g=c/2-1:(g=0<m?(g-a)/m:.5,t&&0<=g&&(g=Math.sqrt(g)),g=Math.ceil(c+g*(d-c))/2),e.push(g);this.radii=e},animate:function(a){var b=this.options.animation;a||(q(this.points,function(a){var c=a.graphic,f;c&&c.width&&
(f={x:c.x,y:c.y,width:c.width,height:c.height},c.attr({x:a.plotX,y:a.plotY,width:1,height:1}),c.animate(f,b))}),this.animate=null)},translate:function(){var b,c=this.data,d,g,h=this.radii;t.scatter.prototype.translate.call(this);for(b=c.length;b--;)d=c[b],g=h?h[b]:0,w(g)&&g>=this.minPxSize/2?(d.marker=a.extend(d.marker,{radius:g,width:2*g,height:2*g}),d.dlBox={x:d.plotX-g,y:d.plotY-g,width:2*g,height:2*g}):d.shapeArgs=d.plotY=d.dlBox=void 0},alignDataLabel:t.column.prototype.alignDataLabel,buildKDTree:x,
applyZones:x},{haloPath:function(a){return b.prototype.haloPath.call(this,0===a?0:(this.marker?this.marker.radius||0:0)+a)},ttBelow:!1});l.prototype.beforePadding=function(){var a=this,b=this.len,c=this.chart,g=0,h=b,e=this.isXAxis,t=e?"xData":"yData",l=this.min,x={},y=Math.min(c.plotWidth,c.plotHeight),D=Number.MAX_VALUE,E=-Number.MAX_VALUE,F=this.max-l,C=b/F,G=[];q(this.series,function(b){var g=b.options;!b.bubblePadding||!b.visible&&c.options.chart.ignoreHiddenSeries||(a.allowZoomOutside=!0,G.push(b),
e&&(q(["minSize","maxSize"],function(a){var b=g[a],c=/%$/.test(b),b=d(b);x[a]=c?y*b/100:b}),b.minPxSize=x.minSize,b.maxPxSize=Math.max(x.maxSize,x.minSize),b=b.zData,b.length&&(D=v(g.zMin,Math.min(D,Math.max(p(b),!1===g.displayNegative?g.zThreshold:-Number.MAX_VALUE))),E=v(g.zMax,Math.max(E,m(b))))))});q(G,function(b){var c=b[t],d=c.length,f;e&&b.getRadii(D,E,b.minPxSize,b.maxPxSize);if(0<F)for(;d--;)w(c[d])&&a.dataMin<=c[d]&&c[d]<=a.dataMax&&(f=b.radii[d],g=Math.min((c[d]-l)*C-f,g),h=Math.max((c[d]-
l)*C+f,h))});G.length&&0<F&&!this.isLog&&(h-=b,C*=(b+g-h)/b,q([["min","userMin",g],["max","userMax",h]],function(b){void 0===v(a.options[b[0]],a[b[1]])&&(a[b[0]]+=b[2]/C)}))}})(y);(function(a){var m=a.merge,p=a.Point,l=a.seriesType,e=a.seriesTypes;e.bubble&&l("mapbubble","bubble",{animationLimit:500,tooltip:{pointFormat:"{point.name}: {point.z}"}},{xyFromShape:!0,type:"mapbubble",pointArrayMap:["z"],getMapData:e.map.prototype.getMapData,getBox:e.map.prototype.getBox,setData:e.map.prototype.setData},
{applyOptions:function(a,l){return a&&void 0!==a.lat&&void 0!==a.lon?p.prototype.applyOptions.call(this,m(a,this.series.chart.fromLatLonToPoint(a)),l):e.map.prototype.pointClass.prototype.applyOptions.call(this,a,l)},ttBelow:!1})})(y);(function(a){var m=a.colorPointMixin,p=a.each,l=a.merge,e=a.noop,q=a.pick,w=a.Series,x=a.seriesType,v=a.seriesTypes;x("heatmap","scatter",{animation:!1,borderWidth:0,nullColor:"#f7f7f7",dataLabels:{formatter:function(){return this.point.value},inside:!0,verticalAlign:"middle",
crop:!1,overflow:!1,padding:0},marker:null,pointRange:null,tooltip:{pointFormat:"{point.x}, {point.y}: {point.value}\x3cbr/\x3e"},states:{normal:{animation:!0},hover:{halo:!1,brightness:.2}}},l(a.colorSeriesMixin,{pointArrayMap:["y","value"],hasPointSpecificOptions:!0,supportsDrilldown:!0,getExtremesFromAll:!0,directTouch:!0,init:function(){var a;v.scatter.prototype.init.apply(this,arguments);a=this.options;a.pointRange=q(a.pointRange,a.colsize||1);this.yAxis.axisPointRange=a.rowsize||1},translate:function(){var a=
this.options,b=this.xAxis,c=this.yAxis,g=function(a,b,c){return Math.min(Math.max(b,a),c)};this.generatePoints();p(this.points,function(d){var k=(a.colsize||1)/2,f=(a.rowsize||1)/2,e=g(Math.round(b.len-b.translate(d.x-k,0,1,0,1)),-b.len,2*b.len),k=g(Math.round(b.len-b.translate(d.x+k,0,1,0,1)),-b.len,2*b.len),l=g(Math.round(c.translate(d.y-f,0,1,0,1)),-c.len,2*c.len),f=g(Math.round(c.translate(d.y+f,0,1,0,1)),-c.len,2*c.len);d.plotX=d.clientX=(e+k)/2;d.plotY=(l+f)/2;d.shapeType="rect";d.shapeArgs=
{x:Math.min(e,k),y:Math.min(l,f),width:Math.abs(k-e),height:Math.abs(f-l)}});this.translateColors()},drawPoints:function(){v.column.prototype.drawPoints.call(this);p(this.points,function(a){a.graphic.attr(this.colorAttribs(a))},this)},animate:e,getBox:e,drawLegendSymbol:a.LegendSymbolMixin.drawRectangle,alignDataLabel:v.column.prototype.alignDataLabel,getExtremes:function(){w.prototype.getExtremes.call(this,this.valueData);this.valueMin=this.dataMin;this.valueMax=this.dataMax;w.prototype.getExtremes.call(this)}}),
m)})(y);(function(a){function m(a,b){var c,g,d,e=!1,f=a.x,n=a.y;a=0;for(c=b.length-1;a<b.length;c=a++)g=b[a][1]>n,d=b[c][1]>n,g!==d&&f<(b[c][0]-b[a][0])*(n-b[a][1])/(b[c][1]-b[a][1])+b[a][0]&&(e=!e);return e}var p=a.Chart,l=a.each,e=a.extend,q=a.format,w=a.merge,x=a.win,v=a.wrap;p.prototype.transformFromLatLon=function(d,b){if(void 0===x.proj4)return a.error(21),{x:0,y:null};d=x.proj4(b.crs,[d.lon,d.lat]);var c=b.cosAngle||b.rotation&&Math.cos(b.rotation),g=b.sinAngle||b.rotation&&Math.sin(b.rotation);
d=b.rotation?[d[0]*c+d[1]*g,-d[0]*g+d[1]*c]:d;return{x:((d[0]-(b.xoffset||0))*(b.scale||1)+(b.xpan||0))*(b.jsonres||1)+(b.jsonmarginX||0),y:(((b.yoffset||0)-d[1])*(b.scale||1)+(b.ypan||0))*(b.jsonres||1)-(b.jsonmarginY||0)}};p.prototype.transformToLatLon=function(d,b){if(void 0===x.proj4)a.error(21);else{d={x:((d.x-(b.jsonmarginX||0))/(b.jsonres||1)-(b.xpan||0))/(b.scale||1)+(b.xoffset||0),y:((-d.y-(b.jsonmarginY||0))/(b.jsonres||1)+(b.ypan||0))/(b.scale||1)+(b.yoffset||0)};var c=b.cosAngle||b.rotation&&
Math.cos(b.rotation),g=b.sinAngle||b.rotation&&Math.sin(b.rotation);b=x.proj4(b.crs,"WGS84",b.rotation?{x:d.x*c+d.y*-g,y:d.x*g+d.y*c}:d);return{lat:b.y,lon:b.x}}};p.prototype.fromPointToLatLon=function(d){var b=this.mapTransforms,c;if(b){for(c in b)if(b.hasOwnProperty(c)&&b[c].hitZone&&m({x:d.x,y:-d.y},b[c].hitZone.coordinates[0]))return this.transformToLatLon(d,b[c]);return this.transformToLatLon(d,b["default"])}a.error(22)};p.prototype.fromLatLonToPoint=function(d){var b=this.mapTransforms,c,g;
if(!b)return a.error(22),{x:0,y:null};for(c in b)if(b.hasOwnProperty(c)&&b[c].hitZone&&(g=this.transformFromLatLon(d,b[c]),m({x:g.x,y:-g.y},b[c].hitZone.coordinates[0])))return g;return this.transformFromLatLon(d,b["default"])};a.geojson=function(a,b,c){var g=[],d=[],k=function(a){var b,c=a.length;d.push("M");for(b=0;b<c;b++)1===b&&d.push("L"),d.push(a[b][0],-a[b][1])};b=b||"map";l(a.features,function(a){var c=a.geometry,f=c.type,c=c.coordinates;a=a.properties;var h;d=[];"map"===b||"mapbubble"===
b?("Polygon"===f?(l(c,k),d.push("Z")):"MultiPolygon"===f&&(l(c,function(a){l(a,k)}),d.push("Z")),d.length&&(h={path:d})):"mapline"===b?("LineString"===f?k(c):"MultiLineString"===f&&l(c,k),d.length&&(h={path:d})):"mappoint"===b&&"Point"===f&&(h={x:c[0],y:-c[1]});h&&g.push(e(h,{name:a.name||a.NAME,properties:a}))});c&&a.copyrightShort&&(c.chart.mapCredits=q(c.chart.options.credits.mapText,{geojson:a}),c.chart.mapCreditsFull=q(c.chart.options.credits.mapTextFull,{geojson:a}));return g};v(p.prototype,
"addCredits",function(a,b){b=w(!0,this.options.credits,b);this.mapCredits&&(b.href=null);a.call(this,b);this.credits&&this.mapCreditsFull&&this.credits.attr({title:this.mapCreditsFull})})})(y);(function(a){function m(a,b,d,e,f,l,m,h){return["M",a+f,b,"L",a+d-l,b,"C",a+d-l/2,b,a+d,b+l/2,a+d,b+l,"L",a+d,b+e-m,"C",a+d,b+e-m/2,a+d-m/2,b+e,a+d-m,b+e,"L",a+h,b+e,"C",a+h/2,b+e,a,b+e-h/2,a,b+e-h,"L",a,b+f,"C",a,b+f/2,a+f/2,b,a+f,b,"Z"]}var p=a.Chart,l=a.defaultOptions,e=a.each,q=a.extend,w=a.merge,x=a.pick,
v=a.Renderer,d=a.SVGRenderer,b=a.VMLRenderer;q(l.lang,{zoomIn:"Zoom in",zoomOut:"Zoom out"});l.mapNavigation={buttonOptions:{alignTo:"plotBox",align:"left",verticalAlign:"top",x:0,width:18,height:18,padding:5,style:{fontSize:"15px",fontWeight:"bold"},theme:{"stroke-width":1,"text-align":"center"}},buttons:{zoomIn:{onclick:function(){this.mapZoom(.5)},text:"+",y:0},zoomOut:{onclick:function(){this.mapZoom(2)},text:"-",y:28}},mouseWheelSensitivity:1.1};a.splitPath=function(a){var b;a=a.replace(/([A-Za-z])/g,
" $1 ");a=a.replace(/^\s*/,"").replace(/\s*$/,"");a=a.split(/[ ,]+/);for(b=0;b<a.length;b++)/[a-zA-Z]/.test(a[b])||(a[b]=parseFloat(a[b]));return a};a.maps={};d.prototype.symbols.topbutton=function(a,b,d,e,f){return m(a-1,b-1,d,e,f.r,f.r,0,0)};d.prototype.symbols.bottombutton=function(a,b,d,e,f){return m(a-1,b-1,d,e,0,0,f.r,f.r)};v===b&&e(["topbutton","bottombutton"],function(a){b.prototype.symbols[a]=d.prototype.symbols[a]});a.Map=a.mapChart=function(b,d,e){var c="string"===typeof b||b.nodeName,
f=arguments[c?1:0],g={endOnTick:!1,visible:!1,minPadding:0,maxPadding:0,startOnTick:!1},l,h=a.getOptions().credits;l=f.series;f.series=null;f=w({chart:{panning:"xy",type:"map"},credits:{mapText:x(h.mapText,' \u00a9 \x3ca href\x3d"{geojson.copyrightUrl}"\x3e{geojson.copyrightShort}\x3c/a\x3e'),mapTextFull:x(h.mapTextFull,"{geojson.copyright}")},tooltip:{followTouchMove:!1},xAxis:g,yAxis:w(g,{reversed:!0})},f,{chart:{inverted:!1,alignTicks:!1}});f.series=l;return c?new p(b,f,e):new p(f,d)}})(y)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 | 1 1 1 1 1 1 1 | /**
* @license Highmaps JS v5.0.10 (2017-03-31)
* Highmaps as a plugin for Highcharts 4.1.x or Highstock 2.1.x (x being the patch version of this file)
*
* (c) 2011-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
each = H.each,
pick = H.pick,
wrap = H.wrap;
/**
* Override to use the extreme coordinates from the SVG shape, not the
* data values
*/
wrap(Axis.prototype, 'getSeriesExtremes', function(proceed) {
var isXAxis = this.isXAxis,
dataMin,
dataMax,
xData = [],
useMapGeometry;
// Remove the xData array and cache it locally so that the proceed method doesn't use it
if (isXAxis) {
each(this.series, function(series, i) {
if (series.useMapGeometry) {
xData[i] = series.xData;
series.xData = [];
}
});
}
// Call base to reach normal cartesian series (like mappoint)
proceed.call(this);
// Run extremes logic for map and mapline
if (isXAxis) {
dataMin = pick(this.dataMin, Number.MAX_VALUE);
dataMax = pick(this.dataMax, -Number.MAX_VALUE);
each(this.series, function(series, i) {
if (series.useMapGeometry) {
dataMin = Math.min(dataMin, pick(series.minX, dataMin));
dataMax = Math.max(dataMax, pick(series.maxX, dataMin));
series.xData = xData[i]; // Reset xData array
useMapGeometry = true;
}
});
if (useMapGeometry) {
this.dataMin = dataMin;
this.dataMax = dataMax;
}
}
});
/**
* Override axis translation to make sure the aspect ratio is always kept
*/
wrap(Axis.prototype, 'setAxisTranslation', function(proceed) {
var chart = this.chart,
mapRatio,
plotRatio = chart.plotWidth / chart.plotHeight,
adjustedAxisLength,
xAxis = chart.xAxis[0],
padAxis,
fixTo,
fixDiff,
preserveAspectRatio;
// Run the parent method
proceed.call(this);
// Check for map-like series
if (this.coll === 'yAxis' && xAxis.transA !== undefined) {
each(this.series, function(series) {
if (series.preserveAspectRatio) {
preserveAspectRatio = true;
}
});
}
// On Y axis, handle both
if (preserveAspectRatio) {
// Use the same translation for both axes
this.transA = xAxis.transA = Math.min(this.transA, xAxis.transA);
mapRatio = plotRatio / ((xAxis.max - xAxis.min) / (this.max - this.min));
// What axis to pad to put the map in the middle
padAxis = mapRatio < 1 ? this : xAxis;
// Pad it
adjustedAxisLength = (padAxis.max - padAxis.min) * padAxis.transA;
padAxis.pixelPadding = padAxis.len - adjustedAxisLength;
padAxis.minPixelPadding = padAxis.pixelPadding / 2;
fixTo = padAxis.fixTo;
if (fixTo) {
fixDiff = fixTo[1] - padAxis.toValue(fixTo[0], true);
fixDiff *= padAxis.transA;
if (Math.abs(fixDiff) > padAxis.minPixelPadding || (padAxis.min === padAxis.dataMin && padAxis.max === padAxis.dataMax)) { // zooming out again, keep within restricted area
fixDiff = 0;
}
padAxis.minPixelPadding -= fixDiff;
}
}
});
/**
* Override Axis.render in order to delete the fixTo prop
*/
wrap(Axis.prototype, 'render', function(proceed) {
proceed.call(this);
this.fixTo = null;
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Axis = H.Axis,
Chart = H.Chart,
color = H.color,
ColorAxis,
each = H.each,
extend = H.extend,
isNumber = H.isNumber,
Legend = H.Legend,
LegendSymbolMixin = H.LegendSymbolMixin,
noop = H.noop,
merge = H.merge,
pick = H.pick,
wrap = H.wrap;
/**
* The ColorAxis object for inclusion in gradient legends
*/
ColorAxis = H.ColorAxis = function() {
this.init.apply(this, arguments);
};
extend(ColorAxis.prototype, Axis.prototype);
extend(ColorAxis.prototype, {
defaultColorAxisOptions: {
lineWidth: 0,
minPadding: 0,
maxPadding: 0,
gridLineWidth: 1,
tickPixelInterval: 72,
startOnTick: true,
endOnTick: true,
offset: 0,
marker: {
animation: {
duration: 50
},
width: 0.01,
color: '#999999'
},
labels: {
overflow: 'justify',
rotation: 0
},
minColor: '#e6ebf5',
maxColor: '#003399',
tickLength: 5,
showInLegend: true
},
// Properties to preserve after destroy, for Axis.update (#5881, #6025)
keepProps: [
'legendGroup',
'legendItemHeight',
'legendItemWidth',
'legendItem',
'legendSymbol'
].concat(Axis.prototype.keepProps),
/**
* Initialize the color axis
*/
init: function(chart, userOptions) {
var horiz = chart.options.legend.layout !== 'vertical',
options;
this.coll = 'colorAxis';
// Build the options
options = merge(this.defaultColorAxisOptions, {
side: horiz ? 2 : 1,
reversed: !horiz
}, userOptions, {
opposite: !horiz,
showEmpty: false,
title: null
});
Axis.prototype.init.call(this, chart, options);
// Base init() pushes it to the xAxis array, now pop it again
//chart[this.isXAxis ? 'xAxis' : 'yAxis'].pop();
// Prepare data classes
if (userOptions.dataClasses) {
this.initDataClasses(userOptions);
}
this.initStops(userOptions);
// Override original axis properties
this.horiz = horiz;
this.zoomEnabled = false;
// Add default values
this.defaultLegendLength = 200;
},
/*
* Return an intermediate color between two colors, according to pos where 0
* is the from color and 1 is the to color.
* NOTE: Changes here should be copied
* to the same function in drilldown.src.js and solid-gauge-src.js.
*/
tweenColors: function(from, to, pos) {
// Check for has alpha, because rgba colors perform worse due to lack of
// support in WebKit.
var hasAlpha,
ret;
// Unsupported color, return to-color (#3920)
if (!to.rgba.length || !from.rgba.length) {
ret = to.input || 'none';
// Interpolate
} else {
from = from.rgba;
to = to.rgba;
hasAlpha = (to[3] !== 1 || from[3] !== 1);
ret = (hasAlpha ? 'rgba(' : 'rgb(') +
Math.round(to[0] + (from[0] - to[0]) * (1 - pos)) + ',' +
Math.round(to[1] + (from[1] - to[1]) * (1 - pos)) + ',' +
Math.round(to[2] + (from[2] - to[2]) * (1 - pos)) +
(hasAlpha ? (',' + (to[3] + (from[3] - to[3]) * (1 - pos))) : '') + ')';
}
return ret;
},
initDataClasses: function(userOptions) {
var axis = this,
chart = this.chart,
dataClasses,
colorCounter = 0,
colorCount = chart.options.chart.colorCount,
options = this.options,
len = userOptions.dataClasses.length;
this.dataClasses = dataClasses = [];
this.legendItems = [];
each(userOptions.dataClasses, function(dataClass, i) {
var colors;
dataClass = merge(dataClass);
dataClasses.push(dataClass);
if (!dataClass.color) {
if (options.dataClassColor === 'category') {
colors = chart.options.colors;
colorCount = colors.length;
dataClass.color = colors[colorCounter];
dataClass.colorIndex = colorCounter;
// increase and loop back to zero
colorCounter++;
if (colorCounter === colorCount) {
colorCounter = 0;
}
} else {
dataClass.color = axis.tweenColors(
color(options.minColor),
color(options.maxColor),
len < 2 ? 0.5 : i / (len - 1) // #3219
);
}
}
});
},
initStops: function(userOptions) {
this.stops = userOptions.stops || [
[0, this.options.minColor],
[1, this.options.maxColor]
];
each(this.stops, function(stop) {
stop.color = color(stop[1]);
});
},
/**
* Extend the setOptions method to process extreme colors and color
* stops.
*/
setOptions: function(userOptions) {
Axis.prototype.setOptions.call(this, userOptions);
this.options.crosshair = this.options.marker;
},
setAxisSize: function() {
var symbol = this.legendSymbol,
chart = this.chart,
legendOptions = chart.options.legend || {},
x,
y,
width,
height;
if (symbol) {
this.left = x = symbol.attr('x');
this.top = y = symbol.attr('y');
this.width = width = symbol.attr('width');
this.height = height = symbol.attr('height');
this.right = chart.chartWidth - x - width;
this.bottom = chart.chartHeight - y - height;
this.len = this.horiz ? width : height;
this.pos = this.horiz ? x : y;
} else {
// Fake length for disabled legend to avoid tick issues and such (#5205)
this.len = (this.horiz ? legendOptions.symbolWidth : legendOptions.symbolHeight) || this.defaultLegendLength;
}
},
/**
* Translate from a value to a color
*/
toColor: function(value, point) {
var pos,
stops = this.stops,
from,
to,
color,
dataClasses = this.dataClasses,
dataClass,
i;
if (dataClasses) {
i = dataClasses.length;
while (i--) {
dataClass = dataClasses[i];
from = dataClass.from;
to = dataClass.to;
if ((from === undefined || value >= from) && (to === undefined || value <= to)) {
color = dataClass.color;
if (point) {
point.dataClass = i;
point.colorIndex = dataClass.colorIndex;
}
break;
}
}
} else {
if (this.isLog) {
value = this.val2lin(value);
}
pos = 1 - ((this.max - value) / ((this.max - this.min) || 1));
i = stops.length;
while (i--) {
if (pos > stops[i][0]) {
break;
}
}
from = stops[i] || stops[i + 1];
to = stops[i + 1] || from;
// The position within the gradient
pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1);
color = this.tweenColors(
from.color,
to.color,
pos
);
}
return color;
},
/**
* Override the getOffset method to add the whole axis groups inside the legend.
*/
getOffset: function() {
var group = this.legendGroup,
sideOffset = this.chart.axisOffset[this.side];
if (group) {
// Hook for the getOffset method to add groups to this parent group
this.axisParent = group;
// Call the base
Axis.prototype.getOffset.call(this);
// First time only
if (!this.added) {
this.added = true;
this.labelLeft = 0;
this.labelRight = this.width;
}
// Reset it to avoid color axis reserving space
this.chart.axisOffset[this.side] = sideOffset;
}
},
/**
* Create the color gradient
*/
setLegendColor: function() {
var grad,
horiz = this.horiz,
options = this.options,
reversed = this.reversed,
one = reversed ? 1 : 0,
zero = reversed ? 0 : 1;
grad = horiz ? [one, 0, zero, 0] : [0, zero, 0, one]; // #3190
this.legendColor = {
linearGradient: {
x1: grad[0],
y1: grad[1],
x2: grad[2],
y2: grad[3]
},
stops: options.stops || [
[0, options.minColor],
[1, options.maxColor]
]
};
},
/**
* The color axis appears inside the legend and has its own legend symbol
*/
drawLegendSymbol: function(legend, item) {
var padding = legend.padding,
legendOptions = legend.options,
horiz = this.horiz,
width = pick(legendOptions.symbolWidth, horiz ? this.defaultLegendLength : 12),
height = pick(legendOptions.symbolHeight, horiz ? 12 : this.defaultLegendLength),
labelPadding = pick(legendOptions.labelPadding, horiz ? 16 : 30),
itemDistance = pick(legendOptions.itemDistance, 10);
this.setLegendColor();
// Create the gradient
item.legendSymbol = this.chart.renderer.rect(
0,
legend.baseline - 11,
width,
height
).attr({
zIndex: 1
}).add(item.legendGroup);
// Set how much space this legend item takes up
this.legendItemWidth = width + padding + (horiz ? itemDistance : labelPadding);
this.legendItemHeight = height + padding + (horiz ? labelPadding : 0);
},
/**
* Fool the legend
*/
setState: noop,
visible: true,
setVisible: noop,
getSeriesExtremes: function() {
var series = this.series,
i = series.length;
this.dataMin = Infinity;
this.dataMax = -Infinity;
while (i--) {
if (series[i].valueMin !== undefined) {
this.dataMin = Math.min(this.dataMin, series[i].valueMin);
this.dataMax = Math.max(this.dataMax, series[i].valueMax);
}
}
},
drawCrosshair: function(e, point) {
var plotX = point && point.plotX,
plotY = point && point.plotY,
crossPos,
axisPos = this.pos,
axisLen = this.len;
if (point) {
crossPos = this.toPixels(point[point.series.colorKey]);
if (crossPos < axisPos) {
crossPos = axisPos - 2;
} else if (crossPos > axisPos + axisLen) {
crossPos = axisPos + axisLen + 2;
}
point.plotX = crossPos;
point.plotY = this.len - crossPos;
Axis.prototype.drawCrosshair.call(this, e, point);
point.plotX = plotX;
point.plotY = plotY;
if (this.cross) {
this.cross
.addClass('highcharts-coloraxis-marker')
.add(this.legendGroup);
this.cross.attr({
fill: this.crosshair.color
});
}
}
},
getPlotLinePath: function(a, b, c, d, pos) {
return isNumber(pos) ? // crosshairs only // #3969 pos can be 0 !!
(this.horiz ? ['M', pos - 4, this.top - 6, 'L', pos + 4, this.top - 6, pos, this.top, 'Z'] : ['M', this.left, pos, 'L', this.left - 6, pos + 6, this.left - 6, pos - 6, 'Z']) :
Axis.prototype.getPlotLinePath.call(this, a, b, c, d);
},
update: function(newOptions, redraw) {
var chart = this.chart,
legend = chart.legend;
each(this.series, function(series) {
series.isDirtyData = true; // Needed for Axis.update when choropleth colors change
});
// When updating data classes, destroy old items and make sure new ones are created (#3207)
if (newOptions.dataClasses && legend.allItems) {
each(legend.allItems, function(item) {
if (item.isDataClass) {
item.legendGroup.destroy();
}
});
chart.isDirtyLegend = true;
}
// Keep the options structure updated for export. Unlike xAxis and yAxis, the colorAxis is
// not an array. (#3207)
chart.options[this.coll] = merge(this.userOptions, newOptions);
Axis.prototype.update.call(this, newOptions, redraw);
if (this.legendItem) {
this.setLegendColor();
legend.colorizeItem(this, true);
}
},
/**
* Get the legend item symbols for data classes
*/
getDataClassLegendSymbols: function() {
var axis = this,
chart = this.chart,
legendItems = this.legendItems,
legendOptions = chart.options.legend,
valueDecimals = legendOptions.valueDecimals,
valueSuffix = legendOptions.valueSuffix || '',
name;
if (!legendItems.length) {
each(this.dataClasses, function(dataClass, i) {
var vis = true,
from = dataClass.from,
to = dataClass.to;
// Assemble the default name. This can be overridden by legend.options.labelFormatter
name = '';
if (from === undefined) {
name = '< ';
} else if (to === undefined) {
name = '> ';
}
if (from !== undefined) {
name += H.numberFormat(from, valueDecimals) + valueSuffix;
}
if (from !== undefined && to !== undefined) {
name += ' - ';
}
if (to !== undefined) {
name += H.numberFormat(to, valueDecimals) + valueSuffix;
}
// Add a mock object to the legend items
legendItems.push(extend({
chart: chart,
name: name,
options: {},
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
visible: true,
setState: noop,
isDataClass: true,
setVisible: function() {
vis = this.visible = !vis;
each(axis.series, function(series) {
each(series.points, function(point) {
if (point.dataClass === i) {
point.setVisible(vis);
}
});
});
chart.legend.colorizeItem(this, vis);
}
}, dataClass));
});
}
return legendItems;
},
name: '' // Prevents 'undefined' in legend in IE8
});
/**
* Handle animation of the color attributes directly
*/
each(['fill', 'stroke'], function(prop) {
H.Fx.prototype[prop + 'Setter'] = function() {
this.elem.attr(
prop,
ColorAxis.prototype.tweenColors(
color(this.start),
color(this.end),
this.pos
),
null,
true
);
};
});
/**
* Extend the chart getAxes method to also get the color axis
*/
wrap(Chart.prototype, 'getAxes', function(proceed) {
var options = this.options,
colorAxisOptions = options.colorAxis;
proceed.call(this);
this.colorAxis = [];
if (colorAxisOptions) {
new ColorAxis(this, colorAxisOptions); // eslint-disable-line no-new
}
});
/**
* Wrap the legend getAllItems method to add the color axis. This also removes the
* axis' own series to prevent them from showing up individually.
*/
wrap(Legend.prototype, 'getAllItems', function(proceed) {
var allItems = [],
colorAxis = this.chart.colorAxis[0];
if (colorAxis && colorAxis.options) {
if (colorAxis.options.showInLegend) {
// Data classes
if (colorAxis.options.dataClasses) {
allItems = allItems.concat(colorAxis.getDataClassLegendSymbols());
// Gradient legend
} else {
// Add this axis on top
allItems.push(colorAxis);
}
}
// Don't add the color axis' series
each(colorAxis.series, function(series) {
series.options.showInLegend = false;
});
}
return allItems.concat(proceed.call(this));
});
wrap(Legend.prototype, 'colorizeItem', function(proceed, item, visible) {
proceed.call(this, item, visible);
if (visible && item.legendColor) {
item.legendSymbol.attr({
fill: item.legendColor
});
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var defined = H.defined,
each = H.each,
noop = H.noop,
seriesTypes = H.seriesTypes;
/**
* Mixin for maps and heatmaps
*/
H.colorPointMixin = {
/**
* Color points have a value option that determines whether or not it is a null point
*/
isValid: function() {
return this.value !== null;
},
/**
* Set the visibility of a single point
*/
setVisible: function(vis) {
var point = this,
method = vis ? 'show' : 'hide';
// Show and hide associated elements
each(['graphic', 'dataLabel'], function(key) {
if (point[key]) {
point[key][method]();
}
});
},
setState: function(state) {
H.Point.prototype.setState.call(this, state);
if (this.graphic) {
this.graphic.attr({
zIndex: state === 'hover' ? 1 : 0
});
}
}
};
H.colorSeriesMixin = {
pointArrayMap: ['value'],
axisTypes: ['xAxis', 'yAxis', 'colorAxis'],
optionalAxis: 'colorAxis',
trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
getSymbol: noop,
parallelArrays: ['x', 'y', 'value'],
colorKey: 'value',
pointAttribs: seriesTypes.column.prototype.pointAttribs,
/**
* In choropleth maps, the color is a result of the value, so this needs translation too
*/
translateColors: function() {
var series = this,
nullColor = this.options.nullColor,
colorAxis = this.colorAxis,
colorKey = this.colorKey;
each(this.data, function(point) {
var value = point[colorKey],
color;
color = point.options.color ||
(point.isNull ? nullColor : (colorAxis && value !== undefined) ? colorAxis.toColor(value, point) : point.color || series.color);
if (color) {
point.color = color;
}
});
},
/**
* Get the color attibutes to apply on the graphic
*/
colorAttribs: function(point) {
var ret = {};
if (defined(point.color)) {
ret[this.colorProp || 'fill'] = point.color;
}
return ret;
}
};
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
Chart = H.Chart,
doc = H.doc,
each = H.each,
extend = H.extend,
merge = H.merge,
pick = H.pick,
wrap = H.wrap;
function stopEvent(e) {
if (e) {
if (e.preventDefault) {
e.preventDefault();
}
if (e.stopPropagation) {
e.stopPropagation();
}
e.cancelBubble = true;
}
}
/**
* The MapNavigation handles buttons for navigation in addition to mousewheel
* and doubleclick handlers for chart zooming.
* @param {Chart} chart The Chart instance.
* @class
*/
function MapNavigation(chart) {
this.init(chart);
}
/**
* Initiator function.
* @param {Chart} chart The Chart instance.
*/
MapNavigation.prototype.init = function(chart) {
this.chart = chart;
chart.mapNavButtons = [];
};
/**
* Update the map navigation with new options. Calling this is the same as
* calling `chart.update({ mapNavigation: {} })`.
* @param {Object} options New options for the map navigation.
*/
MapNavigation.prototype.update = function(options) {
var chart = this.chart,
o = chart.options.mapNavigation,
buttons,
n,
button,
buttonOptions,
attr,
states,
hoverStates,
selectStates,
outerHandler = function(e) {
this.handler.call(chart, e);
stopEvent(e); // Stop default click event (#4444)
},
mapNavButtons = chart.mapNavButtons;
// Merge in new options in case of update, and register back to chart
// options.
if (options) {
o = chart.options.mapNavigation =
merge(chart.options.mapNavigation, options);
}
// Destroy buttons in case of dynamic update
while (mapNavButtons.length) {
mapNavButtons.pop().destroy();
}
if (pick(o.enableButtons, o.enabled) && !chart.renderer.forExport) {
buttons = o.buttons;
for (n in buttons) {
if (buttons.hasOwnProperty(n)) {
buttonOptions = merge(o.buttonOptions, buttons[n]);
// Presentational
attr = buttonOptions.theme;
attr.style = merge(
buttonOptions.theme.style,
buttonOptions.style // #3203
);
states = attr.states;
hoverStates = states && states.hover;
selectStates = states && states.select;
button = chart.renderer.button(
buttonOptions.text,
0,
0,
outerHandler,
attr,
hoverStates,
selectStates,
0,
n === 'zoomIn' ? 'topbutton' : 'bottombutton'
)
.addClass('highcharts-map-navigation')
.attr({
width: buttonOptions.width,
height: buttonOptions.height,
title: chart.options.lang[n],
padding: buttonOptions.padding,
zIndex: 5
})
.add();
button.handler = buttonOptions.onclick;
button.align(
extend(buttonOptions, {
width: button.width,
height: 2 * button.height
}),
null,
buttonOptions.alignTo
);
// Stop double click event (#4444)
addEvent(button.element, 'dblclick', stopEvent);
mapNavButtons.push(button);
}
}
}
this.updateEvents(o);
};
/**
* Update events, called internally from the update function. Add new event
* handlers, or unbinds events if disabled.
* @param {Object} options Options for map navigation.
*/
MapNavigation.prototype.updateEvents = function(options) {
var chart = this.chart;
// Add the double click event
if (
pick(options.enableDoubleClickZoom, options.enabled) ||
options.enableDoubleClickZoomTo
) {
this.unbindDblClick = this.unbindDblClick || addEvent(
chart.container,
'dblclick',
function(e) {
chart.pointer.onContainerDblClick(e);
}
);
} else if (this.unbindDblClick) {
// Unbind and set unbinder to undefined
this.unbindDblClick = this.unbindDblClick();
}
// Add the mousewheel event
if (pick(options.enableMouseWheelZoom, options.enabled)) {
this.unbindMouseWheel = this.unbindMouseWheel || addEvent(
chart.container,
doc.onmousewheel === undefined ? 'DOMMouseScroll' : 'mousewheel',
function(e) {
chart.pointer.onContainerMouseWheel(e);
// Issue #5011, returning false from non-jQuery event does
// not prevent default
stopEvent(e);
return false;
}
);
} else if (this.unbindMouseWheel) {
// Unbind and set unbinder to undefined
this.unbindMouseWheel = this.unbindMouseWheel();
}
};
// Add events to the Chart object itself
extend(Chart.prototype, {
/**
* Fit an inner box to an outer. If the inner box overflows left or right, align it to the sides of the
* outer. If it overflows both sides, fit it within the outer. This is a pattern that occurs more places
* in Highcharts, perhaps it should be elevated to a common utility function.
*/
fitToBox: function(inner, outer) {
each([
['x', 'width'],
['y', 'height']
], function(dim) {
var pos = dim[0],
size = dim[1];
if (inner[pos] + inner[size] > outer[pos] + outer[size]) { // right overflow
if (inner[size] > outer[size]) { // the general size is greater, fit fully to outer
inner[size] = outer[size];
inner[pos] = outer[pos];
} else { // align right
inner[pos] = outer[pos] + outer[size] - inner[size];
}
}
if (inner[size] > outer[size]) {
inner[size] = outer[size];
}
if (inner[pos] < outer[pos]) {
inner[pos] = outer[pos];
}
});
return inner;
},
/**
* Zoom the map in or out by a certain amount. Less than 1 zooms in, greater than 1 zooms out.
*/
mapZoom: function(howMuch, centerXArg, centerYArg, mouseX, mouseY) {
/*if (this.isMapZooming) {
this.mapZoomQueue = arguments;
return;
}*/
var chart = this,
xAxis = chart.xAxis[0],
xRange = xAxis.max - xAxis.min,
centerX = pick(centerXArg, xAxis.min + xRange / 2),
newXRange = xRange * howMuch,
yAxis = chart.yAxis[0],
yRange = yAxis.max - yAxis.min,
centerY = pick(centerYArg, yAxis.min + yRange / 2),
newYRange = yRange * howMuch,
fixToX = mouseX ? ((mouseX - xAxis.pos) / xAxis.len) : 0.5,
fixToY = mouseY ? ((mouseY - yAxis.pos) / yAxis.len) : 0.5,
newXMin = centerX - newXRange * fixToX,
newYMin = centerY - newYRange * fixToY,
newExt = chart.fitToBox({
x: newXMin,
y: newYMin,
width: newXRange,
height: newYRange
}, {
x: xAxis.dataMin,
y: yAxis.dataMin,
width: xAxis.dataMax - xAxis.dataMin,
height: yAxis.dataMax - yAxis.dataMin
}),
zoomOut = newExt.x <= xAxis.dataMin &&
newExt.width >= xAxis.dataMax - xAxis.dataMin &&
newExt.y <= yAxis.dataMin &&
newExt.height >= yAxis.dataMax - yAxis.dataMin;
// When mousewheel zooming, fix the point under the mouse
if (mouseX) {
xAxis.fixTo = [mouseX - xAxis.pos, centerXArg];
}
if (mouseY) {
yAxis.fixTo = [mouseY - yAxis.pos, centerYArg];
}
// Zoom
if (howMuch !== undefined && !zoomOut) {
xAxis.setExtremes(newExt.x, newExt.x + newExt.width, false);
yAxis.setExtremes(newExt.y, newExt.y + newExt.height, false);
// Reset zoom
} else {
xAxis.setExtremes(undefined, undefined, false);
yAxis.setExtremes(undefined, undefined, false);
}
// Prevent zooming until this one is finished animating
/*chart.holdMapZoom = true;
setTimeout(function () {
chart.holdMapZoom = false;
}, 200);*/
/*delay = animation ? animation.duration || 500 : 0;
if (delay) {
chart.isMapZooming = true;
setTimeout(function () {
chart.isMapZooming = false;
if (chart.mapZoomQueue) {
chart.mapZoom.apply(chart, chart.mapZoomQueue);
}
chart.mapZoomQueue = null;
}, delay);
}*/
chart.redraw();
}
});
/**
* Extend the Chart.render method to add zooming and panning
*/
wrap(Chart.prototype, 'render', function(proceed) {
// Render the plus and minus buttons. Doing this before the shapes makes getBBox much quicker, at least in Chrome.
this.mapNavigation = new MapNavigation(this);
this.mapNavigation.update();
proceed.call(this);
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var extend = H.extend,
pick = H.pick,
Pointer = H.Pointer,
wrap = H.wrap;
// Extend the Pointer
extend(Pointer.prototype, {
/**
* The event handler for the doubleclick event
*/
onContainerDblClick: function(e) {
var chart = this.chart;
e = this.normalize(e);
if (chart.options.mapNavigation.enableDoubleClickZoomTo) {
if (chart.pointer.inClass(e.target, 'highcharts-tracker') && chart.hoverPoint) {
chart.hoverPoint.zoomTo();
}
} else if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
chart.mapZoom(
0.5,
chart.xAxis[0].toValue(e.chartX),
chart.yAxis[0].toValue(e.chartY),
e.chartX,
e.chartY
);
}
},
/**
* The event handler for the mouse scroll event
*/
onContainerMouseWheel: function(e) {
var chart = this.chart,
delta;
e = this.normalize(e);
// Firefox uses e.detail, WebKit and IE uses wheelDelta
delta = e.detail || -(e.wheelDelta / 120);
if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
chart.mapZoom(
Math.pow(chart.options.mapNavigation.mouseWheelSensitivity, delta),
chart.xAxis[0].toValue(e.chartX),
chart.yAxis[0].toValue(e.chartY),
e.chartX,
e.chartY
);
}
}
});
// The pinchType is inferred from mapNavigation options.
wrap(Pointer.prototype, 'zoomOption', function(proceed) {
var mapNavigation = this.chart.options.mapNavigation;
// Pinch status
if (pick(mapNavigation.enableTouchZoom, mapNavigation.enabled)) {
this.chart.options.chart.pinchType = 'xy';
}
proceed.apply(this, [].slice.call(arguments, 1));
});
// Extend the pinchTranslate method to preserve fixed ratio when zooming
wrap(Pointer.prototype, 'pinchTranslate', function(proceed, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
var xBigger;
proceed.call(this, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
// Keep ratio
if (this.chart.options.chart.type === 'map' && this.hasZoom) {
xBigger = transform.scaleX > transform.scaleY;
this.pinchTranslateDirection(!xBigger,
pinchDown,
touches,
transform,
selectionMarker,
clip,
lastValidTouch,
xBigger ? transform.scaleX : transform.scaleY
);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var color = H.color,
ColorAxis = H.ColorAxis,
colorPointMixin = H.colorPointMixin,
colorSeriesMixin = H.colorSeriesMixin,
doc = H.doc,
each = H.each,
extend = H.extend,
isNumber = H.isNumber,
LegendSymbolMixin = H.LegendSymbolMixin,
map = H.map,
merge = H.merge,
noop = H.noop,
pick = H.pick,
isArray = H.isArray,
Point = H.Point,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes,
splat = H.splat;
// The vector-effect attribute is not supported in IE <= 11 (at least), so we need
// diffent logic (#3218)
var supportsVectorEffect = doc.documentElement.style.vectorEffect !== undefined;
/**
* The MapAreaPoint object
*/
/**
* Add the map series type
*/
seriesType('map', 'scatter', {
allAreas: true,
animation: false, // makes the complex shapes slow
nullColor: '#f7f7f7',
borderColor: '#cccccc',
borderWidth: 1,
marker: null,
stickyTracking: false,
joinBy: 'hc-key',
dataLabels: {
formatter: function() { // #2945
return this.point.value;
},
inside: true, // for the color
verticalAlign: 'middle',
crop: false,
overflow: false,
padding: 0
},
turboThreshold: 0,
tooltip: {
followPointer: true,
pointFormat: '{point.name}: {point.value}<br/>'
},
states: {
normal: {
animation: true
},
hover: {
brightness: 0.2,
halo: null
},
select: {
color: '#cccccc'
}
}
// Prototype members
}, merge(colorSeriesMixin, {
type: 'map',
supportsDrilldown: true,
getExtremesFromAll: true,
useMapGeometry: true, // get axis extremes from paths, not values
forceDL: true,
searchPoint: noop,
directTouch: true, // When tooltip is not shared, this series (and derivatives) requires direct touch/hover. KD-tree does not apply.
preserveAspectRatio: true, // X axis and Y axis must have same translation slope
pointArrayMap: ['value'],
/**
* Get the bounding box of all paths in the map combined.
*/
getBox: function(paths) {
var MAX_VALUE = Number.MAX_VALUE,
maxX = -MAX_VALUE,
minX = MAX_VALUE,
maxY = -MAX_VALUE,
minY = MAX_VALUE,
minRange = MAX_VALUE,
xAxis = this.xAxis,
yAxis = this.yAxis,
hasBox;
// Find the bounding box
each(paths || [], function(point) {
if (point.path) {
if (typeof point.path === 'string') {
point.path = H.splitPath(point.path);
}
var path = point.path || [],
i = path.length,
even = false, // while loop reads from the end
pointMaxX = -MAX_VALUE,
pointMinX = MAX_VALUE,
pointMaxY = -MAX_VALUE,
pointMinY = MAX_VALUE,
properties = point.properties;
// The first time a map point is used, analyze its box
if (!point._foundBox) {
while (i--) {
if (isNumber(path[i])) {
if (even) { // even = x
pointMaxX = Math.max(pointMaxX, path[i]);
pointMinX = Math.min(pointMinX, path[i]);
} else { // odd = Y
pointMaxY = Math.max(pointMaxY, path[i]);
pointMinY = Math.min(pointMinY, path[i]);
}
even = !even;
}
}
// Cache point bounding box for use to position data labels, bubbles etc
point._midX = pointMinX + (pointMaxX - pointMinX) *
(point.middleX || (properties && properties['hc-middle-x']) || 0.5); // pick is slower and very marginally needed
point._midY = pointMinY + (pointMaxY - pointMinY) *
(point.middleY || (properties && properties['hc-middle-y']) || 0.5);
point._maxX = pointMaxX;
point._minX = pointMinX;
point._maxY = pointMaxY;
point._minY = pointMinY;
point.labelrank = pick(point.labelrank, (pointMaxX - pointMinX) * (pointMaxY - pointMinY));
point._foundBox = true;
}
maxX = Math.max(maxX, point._maxX);
minX = Math.min(minX, point._minX);
maxY = Math.max(maxY, point._maxY);
minY = Math.min(minY, point._minY);
minRange = Math.min(point._maxX - point._minX, point._maxY - point._minY, minRange);
hasBox = true;
}
});
// Set the box for the whole series
if (hasBox) {
this.minY = Math.min(minY, pick(this.minY, MAX_VALUE));
this.maxY = Math.max(maxY, pick(this.maxY, -MAX_VALUE));
this.minX = Math.min(minX, pick(this.minX, MAX_VALUE));
this.maxX = Math.max(maxX, pick(this.maxX, -MAX_VALUE));
// If no minRange option is set, set the default minimum zooming range to 5 times the
// size of the smallest element
if (xAxis && xAxis.options.minRange === undefined) {
xAxis.minRange = Math.min(5 * minRange, (this.maxX - this.minX) / 5, xAxis.minRange || MAX_VALUE);
}
if (yAxis && yAxis.options.minRange === undefined) {
yAxis.minRange = Math.min(5 * minRange, (this.maxY - this.minY) / 5, yAxis.minRange || MAX_VALUE);
}
}
},
getExtremes: function() {
// Get the actual value extremes for colors
Series.prototype.getExtremes.call(this, this.valueData);
// Recalculate box on updated data
if (this.chart.hasRendered && this.isDirtyData) {
this.getBox(this.options.data);
}
this.valueMin = this.dataMin;
this.valueMax = this.dataMax;
// Extremes for the mock Y axis
this.dataMin = this.minY;
this.dataMax = this.maxY;
},
/**
* Translate the path so that it automatically fits into the plot area box
* @param {Object} path
*/
translatePath: function(path) {
var series = this,
even = false, // while loop reads from the end
xAxis = series.xAxis,
yAxis = series.yAxis,
xMin = xAxis.min,
xTransA = xAxis.transA,
xMinPixelPadding = xAxis.minPixelPadding,
yMin = yAxis.min,
yTransA = yAxis.transA,
yMinPixelPadding = yAxis.minPixelPadding,
i,
ret = []; // Preserve the original
// Do the translation
if (path) {
i = path.length;
while (i--) {
if (isNumber(path[i])) {
ret[i] = even ?
(path[i] - xMin) * xTransA + xMinPixelPadding :
(path[i] - yMin) * yTransA + yMinPixelPadding;
even = !even;
} else {
ret[i] = path[i];
}
}
}
return ret;
},
/**
* Extend setData to join in mapData. If the allAreas option is true, all areas
* from the mapData are used, and those that don't correspond to a data value
* are given null values.
*/
setData: function(data, redraw, animation, updatePoints) {
var options = this.options,
chartOptions = this.chart.options.chart,
globalMapData = chartOptions && chartOptions.map,
mapData = options.mapData,
joinBy = options.joinBy,
joinByNull = joinBy === null,
pointArrayMap = options.keys || this.pointArrayMap,
dataUsed = [],
mapMap = {},
mapPoint,
transform,
mapTransforms = this.chart.mapTransforms,
props,
i;
// Collect mapData from chart options if not defined on series
if (!mapData && globalMapData) {
mapData = typeof globalMapData === 'string' ? H.maps[globalMapData] : globalMapData;
}
if (joinByNull) {
joinBy = '_i';
}
joinBy = this.joinBy = splat(joinBy);
if (!joinBy[1]) {
joinBy[1] = joinBy[0];
}
// Pick up numeric values, add index
// Convert Array point definitions to objects using pointArrayMap
if (data) {
each(data, function(val, i) {
var ix = 0;
if (isNumber(val)) {
data[i] = {
value: val
};
} else if (isArray(val)) {
data[i] = {};
// Automatically copy first item to hc-key if there is an extra leading string
if (!options.keys && val.length > pointArrayMap.length && typeof val[0] === 'string') {
data[i]['hc-key'] = val[0];
++ix;
}
// Run through pointArrayMap and what's left of the point data array in parallel, copying over the values
for (var j = 0; j < pointArrayMap.length; ++j, ++ix) {
if (pointArrayMap[j]) {
data[i][pointArrayMap[j]] = val[ix];
}
}
}
if (joinByNull) {
data[i]._i = i;
}
});
}
this.getBox(data);
// Pick up transform definitions for chart
this.chart.mapTransforms = mapTransforms = chartOptions && chartOptions.mapTransforms || mapData && mapData['hc-transform'] || mapTransforms;
// Cache cos/sin of transform rotation angle
if (mapTransforms) {
for (transform in mapTransforms) {
if (mapTransforms.hasOwnProperty(transform) && transform.rotation) {
transform.cosAngle = Math.cos(transform.rotation);
transform.sinAngle = Math.sin(transform.rotation);
}
}
}
if (mapData) {
if (mapData.type === 'FeatureCollection') {
this.mapTitle = mapData.title;
mapData = H.geojson(mapData, this.type, this);
}
this.mapData = mapData;
this.mapMap = {};
for (i = 0; i < mapData.length; i++) {
mapPoint = mapData[i];
props = mapPoint.properties;
mapPoint._i = i;
// Copy the property over to root for faster access
if (joinBy[0] && props && props[joinBy[0]]) {
mapPoint[joinBy[0]] = props[joinBy[0]];
}
mapMap[mapPoint[joinBy[0]]] = mapPoint;
}
this.mapMap = mapMap;
// Registered the point codes that actually hold data
if (data && joinBy[1]) {
each(data, function(point) {
if (mapMap[point[joinBy[1]]]) {
dataUsed.push(mapMap[point[joinBy[1]]]);
}
});
}
if (options.allAreas) {
this.getBox(mapData);
data = data || [];
// Registered the point codes that actually hold data
if (joinBy[1]) {
each(data, function(point) {
dataUsed.push(point[joinBy[1]]);
});
}
// Add those map points that don't correspond to data, which will be drawn as null points
dataUsed = '|' + map(dataUsed, function(point) {
return point && point[joinBy[0]];
}).join('|') + '|'; // String search is faster than array.indexOf
each(mapData, function(mapPoint) {
if (!joinBy[0] || dataUsed.indexOf('|' + mapPoint[joinBy[0]] + '|') === -1) {
data.push(merge(mapPoint, {
value: null
}));
updatePoints = false; // #5050 - adding all areas causes the update optimization of setData to kick in, even though the point order has changed
}
});
} else {
this.getBox(dataUsed); // Issue #4784
}
}
Series.prototype.setData.call(this, data, redraw, animation, updatePoints);
},
/**
* No graph for the map series
*/
drawGraph: noop,
/**
* We need the points' bounding boxes in order to draw the data labels, so
* we skip it now and call it from drawPoints instead.
*/
drawDataLabels: noop,
/**
* Allow a quick redraw by just translating the area group. Used for zooming and panning
* in capable browsers.
*/
doFullTranslate: function() {
return this.isDirtyData || this.chart.isResizing || this.chart.renderer.isVML || !this.baseTrans;
},
/**
* Add the path option for data points. Find the max value for color calculation.
*/
translate: function() {
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis,
doFullTranslate = series.doFullTranslate();
series.generatePoints();
each(series.data, function(point) {
// Record the middle point (loosely based on centroid), determined
// by the middleX and middleY options.
point.plotX = xAxis.toPixels(point._midX, true);
point.plotY = yAxis.toPixels(point._midY, true);
if (doFullTranslate) {
point.shapeType = 'path';
point.shapeArgs = {
d: series.translatePath(point.path)
};
}
});
series.translateColors();
},
/**
* Get presentational attributes. In the maps series this runs in both
* styled and non-styled mode, because colors hold data when a colorAxis
* is used.
*/
pointAttribs: function(point, state) {
var attr;
attr = seriesTypes.column.prototype.pointAttribs.call(
this, point, state
);
// Prevent flickering whan called from setState
if (point.isFading) {
delete attr.fill;
}
// If vector-effect is not supported, we set the stroke-width on the group element
// and let all point graphics inherit. That way we don't have to iterate over all
// points to update the stroke-width on zooming. TODO: Check unstyled
if (supportsVectorEffect) {
attr['vector-effect'] = 'non-scaling-stroke';
} else {
attr['stroke-width'] = 'inherit';
}
return attr;
},
/**
* Use the drawPoints method of column, that is able to handle simple shapeArgs.
* Extend it by assigning the tooltip position.
*/
drawPoints: function() {
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis,
group = series.group,
chart = series.chart,
renderer = chart.renderer,
scaleX,
scaleY,
translateX,
translateY,
baseTrans = this.baseTrans,
transformGroup,
startTranslateX,
startTranslateY,
startScaleX,
startScaleY;
// Set a group that handles transform during zooming and panning in order to preserve clipping
// on series.group
if (!series.transformGroup) {
series.transformGroup = renderer.g()
.attr({
scaleX: 1,
scaleY: 1
})
.add(group);
series.transformGroup.survive = true;
}
// Draw the shapes again
if (series.doFullTranslate()) {
// Individual point actions. TODO: Check unstyled.
if (chart.hasRendered) {
each(series.points, function(point) {
// Restore state color on update/redraw (#3529)
if (point.shapeArgs) {
point.shapeArgs.fill = series.pointAttribs(point, point.state).fill;
}
});
}
// Draw them in transformGroup
series.group = series.transformGroup;
seriesTypes.column.prototype.drawPoints.apply(series);
series.group = group; // Reset
// Add class names
each(series.points, function(point) {
if (point.graphic) {
if (point.name) {
point.graphic.addClass('highcharts-name-' + point.name.replace(/ /g, '-').toLowerCase());
}
if (point.properties && point.properties['hc-key']) {
point.graphic.addClass('highcharts-key-' + point.properties['hc-key'].toLowerCase());
}
}
});
// Set the base for later scale-zooming. The originX and originY properties are the
// axis values in the plot area's upper left corner.
this.baseTrans = {
originX: xAxis.min - xAxis.minPixelPadding / xAxis.transA,
originY: yAxis.min - yAxis.minPixelPadding / yAxis.transA + (yAxis.reversed ? 0 : yAxis.len / yAxis.transA),
transAX: xAxis.transA,
transAY: yAxis.transA
};
// Reset transformation in case we're doing a full translate (#3789)
this.transformGroup.animate({
translateX: 0,
translateY: 0,
scaleX: 1,
scaleY: 1
});
// Just update the scale and transform for better performance
} else {
scaleX = xAxis.transA / baseTrans.transAX;
scaleY = yAxis.transA / baseTrans.transAY;
translateX = xAxis.toPixels(baseTrans.originX, true);
translateY = yAxis.toPixels(baseTrans.originY, true);
// Handle rounding errors in normal view (#3789)
if (scaleX > 0.99 && scaleX < 1.01 && scaleY > 0.99 && scaleY < 1.01) {
scaleX = 1;
scaleY = 1;
translateX = Math.round(translateX);
translateY = Math.round(translateY);
}
// Animate or move to the new zoom level. In order to prevent
// flickering as the different transform components are set out of
// sync (#5991), we run a fake animator attribute and set scale and
// translation synchronously in the same step.
// A possible improvement to the API would be to handle this in the
// renderer or animation engine itself, to ensure that when we are
// animating multiple properties, we make sure that each step for
// each property is performed in the same step. Also, for symbols
// and for transform properties, it should induce a single
// updateTransform and symbolAttr call.
transformGroup = this.transformGroup;
if (chart.renderer.globalAnimation) {
startTranslateX = transformGroup.attr('translateX');
startTranslateY = transformGroup.attr('translateY');
startScaleX = transformGroup.attr('scaleX');
startScaleY = transformGroup.attr('scaleY');
transformGroup
.attr({
animator: 0
})
.animate({
animator: 1
}, {
step: function(now, fx) {
transformGroup.attr({
translateX: startTranslateX +
(translateX - startTranslateX) * fx.pos,
translateY: startTranslateY +
(translateY - startTranslateY) * fx.pos,
scaleX: startScaleX +
(scaleX - startScaleX) * fx.pos,
scaleY: startScaleY +
(scaleY - startScaleY) * fx.pos
});
}
});
// When dragging, animation is off.
} else {
transformGroup.attr({
translateX: translateX,
translateY: translateY,
scaleX: scaleX,
scaleY: scaleY
});
}
}
// Set the stroke-width directly on the group element so the children inherit it. We need to use
// setAttribute directly, because the stroke-widthSetter method expects a stroke color also to be
// set.
if (!supportsVectorEffect) {
series.group.element.setAttribute(
'stroke-width',
series.options[
(series.pointAttrToOptions && series.pointAttrToOptions['stroke-width']) || 'borderWidth'
] / (scaleX || 1)
);
}
this.drawMapDataLabels();
},
/**
* Draw the data labels. Special for maps is the time that the data labels are drawn (after points),
* and the clipping of the dataLabelsGroup.
*/
drawMapDataLabels: function() {
Series.prototype.drawDataLabels.call(this);
if (this.dataLabelsGroup) {
this.dataLabelsGroup.clip(this.chart.clipRect);
}
},
/**
* Override render to throw in an async call in IE8. Otherwise it chokes on the US counties demo.
*/
render: function() {
var series = this,
render = Series.prototype.render;
// Give IE8 some time to breathe.
if (series.chart.renderer.isVML && series.data.length > 3000) {
setTimeout(function() {
render.call(series);
});
} else {
render.call(series);
}
},
/**
* The initial animation for the map series. By default, animation is disabled.
* Animation of map shapes is not at all supported in VML browsers.
*/
animate: function(init) {
var chart = this.chart,
animation = this.options.animation,
group = this.group,
xAxis = this.xAxis,
yAxis = this.yAxis,
left = xAxis.pos,
top = yAxis.pos;
if (chart.renderer.isSVG) {
if (animation === true) {
animation = {
duration: 1000
};
}
// Initialize the animation
if (init) {
// Scale down the group and place it in the center
group.attr({
translateX: left + xAxis.len / 2,
translateY: top + yAxis.len / 2,
scaleX: 0.001, // #1499
scaleY: 0.001
});
// Run the animation
} else {
group.animate({
translateX: left,
translateY: top,
scaleX: 1,
scaleY: 1
}, animation);
// Delete this function to allow it only once
this.animate = null;
}
}
},
/**
* Animate in the new series from the clicked point in the old series.
* Depends on the drilldown.js module
*/
animateDrilldown: function(init) {
var toBox = this.chart.plotBox,
level = this.chart.drilldownLevels[this.chart.drilldownLevels.length - 1],
fromBox = level.bBox,
animationOptions = this.chart.options.drilldown.animation,
scale;
if (!init) {
scale = Math.min(fromBox.width / toBox.width, fromBox.height / toBox.height);
level.shapeArgs = {
scaleX: scale,
scaleY: scale,
translateX: fromBox.x,
translateY: fromBox.y
};
each(this.points, function(point) {
if (point.graphic) {
point.graphic
.attr(level.shapeArgs)
.animate({
scaleX: 1,
scaleY: 1,
translateX: 0,
translateY: 0
}, animationOptions);
}
});
this.animate = null;
}
},
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
/**
* When drilling up, pull out the individual point graphics from the lower series
* and animate them into the origin point in the upper series.
*/
animateDrillupFrom: function(level) {
seriesTypes.column.prototype.animateDrillupFrom.call(this, level);
},
/**
* When drilling up, keep the upper series invisible until the lower series has
* moved into place
*/
animateDrillupTo: function(init) {
seriesTypes.column.prototype.animateDrillupTo.call(this, init);
}
// Point class
}), extend({
/**
* Extend the Point object to split paths
*/
applyOptions: function(options, x) {
var point = Point.prototype.applyOptions.call(this, options, x),
series = this.series,
joinBy = series.joinBy,
mapPoint;
if (series.mapData) {
mapPoint = point[joinBy[1]] !== undefined && series.mapMap[point[joinBy[1]]];
if (mapPoint) {
// This applies only to bubbles
if (series.xyFromShape) {
point.x = mapPoint._midX;
point.y = mapPoint._midY;
}
extend(point, mapPoint); // copy over properties
} else {
point.value = point.value || null;
}
}
return point;
},
/**
* Stop the fade-out
*/
onMouseOver: function(e) {
clearTimeout(this.colorInterval);
if (this.value !== null) {
Point.prototype.onMouseOver.call(this, e);
} else { //#3401 Tooltip doesn't hide when hovering over null points
this.series.onMouseOut(e);
}
},
// Todo: check unstyled
/**
* Custom animation for tweening out the colors. Animation reduces blinking when hovering
* over islands and coast lines. We run a custom implementation of animation becuase we
* need to be able to run this independently from other animations like zoom redraw. Also,
* adding color animation to the adapters would introduce almost the same amount of code.
*/
onMouseOut: function() {
var point = this,
start = +new Date(),
normalColor = color(this.series.pointAttribs(point).fill),
hoverColor = color(this.series.pointAttribs(point, 'hover').fill),
animation = point.series.options.states.normal.animation,
duration = animation && (animation.duration || 500);
if (duration && normalColor.rgba.length === 4 && hoverColor.rgba.length === 4 && point.state !== 'select') {
clearTimeout(point.colorInterval);
point.colorInterval = setInterval(function() {
var pos = (new Date() - start) / duration,
graphic = point.graphic;
if (pos > 1) {
pos = 1;
}
if (graphic) {
graphic.attr('fill', ColorAxis.prototype.tweenColors.call(0, hoverColor, normalColor, pos));
}
if (pos >= 1) {
clearTimeout(point.colorInterval);
}
}, 13);
point.isFading = true;
}
Point.prototype.onMouseOut.call(point);
point.isFading = null;
},
/**
* Zoom the chart to view a specific area point
*/
zoomTo: function() {
var point = this,
series = point.series;
series.xAxis.setExtremes(
point._minX,
point._maxX,
false
);
series.yAxis.setExtremes(
point._minY,
point._maxY,
false
);
series.chart.redraw();
}
}, colorPointMixin));
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
// The mapline series type
seriesType('mapline', 'map', {
lineWidth: 1,
fillColor: 'none'
}, {
type: 'mapline',
colorProp: 'stroke',
pointAttrToOptions: {
'stroke': 'color',
'stroke-width': 'lineWidth'
},
/**
* Get presentational attributes
*/
pointAttribs: function(point, state) {
var attr = seriesTypes.map.prototype.pointAttribs.call(this, point, state);
// The difference from a map series is that the stroke takes the point color
attr.fill = this.options.fillColor;
return attr;
},
drawLegendSymbol: seriesTypes.line.prototype.drawLegendSymbol
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var merge = H.merge,
Point = H.Point,
seriesType = H.seriesType;
// The mappoint series type
seriesType('mappoint', 'scatter', {
dataLabels: {
enabled: true,
formatter: function() { // #2945
return this.point.name;
},
crop: false,
defer: false,
overflow: false,
style: {
color: '#000000'
}
}
// Prototype members
}, {
type: 'mappoint',
forceDL: true
// Point class
}, {
applyOptions: function(options, x) {
var mergedOptions = options.lat !== undefined && options.lon !== undefined ? merge(options, this.series.chart.fromLatLonToPoint(options)) : options;
return Point.prototype.applyOptions.call(this, mergedOptions, x);
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
Axis = H.Axis,
color = H.color,
each = H.each,
isNumber = H.isNumber,
noop = H.noop,
pick = H.pick,
pInt = H.pInt,
Point = H.Point,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/* ****************************************************************************
* Start Bubble series code *
*****************************************************************************/
seriesType('bubble', 'scatter', {
dataLabels: {
formatter: function() { // #2945
return this.point.z;
},
inside: true,
verticalAlign: 'middle'
},
// displayNegative: true,
marker: {
// fillOpacity: 0.5,
lineColor: null, // inherit from series.color
lineWidth: 1,
// Avoid offset in Point.setState
radius: null,
states: {
hover: {
radiusPlus: 0
}
},
symbol: 'circle'
},
minSize: 8,
maxSize: '20%',
// negativeColor: null,
// sizeBy: 'area'
softThreshold: false,
states: {
hover: {
halo: {
size: 5
}
}
},
tooltip: {
pointFormat: '({point.x}, {point.y}), Size: {point.z}'
},
turboThreshold: 0,
zThreshold: 0,
zoneAxis: 'z'
// Prototype members
}, {
pointArrayMap: ['y', 'z'],
parallelArrays: ['x', 'y', 'z'],
trackerGroups: ['markerGroup', 'dataLabelsGroup'],
bubblePadding: true,
zoneAxis: 'z',
directTouch: true,
pointAttribs: function(point, state) {
var markerOptions = this.options.marker,
fillOpacity = pick(markerOptions.fillOpacity, 0.5),
attr = Series.prototype.pointAttribs.call(this, point, state);
if (fillOpacity !== 1) {
attr.fill = color(attr.fill).setOpacity(fillOpacity).get('rgba');
}
return attr;
},
/**
* Get the radius for each point based on the minSize, maxSize and each point's Z value. This
* must be done prior to Series.translate because the axis needs to add padding in
* accordance with the point sizes.
*/
getRadii: function(zMin, zMax, minSize, maxSize) {
var len,
i,
pos,
zData = this.zData,
radii = [],
options = this.options,
sizeByArea = options.sizeBy !== 'width',
zThreshold = options.zThreshold,
zRange = zMax - zMin,
value,
radius;
// Set the shape type and arguments to be picked up in drawPoints
for (i = 0, len = zData.length; i < len; i++) {
value = zData[i];
// When sizing by threshold, the absolute value of z determines the size
// of the bubble.
if (options.sizeByAbsoluteValue && value !== null) {
value = Math.abs(value - zThreshold);
zMax = Math.max(zMax - zThreshold, Math.abs(zMin - zThreshold));
zMin = 0;
}
if (value === null) {
radius = null;
// Issue #4419 - if value is less than zMin, push a radius that's always smaller than the minimum size
} else if (value < zMin) {
radius = minSize / 2 - 1;
} else {
// Relative size, a number between 0 and 1
pos = zRange > 0 ? (value - zMin) / zRange : 0.5;
if (sizeByArea && pos >= 0) {
pos = Math.sqrt(pos);
}
radius = Math.ceil(minSize + pos * (maxSize - minSize)) / 2;
}
radii.push(radius);
}
this.radii = radii;
},
/**
* Perform animation on the bubbles
*/
animate: function(init) {
var animation = this.options.animation;
if (!init) { // run the animation
each(this.points, function(point) {
var graphic = point.graphic,
animationTarget;
if (graphic && graphic.width) { // URL symbols don't have width
animationTarget = {
x: graphic.x,
y: graphic.y,
width: graphic.width,
height: graphic.height
};
// Start values
graphic.attr({
x: point.plotX,
y: point.plotY,
width: 1,
height: 1
});
// Run animation
graphic.animate(animationTarget, animation);
}
});
// delete this function to allow it only once
this.animate = null;
}
},
/**
* Extend the base translate method to handle bubble size
*/
translate: function() {
var i,
data = this.data,
point,
radius,
radii = this.radii;
// Run the parent method
seriesTypes.scatter.prototype.translate.call(this);
// Set the shape type and arguments to be picked up in drawPoints
i = data.length;
while (i--) {
point = data[i];
radius = radii ? radii[i] : 0; // #1737
if (isNumber(radius) && radius >= this.minPxSize / 2) {
// Shape arguments
point.marker = H.extend(point.marker, {
radius: radius,
width: 2 * radius,
height: 2 * radius
});
// Alignment box for the data label
point.dlBox = {
x: point.plotX - radius,
y: point.plotY - radius,
width: 2 * radius,
height: 2 * radius
};
} else { // below zThreshold
point.shapeArgs = point.plotY = point.dlBox = undefined; // #1691
}
}
},
alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
buildKDTree: noop,
applyZones: noop
// Point class
}, {
haloPath: function(size) {
return Point.prototype.haloPath.call(
this,
size === 0 ? 0 : (this.marker ? this.marker.radius || 0 : 0) + size // #6067
);
},
ttBelow: false
});
/**
* Add logic to pad each axis with the amount of pixels
* necessary to avoid the bubbles to overflow.
*/
Axis.prototype.beforePadding = function() {
var axis = this,
axisLength = this.len,
chart = this.chart,
pxMin = 0,
pxMax = axisLength,
isXAxis = this.isXAxis,
dataKey = isXAxis ? 'xData' : 'yData',
min = this.min,
extremes = {},
smallestSize = Math.min(chart.plotWidth, chart.plotHeight),
zMin = Number.MAX_VALUE,
zMax = -Number.MAX_VALUE,
range = this.max - min,
transA = axisLength / range,
activeSeries = [];
// Handle padding on the second pass, or on redraw
each(this.series, function(series) {
var seriesOptions = series.options,
zData;
if (series.bubblePadding && (series.visible || !chart.options.chart.ignoreHiddenSeries)) {
// Correction for #1673
axis.allowZoomOutside = true;
// Cache it
activeSeries.push(series);
if (isXAxis) { // because X axis is evaluated first
// For each series, translate the size extremes to pixel values
each(['minSize', 'maxSize'], function(prop) {
var length = seriesOptions[prop],
isPercent = /%$/.test(length);
length = pInt(length);
extremes[prop] = isPercent ?
smallestSize * length / 100 :
length;
});
series.minPxSize = extremes.minSize;
// Prioritize min size if conflict to make sure bubbles are
// always visible. #5873
series.maxPxSize = Math.max(extremes.maxSize, extremes.minSize);
// Find the min and max Z
zData = series.zData;
if (zData.length) { // #1735
zMin = pick(seriesOptions.zMin, Math.min(
zMin,
Math.max(
arrayMin(zData),
seriesOptions.displayNegative === false ? seriesOptions.zThreshold : -Number.MAX_VALUE
)
));
zMax = pick(seriesOptions.zMax, Math.max(zMax, arrayMax(zData)));
}
}
}
});
each(activeSeries, function(series) {
var data = series[dataKey],
i = data.length,
radius;
if (isXAxis) {
series.getRadii(zMin, zMax, series.minPxSize, series.maxPxSize);
}
if (range > 0) {
while (i--) {
if (isNumber(data[i]) && axis.dataMin <= data[i] && data[i] <= axis.dataMax) {
radius = series.radii[i];
pxMin = Math.min(((data[i] - min) * transA) - radius, pxMin);
pxMax = Math.max(((data[i] - min) * transA) + radius, pxMax);
}
}
}
});
if (activeSeries.length && range > 0 && !this.isLog) {
pxMax -= axisLength;
transA *= (axisLength + pxMin - pxMax) / axisLength;
each([
['min', 'userMin', pxMin],
['max', 'userMax', pxMax]
], function(keys) {
if (pick(axis.options[keys[0]], axis[keys[1]]) === undefined) {
axis[keys[0]] += keys[2] / transA;
}
});
}
};
/* ****************************************************************************
* End Bubble series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var merge = H.merge,
Point = H.Point,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
// The mapbubble series type
if (seriesTypes.bubble) {
seriesType('mapbubble', 'bubble', {
animationLimit: 500,
tooltip: {
pointFormat: '{point.name}: {point.z}'
}
// Prototype members
}, {
xyFromShape: true,
type: 'mapbubble',
pointArrayMap: ['z'], // If one single value is passed, it is interpreted as z
/**
* Return the map area identified by the dataJoinBy option
*/
getMapData: seriesTypes.map.prototype.getMapData,
getBox: seriesTypes.map.prototype.getBox,
setData: seriesTypes.map.prototype.setData
// Point class
}, {
applyOptions: function(options, x) {
var point;
if (options && options.lat !== undefined && options.lon !== undefined) {
point = Point.prototype.applyOptions.call(
this,
merge(options, this.series.chart.fromLatLonToPoint(options)),
x
);
} else {
point = seriesTypes.map.prototype.pointClass.prototype.applyOptions.call(this, options, x);
}
return point;
},
ttBelow: false
});
}
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var colorPointMixin = H.colorPointMixin,
colorSeriesMixin = H.colorSeriesMixin,
each = H.each,
LegendSymbolMixin = H.LegendSymbolMixin,
merge = H.merge,
noop = H.noop,
pick = H.pick,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
// The Heatmap series type
seriesType('heatmap', 'scatter', {
animation: false,
borderWidth: 0,
nullColor: '#f7f7f7',
dataLabels: {
formatter: function() { // #2945
return this.point.value;
},
inside: true,
verticalAlign: 'middle',
crop: false,
overflow: false,
padding: 0 // #3837
},
marker: null,
pointRange: null, // dynamically set to colsize by default
tooltip: {
pointFormat: '{point.x}, {point.y}: {point.value}<br/>'
},
states: {
normal: {
animation: true
},
hover: {
halo: false, // #3406, halo is not required on heatmaps
brightness: 0.2
}
}
}, merge(colorSeriesMixin, {
pointArrayMap: ['y', 'value'],
hasPointSpecificOptions: true,
supportsDrilldown: true,
getExtremesFromAll: true,
directTouch: true,
/**
* Override the init method to add point ranges on both axes.
*/
init: function() {
var options;
seriesTypes.scatter.prototype.init.apply(this, arguments);
options = this.options;
options.pointRange = pick(options.pointRange, options.colsize || 1); // #3758, prevent resetting in setData
this.yAxis.axisPointRange = options.rowsize || 1; // general point range
},
translate: function() {
var series = this,
options = series.options,
xAxis = series.xAxis,
yAxis = series.yAxis,
between = function(x, a, b) {
return Math.min(Math.max(a, x), b);
};
series.generatePoints();
each(series.points, function(point) {
var xPad = (options.colsize || 1) / 2,
yPad = (options.rowsize || 1) / 2,
x1 = between(Math.round(xAxis.len - xAxis.translate(point.x - xPad, 0, 1, 0, 1)), -xAxis.len, 2 * xAxis.len),
x2 = between(Math.round(xAxis.len - xAxis.translate(point.x + xPad, 0, 1, 0, 1)), -xAxis.len, 2 * xAxis.len),
y1 = between(Math.round(yAxis.translate(point.y - yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len),
y2 = between(Math.round(yAxis.translate(point.y + yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len);
// Set plotX and plotY for use in K-D-Tree and more
point.plotX = point.clientX = (x1 + x2) / 2;
point.plotY = (y1 + y2) / 2;
point.shapeType = 'rect';
point.shapeArgs = {
x: Math.min(x1, x2),
y: Math.min(y1, y2),
width: Math.abs(x2 - x1),
height: Math.abs(y2 - y1)
};
});
series.translateColors();
},
drawPoints: function() {
seriesTypes.column.prototype.drawPoints.call(this);
each(this.points, function(point) {
point.graphic.attr(this.colorAttribs(point));
}, this);
},
animate: noop,
getBox: noop,
drawLegendSymbol: LegendSymbolMixin.drawRectangle,
alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
getExtremes: function() {
// Get the extremes from the value data
Series.prototype.getExtremes.call(this, this.valueData);
this.valueMin = this.dataMin;
this.valueMax = this.dataMax;
// Get the extremes from the y data
Series.prototype.getExtremes.call(this);
}
}), colorPointMixin);
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Chart = H.Chart,
each = H.each,
extend = H.extend,
format = H.format,
merge = H.merge,
win = H.win,
wrap = H.wrap;
/**
* Test for point in polygon. Polygon defined as array of [x,y] points.
*/
function pointInPolygon(point, polygon) {
var i,
j,
rel1,
rel2,
c = false,
x = point.x,
y = point.y;
for (i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
rel1 = polygon[i][1] > y;
rel2 = polygon[j][1] > y;
if (rel1 !== rel2 && (x < (polygon[j][0] - polygon[i][0]) * (y - polygon[i][1]) / (polygon[j][1] - polygon[i][1]) + polygon[i][0])) {
c = !c;
}
}
return c;
}
/**
* Get point from latLon using specified transform definition
*/
Chart.prototype.transformFromLatLon = function(latLon, transform) {
if (win.proj4 === undefined) {
H.error(21);
return {
x: 0,
y: null
};
}
var projected = win.proj4(transform.crs, [latLon.lon, latLon.lat]),
cosAngle = transform.cosAngle || (transform.rotation && Math.cos(transform.rotation)),
sinAngle = transform.sinAngle || (transform.rotation && Math.sin(transform.rotation)),
rotated = transform.rotation ? [projected[0] * cosAngle + projected[1] * sinAngle, -projected[0] * sinAngle + projected[1] * cosAngle] : projected;
return {
x: ((rotated[0] - (transform.xoffset || 0)) * (transform.scale || 1) + (transform.xpan || 0)) * (transform.jsonres || 1) + (transform.jsonmarginX || 0),
y: (((transform.yoffset || 0) - rotated[1]) * (transform.scale || 1) + (transform.ypan || 0)) * (transform.jsonres || 1) - (transform.jsonmarginY || 0)
};
};
/**
* Get latLon from point using specified transform definition
*/
Chart.prototype.transformToLatLon = function(point, transform) {
if (win.proj4 === undefined) {
H.error(21);
return;
}
var normalized = {
x: ((point.x - (transform.jsonmarginX || 0)) / (transform.jsonres || 1) - (transform.xpan || 0)) / (transform.scale || 1) + (transform.xoffset || 0),
y: ((-point.y - (transform.jsonmarginY || 0)) / (transform.jsonres || 1) + (transform.ypan || 0)) / (transform.scale || 1) + (transform.yoffset || 0)
},
cosAngle = transform.cosAngle || (transform.rotation && Math.cos(transform.rotation)),
sinAngle = transform.sinAngle || (transform.rotation && Math.sin(transform.rotation)),
// Note: Inverted sinAngle to reverse rotation direction
projected = win.proj4(transform.crs, 'WGS84', transform.rotation ? {
x: normalized.x * cosAngle + normalized.y * -sinAngle,
y: normalized.x * sinAngle + normalized.y * cosAngle
} : normalized);
return {
lat: projected.y,
lon: projected.x
};
};
Chart.prototype.fromPointToLatLon = function(point) {
var transforms = this.mapTransforms,
transform;
if (!transforms) {
H.error(22);
return;
}
for (transform in transforms) {
if (transforms.hasOwnProperty(transform) && transforms[transform].hitZone &&
pointInPolygon({
x: point.x,
y: -point.y
}, transforms[transform].hitZone.coordinates[0])) {
return this.transformToLatLon(point, transforms[transform]);
}
}
return this.transformToLatLon(point, transforms['default']); // eslint-disable-line dot-notation
};
Chart.prototype.fromLatLonToPoint = function(latLon) {
var transforms = this.mapTransforms,
transform,
coords;
if (!transforms) {
H.error(22);
return {
x: 0,
y: null
};
}
for (transform in transforms) {
if (transforms.hasOwnProperty(transform) && transforms[transform].hitZone) {
coords = this.transformFromLatLon(latLon, transforms[transform]);
if (pointInPolygon({
x: coords.x,
y: -coords.y
}, transforms[transform].hitZone.coordinates[0])) {
return coords;
}
}
}
return this.transformFromLatLon(latLon, transforms['default']); // eslint-disable-line dot-notation
};
/**
* Convert a geojson object to map data of a given Highcharts type (map, mappoint or mapline).
*/
H.geojson = function(geojson, hType, series) {
var mapData = [],
path = [],
polygonToPath = function(polygon) {
var i,
len = polygon.length;
path.push('M');
for (i = 0; i < len; i++) {
if (i === 1) {
path.push('L');
}
path.push(polygon[i][0], -polygon[i][1]);
}
};
hType = hType || 'map';
each(geojson.features, function(feature) {
var geometry = feature.geometry,
type = geometry.type,
coordinates = geometry.coordinates,
properties = feature.properties,
point;
path = [];
if (hType === 'map' || hType === 'mapbubble') {
if (type === 'Polygon') {
each(coordinates, polygonToPath);
path.push('Z');
} else if (type === 'MultiPolygon') {
each(coordinates, function(items) {
each(items, polygonToPath);
});
path.push('Z');
}
if (path.length) {
point = {
path: path
};
}
} else if (hType === 'mapline') {
if (type === 'LineString') {
polygonToPath(coordinates);
} else if (type === 'MultiLineString') {
each(coordinates, polygonToPath);
}
if (path.length) {
point = {
path: path
};
}
} else if (hType === 'mappoint') {
if (type === 'Point') {
point = {
x: coordinates[0],
y: -coordinates[1]
};
}
}
if (point) {
mapData.push(extend(point, {
name: properties.name || properties.NAME,
properties: properties
}));
}
});
// Create a credits text that includes map source, to be picked up in Chart.addCredits
if (series && geojson.copyrightShort) {
series.chart.mapCredits = format(series.chart.options.credits.mapText, {
geojson: geojson
});
series.chart.mapCreditsFull = format(series.chart.options.credits.mapTextFull, {
geojson: geojson
});
}
return mapData;
};
/**
* Override addCredits to include map source by default
*/
wrap(Chart.prototype, 'addCredits', function(proceed, credits) {
credits = merge(true, this.options.credits, credits);
// Disable credits link if map credits enabled. This to allow for in-text anchors.
if (this.mapCredits) {
credits.href = null;
}
proceed.call(this, credits);
// Add full map credits to hover
if (this.credits && this.mapCreditsFull) {
this.credits.attr({
title: this.mapCreditsFull
});
}
});
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var Chart = H.Chart,
defaultOptions = H.defaultOptions,
each = H.each,
extend = H.extend,
merge = H.merge,
pick = H.pick,
Renderer = H.Renderer,
SVGRenderer = H.SVGRenderer,
VMLRenderer = H.VMLRenderer;
// Add language
extend(defaultOptions.lang, {
zoomIn: 'Zoom in',
zoomOut: 'Zoom out'
});
// Set the default map navigation options
defaultOptions.mapNavigation = {
buttonOptions: {
alignTo: 'plotBox',
align: 'left',
verticalAlign: 'top',
x: 0,
width: 18,
height: 18,
padding: 5,
style: {
fontSize: '15px',
fontWeight: 'bold'
},
theme: {
'stroke-width': 1,
'text-align': 'center'
}
},
buttons: {
zoomIn: {
onclick: function() {
this.mapZoom(0.5);
},
text: '+',
y: 0
},
zoomOut: {
onclick: function() {
this.mapZoom(2);
},
text: '-',
y: 28
}
},
mouseWheelSensitivity: 1.1
// enabled: false,
// enableButtons: null, // inherit from enabled
// enableTouchZoom: null, // inherit from enabled
// enableDoubleClickZoom: null, // inherit from enabled
// enableDoubleClickZoomTo: false
// enableMouseWheelZoom: null, // inherit from enabled
};
/**
* Utility for reading SVG paths directly.
*/
H.splitPath = function(path) {
var i;
// Move letters apart
path = path.replace(/([A-Za-z])/g, ' $1 ');
// Trim
path = path.replace(/^\s*/, '').replace(/\s*$/, '');
// Split on spaces and commas
path = path.split(/[ ,]+/); // Extra comma to escape gulp.scripts task
// Parse numbers
for (i = 0; i < path.length; i++) {
if (!/[a-zA-Z]/.test(path[i])) {
path[i] = parseFloat(path[i]);
}
}
return path;
};
// A placeholder for map definitions
H.maps = {};
// Create symbols for the zoom buttons
function selectiveRoundedRect(x, y, w, h, rTopLeft, rTopRight, rBottomRight, rBottomLeft) {
return [
'M', x + rTopLeft, y,
// top side
'L', x + w - rTopRight, y,
// top right corner
'C', x + w - rTopRight / 2,
y, x + w,
y + rTopRight / 2, x + w, y + rTopRight,
// right side
'L', x + w, y + h - rBottomRight,
// bottom right corner
'C', x + w, y + h - rBottomRight / 2,
x + w - rBottomRight / 2, y + h,
x + w - rBottomRight, y + h,
// bottom side
'L', x + rBottomLeft, y + h,
// bottom left corner
'C', x + rBottomLeft / 2, y + h,
x, y + h - rBottomLeft / 2,
x, y + h - rBottomLeft,
// left side
'L', x, y + rTopLeft,
// top left corner
'C', x, y + rTopLeft / 2,
x + rTopLeft / 2, y,
x + rTopLeft, y,
'Z'
];
}
SVGRenderer.prototype.symbols.topbutton = function(x, y, w, h, attr) {
return selectiveRoundedRect(x - 1, y - 1, w, h, attr.r, attr.r, 0, 0);
};
SVGRenderer.prototype.symbols.bottombutton = function(x, y, w, h, attr) {
return selectiveRoundedRect(x - 1, y - 1, w, h, 0, 0, attr.r, attr.r);
};
// The symbol callbacks are generated on the SVGRenderer object in all browsers. Even
// VML browsers need this in order to generate shapes in export. Now share
// them with the VMLRenderer.
if (Renderer === VMLRenderer) {
each(['topbutton', 'bottombutton'], function(shape) {
VMLRenderer.prototype.symbols[shape] = SVGRenderer.prototype.symbols[shape];
});
}
/**
* A wrapper for Chart with all the default values for a Map
*/
H.Map = H.mapChart = function(a, b, c) {
var hasRenderToArg = typeof a === 'string' || a.nodeName,
options = arguments[hasRenderToArg ? 1 : 0],
hiddenAxis = {
endOnTick: false,
visible: false,
minPadding: 0,
maxPadding: 0,
startOnTick: false
},
seriesOptions,
defaultCreditsOptions = H.getOptions().credits;
/* For visual testing
hiddenAxis.gridLineWidth = 1;
hiddenAxis.gridZIndex = 10;
hiddenAxis.tickPositions = undefined;
// */
// Don't merge the data
seriesOptions = options.series;
options.series = null;
options = merge({
chart: {
panning: 'xy',
type: 'map'
},
credits: {
mapText: pick(defaultCreditsOptions.mapText, ' \u00a9 <a href="{geojson.copyrightUrl}">{geojson.copyrightShort}</a>'),
mapTextFull: pick(defaultCreditsOptions.mapTextFull, '{geojson.copyright}')
},
tooltip: {
followTouchMove: false
},
xAxis: hiddenAxis,
yAxis: merge(hiddenAxis, {
reversed: true
})
},
options, // user's options
{ // forced options
chart: {
inverted: false,
alignTicks: false
}
}
);
options.series = seriesOptions;
return hasRenderToArg ?
new Chart(a, options, c) :
new Chart(options, b);
};
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Plugin for displaying a message when there is no data visible in chart.
(c) 2010-2017 Highsoft AS
Author: Oystein Moseng
License: www.highcharts.com/license
*/
(function(d){"object"===typeof module&&module.exports?module.exports=d:d(Highcharts)})(function(d){(function(c){function d(){return!!this.points.length}function g(){this.hasData()?this.hideNoData():this.showNoData()}var h=c.seriesTypes,e=c.Chart.prototype,f=c.getOptions(),k=c.extend,l=c.each;k(f.lang,{noData:"No data to display"});f.noData={position:{x:0,y:0,align:"center",verticalAlign:"middle"}};f.noData.style={fontWeight:"bold",fontSize:"12px",color:"#666666"};l(["pie","gauge","waterfall","bubble",
"treemap"],function(a){h[a]&&(h[a].prototype.hasData=d)});c.Series.prototype.hasData=function(){return this.visible&&void 0!==this.dataMax&&void 0!==this.dataMin};e.showNoData=function(a){var b=this.options;a=a||b.lang.noData;b=b.noData;this.noDataLabel||(this.noDataLabel=this.renderer.label(a,0,0,null,null,null,b.useHTML,null,"no-data"),this.noDataLabel.attr(b.attr).css(b.style),this.noDataLabel.add(),this.noDataLabel.align(k(this.noDataLabel.getBBox(),b.position),!1,"plotBox"))};e.hideNoData=function(){this.noDataLabel&&
(this.noDataLabel=this.noDataLabel.destroy())};e.hasData=function(){for(var a=this.series,b=a.length;b--;)if(a[b].hasData()&&!a[b].options.isInternal)return!0;return!1};e.callbacks.push(function(a){c.addEvent(a,"load",g);c.addEvent(a,"redraw",g)})})(d)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Plugin for displaying a message when there is no data visible in chart.
*
* (c) 2010-2017 Highsoft AS
* Author: Oystein Moseng
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* Plugin for displaying a message when there is no data visible in chart.
*
* (c) 2010-2017 Highsoft AS
* Author: Oystein Moseng
*
* License: www.highcharts.com/license
*/
var seriesTypes = H.seriesTypes,
chartPrototype = H.Chart.prototype,
defaultOptions = H.getOptions(),
extend = H.extend,
each = H.each;
// Add language option
extend(defaultOptions.lang, {
noData: 'No data to display'
});
// Add default display options for message
defaultOptions.noData = {
position: {
x: 0,
y: 0,
align: 'center',
verticalAlign: 'middle'
}
// useHTML: false
};
// Presentational
defaultOptions.noData.style = {
fontWeight: 'bold',
fontSize: '12px',
color: '#666666'
};
/**
* Define hasData functions for series. These return true if there are data points on this series within the plot area
*/
function hasDataPie() {
return !!this.points.length; /* != 0 */
}
each(['pie', 'gauge', 'waterfall', 'bubble', 'treemap'], function(type) {
if (seriesTypes[type]) {
seriesTypes[type].prototype.hasData = hasDataPie;
}
});
H.Series.prototype.hasData = function() {
return this.visible && this.dataMax !== undefined && this.dataMin !== undefined; // #3703
};
/**
* Display a no-data message.
*
* @param {String} str An optional message to show in place of the default one
*/
chartPrototype.showNoData = function(str) {
var chart = this,
options = chart.options,
text = str || options.lang.noData,
noDataOptions = options.noData;
if (!chart.noDataLabel) {
chart.noDataLabel = chart.renderer
.label(
text,
0,
0,
null,
null,
null,
noDataOptions.useHTML,
null,
'no-data'
);
chart.noDataLabel
.attr(noDataOptions.attr)
.css(noDataOptions.style);
chart.noDataLabel.add();
chart.noDataLabel.align(extend(chart.noDataLabel.getBBox(), noDataOptions.position), false, 'plotBox');
}
};
/**
* Hide no-data message
*/
chartPrototype.hideNoData = function() {
var chart = this;
if (chart.noDataLabel) {
chart.noDataLabel = chart.noDataLabel.destroy();
}
};
/**
* Returns true if there are data points within the plot area now
*/
chartPrototype.hasData = function() {
var chart = this,
series = chart.series,
i = series.length;
while (i--) {
if (series[i].hasData() && !series[i].options.isInternal) {
return true;
}
}
return false;
};
/**
* Show no-data message if there is no data in sight. Otherwise, hide it.
*/
function handleNoData() {
var chart = this;
if (chart.hasData()) {
chart.hideNoData();
} else {
chart.showNoData();
}
}
/**
* Add event listener to handle automatic display of no-data message
*/
chartPrototype.callbacks.push(function(chart) {
H.addEvent(chart, 'load', handleNoData);
H.addEvent(chart, 'redraw', handleNoData);
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Client side exporting module
(c) 2015 Torstein Honsi / Oystein Moseng
License: www.highcharts.com/license
*/
(function(n){"object"===typeof module&&module.exports?module.exports=n:n(Highcharts)})(function(n){(function(d){function n(a,d){var c=t.getElementsByTagName("head")[0],b=t.createElement("script");b.type="text/javascript";b.src=a;b.onload=d;b.onerror=function(){console.error("Error loading script",a)};c.appendChild(b)}var C=d.merge,e=d.win,r=e.navigator,t=e.document,z=d.each,w=e.URL||e.webkitURL||e,B=/Edge\/|Trident\/|MSIE /.test(r.userAgent),D=/Edge\/\d+/.test(r.userAgent),E=B?150:0;d.CanVGRenderer=
{};d.dataURLtoBlob=function(a){if(e.atob&&e.ArrayBuffer&&e.Uint8Array&&e.Blob&&w.createObjectURL){a=a.match(/data:([^;]*)(;base64)?,([0-9A-Za-z+/]+)/);for(var d=e.atob(a[3]),c=new e.ArrayBuffer(d.length),c=new e.Uint8Array(c),b=0;b<c.length;++b)c[b]=d.charCodeAt(b);a=new e.Blob([c],{type:a[1]});return w.createObjectURL(a)}};d.downloadURL=function(a,f){var c=t.createElement("a"),b;if(r.msSaveOrOpenBlob)r.msSaveOrOpenBlob(a,f);else{if(2E6<a.length&&(a=d.dataURLtoBlob(a),!a))throw"Data URL length limit reached";
if(void 0!==c.download)c.href=a,c.download=f,c.target="_blank",t.body.appendChild(c),c.click(),t.body.removeChild(c);else try{if(b=e.open(a,"chart"),void 0===b||null===b)throw"Failed to open window";}catch(u){e.location.href=a}}};d.svgToDataUrl=function(a){var d=-1<r.userAgent.indexOf("WebKit")&&0>r.userAgent.indexOf("Chrome");try{if(!d&&0>r.userAgent.toLowerCase().indexOf("firefox"))return w.createObjectURL(new e.Blob([a],{type:"image/svg+xml;charset-utf-16"}))}catch(c){}return"data:image/svg+xml;charset\x3dUTF-8,"+
encodeURIComponent(a)};d.imageToDataUrl=function(a,d,c,b,u,l,k,m,p){var g=new e.Image,h,f=function(){setTimeout(function(){var e=t.createElement("canvas"),f=e.getContext&&e.getContext("2d"),x;try{if(f){e.height=g.height*b;e.width=g.width*b;f.drawImage(g,0,0,e.width,e.height);try{x=e.toDataURL(d),u(x,d,c,b)}catch(F){h(a,d,c,b)}}else k(a,d,c,b)}finally{p&&p(a,d,c,b)}},E)},q=function(){m(a,d,c,b);p&&p(a,d,c,b)};h=function(){g=new e.Image;h=l;g.crossOrigin="Anonymous";g.onload=f;g.onerror=q;g.src=a};
g.onload=f;g.onerror=q;g.src=a};d.downloadSVGLocal=function(a,f,c,b){function u(b,a){a=new e.jsPDF("l","pt",[b.width.baseVal.value+2*a,b.height.baseVal.value+2*a]);e.svg2pdf(b,a,{removeInvalid:!0});return a.output("datauristring")}function l(){y.innerHTML=a;var e=y.getElementsByTagName("text"),g,f=y.getElementsByTagName("svg")[0].style;z(e,function(b){z(["font-family","font-size"],function(a){!b.style[a]&&f[a]&&(b.style[a]=f[a])});b.style["font-family"]=b.style["font-family"]&&b.style["font-family"].split(" ").splice(-1);
g=b.getElementsByTagName("title");z(g,function(a){b.removeChild(a)})});e=u(y.firstChild,0);try{d.downloadURL(e,v),b&&b()}catch(G){c()}}var k,m,p=!0,g,h=f.libURL||d.getOptions().exporting.libURL,y=t.createElement("div"),q=f.type||"image/png",v=(f.filename||"chart")+"."+("image/svg+xml"===q?"svg":q.split("/")[1]),A=f.scale||1,h="/"!==h.slice(-1)?h+"/":h;if("image/svg+xml"===q)try{r.msSaveOrOpenBlob?(m=new MSBlobBuilder,m.append(a),k=m.getBlob("image/svg+xml")):k=d.svgToDataUrl(a),d.downloadURL(k,v),
b&&b()}catch(x){c()}else"application/pdf"===q?e.jsPDF&&e.svg2pdf?l():(p=!0,n(h+"jspdf.js",function(){n(h+"svg2pdf.js",function(){l()})})):(k=d.svgToDataUrl(a),g=function(){try{w.revokeObjectURL(k)}catch(x){}},d.imageToDataUrl(k,q,{},A,function(a){try{d.downloadURL(a,v),b&&b()}catch(F){c()}},function(){var f=t.createElement("canvas"),u=f.getContext("2d"),l=a.match(/^<svg[^>]*width\s*=\s*\"?(\d+)\"?[^>]*>/)[1]*A,k=a.match(/^<svg[^>]*height\s*=\s*\"?(\d+)\"?[^>]*>/)[1]*A,m=function(){u.drawSvg(a,0,0,
l,k);try{d.downloadURL(r.msSaveOrOpenBlob?f.msToBlob():f.toDataURL(q),v),b&&b()}catch(H){c()}finally{g()}};f.width=l;f.height=k;e.canvg?m():(p=!0,n(h+"rgbcolor.js",function(){n(h+"canvg.js",function(){m()})}))},c,c,function(){p&&g()}))};d.Chart.prototype.getSVGForLocalExport=function(a,e,c,b){var f=this,l,k=0,m,p,g,h,n,q=function(a,d,c){++k;c.imageElement.setAttributeNS("http://www.w3.org/1999/xlink","href",a);k===l.length&&b(f.sanitizeSVG(m.innerHTML,p))};d.wrap(d.Chart.prototype,"getChartHTML",
function(b){var a=b.apply(this,Array.prototype.slice.call(arguments,1));p=this.options;m=this.container.cloneNode(!0);return a});f.getSVGForExport(a,e);l=m.getElementsByTagName("image");try{if(l.length)for(h=0,n=l.length;h<n;++h)g=l[h],d.imageToDataUrl(g.getAttributeNS("http://www.w3.org/1999/xlink","href"),"image/png",{imageElement:g},a.scale,q,c,c,c);else b(f.sanitizeSVG(m.innerHTML,p))}catch(v){c()}};d.Chart.prototype.exportChartLocal=function(a,e){var c=this,b=d.merge(c.options.exporting,a),f=
function(){if(!1===b.fallbackToExportServer)if(b.error)b.error(b);else throw"Fallback to export server disabled";else c.exportChart(b)};B&&("application/pdf"===b.type||c.container.getElementsByTagName("image").length&&"image/svg+xml"!==b.type)||D&&"image/svg+xml"!==b.type||"application/pdf"===b.type&&c.container.getElementsByTagName("image").length?f():c.getSVGForLocalExport(b,e,f,function(a){-1<a.indexOf("\x3cforeignObject")&&"image/svg+xml"!==b.type?f():d.downloadSVGLocal(a,b,f)})};C(!0,d.getOptions().exporting,
{libURL:"https://code.highcharts.com/5.0.10/lib/",buttons:{contextButton:{menuItems:[{textKey:"printChart",onclick:function(){this.print()}},{separator:!0},{textKey:"downloadPNG",onclick:function(){this.exportChartLocal()}},{textKey:"downloadJPEG",onclick:function(){this.exportChartLocal({type:"image/jpeg"})}},{textKey:"downloadSVG",onclick:function(){this.exportChartLocal({type:"image/svg+xml"})}},{textKey:"downloadPDF",onclick:function(){this.exportChartLocal({type:"application/pdf"})}}]}}})})(n)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | 1 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Client side exporting module
*
* (c) 2015 Torstein Honsi / Oystein Moseng
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(Highcharts) {
/**
* Client side exporting module
*
* (c) 2015 Torstein Honsi / Oystein Moseng
*
* License: www.highcharts.com/license
*/
/*global MSBlobBuilder */
var merge = Highcharts.merge,
win = Highcharts.win,
nav = win.navigator,
doc = win.document,
each = Highcharts.each,
domurl = win.URL || win.webkitURL || win,
isMSBrowser = /Edge\/|Trident\/|MSIE /.test(nav.userAgent),
isEdgeBrowser = /Edge\/\d+/.test(nav.userAgent),
loadEventDeferDelay = isMSBrowser ? 150 : 0; // Milliseconds to defer image load event handlers to offset IE bug
// Dummy object so we can reuse our canvas-tools.js without errors
Highcharts.CanVGRenderer = {};
/**
* Downloads a script and executes a callback when done.
* @param {String} scriptLocation
* @param {Function} callback
*/
function getScript(scriptLocation, callback) {
var head = doc.getElementsByTagName('head')[0],
script = doc.createElement('script');
script.type = 'text/javascript';
script.src = scriptLocation;
script.onload = callback;
script.onerror = function() {
console.error('Error loading script', scriptLocation); // eslint-disable-line no-console
};
head.appendChild(script);
}
// Convert dataURL to Blob if supported, otherwise returns undefined
Highcharts.dataURLtoBlob = function(dataURL) {
if (
win.atob &&
win.ArrayBuffer &&
win.Uint8Array &&
win.Blob &&
domurl.createObjectURL
) {
// Try to convert data URL to Blob
var parts = dataURL.match(/data:([^;]*)(;base64)?,([0-9A-Za-z+/]+)/),
binStr = win.atob(parts[3]), // Assume base64 encoding
buf = new win.ArrayBuffer(binStr.length),
binary = new win.Uint8Array(buf),
blob;
for (var i = 0; i < binary.length; ++i) {
binary[i] = binStr.charCodeAt(i);
}
blob = new win.Blob([binary], {
'type': parts[1]
});
return domurl.createObjectURL(blob);
}
};
// Download contents by dataURL/blob
Highcharts.downloadURL = function(dataURL, filename) {
var a = doc.createElement('a'),
windowRef;
// IE specific blob implementation
if (nav.msSaveOrOpenBlob) {
nav.msSaveOrOpenBlob(dataURL, filename);
return;
}
// Some browsers have limitations for data URL lengths. Try to convert to
// Blob or fall back.
if (dataURL.length > 2000000) {
dataURL = Highcharts.dataURLtoBlob(dataURL);
if (!dataURL) {
throw 'Data URL length limit reached';
}
}
// Try HTML5 download attr if supported
if (a.download !== undefined) {
a.href = dataURL;
a.download = filename; // HTML5 download attribute
a.target = '_blank';
doc.body.appendChild(a);
a.click();
doc.body.removeChild(a);
} else {
// No download attr, just opening data URI
try {
windowRef = win.open(dataURL, 'chart');
if (windowRef === undefined || windowRef === null) {
throw 'Failed to open window';
}
} catch (e) {
// window.open failed, trying location.href
win.location.href = dataURL;
}
}
};
// Get blob URL from SVG code. Falls back to normal data URI.
Highcharts.svgToDataUrl = function(svg) {
var webKit = nav.userAgent.indexOf('WebKit') > -1 && nav.userAgent.indexOf('Chrome') < 0; // Webkit and not chrome
try {
// Safari requires data URI since it doesn't allow navigation to blob URLs
// Firefox has an issue with Blobs and internal references, leading to gradients not working using Blobs (#4550)
if (!webKit && nav.userAgent.toLowerCase().indexOf('firefox') < 0) {
return domurl.createObjectURL(new win.Blob([svg], {
type: 'image/svg+xml;charset-utf-16'
}));
}
} catch (e) {
// Ignore
}
return 'data:image/svg+xml;charset=UTF-8,' + encodeURIComponent(svg);
};
// Get data:URL from image URL
// Pass in callbacks to handle results. finallyCallback is always called at the end of the process. Supplying this callback is optional.
// All callbacks receive four arguments: imageURL, imageType, callbackArgs and scale. callbackArgs is used only by callbacks and can contain whatever.
Highcharts.imageToDataUrl = function(imageURL, imageType, callbackArgs, scale, successCallback, taintedCallback, noCanvasSupportCallback, failedLoadCallback, finallyCallback) {
var img = new win.Image(),
taintedHandler,
loadHandler = function() {
setTimeout(function() {
var canvas = doc.createElement('canvas'),
ctx = canvas.getContext && canvas.getContext('2d'),
dataURL;
try {
if (!ctx) {
noCanvasSupportCallback(imageURL, imageType, callbackArgs, scale);
} else {
canvas.height = img.height * scale;
canvas.width = img.width * scale;
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
// Now we try to get the contents of the canvas.
try {
dataURL = canvas.toDataURL(imageType);
successCallback(dataURL, imageType, callbackArgs, scale);
} catch (e) {
taintedHandler(imageURL, imageType, callbackArgs, scale);
}
}
} finally {
if (finallyCallback) {
finallyCallback(imageURL, imageType, callbackArgs, scale);
}
}
}, loadEventDeferDelay); // IE bug where image is not always ready despite calling load event.
},
// Image load failed (e.g. invalid URL)
errorHandler = function() {
failedLoadCallback(imageURL, imageType, callbackArgs, scale);
if (finallyCallback) {
finallyCallback(imageURL, imageType, callbackArgs, scale);
}
};
// This is called on load if the image drawing to canvas failed with a security error.
// We retry the drawing with crossOrigin set to Anonymous.
taintedHandler = function() {
img = new win.Image();
taintedHandler = taintedCallback;
img.crossOrigin = 'Anonymous'; // Must be set prior to loading image source
img.onload = loadHandler;
img.onerror = errorHandler;
img.src = imageURL;
};
img.onload = loadHandler;
img.onerror = errorHandler;
img.src = imageURL;
};
/**
* Get data URL to an image of an SVG and call download on it
*
* options object:
* filename: Name of resulting downloaded file without extension
* type: File type of resulting download
* scale: Scaling factor of downloaded image compared to source
* libURL: URL pointing to location of dependency scripts to download on demand
*/
Highcharts.downloadSVGLocal = function(svg, options, failCallback, successCallback) {
var svgurl,
blob,
objectURLRevoke = true,
finallyHandler,
libURL = options.libURL || Highcharts.getOptions().exporting.libURL,
dummySVGContainer = doc.createElement('div'),
imageType = options.type || 'image/png',
filename = (options.filename || 'chart') + '.' + (imageType === 'image/svg+xml' ? 'svg' : imageType.split('/')[1]),
scale = options.scale || 1;
libURL = libURL.slice(-1) !== '/' ? libURL + '/' : libURL; // Allow libURL to end with or without fordward slash
function svgToPdf(svgElement, margin) {
var width = svgElement.width.baseVal.value + 2 * margin,
height = svgElement.height.baseVal.value + 2 * margin,
pdf = new win.jsPDF('l', 'pt', [width, height]); // eslint-disable-line new-cap
win.svg2pdf(svgElement, pdf, {
removeInvalid: true
});
return pdf.output('datauristring');
}
function downloadPDF() {
dummySVGContainer.innerHTML = svg;
var textElements = dummySVGContainer.getElementsByTagName('text'),
titleElements,
svgData,
svgElementStyle = dummySVGContainer.getElementsByTagName('svg')[0].style;
// Workaround for the text styling. Making sure it does pick up the root element
each(textElements, function(el) {
// Workaround for the text styling. making sure it does pick up the root element
each(['font-family', 'font-size'], function(property) {
if (!el.style[property] && svgElementStyle[property]) {
el.style[property] = svgElementStyle[property];
}
});
el.style['font-family'] = el.style['font-family'] && el.style['font-family'].split(' ').splice(-1);
// Workaround for plotband with width, removing title from text nodes
titleElements = el.getElementsByTagName('title');
each(titleElements, function(titleElement) {
el.removeChild(titleElement);
});
});
svgData = svgToPdf(dummySVGContainer.firstChild, 0);
try {
Highcharts.downloadURL(svgData, filename);
if (successCallback) {
successCallback();
}
} catch (e) {
failCallback();
}
}
// Initiate download depending on file type
if (imageType === 'image/svg+xml') {
// SVG download. In this case, we want to use Microsoft specific Blob if available
try {
if (nav.msSaveOrOpenBlob) {
blob = new MSBlobBuilder();
blob.append(svg);
svgurl = blob.getBlob('image/svg+xml');
} else {
svgurl = Highcharts.svgToDataUrl(svg);
}
Highcharts.downloadURL(svgurl, filename);
if (successCallback) {
successCallback();
}
} catch (e) {
failCallback();
}
} else if (imageType === 'application/pdf') {
if (win.jsPDF && win.svg2pdf) {
downloadPDF();
} else {
// Must load pdf libraries first
objectURLRevoke = true; // Don't destroy the object URL yet since we are doing things asynchronously. A cleaner solution would be nice, but this will do for now.
getScript(libURL + 'jspdf.js', function() {
getScript(libURL + 'svg2pdf.js', function() {
downloadPDF();
});
});
}
} else {
// PNG/JPEG download - create bitmap from SVG
svgurl = Highcharts.svgToDataUrl(svg);
finallyHandler = function() {
try {
domurl.revokeObjectURL(svgurl);
} catch (e) {
// Ignore
}
};
// First, try to get PNG by rendering on canvas
Highcharts.imageToDataUrl(svgurl, imageType, { /* args */ }, scale, function(imageURL) {
// Success
try {
Highcharts.downloadURL(imageURL, filename);
if (successCallback) {
successCallback();
}
} catch (e) {
failCallback();
}
}, function() {
// Failed due to tainted canvas
// Create new and untainted canvas
var canvas = doc.createElement('canvas'),
ctx = canvas.getContext('2d'),
imageWidth = svg.match(/^<svg[^>]*width\s*=\s*\"?(\d+)\"?[^>]*>/)[1] * scale,
imageHeight = svg.match(/^<svg[^>]*height\s*=\s*\"?(\d+)\"?[^>]*>/)[1] * scale,
downloadWithCanVG = function() {
ctx.drawSvg(svg, 0, 0, imageWidth, imageHeight);
try {
Highcharts.downloadURL(nav.msSaveOrOpenBlob ? canvas.msToBlob() : canvas.toDataURL(imageType), filename);
if (successCallback) {
successCallback();
}
} catch (e) {
failCallback();
} finally {
finallyHandler();
}
};
canvas.width = imageWidth;
canvas.height = imageHeight;
if (win.canvg) {
// Use preloaded canvg
downloadWithCanVG();
} else {
// Must load canVG first
objectURLRevoke = true; // Don't destroy the object URL yet since we are doing things asynchronously. A cleaner solution would be nice, but this will do for now.
getScript(libURL + 'rgbcolor.js', function() { // Get RGBColor.js first
getScript(libURL + 'canvg.js', function() {
downloadWithCanVG();
});
});
}
},
// No canvas support
failCallback,
// Failed to load image
failCallback,
// Finally
function() {
if (objectURLRevoke) {
finallyHandler();
}
});
}
};
// Get SVG of chart prepared for client side export. This converts embedded images in the SVG to data URIs.
// The options and chartOptions arguments are passed to the getSVGForExport function.
Highcharts.Chart.prototype.getSVGForLocalExport = function(options, chartOptions, failCallback, successCallback) {
var chart = this,
images,
imagesEmbedded = 0,
chartCopyContainer,
chartCopyOptions,
el,
i,
l,
// After grabbing the SVG of the chart's copy container we need to do sanitation on the SVG
sanitize = function(svg) {
return chart.sanitizeSVG(svg, chartCopyOptions);
},
// Success handler, we converted image to base64!
embeddedSuccess = function(imageURL, imageType, callbackArgs) {
++imagesEmbedded;
// Change image href in chart copy
callbackArgs.imageElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', imageURL);
// When done with last image we have our SVG
if (imagesEmbedded === images.length) {
successCallback(sanitize(chartCopyContainer.innerHTML));
}
};
// Hook into getSVG to get a copy of the chart copy's container
Highcharts.wrap(
Highcharts.Chart.prototype,
'getChartHTML',
function(proceed) {
var ret = proceed.apply(
this,
Array.prototype.slice.call(arguments, 1)
);
chartCopyOptions = this.options;
chartCopyContainer = this.container.cloneNode(true);
return ret;
}
);
// Trigger hook to get chart copy
chart.getSVGForExport(options, chartOptions);
images = chartCopyContainer.getElementsByTagName('image');
try {
// If there are no images to embed, the SVG is okay now.
if (!images.length) {
successCallback(sanitize(chartCopyContainer.innerHTML)); // Use SVG of chart copy
return;
}
// Go through the images we want to embed
for (i = 0, l = images.length; i < l; ++i) {
el = images[i];
Highcharts.imageToDataUrl(el.getAttributeNS('http://www.w3.org/1999/xlink', 'href'), 'image/png', {
imageElement: el
}, options.scale,
embeddedSuccess,
// Tainted canvas
failCallback,
// No canvas support
failCallback,
// Failed to load source
failCallback
);
}
} catch (e) {
failCallback();
}
};
/**
* Add a new method to the Chart object to perform a local download
*/
Highcharts.Chart.prototype.exportChartLocal = function(exportingOptions, chartOptions) {
var chart = this,
options = Highcharts.merge(chart.options.exporting, exportingOptions),
fallbackToExportServer = function() {
if (options.fallbackToExportServer === false) {
if (options.error) {
options.error(options);
} else {
throw 'Fallback to export server disabled';
}
} else {
chart.exportChart(options);
}
},
svgSuccess = function(svg) {
// If SVG contains foreignObjects all exports except SVG will fail,
// as both CanVG and svg2pdf choke on this. Gracefully fall back.
if (
svg.indexOf('<foreignObject') > -1 &&
options.type !== 'image/svg+xml'
) {
fallbackToExportServer();
} else {
Highcharts.downloadSVGLocal(svg, options, fallbackToExportServer);
}
};
// Always fall back on:
// - MS browsers: Embedded images JPEG/PNG, or any PDF
// - Edge: PNG/JPEG all cases
// - Embedded images and PDF
if (
(
isMSBrowser &&
(
options.type === 'application/pdf' ||
chart.container.getElementsByTagName('image').length &&
options.type !== 'image/svg+xml'
)
) || (
isEdgeBrowser && options.type !== 'image/svg+xml'
) || (
options.type === 'application/pdf' &&
chart.container.getElementsByTagName('image').length
)
) {
fallbackToExportServer();
return;
}
chart.getSVGForLocalExport(options, chartOptions, fallbackToExportServer, svgSuccess);
};
// Extend the default options to use the local exporter logic
merge(true, Highcharts.getOptions().exporting, {
libURL: 'https://code.highcharts.com/5.0.10/lib/',
buttons: {
contextButton: {
menuItems: [{
textKey: 'printChart',
onclick: function() {
this.print();
}
}, {
separator: true
}, {
textKey: 'downloadPNG',
onclick: function() {
this.exportChartLocal();
}
}, {
textKey: 'downloadJPEG',
onclick: function() {
this.exportChartLocal({
type: 'image/jpeg'
});
}
}, {
textKey: 'downloadSVG',
onclick: function() {
this.exportChartLocal({
type: 'image/svg+xml'
});
}
}, {
textKey: 'downloadPDF',
onclick: function() {
this.exportChartLocal({
type: 'application/pdf'
});
}
}]
}
}
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
(c) 2009-2017 Torstein Honsi
License: www.highcharts.com/license
*/
(function(a){"object"===typeof module&&module.exports?module.exports=a:a(Highcharts)})(function(a){(function(a){var h=a.Chart,k=a.each,q=a.pick,r=a.addEvent;h.prototype.callbacks.push(function(f){function a(){var a=[];k(f.series||[],function(b){var c=b.options.dataLabels,d=b.dataLabelCollections||["dataLabel"];(c.enabled||b._hasPointLabels)&&!c.allowOverlap&&b.visible&&k(d,function(c){k(b.points,function(b){b[c]&&(b[c].labelrank=q(b.labelrank,b.shapeArgs&&b.shapeArgs.height),a.push(b[c]))})})});f.hideOverlappingLabels(a)}
a();r(f,"redraw",a)});h.prototype.hideOverlappingLabels=function(a){var f=a.length,e,b,c,d,l,m,n,p,g,h=function(a,b,c,d,e,f,g,h){return!(e>a+c||e+g<a||f>b+d||f+h<b)};for(b=0;b<f;b++)if(e=a[b])e.oldOpacity=e.opacity,e.newOpacity=1;a.sort(function(a,b){return(b.labelrank||0)-(a.labelrank||0)});for(b=0;b<f;b++)for(c=a[b],e=b+1;e<f;++e)if(d=a[e],c&&d&&c!==d&&c.placed&&d.placed&&0!==c.newOpacity&&0!==d.newOpacity&&(l=c.alignAttr,m=d.alignAttr,n=c.parentGroup,p=d.parentGroup,g=2*(c.box?0:c.padding),l=h(l.x+
n.translateX,l.y+n.translateY,c.width-g,c.height-g,m.x+p.translateX,m.y+p.translateY,d.width-g,d.height-g)))(c.labelrank<d.labelrank?c:d).newOpacity=0;k(a,function(a){var b,c;a&&(c=a.newOpacity,a.oldOpacity!==c&&a.placed&&(c?a.show(!0):b=function(){a.hide()},a.alignAttr.opacity=c,a[a.isOld?"animate":"attr"](a.alignAttr,null,b)),a.isOld=!0)})}})(a)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/**
* Highcharts module to hide overlapping data labels. This module is included in
* Highcharts.
*/
var Chart = H.Chart,
each = H.each,
pick = H.pick,
addEvent = H.addEvent;
// Collect potensial overlapping data labels. Stack labels probably don't need
// to be considered because they are usually accompanied by data labels that lie
// inside the columns.
Chart.prototype.callbacks.push(function(chart) {
function collectAndHide() {
var labels = [];
each(chart.series || [], function(series) {
var dlOptions = series.options.dataLabels,
// Range series have two collections
collections = series.dataLabelCollections || ['dataLabel'];
if (
(dlOptions.enabled || series._hasPointLabels) &&
!dlOptions.allowOverlap &&
series.visible
) { // #3866
each(collections, function(coll) {
each(series.points, function(point) {
if (point[coll]) {
point[coll].labelrank = pick(
point.labelrank,
point.shapeArgs && point.shapeArgs.height
); // #4118
labels.push(point[coll]);
}
});
});
}
});
chart.hideOverlappingLabels(labels);
}
// Do it now ...
collectAndHide();
// ... and after each chart redraw
addEvent(chart, 'redraw', collectAndHide);
});
/**
* Hide overlapping labels. Labels are moved and faded in and out on zoom to
* provide a smooth visual imression.
*/
Chart.prototype.hideOverlappingLabels = function(labels) {
var len = labels.length,
label,
i,
j,
label1,
label2,
isIntersecting,
pos1,
pos2,
parent1,
parent2,
padding,
intersectRect = function(x1, y1, w1, h1, x2, y2, w2, h2) {
return !(
x2 > x1 + w1 ||
x2 + w2 < x1 ||
y2 > y1 + h1 ||
y2 + h2 < y1
);
};
// Mark with initial opacity
for (i = 0; i < len; i++) {
label = labels[i];
if (label) {
label.oldOpacity = label.opacity;
label.newOpacity = 1;
}
}
// Prevent a situation in a gradually rising slope, that each label will
// hide the previous one because the previous one always has lower rank.
labels.sort(function(a, b) {
return (b.labelrank || 0) - (a.labelrank || 0);
});
// Detect overlapping labels
for (i = 0; i < len; i++) {
label1 = labels[i];
for (j = i + 1; j < len; ++j) {
label2 = labels[j];
if (
label1 && label2 &&
label1 !== label2 && // #6465, polar chart with connectEnds
label1.placed && label2.placed &&
label1.newOpacity !== 0 && label2.newOpacity !== 0
) {
pos1 = label1.alignAttr;
pos2 = label2.alignAttr;
// Different panes have different positions
parent1 = label1.parentGroup;
parent2 = label2.parentGroup;
// Substract the padding if no background or border (#4333)
padding = 2 * (label1.box ? 0 : label1.padding);
isIntersecting = intersectRect(
pos1.x + parent1.translateX,
pos1.y + parent1.translateY,
label1.width - padding,
label1.height - padding,
pos2.x + parent2.translateX,
pos2.y + parent2.translateY,
label2.width - padding,
label2.height - padding
);
if (isIntersecting) {
(label1.labelrank < label2.labelrank ? label1 : label2)
.newOpacity = 0;
}
}
}
}
// Hide or show
each(labels, function(label) {
var complete,
newOpacity;
if (label) {
newOpacity = label.newOpacity;
if (label.oldOpacity !== newOpacity && label.placed) {
// Make sure the label is completely hidden to avoid catching
// clicks (#4362)
if (newOpacity) {
label.show(true);
} else {
complete = function() {
label.hide();
};
}
// Animate or set the opacity
label.alignAttr.opacity = newOpacity;
label[label.isOld ? 'animate' : 'attr'](
label.alignAttr,
null,
complete
);
}
label.isOld = true;
}
});
};
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
(c) 2009-2017 Torstein Honsi
License: www.highcharts.com/license
*/
(function(u){"object"===typeof module&&module.exports?module.exports=u:u(Highcharts)})(function(u){(function(q){function u(f,b,a,m,c,e){f=(e-b)*(a-f)-(m-b)*(c-f);return 0<f?!0:0>f?!1:!0}function v(f,b,a,m,c,e,d,l){return u(f,b,c,e,d,l)!==u(a,m,c,e,d,l)&&u(f,b,a,m,c,e)!==u(f,b,a,m,d,l)}function z(f,b,a,m,c,e,d,l){return v(f,b,f+a,b,c,e,d,l)||v(f+a,b,f+a,b+m,c,e,d,l)||v(f,b+m,f+a,b+m,c,e,d,l)||v(f,b,f,b+m,c,e,d,l)}function A(f){var b=this,a=Math.max(q.animObject(b.renderer.globalAnimation).duration,
250),m=!b.hasRendered;f.apply(b,[].slice.call(arguments,1));b.labelSeries=[];clearTimeout(b.seriesLabelTimer);w(b.series,function(c){var e=c.labelBySeries,d=e&&e.closest;c.options.label.enabled&&c.visible&&(c.graph||c.area)&&(b.labelSeries.push(c),m&&(a=Math.max(a,q.animObject(c.options.animation).duration)),d&&(void 0!==d[0].plotX?e.animate({x:d[0].plotX+d[1],y:d[0].plotY+d[2]}):e.attr({opacity:0})))});b.seriesLabelTimer=setTimeout(function(){b.drawSeriesLabels()},a)}var B=q.wrap,w=q.each,D=q.extend,
x=q.isNumber,C=q.Series,E=q.SVGRenderer,y=q.Chart;q.setOptions({plotOptions:{series:{label:{enabled:!0,connectorAllowed:!0,connectorNeighbourDistance:24,styles:{fontWeight:"bold"}}}}});E.prototype.symbols.connector=function(f,b,a,m,c){var e=c&&c.anchorX;c=c&&c.anchorY;var d,l,h=a/2;x(e)&&x(c)&&(d=["M",e,c],l=b-c,0>l&&(l=-m-l),l<a&&(h=e<f+a/2?l:a-l),c>b+m?d.push("L",f+h,b+m):c<b?d.push("L",f+h,b):e<f?d.push("L",f,b+m/2):e>f+a&&d.push("L",f+a,b+m/2));return d||[]};C.prototype.getPointsOnGraph=function(){var f=
this.points,b,a,m=[],c,e,d,l;e=this.graph||this.area;d=e.element;var h=(b=this.chart.inverted)?this.yAxis.pos:this.xAxis.pos,n=b?this.xAxis.pos:this.yAxis.pos;if(this.getPointSpline&&d.getPointAtLength){e.toD&&(a=e.attr("d"),e.attr({d:e.toD}));l=d.getTotalLength();for(c=0;c<l;c+=16)b=d.getPointAtLength(c),m.push({chartX:h+b.x,chartY:n+b.y,plotX:b.x,plotY:b.y});a&&e.attr({d:a});b=f[f.length-1];b.chartX=h+b.plotX;b.chartY=n+b.plotY;m.push(b)}else for(l=f.length,c=0;c<l;c+=1){b=f[c];a=f[c-1];b.chartX=
h+b.plotX;b.chartY=n+b.plotY;if(0<c&&(e=Math.abs(b.chartX-a.chartX),d=Math.abs(b.chartY-a.chartY),e=Math.max(e,d),16<e))for(e=Math.ceil(e/16),d=1;d<e;d+=1)m.push({chartX:a.chartX+d/e*(b.chartX-a.chartX),chartY:a.chartY+d/e*(b.chartY-a.chartY),plotX:a.plotX+d/e*(b.plotX-a.plotX),plotY:a.plotY+d/e*(b.plotY-a.plotY)});x(b.plotY)&&m.push(b)}return m};C.prototype.checkClearPoint=function(f,b,a,m){var c=Number.MAX_VALUE,e=Number.MAX_VALUE,d,l,h=this.options.label.connectorAllowed,n=this.chart,p,g,r,k;for(r=
0;r<n.boxesToAvoid.length;r+=1){g=n.boxesToAvoid[r];k=f+a.width;p=b;var q=b+a.height;if(!(f>g.right||k<g.left||p>g.bottom||q<g.top))return!1}for(r=0;r<n.series.length;r+=1)if(p=n.series[r],g=p.interpolatedPoints,p.visible&&g){for(k=1;k<g.length;k+=1){if(z(f,b,a.width,a.height,g[k-1].chartX,g[k-1].chartY,g[k].chartX,g[k].chartY))return!1;this===p&&!d&&m&&(d=z(f-16,b-16,a.width+32,a.height+32,g[k-1].chartX,g[k-1].chartY,g[k].chartX,g[k].chartY));this!==p&&(c=Math.min(c,Math.pow(f+a.width/2-g[k].chartX,
2)+Math.pow(b+a.height/2-g[k].chartY,2),Math.pow(f-g[k].chartX,2)+Math.pow(b-g[k].chartY,2),Math.pow(f+a.width-g[k].chartX,2)+Math.pow(b-g[k].chartY,2),Math.pow(f+a.width-g[k].chartX,2)+Math.pow(b+a.height-g[k].chartY,2),Math.pow(f-g[k].chartX,2)+Math.pow(b+a.height-g[k].chartY,2)))}if(h&&this===p&&(m&&!d||c<Math.pow(this.options.label.connectorNeighbourDistance,2))){for(k=1;k<g.length;k+=1)d=Math.min(Math.pow(f+a.width/2-g[k].chartX,2)+Math.pow(b+a.height/2-g[k].chartY,2),Math.pow(f-g[k].chartX,
2)+Math.pow(b-g[k].chartY,2),Math.pow(f+a.width-g[k].chartX,2)+Math.pow(b-g[k].chartY,2),Math.pow(f+a.width-g[k].chartX,2)+Math.pow(b+a.height-g[k].chartY,2),Math.pow(f-g[k].chartX,2)+Math.pow(b+a.height-g[k].chartY,2)),d<e&&(e=d,l=g[k]);d=!0}}return!m||d?{x:f,y:b,weight:c-(l?e:0),connectorPoint:l}:!1};y.prototype.drawSeriesLabels=function(){var f=this,b=this.labelSeries;f.boxesToAvoid=[];w(b,function(a){a.interpolatedPoints=a.getPointsOnGraph();w(a.options.label.boxesToAvoid||[],function(a){f.boxesToAvoid.push(a)})});
w(f.series,function(a){function b(a,b,c){return a>g&&a<=g+k-c.width&&b>=r&&b<=r+q-c.height}var c,e,d,l=[],h,n,p=f.inverted,g=p?a.yAxis.pos:a.xAxis.pos,r=p?a.xAxis.pos:a.yAxis.pos,k=f.inverted?a.yAxis.len:a.xAxis.len,q=f.inverted?a.xAxis.len:a.yAxis.len,t=a.interpolatedPoints,p=a.labelBySeries;if(a.visible&&t){p||(a.labelBySeries=p=f.renderer.label(a.name,0,-9999,"connector").css(D({color:a.color},a.options.label.styles)).attr({padding:0,opacity:0,stroke:a.color,"stroke-width":1}).add(a.group).animate({opacity:1},
{duration:200}));c=p.getBBox();c.width=Math.round(c.width);for(n=t.length-1;0<n;--n)e=t[n].chartX+3,d=t[n].chartY-c.height-3,b(e,d,c)&&(h=a.checkClearPoint(e,d,c)),h&&l.push(h),e=t[n].chartX+3,d=t[n].chartY+3,b(e,d,c)&&(h=a.checkClearPoint(e,d,c)),h&&l.push(h),e=t[n].chartX-c.width-3,d=t[n].chartY+3,b(e,d,c)&&(h=a.checkClearPoint(e,d,c)),h&&l.push(h),e=t[n].chartX-c.width-3,d=t[n].chartY-c.height-3,b(e,d,c)&&(h=a.checkClearPoint(e,d,c)),h&&l.push(h);if(!l.length)for(e=g+k-c.width;e>=g;e-=16)for(d=
r;d<r+q-c.height;d+=16)(h=a.checkClearPoint(e,d,c,!0))&&l.push(h);if(l.length){if(l.sort(function(a,b){return b.weight-a.weight}),h=l[0],f.boxesToAvoid.push({left:h.x,right:h.x+c.width,top:h.y,bottom:h.y+c.height}),Math.round(h.x)!==Math.round(p.x)||Math.round(h.y)!==Math.round(p.y))a.labelBySeries.attr({opacity:0,x:h.x-g,y:h.y-r,anchorX:h.connectorPoint&&h.connectorPoint.plotX,anchorY:h.connectorPoint&&h.connectorPoint.plotY}).animate({opacity:1}),a.options.kdNow=!0,a.buildKDTree(),a=a.searchPoint({chartX:h.x,
chartY:h.y},!0),p.closest=[a,h.x-g-a.plotX,h.y-r-a.plotY]}else p&&(a.labelBySeries=p.destroy())}})};B(y.prototype,"render",A);B(y.prototype,"redraw",A)})(u)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | 1 1 1 1 1 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/**
* EXPERIMENTAL Highcharts module to place labels next to a series in a natural position.
*
* TODO:
* - add column support (box collision detection, boxesToAvoid logic)
* - other series types, area etc.
* - avoid data labels, when data labels above, show series label below.
* - add more options (connector, format, formatter)
*
* http://jsfiddle.net/highcharts/L2u9rpwr/
* http://jsfiddle.net/highcharts/y5A37/
* http://jsfiddle.net/highcharts/264Nm/
* http://jsfiddle.net/highcharts/y5A37/
*/
var labelDistance = 3,
wrap = H.wrap,
each = H.each,
extend = H.extend,
isNumber = H.isNumber,
Series = H.Series,
SVGRenderer = H.SVGRenderer,
Chart = H.Chart;
H.setOptions({
plotOptions: {
series: {
label: {
enabled: true,
// Allow labels to be placed distant to the graph if necessary, and
// draw a connector line to the graph
connectorAllowed: true,
connectorNeighbourDistance: 24, // If the label is closer than this to a neighbour graph, draw a connector
styles: {
fontWeight: 'bold'
}
// boxesToAvoid: []
}
}
}
});
/**
* Counter-clockwise, part of the fast line intersection logic
*/
function ccw(x1, y1, x2, y2, x3, y3) {
var cw = ((y3 - y1) * (x2 - x1)) - ((y2 - y1) * (x3 - x1));
return cw > 0 ? true : cw < 0 ? false : true;
}
/**
* Detect if two lines intersect
*/
function intersectLine(x1, y1, x2, y2, x3, y3, x4, y4) {
return ccw(x1, y1, x3, y3, x4, y4) !== ccw(x2, y2, x3, y3, x4, y4) &&
ccw(x1, y1, x2, y2, x3, y3) !== ccw(x1, y1, x2, y2, x4, y4);
}
/**
* Detect if a box intersects with a line
*/
function boxIntersectLine(x, y, w, h, x1, y1, x2, y2) {
return (
intersectLine(x, y, x + w, y, x1, y1, x2, y2) || // top of label
intersectLine(x + w, y, x + w, y + h, x1, y1, x2, y2) || // right of label
intersectLine(x, y + h, x + w, y + h, x1, y1, x2, y2) || // bottom of label
intersectLine(x, y, x, y + h, x1, y1, x2, y2) // left of label
);
}
/**
* General symbol definition for labels with connector
*/
SVGRenderer.prototype.symbols.connector = function(x, y, w, h, options) {
var anchorX = options && options.anchorX,
anchorY = options && options.anchorY,
path,
yOffset,
lateral = w / 2;
if (isNumber(anchorX) && isNumber(anchorY)) {
path = ['M', anchorX, anchorY];
// Prefer 45 deg connectors
yOffset = y - anchorY;
if (yOffset < 0) {
yOffset = -h - yOffset;
}
if (yOffset < w) {
lateral = anchorX < x + (w / 2) ? yOffset : w - yOffset;
}
// Anchor below label
if (anchorY > y + h) {
path.push('L', x + lateral, y + h);
// Anchor above label
} else if (anchorY < y) {
path.push('L', x + lateral, y);
// Anchor left of label
} else if (anchorX < x) {
path.push('L', x, y + h / 2);
// Anchor right of label
} else if (anchorX > x + w) {
path.push('L', x + w, y + h / 2);
}
}
return path || [];
};
/**
* Points to avoid. In addition to actual data points, the label should avoid
* interpolated positions.
*/
Series.prototype.getPointsOnGraph = function() {
var distance = 16,
points = this.points,
point,
last,
interpolated = [],
i,
deltaX,
deltaY,
delta,
len,
n,
j,
d,
graph = this.graph || this.area,
node = graph.element,
inverted = this.chart.inverted,
paneLeft = inverted ? this.yAxis.pos : this.xAxis.pos,
paneTop = inverted ? this.xAxis.pos : this.yAxis.pos;
// For splines, get the point at length (possible caveat: peaks are not correctly detected)
if (this.getPointSpline && node.getPointAtLength) {
// If it is animating towards a path definition, use that briefly, and reset
if (graph.toD) {
d = graph.attr('d');
graph.attr({
d: graph.toD
});
}
len = node.getTotalLength();
for (i = 0; i < len; i += distance) {
point = node.getPointAtLength(i);
interpolated.push({
chartX: paneLeft + point.x,
chartY: paneTop + point.y,
plotX: point.x,
plotY: point.y
});
}
if (d) {
graph.attr({
d: d
});
}
// Last point
point = points[points.length - 1];
point.chartX = paneLeft + point.plotX;
point.chartY = paneTop + point.plotY;
interpolated.push(point);
// Interpolate
} else {
len = points.length;
for (i = 0; i < len; i += 1) {
point = points[i];
last = points[i - 1];
// Absolute coordinates so we can compare different panes
point.chartX = paneLeft + point.plotX;
point.chartY = paneTop + point.plotY;
// Add interpolated points
if (i > 0) {
deltaX = Math.abs(point.chartX - last.chartX);
deltaY = Math.abs(point.chartY - last.chartY);
delta = Math.max(deltaX, deltaY);
if (delta > distance) {
n = Math.ceil(delta / distance);
for (j = 1; j < n; j += 1) {
interpolated.push({
chartX: last.chartX + (point.chartX - last.chartX) * (j / n),
chartY: last.chartY + (point.chartY - last.chartY) * (j / n),
plotX: last.plotX + (point.plotX - last.plotX) * (j / n),
plotY: last.plotY + (point.plotY - last.plotY) * (j / n)
});
}
}
}
// Add the real point in order to find positive and negative peaks
if (isNumber(point.plotY)) {
interpolated.push(point);
}
}
}
return interpolated;
};
/**
* Check whether a proposed label position is clear of other elements
*/
Series.prototype.checkClearPoint = function(x, y, bBox, checkDistance) {
var distToOthersSquared = Number.MAX_VALUE, // distance to other graphs
distToPointSquared = Number.MAX_VALUE,
dist,
connectorPoint,
connectorEnabled = this.options.label.connectorAllowed,
chart = this.chart,
series,
points,
leastDistance = 16,
withinRange,
i,
j;
function intersectRect(r1, r2) {
return !(r2.left > r1.right ||
r2.right < r1.left ||
r2.top > r1.bottom ||
r2.bottom < r1.top);
}
/**
* Get the weight in order to determine the ideal position. Larger distance to
* other series gives more weight. Smaller distance to the actual point (connector points only)
* gives more weight.
*/
function getWeight(distToOthersSquared, distToPointSquared) {
return distToOthersSquared - distToPointSquared;
}
// First check for collision with existing labels
for (i = 0; i < chart.boxesToAvoid.length; i += 1) {
if (intersectRect(chart.boxesToAvoid[i], {
left: x,
right: x + bBox.width,
top: y,
bottom: y + bBox.height
})) {
return false;
}
}
// For each position, check if the lines around the label intersect with any of the
// graphs
for (i = 0; i < chart.series.length; i += 1) {
series = chart.series[i];
points = series.interpolatedPoints;
if (series.visible && points) {
for (j = 1; j < points.length; j += 1) {
// If any of the box sides intersect with the line, return
if (boxIntersectLine(
x,
y,
bBox.width,
bBox.height,
points[j - 1].chartX,
points[j - 1].chartY,
points[j].chartX,
points[j].chartY
)) {
return false;
}
// But if it is too far away (a padded box doesn't intersect), also return
if (this === series && !withinRange && checkDistance) {
withinRange = boxIntersectLine(
x - leastDistance,
y - leastDistance,
bBox.width + 2 * leastDistance,
bBox.height + 2 * leastDistance,
points[j - 1].chartX,
points[j - 1].chartY,
points[j].chartX,
points[j].chartY
);
}
// Find the squared distance from the center of the label
if (this !== series) {
distToOthersSquared = Math.min(
distToOthersSquared,
Math.pow(x + bBox.width / 2 - points[j].chartX, 2) + Math.pow(y + bBox.height / 2 - points[j].chartY, 2),
Math.pow(x - points[j].chartX, 2) + Math.pow(y - points[j].chartY, 2),
Math.pow(x + bBox.width - points[j].chartX, 2) + Math.pow(y - points[j].chartY, 2),
Math.pow(x + bBox.width - points[j].chartX, 2) + Math.pow(y + bBox.height - points[j].chartY, 2),
Math.pow(x - points[j].chartX, 2) + Math.pow(y + bBox.height - points[j].chartY, 2)
);
}
}
// Do we need a connector?
if (connectorEnabled && this === series && ((checkDistance && !withinRange) ||
distToOthersSquared < Math.pow(this.options.label.connectorNeighbourDistance, 2))) {
for (j = 1; j < points.length; j += 1) {
dist = Math.min(
Math.pow(x + bBox.width / 2 - points[j].chartX, 2) + Math.pow(y + bBox.height / 2 - points[j].chartY, 2),
Math.pow(x - points[j].chartX, 2) + Math.pow(y - points[j].chartY, 2),
Math.pow(x + bBox.width - points[j].chartX, 2) + Math.pow(y - points[j].chartY, 2),
Math.pow(x + bBox.width - points[j].chartX, 2) + Math.pow(y + bBox.height - points[j].chartY, 2),
Math.pow(x - points[j].chartX, 2) + Math.pow(y + bBox.height - points[j].chartY, 2)
);
if (dist < distToPointSquared) {
distToPointSquared = dist;
connectorPoint = points[j];
}
}
withinRange = true;
}
}
}
return !checkDistance || withinRange ? {
x: x,
y: y,
weight: getWeight(distToOthersSquared, connectorPoint ? distToPointSquared : 0),
connectorPoint: connectorPoint
} : false;
};
/**
* The main initiator method that runs on chart level after initiation and redraw. It runs in
* a timeout to prevent locking, and loops over all series, taking all series and labels into
* account when placing the labels.
*/
Chart.prototype.drawSeriesLabels = function() {
var chart = this,
labelSeries = this.labelSeries;
chart.boxesToAvoid = [];
// Build the interpolated points
each(labelSeries, function(series) {
series.interpolatedPoints = series.getPointsOnGraph();
each(series.options.label.boxesToAvoid || [], function(box) {
chart.boxesToAvoid.push(box);
});
});
each(chart.series, function(series) {
var bBox,
x,
y,
results = [],
clearPoint,
i,
best,
inverted = chart.inverted,
paneLeft = inverted ? series.yAxis.pos : series.xAxis.pos,
paneTop = inverted ? series.xAxis.pos : series.yAxis.pos,
paneWidth = chart.inverted ? series.yAxis.len : series.xAxis.len,
paneHeight = chart.inverted ? series.xAxis.len : series.yAxis.len,
points = series.interpolatedPoints,
label = series.labelBySeries;
function insidePane(x, y, bBox) {
return x > paneLeft && x <= paneLeft + paneWidth - bBox.width &&
y >= paneTop && y <= paneTop + paneHeight - bBox.height;
}
if (series.visible && points) {
if (!label) {
series.labelBySeries = label = chart.renderer
.label(series.name, 0, -9999, 'connector')
.css(extend({
color: series.color
}, series.options.label.styles))
.attr({
padding: 0,
opacity: 0,
stroke: series.color,
'stroke-width': 1
})
.add(series.group)
.animate({
opacity: 1
}, {
duration: 200
});
}
bBox = label.getBBox();
bBox.width = Math.round(bBox.width);
// Ideal positions are centered above or below a point on right side
// of chart
for (i = points.length - 1; i > 0; i -= 1) {
// Right - up
x = points[i].chartX + labelDistance;
y = points[i].chartY - bBox.height - labelDistance;
if (insidePane(x, y, bBox)) {
best = series.checkClearPoint(
x,
y,
bBox
);
}
if (best) {
results.push(best);
}
// Right - down
x = points[i].chartX + labelDistance;
y = points[i].chartY + labelDistance;
if (insidePane(x, y, bBox)) {
best = series.checkClearPoint(
x,
y,
bBox
);
}
if (best) {
results.push(best);
}
// Left - down
x = points[i].chartX - bBox.width - labelDistance;
y = points[i].chartY + labelDistance;
if (insidePane(x, y, bBox)) {
best = series.checkClearPoint(
x,
y,
bBox
);
}
if (best) {
results.push(best);
}
// Left - up
x = points[i].chartX - bBox.width - labelDistance;
y = points[i].chartY - bBox.height - labelDistance;
if (insidePane(x, y, bBox)) {
best = series.checkClearPoint(
x,
y,
bBox
);
}
if (best) {
results.push(best);
}
}
// Brute force, try all positions on the chart in a 16x16 grid
if (!results.length) {
for (x = paneLeft + paneWidth - bBox.width; x >= paneLeft; x -= 16) {
for (y = paneTop; y < paneTop + paneHeight - bBox.height; y += 16) {
clearPoint = series.checkClearPoint(x, y, bBox, true);
if (clearPoint) {
results.push(clearPoint);
}
}
}
}
if (results.length) {
results.sort(function(a, b) {
return b.weight - a.weight;
});
best = results[0];
chart.boxesToAvoid.push({
left: best.x,
right: best.x + bBox.width,
top: best.y,
bottom: best.y + bBox.height
});
// Move it if needed
if (Math.round(best.x) !== Math.round(label.x) ||
Math.round(best.y) !== Math.round(label.y)) {
series.labelBySeries
.attr({
opacity: 0,
x: best.x - paneLeft,
y: best.y - paneTop,
anchorX: best.connectorPoint && best.connectorPoint.plotX,
anchorY: best.connectorPoint && best.connectorPoint.plotY
})
.animate({
opacity: 1
});
// Record closest point to stick to for sync redraw
series.options.kdNow = true;
series.buildKDTree();
var closest = series.searchPoint({
chartX: best.x,
chartY: best.y
}, true);
label.closest = [
closest,
best.x - paneLeft - closest.plotX,
best.y - paneTop - closest.plotY
];
}
} else if (label) {
series.labelBySeries = label.destroy();
}
}
});
};
/**
* Prepare drawing series labels
*/
function drawLabels(proceed) {
var chart = this,
delay = Math.max(
H.animObject(chart.renderer.globalAnimation).duration,
250
),
initial = !chart.hasRendered;
proceed.apply(chart, [].slice.call(arguments, 1));
chart.labelSeries = [];
clearTimeout(chart.seriesLabelTimer);
// Which series should have labels
each(chart.series, function(series) {
var options = series.options.label,
label = series.labelBySeries,
closest = label && label.closest;
if (options.enabled && series.visible && (series.graph || series.area)) {
chart.labelSeries.push(series);
// The labels are processing heavy, wait until the animation is done
if (initial) {
delay = Math.max(
delay,
H.animObject(series.options.animation).duration
);
}
// Keep the position updated to the axis while redrawing
if (closest) {
if (closest[0].plotX !== undefined) {
label.animate({
x: closest[0].plotX + closest[1],
y: closest[0].plotY + closest[2]
});
} else {
label.attr({
opacity: 0
});
}
}
}
});
chart.seriesLabelTimer = setTimeout(function() {
chart.drawSeriesLabels();
}, delay);
}
wrap(Chart.prototype, 'render', drawLabels);
wrap(Chart.prototype, 'redraw', drawLabels);
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Solid angular gauge module
(c) 2010-2017 Torstein Honsi
License: www.highcharts.com/license
*/
(function(l){"object"===typeof module&&module.exports?module.exports=l:l(Highcharts)})(function(l){(function(f){var l=f.pInt,u=f.pick,m=f.each,v=f.isNumber,w=f.wrap,n;w(f.Renderer.prototype.symbols,"arc",function(a,d,e,c,f,g){a=a(d,e,c,f,g);g.rounded&&(c=((g.r||c)-g.innerR)/2,g=["A",c,c,0,1,1,a[12],a[13]],a.splice.apply(a,[a.length-1,0].concat(["A",c,c,0,1,1,a[1],a[2]])),a.splice.apply(a,[11,3].concat(g)));return a});n={initDataClasses:function(a){var d=this,e=this.chart,c,t=0,g=this.options;this.dataClasses=
c=[];m(a.dataClasses,function(h,b){h=f.merge(h);c.push(h);h.color||("category"===g.dataClassColor?(b=e.options.colors,h.color=b[t++],t===b.length&&(t=0)):h.color=d.tweenColors(f.color(g.minColor),f.color(g.maxColor),b/(a.dataClasses.length-1)))})},initStops:function(a){this.stops=a.stops||[[0,this.options.minColor],[1,this.options.maxColor]];m(this.stops,function(a){a.color=f.color(a[1])})},toColor:function(a,d){var e=this.stops,c,f,g=this.dataClasses,h,b;if(g)for(b=g.length;b--;){if(h=g[b],c=h.from,
e=h.to,(void 0===c||a>=c)&&(void 0===e||a<=e)){f=h.color;d&&(d.dataClass=b);break}}else{this.isLog&&(a=this.val2lin(a));a=1-(this.max-a)/(this.max-this.min);for(b=e.length;b--&&!(a>e[b][0]););c=e[b]||e[b+1];e=e[b+1]||c;a=1-(e[0]-a)/(e[0]-c[0]||1);f=this.tweenColors(c.color,e.color,a)}return f},tweenColors:function(a,d,e){var c;d.rgba.length&&a.rgba.length?(a=a.rgba,d=d.rgba,c=1!==d[3]||1!==a[3],a=(c?"rgba(":"rgb(")+Math.round(d[0]+(a[0]-d[0])*(1-e))+","+Math.round(d[1]+(a[1]-d[1])*(1-e))+","+Math.round(d[2]+
(a[2]-d[2])*(1-e))+(c?","+(d[3]+(a[3]-d[3])*(1-e)):"")+")"):a=d.input||"none";return a}};m(["fill","stroke"],function(a){f.Fx.prototype[a+"Setter"]=function(){this.elem.attr(a,n.tweenColors(f.color(this.start),f.color(this.end),this.pos),null,!0)}});f.seriesType("solidgauge","gauge",{colorByPoint:!0},{translate:function(){var a=this.yAxis;f.extend(a,n);!a.dataClasses&&a.options.dataClasses&&a.initDataClasses(a.options);a.initStops(a.options);f.seriesTypes.gauge.prototype.translate.call(this)},drawPoints:function(){var a=
this,d=a.yAxis,e=d.center,c=a.options,t=a.chart.renderer,g=c.overshoot,h=v(g)?g/180*Math.PI:0,b;v(c.threshold)&&(b=d.startAngleRad+d.translate(c.threshold,null,null,null,!0));this.thresholdAngleRad=u(b,d.startAngleRad);m(a.points,function(b){var g=b.graphic,k=d.startAngleRad+d.translate(b.y,null,null,null,!0),m=l(u(b.options.radius,c.radius,100))*e[2]/200,p=l(u(b.options.innerRadius,c.innerRadius,60))*e[2]/200,q=d.toColor(b.y,b),r=Math.min(d.startAngleRad,d.endAngleRad),n=Math.max(d.startAngleRad,
d.endAngleRad);"none"===q&&(q=b.color||a.color||"none");"none"!==q&&(b.color=q);k=Math.max(r-h,Math.min(n+h,k));!1===c.wrap&&(k=Math.max(r,Math.min(n,k)));r=Math.min(k,a.thresholdAngleRad);k=Math.max(k,a.thresholdAngleRad);k-r>2*Math.PI&&(k=r+2*Math.PI);b.shapeArgs=p={x:e[0],y:e[1],r:m,innerR:p,start:r,end:k,rounded:c.rounded};b.startR=m;g?(b=p.d,g.animate(f.extend({fill:q},p)),b&&(p.d=b)):(b.graphic=t.arc(p).addClass("highcharts-point").attr({fill:q,"sweep-flag":0}).add(a.group),"square"!==c.linecap&&
b.graphic.attr({"stroke-linecap":"round","stroke-linejoin":"round"}),b.graphic.attr({stroke:c.borderColor||"none","stroke-width":c.borderWidth||0}))})},animate:function(a){a||(this.startAngleRad=this.thresholdAngleRad,f.seriesTypes.pie.prototype.animate.call(this,a))}})})(l)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Solid angular gauge module
*
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* Solid angular gauge module
*
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var pInt = H.pInt,
pick = H.pick,
each = H.each,
isNumber = H.isNumber,
wrap = H.wrap,
Renderer = H.Renderer,
colorAxisMethods;
/**
* Symbol definition of an arc with round edges.
*
* @param {Number} x - The X coordinate for the top left position.
* @param {Number} y - The Y coordinate for the top left position.
* @param {Number} w - The pixel width.
* @param {Number} h - The pixel height.
* @param {Object} [options] - Additional options, depending on the actual
* symbol drawn.
* @param {boolean} [options.rounded] - Whether to draw rounded edges.
* @return {Array} Path of the created arc.
*/
wrap(Renderer.prototype.symbols, 'arc', function(proceed, x, y, w, h, options) {
var arc = proceed,
path = arc(x, y, w, h, options);
if (options.rounded) {
var r = options.r || w,
smallR = (r - options.innerR) / 2,
x1 = path[1],
y1 = path[2],
x2 = path[12],
y2 = path[13],
roundStart = ['A', smallR, smallR, 0, 1, 1, x1, y1],
roundEnd = ['A', smallR, smallR, 0, 1, 1, x2, y2];
// Insert rounded edge on end, and remove line.
path.splice.apply(path, [path.length - 1, 0].concat(roundStart));
// Insert rounded edge on end, and remove line.
path.splice.apply(path, [11, 3].concat(roundEnd));
}
return path;
});
// These methods are defined in the ColorAxis object, and copied here.
// If we implement an AMD system we should make ColorAxis a dependency.
colorAxisMethods = {
initDataClasses: function(userOptions) {
var axis = this,
chart = this.chart,
dataClasses,
colorCounter = 0,
options = this.options;
this.dataClasses = dataClasses = [];
each(userOptions.dataClasses, function(dataClass, i) {
var colors;
dataClass = H.merge(dataClass);
dataClasses.push(dataClass);
if (!dataClass.color) {
if (options.dataClassColor === 'category') {
colors = chart.options.colors;
dataClass.color = colors[colorCounter++];
// loop back to zero
if (colorCounter === colors.length) {
colorCounter = 0;
}
} else {
dataClass.color = axis.tweenColors(H.color(options.minColor), H.color(options.maxColor), i / (userOptions.dataClasses.length - 1));
}
}
});
},
initStops: function(userOptions) {
this.stops = userOptions.stops || [
[0, this.options.minColor],
[1, this.options.maxColor]
];
each(this.stops, function(stop) {
stop.color = H.color(stop[1]);
});
},
/**
* Translate from a value to a color
*/
toColor: function(value, point) {
var pos,
stops = this.stops,
from,
to,
color,
dataClasses = this.dataClasses,
dataClass,
i;
if (dataClasses) {
i = dataClasses.length;
while (i--) {
dataClass = dataClasses[i];
from = dataClass.from;
to = dataClass.to;
if ((from === undefined || value >= from) && (to === undefined || value <= to)) {
color = dataClass.color;
if (point) {
point.dataClass = i;
}
break;
}
}
} else {
if (this.isLog) {
value = this.val2lin(value);
}
pos = 1 - ((this.max - value) / (this.max - this.min));
i = stops.length;
while (i--) {
if (pos > stops[i][0]) {
break;
}
}
from = stops[i] || stops[i + 1];
to = stops[i + 1] || from;
// The position within the gradient
pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1);
color = this.tweenColors(
from.color,
to.color,
pos
);
}
return color;
},
/*
* Return an intermediate color between two colors, according to pos where 0
* is the from color and 1 is the to color.
*/
tweenColors: function(from, to, pos) {
// Check for has alpha, because rgba colors perform worse due to lack of
// support in WebKit.
var hasAlpha,
ret;
// Unsupported color, return to-color (#3920)
if (!to.rgba.length || !from.rgba.length) {
ret = to.input || 'none';
// Interpolate
} else {
from = from.rgba;
to = to.rgba;
hasAlpha = (to[3] !== 1 || from[3] !== 1);
ret = (hasAlpha ? 'rgba(' : 'rgb(') +
Math.round(to[0] + (from[0] - to[0]) * (1 - pos)) + ',' +
Math.round(to[1] + (from[1] - to[1]) * (1 - pos)) + ',' +
Math.round(to[2] + (from[2] - to[2]) * (1 - pos)) +
(hasAlpha ? (',' + (to[3] + (from[3] - to[3]) * (1 - pos))) : '') + ')';
}
return ret;
}
};
/**
* Handle animation of the color attributes directly
*/
each(['fill', 'stroke'], function(prop) {
H.Fx.prototype[prop + 'Setter'] = function() {
this.elem.attr(
prop,
colorAxisMethods.tweenColors(
H.color(this.start),
H.color(this.end),
this.pos
),
null,
true
);
};
});
// The solidgauge series type
H.seriesType('solidgauge', 'gauge', {
colorByPoint: true
}, {
/**
* Extend the translate function to extend the Y axis with the necessary
* decoration (#5895).
*/
translate: function() {
var axis = this.yAxis;
H.extend(axis, colorAxisMethods);
// Prepare data classes
if (!axis.dataClasses && axis.options.dataClasses) {
axis.initDataClasses(axis.options);
}
axis.initStops(axis.options);
// Generate points and inherit data label position
H.seriesTypes.gauge.prototype.translate.call(this);
},
/**
* Draw the points where each point is one needle
*/
drawPoints: function() {
var series = this,
yAxis = series.yAxis,
center = yAxis.center,
options = series.options,
renderer = series.chart.renderer,
overshoot = options.overshoot,
overshootVal = isNumber(overshoot) ? overshoot / 180 * Math.PI : 0,
thresholdAngleRad;
// Handle the threshold option
if (isNumber(options.threshold)) {
thresholdAngleRad = yAxis.startAngleRad + yAxis.translate(
options.threshold,
null,
null,
null,
true
);
}
this.thresholdAngleRad = pick(thresholdAngleRad, yAxis.startAngleRad);
each(series.points, function(point) {
var graphic = point.graphic,
rotation = yAxis.startAngleRad + yAxis.translate(point.y, null, null, null, true),
radius = (pInt(pick(point.options.radius, options.radius, 100)) * center[2]) / 200,
innerRadius = (pInt(pick(point.options.innerRadius, options.innerRadius, 60)) * center[2]) / 200,
shapeArgs,
d,
toColor = yAxis.toColor(point.y, point),
axisMinAngle = Math.min(yAxis.startAngleRad, yAxis.endAngleRad),
axisMaxAngle = Math.max(yAxis.startAngleRad, yAxis.endAngleRad),
minAngle,
maxAngle;
if (toColor === 'none') { // #3708
toColor = point.color || series.color || 'none';
}
if (toColor !== 'none') {
point.color = toColor;
}
// Handle overshoot and clipping to axis max/min
rotation = Math.max(axisMinAngle - overshootVal, Math.min(axisMaxAngle + overshootVal, rotation));
// Handle the wrap option
if (options.wrap === false) {
rotation = Math.max(axisMinAngle, Math.min(axisMaxAngle, rotation));
}
minAngle = Math.min(rotation, series.thresholdAngleRad);
maxAngle = Math.max(rotation, series.thresholdAngleRad);
if (maxAngle - minAngle > 2 * Math.PI) {
maxAngle = minAngle + 2 * Math.PI;
}
point.shapeArgs = shapeArgs = {
x: center[0],
y: center[1],
r: radius,
innerR: innerRadius,
start: minAngle,
end: maxAngle,
rounded: options.rounded
};
point.startR = radius; // For PieSeries.animate
if (graphic) {
d = shapeArgs.d;
graphic.animate(H.extend({
fill: toColor
}, shapeArgs));
if (d) {
shapeArgs.d = d; // animate alters it
}
} else {
point.graphic = renderer.arc(shapeArgs)
.addClass('highcharts-point')
.attr({
fill: toColor,
'sweep-flag': 0
})
.add(series.group);
if (options.linecap !== 'square') {
point.graphic.attr({
'stroke-linecap': 'round',
'stroke-linejoin': 'round'
});
}
point.graphic.attr({
stroke: options.borderColor || 'none',
'stroke-width': options.borderWidth || 0
});
}
});
},
/**
* Extend the pie slice animation by animating from start angle and up
*/
animate: function(init) {
if (!init) {
this.startAngleRad = this.thresholdAngleRad;
H.seriesTypes.pie.prototype.animate.call(this, init);
}
}
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
StaticScale
(c) 2016 Torstein Honsi, Lars A. V. Cabrera
--- WORK IN PROGRESS ---
License: www.highcharts.com/license
*/
(function(a){"object"===typeof module&&module.exports?module.exports=a:a(Highcharts)})(function(a){(function(c){var a=c.Chart,e=c.each,f=c.pick;a.prototype.adjustHeight=function(){e(this.axes,function(b){var a=b.chart,e=!!a.initiatedScale&&a.options.animation,d=b.options.staticScale;c.isNumber(d)&&!b.horiz&&c.defined(b.min)&&(b=f(b.unitLength,b.max+b.tickInterval-b.min)*d,b=Math.max(b,d),d=b-a.plotHeight,1<=Math.abs(d)&&(a.plotHeight=b,a.setSize(null,a.chartHeight+d,e)))});this.initiatedScale=!0};
c.addEvent(a.prototype,"render",a.prototype.adjustHeight)})(a)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* StaticScale
*
* (c) 2016 Torstein Honsi, Lars A. V. Cabrera
*
* --- WORK IN PROGRESS ---
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2017 Torstein Honsi, Lars Cabrera
*
* License: www.highcharts.com/license
*/
var Chart = H.Chart,
each = H.each,
pick = H.pick;
Chart.prototype.adjustHeight = function() {
each(this.axes, function(axis) {
var chart = axis.chart,
animate = !!chart.initiatedScale && chart.options.animation,
staticScale = axis.options.staticScale,
height,
diff;
if (
H.isNumber(staticScale) &&
!axis.horiz &&
H.defined(axis.min)
) {
height = pick(
axis.unitLength,
axis.max + axis.tickInterval - axis.min
) * staticScale;
// Minimum height is 1 x staticScale.
height = Math.max(height, staticScale);
diff = height - chart.plotHeight;
if (Math.abs(diff) >= 1) {
chart.plotHeight = height;
chart.setSize(null, chart.chartHeight + diff, animate);
}
}
});
this.initiatedScale = true;
};
H.addEvent(Chart.prototype, 'render', Chart.prototype.adjustHeight);
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 1 1 1 1 1 1 1 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
Highstock as a plugin for Highcharts
(c) 2017 Torstein Honsi
License: www.highcharts.com/license
*/
(function(J){"object"===typeof module&&module.exports?module.exports=J:J(Highcharts)})(function(J){(function(a){var F=a.addEvent,p=a.Axis,z=a.Chart,D=a.css,G=a.dateFormat,H=a.defined,y=a.each,w=a.extend,x=a.noop,n=a.Series,I=a.timeUnits;a=a.wrap;a(n.prototype,"init",function(a){var b;a.apply(this,Array.prototype.slice.call(arguments,1));(b=this.xAxis)&&b.options.ordinal&&F(this,"updatedData",function(){delete b.ordinalIndex})});a(p.prototype,"getTimeTicks",function(a,b,c,k,l,d,E,e){var f=0,r,q,g=
{},h,C,t,A=[],m=-Number.MAX_VALUE,u=this.options.tickPixelInterval;if(!this.options.ordinal&&!this.options.breaks||!d||3>d.length||void 0===c)return a.call(this,b,c,k,l);C=d.length;for(r=0;r<C;r++){t=r&&d[r-1]>k;d[r]<c&&(f=r);if(r===C-1||d[r+1]-d[r]>5*E||t){if(d[r]>m){for(q=a.call(this,b,d[f],d[r],l);q.length&&q[0]<=m;)q.shift();q.length&&(m=q[q.length-1]);A=A.concat(q)}f=r+1}if(t)break}a=q.info;if(e&&a.unitRange<=I.hour){r=A.length-1;for(f=1;f<r;f++)G("%d",A[f])!==G("%d",A[f-1])&&(g[A[f]]="day",
h=!0);h&&(g[A[0]]="day");a.higherRanks=g}A.info=a;if(e&&H(u)){e=a=A.length;r=[];var B;for(h=[];e--;)f=this.translate(A[e]),B&&(h[e]=B-f),r[e]=B=f;h.sort();h=h[Math.floor(h.length/2)];h<.6*u&&(h=null);e=A[a-1]>k?a-1:a;for(B=void 0;e--;)f=r[e],k=Math.abs(B-f),B&&k<.8*u&&(null===h||k<.8*h)?(g[A[e]]&&!g[A[e+1]]?(k=e+1,B=f):k=e,A.splice(k,1)):B=f}return A});w(p.prototype,{beforeSetTickPositions:function(){var a,b=[],c=!1,k,l=this.getExtremes(),d=l.min,E=l.max,e,f=this.isXAxis&&!!this.options.breaks,l=
this.options.ordinal,r=this.chart.options.chart.ignoreHiddenSeries;if(l||f){y(this.series,function(e,g){if(!(r&&!1===e.visible||!1===e.takeOrdinalPosition&&!f)&&(b=b.concat(e.processedXData),a=b.length,b.sort(function(g,e){return g-e}),a))for(g=a-1;g--;)b[g]===b[g+1]&&b.splice(g,1)});a=b.length;if(2<a){k=b[1]-b[0];for(e=a-1;e--&&!c;)b[e+1]-b[e]!==k&&(c=!0);!this.options.keepOrdinalPadding&&(b[0]-d>k||E-b[b.length-1]>k)&&(c=!0)}c?(this.ordinalPositions=b,k=this.ordinal2lin(Math.max(d,b[0]),!0),e=Math.max(this.ordinal2lin(Math.min(E,
b[b.length-1]),!0),1),this.ordinalSlope=E=(E-d)/(e-k),this.ordinalOffset=d-k*E):this.ordinalPositions=this.ordinalSlope=this.ordinalOffset=void 0}this.isOrdinal=l&&c;this.groupIntervalFactor=null},val2lin:function(a,b){var c=this.ordinalPositions;if(c){var k=c.length,l,d;for(l=k;l--;)if(c[l]===a){d=l;break}for(l=k-1;l--;)if(a>c[l]||0===l){a=(a-c[l])/(c[l+1]-c[l]);d=l+a;break}b=b?d:this.ordinalSlope*(d||0)+this.ordinalOffset}else b=a;return b},lin2val:function(a,b){var c=this.ordinalPositions;if(c){var k=
this.ordinalSlope,l=this.ordinalOffset,d=c.length-1,q;if(b)0>a?a=c[0]:a>d?a=c[d]:(d=Math.floor(a),q=a-d);else for(;d--;)if(b=k*d+l,a>=b){k=k*(d+1)+l;q=(a-b)/(k-b);break}return void 0!==q&&void 0!==c[d]?c[d]+(q?q*(c[d+1]-c[d]):0):a}return a},getExtendedPositions:function(){var a=this.chart,b=this.series[0].currentDataGrouping,c=this.ordinalIndex,k=b?b.count+b.unitName:"raw",l=this.getExtremes(),d,E;c||(c=this.ordinalIndex={});c[k]||(d={series:[],chart:a,getExtremes:function(){return{min:l.dataMin,
max:l.dataMax}},options:{ordinal:!0},val2lin:p.prototype.val2lin,ordinal2lin:p.prototype.ordinal2lin},y(this.series,function(e){E={xAxis:d,xData:e.xData,chart:a,destroyGroupedData:x};E.options={dataGrouping:b?{enabled:!0,forced:!0,approximation:"open",units:[[b.unitName,[b.count]]]}:{enabled:!1}};e.processData.apply(E);d.series.push(E)}),this.beforeSetTickPositions.apply(d),c[k]=d.ordinalPositions);return c[k]},getGroupIntervalFactor:function(a,b,c){var k;c=c.processedXData;var l=c.length,d=[];k=
this.groupIntervalFactor;if(!k){for(k=0;k<l-1;k++)d[k]=c[k+1]-c[k];d.sort(function(a,e){return a-e});d=d[Math.floor(l/2)];a=Math.max(a,c[0]);b=Math.min(b,c[l-1]);this.groupIntervalFactor=k=l*d/(b-a)}return k},postProcessTickInterval:function(a){var b=this.ordinalSlope;return b?this.options.breaks?this.closestPointRange:a/(b/this.closestPointRange):a}});p.prototype.ordinal2lin=p.prototype.val2lin;a(z.prototype,"pan",function(a,b){var c=this.xAxis[0],k=b.chartX,l=!1;if(c.options.ordinal&&c.series.length){var d=
this.mouseDownX,q=c.getExtremes(),e=q.dataMax,f=q.min,r=q.max,v=this.hoverPoints,g=c.closestPointRange,d=(d-k)/(c.translationSlope*(c.ordinalSlope||g)),h={ordinalPositions:c.getExtendedPositions()},g=c.lin2val,C=c.val2lin,t;h.ordinalPositions?1<Math.abs(d)&&(v&&y(v,function(g){g.setState()}),0>d?(v=h,t=c.ordinalPositions?c:h):(v=c.ordinalPositions?c:h,t=h),h=t.ordinalPositions,e>h[h.length-1]&&h.push(e),this.fixedRange=r-f,d=c.toFixedRange(null,null,g.apply(v,[C.apply(v,[f,!0])+d,!0]),g.apply(t,[C.apply(t,
[r,!0])+d,!0])),d.min>=Math.min(q.dataMin,f)&&d.max<=Math.max(e,r)&&c.setExtremes(d.min,d.max,!0,!1,{trigger:"pan"}),this.mouseDownX=k,D(this.container,{cursor:"move"})):l=!0}else l=!0;l&&a.apply(this,Array.prototype.slice.call(arguments,1))});n.prototype.gappedPath=function(){var a=this.options.gapSize,b=this.points.slice(),c=b.length-1;if(a&&0<c)for(;c--;)b[c+1].x-b[c].x>this.closestPointRange*a&&b.splice(c+1,0,{isNull:!0});return this.getGraphPath(b)}})(J);(function(a){function F(){return Array.prototype.slice.call(arguments,
1)}function p(a){a.apply(this);this.drawBreaks(this.xAxis,["x"]);this.drawBreaks(this.yAxis,z(this.pointArrayMap,["y"]))}var z=a.pick,D=a.wrap,G=a.each,H=a.extend,y=a.isArray,w=a.fireEvent,x=a.Axis,n=a.Series;H(x.prototype,{isInBreak:function(a,q){var b=a.repeat||Infinity,c=a.from,k=a.to-a.from;q=q>=c?(q-c)%b:b-(c-q)%b;return a.inclusive?q<=k:q<k&&0!==q},isInAnyBreak:function(a,q){var b=this.options.breaks,c=b&&b.length,k,l,d;if(c){for(;c--;)this.isInBreak(b[c],a)&&(k=!0,l||(l=z(b[c].showPoints,this.isXAxis?
!1:!0)));d=k&&q?k&&!l:k}return d}});D(x.prototype,"setTickPositions",function(a){a.apply(this,Array.prototype.slice.call(arguments,1));if(this.options.breaks){var q=this.tickPositions,b=this.tickPositions.info,c=[],k;for(k=0;k<q.length;k++)this.isInAnyBreak(q[k])||c.push(q[k]);this.tickPositions=c;this.tickPositions.info=b}});D(x.prototype,"init",function(a,q,b){var c=this;b.breaks&&b.breaks.length&&(b.ordinal=!1);a.call(this,q,b);a=this.options.breaks;c.isBroken=y(a)&&!!a.length;c.isBroken&&(c.val2lin=
function(a){var k=a,b,q;for(q=0;q<c.breakArray.length;q++)if(b=c.breakArray[q],b.to<=a)k-=b.len;else if(b.from>=a)break;else if(c.isInBreak(b,a)){k-=a-b.from;break}return k},c.lin2val=function(a){var b,k;for(k=0;k<c.breakArray.length&&!(b=c.breakArray[k],b.from>=a);k++)b.to<a?a+=b.len:c.isInBreak(b,a)&&(a+=b.len);return a},c.setExtremes=function(a,c,b,q,e){for(;this.isInAnyBreak(a);)a-=this.closestPointRange;for(;this.isInAnyBreak(c);)c-=this.closestPointRange;x.prototype.setExtremes.call(this,a,
c,b,q,e)},c.setAxisTranslation=function(a){x.prototype.setAxisTranslation.call(this,a);var b=c.options.breaks;a=[];var k=[],q=0,e,f,r=c.userMin||c.min,v=c.userMax||c.max,g=z(c.pointRangePadding,0),h,C;for(C in b)f=b[C],e=f.repeat||Infinity,c.isInBreak(f,r)&&(r+=f.to%e-r%e),c.isInBreak(f,v)&&(v-=v%e-f.from%e);for(C in b){f=b[C];h=f.from;for(e=f.repeat||Infinity;h-e>r;)h-=e;for(;h<r;)h+=e;for(;h<v;h+=e)a.push({value:h,move:"in"}),a.push({value:h+(f.to-f.from),move:"out",size:f.breakSize})}a.sort(function(g,
a){return g.value===a.value?("in"===g.move?0:1)-("in"===a.move?0:1):g.value-a.value});b=0;h=r;for(C in a)f=a[C],b+="in"===f.move?1:-1,1===b&&"in"===f.move&&(h=f.value),0===b&&(k.push({from:h,to:f.value,len:f.value-h-(f.size||0)}),q+=f.value-h-(f.size||0));c.breakArray=k;c.unitLength=v-r-q+g;w(c,"afterBreaks");c.transA=c.options.staticScale?c.options.staticScale:(v-c.min+g)/c.unitLength*c.transA;g&&(c.minPixelPadding=c.transA*c.minPointOffset);c.min=r;c.max=v})});D(n.prototype,"generatePoints",function(a){a.apply(this,
F(arguments));var q=this.xAxis,b=this.yAxis,c=this.points,k,l=c.length,d=this.options.connectNulls,n;if(q&&b&&(q.options.breaks||b.options.breaks))for(;l--;)k=c[l],n=null===k.y&&!1===d,n||!q.isInAnyBreak(k.x,!0)&&!b.isInAnyBreak(k.y,!0)||(c.splice(l,1),this.data[l]&&this.data[l].destroyElements())});a.Series.prototype.drawBreaks=function(a,q){var b=this,c=b.points,k,l,d,n;a&&G(q,function(e){k=a.breakArray||[];l=a.isXAxis?a.min:z(b.options.threshold,a.min);G(c,function(f){n=z(f["stack"+e.toUpperCase()],
f[e]);G(k,function(e){d=!1;if(l<e.from&&n>e.to||l>e.from&&n<e.from)d="pointBreak";else if(l<e.from&&n>e.from&&n<e.to||l>e.from&&n>e.to&&n<e.from)d="pointInBreak";d&&w(a,d,{point:f,brk:e})})})})};D(a.seriesTypes.column.prototype,"drawPoints",p);D(a.Series.prototype,"drawPoints",p)})(J);(function(a){var F=a.arrayMax,p=a.arrayMin,z=a.Axis,D=a.defaultPlotOptions,G=a.defined,H=a.each,y=a.extend,w=a.format,x=a.isNumber,n=a.merge,I=a.pick,q=a.Point,b=a.Tooltip,c=a.wrap,k=a.Series.prototype,l=k.processData,
d=k.generatePoints,E=k.destroy,e={approximation:"average",groupPixelWidth:2,dateTimeLabelFormats:{millisecond:["%A, %b %e, %H:%M:%S.%L","%A, %b %e, %H:%M:%S.%L","-%H:%M:%S.%L"],second:["%A, %b %e, %H:%M:%S","%A, %b %e, %H:%M:%S","-%H:%M:%S"],minute:["%A, %b %e, %H:%M","%A, %b %e, %H:%M","-%H:%M"],hour:["%A, %b %e, %H:%M","%A, %b %e, %H:%M","-%H:%M"],day:["%A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],week:["Week from %A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],month:["%B %Y","%B","-%B %Y"],year:["%Y",
"%Y","-%Y"]}},f={line:{},spline:{},area:{},areaspline:{},column:{approximation:"sum",groupPixelWidth:10},arearange:{approximation:"range"},areasplinerange:{approximation:"range"},columnrange:{approximation:"range",groupPixelWidth:10},candlestick:{approximation:"ohlc",groupPixelWidth:10},ohlc:{approximation:"ohlc",groupPixelWidth:5}},r=a.defaultDataGroupingUnits=[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",
[1]],["week",[1]],["month",[1,3,6]],["year",null]],v={sum:function(a){var g=a.length,e;if(!g&&a.hasNulls)e=null;else if(g)for(e=0;g--;)e+=a[g];return e},average:function(a){var g=a.length;a=v.sum(a);x(a)&&g&&(a/=g);return a},open:function(a){return a.length?a[0]:a.hasNulls?null:void 0},high:function(a){return a.length?F(a):a.hasNulls?null:void 0},low:function(a){return a.length?p(a):a.hasNulls?null:void 0},close:function(a){return a.length?a[a.length-1]:a.hasNulls?null:void 0},ohlc:function(a,e,f,
t){a=v.open(a);e=v.high(e);f=v.low(f);t=v.close(t);if(x(a)||x(e)||x(f)||x(t))return[a,e,f,t]},range:function(a,e){a=v.low(a);e=v.high(e);if(x(a)||x(e))return[a,e]}};k.groupData=function(a,e,f,t){var g=this.data,m=this.options.data,u=[],B=[],h=[],c=a.length,b,C,k=!!e,r=[[],[],[],[]];t="function"===typeof t?t:v[t];var q=this.pointArrayMap,l=q&&q.length,d,n=0;for(d=C=0;d<=c&&!(a[d]>=f[0]);d++);for(d;d<=c;d++){for(;(void 0!==f[n+1]&&a[d]>=f[n+1]||d===c)&&(b=f[n],this.dataGroupInfo={start:C,length:r[0].length},
C=t.apply(this,r),void 0!==C&&(u.push(b),B.push(C),h.push(this.dataGroupInfo)),C=d,r[0]=[],r[1]=[],r[2]=[],r[3]=[],n+=1,d!==c););if(d===c)break;if(q){b=this.cropStart+d;b=g&&g[b]||this.pointClass.prototype.applyOptions.apply({series:this},[m[b]]);var w,p;for(w=0;w<l;w++)p=b[q[w]],x(p)?r[w].push(p):null===p&&(r[w].hasNulls=!0)}else b=k?e[d]:null,x(b)?r[0].push(b):null===b&&(r[0].hasNulls=!0)}return[u,B,h]};k.processData=function(){var a=this.chart,e=this.options.dataGrouping,f=!1!==this.allowDG&&e&&
I(e.enabled,a.options.isStock),c=this.visible||!a.options.chart.ignoreHiddenSeries,b;this.forceCrop=f;this.groupPixelWidth=null;this.hasProcessed=!0;if(!1!==l.apply(this,arguments)&&f){this.destroyGroupedData();var m=this.processedXData,u=this.processedYData,B=a.plotSizeX,a=this.xAxis,L=a.options.ordinal,K=this.groupPixelWidth=a.getGroupPixelWidth&&a.getGroupPixelWidth();if(K){this.isDirty=b=!0;var d=a.getExtremes(),f=d.min,d=d.max,L=L&&a.getGroupIntervalFactor(f,d,this)||1,B=K*(d-f)/B*L,K=a.getTimeTicks(a.normalizeTimeTickInterval(B,
e.units||r),Math.min(f,m[0]),Math.max(d,m[m.length-1]),a.options.startOfWeek,m,this.closestPointRange),m=k.groupData.apply(this,[m,u,K,e.approximation]),u=m[0],L=m[1];if(e.smoothed){e=u.length-1;for(u[e]=Math.min(u[e],d);e--&&0<e;)u[e]+=B/2;u[0]=Math.max(u[0],f)}this.currentDataGrouping=K.info;this.closestPointRange=K.info.totalRange;this.groupMap=m[2];G(u[0])&&u[0]<a.dataMin&&c&&(a.min===a.dataMin&&(a.min=u[0]),a.dataMin=u[0]);this.processedXData=u;this.processedYData=L}else this.currentDataGrouping=
this.groupMap=null;this.hasGroupedData=b}};k.destroyGroupedData=function(){var a=this.groupedData;H(a||[],function(e,g){e&&(a[g]=e.destroy?e.destroy():null)});this.groupedData=null};k.generatePoints=function(){d.apply(this);this.destroyGroupedData();this.groupedData=this.hasGroupedData?this.points:null};c(q.prototype,"update",function(e){this.dataGroup?a.error(24):e.apply(this,[].slice.call(arguments,1))});c(b.prototype,"tooltipFooterHeaderFormatter",function(e,f,c){var g=f.series,b=g.tooltipOptions,
m=g.options.dataGrouping,u=b.xDateFormat,B,h=g.xAxis,C=a.dateFormat;return h&&"datetime"===h.options.type&&m&&x(f.key)?(e=g.currentDataGrouping,m=m.dateTimeLabelFormats,e?(h=m[e.unitName],1===e.count?u=h[0]:(u=h[1],B=h[2])):!u&&m&&(u=this.getXDateFormat(f,b,h)),u=C(u,f.key),B&&(u+=C(B,f.key+e.totalRange-1)),w(b[(c?"footer":"header")+"Format"],{point:y(f.point,{key:u}),series:g})):e.call(this,f,c)});k.destroy=function(){for(var a=this.groupedData||[],e=a.length;e--;)a[e]&&a[e].destroy();E.apply(this)};
c(k,"setOptions",function(a,c){a=a.call(this,c);var g=this.type,b=this.chart.options.plotOptions,h=D[g].dataGrouping;f[g]&&(h||(h=n(e,f[g])),a.dataGrouping=n(h,b.series&&b.series.dataGrouping,b[g].dataGrouping,c.dataGrouping));this.chart.options.isStock&&(this.requireSorting=!0);return a});c(z.prototype,"setScale",function(a){a.call(this);H(this.series,function(a){a.hasProcessed=!1})});z.prototype.getGroupPixelWidth=function(){var a=this.series,e=a.length,f,c=0,b=!1,m;for(f=e;f--;)(m=a[f].options.dataGrouping)&&
(c=Math.max(c,m.groupPixelWidth));for(f=e;f--;)(m=a[f].options.dataGrouping)&&a[f].hasProcessed&&(e=(a[f].processedXData||a[f].data).length,a[f].groupPixelWidth||e>this.chart.plotSizeX/c||e&&m.forced)&&(b=!0);return b?c:0};z.prototype.setDataGrouping=function(a,e){var f;e=I(e,!0);a||(a={forced:!1,units:null});if(this instanceof z)for(f=this.series.length;f--;)this.series[f].update({dataGrouping:a},!1);else H(this.chart.options.series,function(e){e.dataGrouping=a},!1);e&&this.chart.redraw()}})(J);
(function(a){var F=a.each,p=a.Point,z=a.seriesType,D=a.seriesTypes;z("ohlc","column",{lineWidth:1,tooltip:{pointFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e \x3cb\x3e {series.name}\x3c/b\x3e\x3cbr/\x3eOpen: {point.open}\x3cbr/\x3eHigh: {point.high}\x3cbr/\x3eLow: {point.low}\x3cbr/\x3eClose: {point.close}\x3cbr/\x3e'},threshold:null,states:{hover:{lineWidth:3}},stickyTracking:!0},{directTouch:!1,pointArrayMap:["open","high","low","close"],toYData:function(a){return[a.open,
a.high,a.low,a.close]},pointValKey:"high",pointAttrToOptions:{stroke:"color","stroke-width":"lineWidth"},pointAttribs:function(a,p){p=D.column.prototype.pointAttribs.call(this,a,p);var y=this.options;delete p.fill;!a.options.color&&y.upColor&&a.open<a.close&&(p.stroke=y.upColor);return p},translate:function(){var a=this,p=a.yAxis,y=!!a.modifyValue,w=["plotOpen","plotHigh","plotLow","plotClose","yBottom"];D.column.prototype.translate.apply(a);F(a.points,function(x){F([x.open,x.high,x.low,x.close,x.low],
function(n,H){null!==n&&(y&&(n=a.modifyValue(n)),x[w[H]]=p.toPixels(n,!0))})})},drawPoints:function(){var a=this,p=a.chart;F(a.points,function(y){var w,x,n,H,q=y.graphic,b,c=!q;void 0!==y.plotY&&(q||(y.graphic=q=p.renderer.path().add(a.group)),q.attr(a.pointAttribs(y,y.selected&&"select")),x=q.strokeWidth()%2/2,b=Math.round(y.plotX)-x,n=Math.round(y.shapeArgs.width/2),H=["M",b,Math.round(y.yBottom),"L",b,Math.round(y.plotY)],null!==y.open&&(w=Math.round(y.plotOpen)+x,H.push("M",b,w,"L",b-n,w)),null!==
y.close&&(w=Math.round(y.plotClose)+x,H.push("M",b,w,"L",b+n,w)),q[c?"attr":"animate"]({d:H}).addClass(y.getClassName(),!0))})},animate:null},{getClassName:function(){return p.prototype.getClassName.call(this)+(this.open<this.close?" highcharts-point-up":" highcharts-point-down")}})})(J);(function(a){var F=a.defaultPlotOptions,p=a.each,z=a.merge,D=a.seriesType,G=a.seriesTypes;D("candlestick","ohlc",z(F.column,{states:{hover:{lineWidth:2}},tooltip:F.ohlc.tooltip,threshold:null,lineColor:"#000000",
lineWidth:1,upColor:"#ffffff",stickyTracking:!0}),{pointAttribs:function(a,p){var w=G.column.prototype.pointAttribs.call(this,a,p),x=this.options,n=a.open<a.close,y=x.lineColor||this.color;w["stroke-width"]=x.lineWidth;w.fill=a.options.color||(n?x.upColor||this.color:this.color);w.stroke=a.lineColor||(n?x.upLineColor||y:y);p&&(a=x.states[p],w.fill=a.color||w.fill,w.stroke=a.lineColor||w.stroke,w["stroke-width"]=a.lineWidth||w["stroke-width"]);return w},drawPoints:function(){var a=this,y=a.chart;p(a.points,
function(p){var x=p.graphic,n,w,q,b,c,k,l,d=!x;void 0!==p.plotY&&(x||(p.graphic=x=y.renderer.path().add(a.group)),x.attr(a.pointAttribs(p,p.selected&&"select")).shadow(a.options.shadow),c=x.strokeWidth()%2/2,k=Math.round(p.plotX)-c,n=p.plotOpen,w=p.plotClose,q=Math.min(n,w),n=Math.max(n,w),l=Math.round(p.shapeArgs.width/2),w=Math.round(q)!==Math.round(p.plotY),b=n!==p.yBottom,q=Math.round(q)+c,n=Math.round(n)+c,c=[],c.push("M",k-l,n,"L",k-l,q,"L",k+l,q,"L",k+l,n,"Z","M",k,q,"L",k,w?Math.round(p.plotY):
q,"M",k,n,"L",k,b?Math.round(p.yBottom):n),x[d?"attr":"animate"]({d:c}).addClass(p.getClassName(),!0))})}})})(J);(function(a){var F=a.addEvent,p=a.each,z=a.merge,D=a.noop,G=a.Renderer,H=a.seriesType,y=a.seriesTypes,w=a.TrackerMixin,x=a.VMLRenderer,n=a.SVGRenderer.prototype.symbols,I=a.stableSort;H("flags","column",{pointRange:0,shape:"flag",stackDistance:12,textAlign:"center",tooltip:{pointFormat:"{point.text}\x3cbr/\x3e"},threshold:null,y:-30,fillColor:"#ffffff",lineWidth:1,states:{hover:{lineColor:"#000000",
fillColor:"#ccd6eb"}},style:{fontSize:"11px",fontWeight:"bold"}},{sorted:!1,noSharedTooltip:!0,allowDG:!1,takeOrdinalPosition:!1,trackerGroups:["markerGroup"],forceCrop:!0,init:a.Series.prototype.init,pointAttribs:function(a,b){var c=this.options,k=a&&a.color||this.color,l=c.lineColor,d=a&&a.lineWidth;a=a&&a.fillColor||c.fillColor;b&&(a=c.states[b].fillColor,l=c.states[b].lineColor,d=c.states[b].lineWidth);return{fill:a||k,stroke:l||k,"stroke-width":d||c.lineWidth||0}},translate:function(){y.column.prototype.translate.apply(this);
var a=this.options,b=this.chart,c=this.points,k=c.length-1,l,d,n=a.onSeries;l=n&&b.get(n);var a=a.onKey||"y",n=l&&l.options.step,e=l&&l.points,f=e&&e.length,r=this.xAxis,v=this.yAxis,g=r.getExtremes(),h=0,C,t,A;if(l&&l.visible&&f)for(h=(l.pointXOffset||0)+(l.barW||0)/2,l=l.currentDataGrouping,t=e[f-1].x+(l?l.totalRange:0),I(c,function(a,e){return a.x-e.x}),a="plot"+a[0].toUpperCase()+a.substr(1);f--&&c[k]&&!(l=c[k],C=e[f],C.x<=l.x&&void 0!==C[a]&&(l.x<=t&&(l.plotY=C[a],C.x<l.x&&!n&&(A=e[f+1])&&void 0!==
A[a]&&(l.plotY+=(l.x-C.x)/(A.x-C.x)*(A[a]-C[a]))),k--,f++,0>k)););p(c,function(a,e){var m;void 0===a.plotY&&(a.x>=g.min&&a.x<=g.max?a.plotY=b.chartHeight-r.bottom-(r.opposite?r.height:0)+r.offset-v.top:a.shapeArgs={});a.plotX+=h;(d=c[e-1])&&d.plotX===a.plotX&&(void 0===d.stackIndex&&(d.stackIndex=0),m=d.stackIndex+1);a.stackIndex=m})},drawPoints:function(){var q=this.points,b=this.chart,c=b.renderer,k,l,d=this.options,n=d.y,e,f,r,v,g,h,C,t=this.yAxis;for(f=q.length;f--;)r=q[f],C=r.plotX>this.xAxis.len,
k=r.plotX,v=r.stackIndex,e=r.options.shape||d.shape,l=r.plotY,void 0!==l&&(l=r.plotY+n-(void 0!==v&&v*d.stackDistance)),g=v?void 0:r.plotX,h=v?void 0:r.plotY,v=r.graphic,void 0!==l&&0<=k&&!C?(v||(v=r.graphic=c.label("",null,null,e,null,null,d.useHTML).attr(this.pointAttribs(r)).css(z(d.style,r.style)).attr({align:"flag"===e?"left":"center",width:d.width,height:d.height,"text-align":d.textAlign}).addClass("highcharts-point").add(this.markerGroup),r.graphic.div&&(r.graphic.div.point=r),v.shadow(d.shadow)),
0<k&&(k-=v.strokeWidth()%2),v.attr({text:r.options.title||d.title||"A",x:k,y:l,anchorX:g,anchorY:h}),r.tooltipPos=b.inverted?[t.len+t.pos-b.plotLeft-l,this.xAxis.len-k]:[k,l+t.pos-b.plotTop]):v&&(r.graphic=v.destroy());d.useHTML&&a.wrap(this.markerGroup,"on",function(e){return a.SVGElement.prototype.on.apply(e.apply(this,[].slice.call(arguments,1)),[].slice.call(arguments,1))})},drawTracker:function(){var a=this.points;w.drawTrackerPoint.apply(this);p(a,function(b){var c=b.graphic;c&&F(c.element,
"mouseover",function(){0<b.stackIndex&&!b.raised&&(b._y=c.y,c.attr({y:b._y-8}),b.raised=!0);p(a,function(a){a!==b&&a.raised&&a.graphic&&(a.graphic.attr({y:a._y}),a.raised=!1)})})})},animate:D,buildKDTree:D,setClip:D});n.flag=function(a,b,c,k,l){return["M",l&&l.anchorX||a,l&&l.anchorY||b,"L",a,b+k,a,b,a+c,b,a+c,b+k,a,b+k,"Z"]};p(["circle","square"],function(a){n[a+"pin"]=function(b,c,k,l,d){var q=d&&d.anchorX;d=d&&d.anchorY;"circle"===a&&l>k&&(b-=Math.round((l-k)/2),k=l);b=n[a](b,c,k,l);q&&d&&b.push("M",
q,c>d?c:c+l,"L",q,d);return b}});G===x&&p(["flag","circlepin","squarepin"],function(a){x.prototype.symbols[a]=n[a]})})(J);(function(a){function F(a,f,c){this.init(a,f,c)}var p=a.addEvent,z=a.Axis,D=a.correctFloat,G=a.defaultOptions,H=a.defined,y=a.destroyObjectProperties,w=a.doc,x=a.each,n=a.fireEvent,I=a.hasTouch,q=a.isTouchDevice,b=a.merge,c=a.pick,k=a.removeEvent,l=a.wrap,d,E={height:q?20:14,barBorderRadius:0,buttonBorderRadius:0,liveRedraw:a.svg&&!q,margin:10,minWidth:6,step:.2,zIndex:3,barBackgroundColor:"#cccccc",
barBorderWidth:1,barBorderColor:"#cccccc",buttonArrowColor:"#333333",buttonBackgroundColor:"#e6e6e6",buttonBorderColor:"#cccccc",buttonBorderWidth:1,rifleColor:"#333333",trackBackgroundColor:"#f2f2f2",trackBorderColor:"#f2f2f2",trackBorderWidth:1};G.scrollbar=b(!0,E,G.scrollbar);a.swapXY=d=function(a,f){var e=a.length,c;if(f)for(f=0;f<e;f+=3)c=a[f+1],a[f+1]=a[f+2],a[f+2]=c;return a};F.prototype={init:function(a,f,d){this.scrollbarButtons=[];this.renderer=a;this.userOptions=f;this.options=b(E,f);this.chart=
d;this.size=c(this.options.size,this.options.height);f.enabled&&(this.render(),this.initEvents(),this.addEvents())},render:function(){var a=this.renderer,f=this.options,c=this.size,b;this.group=b=a.g("scrollbar").attr({zIndex:f.zIndex,translateY:-99999}).add();this.track=a.rect().addClass("highcharts-scrollbar-track").attr({x:0,r:f.trackBorderRadius||0,height:c,width:c}).add(b);this.track.attr({fill:f.trackBackgroundColor,stroke:f.trackBorderColor,"stroke-width":f.trackBorderWidth});this.trackBorderWidth=
this.track.strokeWidth();this.track.attr({y:-this.trackBorderWidth%2/2});this.scrollbarGroup=a.g().add(b);this.scrollbar=a.rect().addClass("highcharts-scrollbar-thumb").attr({height:c,width:c,r:f.barBorderRadius||0}).add(this.scrollbarGroup);this.scrollbarRifles=a.path(d(["M",-3,c/4,"L",-3,2*c/3,"M",0,c/4,"L",0,2*c/3,"M",3,c/4,"L",3,2*c/3],f.vertical)).addClass("highcharts-scrollbar-rifles").add(this.scrollbarGroup);this.scrollbar.attr({fill:f.barBackgroundColor,stroke:f.barBorderColor,"stroke-width":f.barBorderWidth});
this.scrollbarRifles.attr({stroke:f.rifleColor,"stroke-width":1});this.scrollbarStrokeWidth=this.scrollbar.strokeWidth();this.scrollbarGroup.translate(-this.scrollbarStrokeWidth%2/2,-this.scrollbarStrokeWidth%2/2);this.drawScrollbarButton(0);this.drawScrollbarButton(1)},position:function(a,f,c,b){var e=this.options.vertical,h=0,d=this.rendered?"animate":"attr";this.x=a;this.y=f+this.trackBorderWidth;this.width=c;this.xOffset=this.height=b;this.yOffset=h;e?(this.width=this.yOffset=c=h=this.size,this.xOffset=
f=0,this.barWidth=b-2*c,this.x=a+=this.options.margin):(this.height=this.xOffset=b=f=this.size,this.barWidth=c-2*b,this.y+=this.options.margin);this.group[d]({translateX:a,translateY:this.y});this.track[d]({width:c,height:b});this.scrollbarButtons[1][d]({translateX:e?0:c-f,translateY:e?b-h:0})},drawScrollbarButton:function(a){var e=this.renderer,c=this.scrollbarButtons,b=this.options,g=this.size,h;h=e.g().add(this.group);c.push(h);h=e.rect().addClass("highcharts-scrollbar-button").add(h);h.attr({stroke:b.buttonBorderColor,
"stroke-width":b.buttonBorderWidth,fill:b.buttonBackgroundColor});h.attr(h.crisp({x:-.5,y:-.5,width:g+1,height:g+1,r:b.buttonBorderRadius},h.strokeWidth()));h=e.path(d(["M",g/2+(a?-1:1),g/2-3,"L",g/2+(a?-1:1),g/2+3,"L",g/2+(a?2:-2),g/2],b.vertical)).addClass("highcharts-scrollbar-arrow").add(c[a]);h.attr({fill:b.buttonArrowColor})},setRange:function(a,f){var e=this.options,c=e.vertical,b=e.minWidth,h=this.barWidth,d,t,A=this.rendered&&!this.hasDragged?"animate":"attr";H(h)&&(a=Math.max(a,0),d=Math.ceil(h*
a),this.calculatedWidth=t=D(h*Math.min(f,1)-d),t<b&&(d=(h-b+t)*a,t=b),b=Math.floor(d+this.xOffset+this.yOffset),h=t/2-.5,this.from=a,this.to=f,c?(this.scrollbarGroup[A]({translateY:b}),this.scrollbar[A]({height:t}),this.scrollbarRifles[A]({translateY:h}),this.scrollbarTop=b,this.scrollbarLeft=0):(this.scrollbarGroup[A]({translateX:b}),this.scrollbar[A]({width:t}),this.scrollbarRifles[A]({translateX:h}),this.scrollbarLeft=b,this.scrollbarTop=0),12>=t?this.scrollbarRifles.hide():this.scrollbarRifles.show(!0),
!1===e.showFull&&(0>=a&&1<=f?this.group.hide():this.group.show()),this.rendered=!0)},initEvents:function(){var a=this;a.mouseMoveHandler=function(c){var f=a.chart.pointer.normalize(c),b=a.options.vertical?"chartY":"chartX",e=a.initPositions;!a.grabbedCenter||c.touches&&0===c.touches[0][b]||(f=a.cursorToScrollbarPosition(f)[b],b=a[b],b=f-b,a.hasDragged=!0,a.updatePosition(e[0]+b,e[1]+b),a.hasDragged&&n(a,"changed",{from:a.from,to:a.to,trigger:"scrollbar",DOMType:c.type,DOMEvent:c}))};a.mouseUpHandler=
function(c){a.hasDragged&&n(a,"changed",{from:a.from,to:a.to,trigger:"scrollbar",DOMType:c.type,DOMEvent:c});a.grabbedCenter=a.hasDragged=a.chartX=a.chartY=null};a.mouseDownHandler=function(c){c=a.chart.pointer.normalize(c);c=a.cursorToScrollbarPosition(c);a.chartX=c.chartX;a.chartY=c.chartY;a.initPositions=[a.from,a.to];a.grabbedCenter=!0};a.buttonToMinClick=function(c){var b=D(a.to-a.from)*a.options.step;a.updatePosition(D(a.from-b),D(a.to-b));n(a,"changed",{from:a.from,to:a.to,trigger:"scrollbar",
DOMEvent:c})};a.buttonToMaxClick=function(c){var b=(a.to-a.from)*a.options.step;a.updatePosition(a.from+b,a.to+b);n(a,"changed",{from:a.from,to:a.to,trigger:"scrollbar",DOMEvent:c})};a.trackClick=function(c){var b=a.chart.pointer.normalize(c),e=a.to-a.from,f=a.y+a.scrollbarTop,h=a.x+a.scrollbarLeft;a.options.vertical&&b.chartY>f||!a.options.vertical&&b.chartX>h?a.updatePosition(a.from+e,a.to+e):a.updatePosition(a.from-e,a.to-e);n(a,"changed",{from:a.from,to:a.to,trigger:"scrollbar",DOMEvent:c})}},
cursorToScrollbarPosition:function(a){var c=this.options,c=c.minWidth>this.calculatedWidth?c.minWidth:0;return{chartX:(a.chartX-this.x-this.xOffset)/(this.barWidth-c),chartY:(a.chartY-this.y-this.yOffset)/(this.barWidth-c)}},updatePosition:function(a,c){1<c&&(a=D(1-D(c-a)),c=1);0>a&&(c=D(c-a),a=0);this.from=a;this.to=c},update:function(a){this.destroy();this.init(this.chart.renderer,b(!0,this.options,a),this.chart)},addEvents:function(){var a=this.options.inverted?[1,0]:[0,1],c=this.scrollbarButtons,
b=this.scrollbarGroup.element,d=this.mouseDownHandler,g=this.mouseMoveHandler,h=this.mouseUpHandler,a=[[c[a[0]].element,"click",this.buttonToMinClick],[c[a[1]].element,"click",this.buttonToMaxClick],[this.track.element,"click",this.trackClick],[b,"mousedown",d],[w,"mousemove",g],[w,"mouseup",h]];I&&a.push([b,"touchstart",d],[w,"touchmove",g],[w,"touchend",h]);x(a,function(a){p.apply(null,a)});this._events=a},removeEvents:function(){x(this._events,function(a){k.apply(null,a)});this._events=void 0},
destroy:function(){var a=this.chart.scroller;this.removeEvents();x(["track","scrollbarRifles","scrollbar","scrollbarGroup","group"],function(a){this[a]&&this[a].destroy&&(this[a]=this[a].destroy())},this);a&&this===a.scrollbar&&(a.scrollbar=null,y(a.scrollbarButtons))}};l(z.prototype,"init",function(a){var b=this;a.apply(b,Array.prototype.slice.call(arguments,1));b.options.scrollbar&&b.options.scrollbar.enabled&&(b.options.scrollbar.vertical=!b.horiz,b.options.startOnTick=b.options.endOnTick=!1,b.scrollbar=
new F(b.chart.renderer,b.options.scrollbar,b.chart),p(b.scrollbar,"changed",function(a){var e=Math.min(c(b.options.min,b.min),b.min,b.dataMin),g=Math.max(c(b.options.max,b.max),b.max,b.dataMax)-e,h;b.horiz&&!b.reversed||!b.horiz&&b.reversed?(h=e+g*this.to,e+=g*this.from):(h=e+g*(1-this.from),e+=g*(1-this.to));b.setExtremes(e,h,!0,!1,a)}))});l(z.prototype,"render",function(a){var b=Math.min(c(this.options.min,this.min),this.min,this.dataMin),e=Math.max(c(this.options.max,this.max),this.max,this.dataMax),
d=this.scrollbar,g;a.apply(this,Array.prototype.slice.call(arguments,1));if(d){this.horiz?(d.position(this.left,this.top+this.height+2+this.chart.scrollbarsOffsets[1]+(this.opposite?0:this.axisTitleMargin+this.offset),this.width,this.height),g=1):(d.position(this.left+this.width+2+this.chart.scrollbarsOffsets[0]+(this.opposite?this.axisTitleMargin+this.offset:0),this.top,this.width,this.height),g=0);if(!this.opposite&&!this.horiz||this.opposite&&this.horiz)this.chart.scrollbarsOffsets[g]+=this.scrollbar.size+
this.scrollbar.options.margin;isNaN(b)||isNaN(e)||!H(this.min)||!H(this.max)?d.setRange(0,0):(g=(this.min-b)/(e-b),b=(this.max-b)/(e-b),this.horiz&&!this.reversed||!this.horiz&&this.reversed?d.setRange(g,b):d.setRange(1-b,1-g))}});l(z.prototype,"getOffset",function(a){var b=this.horiz?2:1,c=this.scrollbar;a.apply(this,Array.prototype.slice.call(arguments,1));c&&(this.chart.scrollbarsOffsets=[0,0],this.chart.axisOffset[b]+=c.size+c.options.margin)});l(z.prototype,"destroy",function(a){this.scrollbar&&
(this.scrollbar=this.scrollbar.destroy());a.apply(this,Array.prototype.slice.call(arguments,1))});a.Scrollbar=F})(J);(function(a){function F(a){this.init(a)}var p=a.addEvent,z=a.Axis,D=a.Chart,G=a.color,H=a.defaultOptions,y=a.defined,w=a.destroyObjectProperties,x=a.doc,n=a.each,I=a.erase,q=a.error,b=a.extend,c=a.grep,k=a.hasTouch,l=a.isNumber,d=a.isObject,E=a.merge,e=a.pick,f=a.removeEvent,r=a.Scrollbar,v=a.Series,g=a.seriesTypes,h=a.wrap,C=a.swapXY,t=[].concat(a.defaultDataGroupingUnits),A=function(a){var m=
c(arguments,l);if(m.length)return Math[a].apply(0,m)};t[4]=["day",[1,2,3,4]];t[5]=["week",[1,2,3]];g=void 0===g.areaspline?"line":"areaspline";b(H,{navigator:{height:40,margin:25,maskInside:!0,handles:{backgroundColor:"#f2f2f2",borderColor:"#999999"},maskFill:G("#6685c2").setOpacity(.3).get(),outlineColor:"#cccccc",outlineWidth:1,series:{type:g,color:"#335cad",fillOpacity:.05,lineWidth:1,compare:null,dataGrouping:{approximation:"average",enabled:!0,groupPixelWidth:2,smoothed:!0,units:t},dataLabels:{enabled:!1,
zIndex:2},id:"highcharts-navigator-series",className:"highcharts-navigator-series",lineColor:null,marker:{enabled:!1},pointRange:0,shadow:!1,threshold:null},xAxis:{className:"highcharts-navigator-xaxis",tickLength:0,lineWidth:0,gridLineColor:"#e6e6e6",gridLineWidth:1,tickPixelInterval:200,labels:{align:"left",style:{color:"#999999"},x:3,y:-4},crosshair:!1},yAxis:{className:"highcharts-navigator-yaxis",gridLineWidth:0,startOnTick:!1,endOnTick:!1,minPadding:.1,maxPadding:.1,labels:{enabled:!1},crosshair:!1,
title:{text:null},tickLength:0,tickWidth:0}}});F.prototype={drawHandle:function(a,b,c,e){this.handles[b][e](c?{translateX:Math.round(this.left+this.height/2-8),translateY:Math.round(this.top+parseInt(a,10)+.5)}:{translateX:Math.round(this.left+parseInt(a,10)),translateY:Math.round(this.top+this.height/2-8)})},getHandlePath:function(a){return C(["M",-4.5,.5,"L",3.5,.5,"L",3.5,15.5,"L",-4.5,15.5,"L",-4.5,.5,"M",-1.5,4,"L",-1.5,12,"M",.5,4,"L",.5,12],a)},drawOutline:function(a,b,c,e){var m=this.navigatorOptions.maskInside,
u=this.outline.strokeWidth(),B=u/2,u=u%2/2,g=this.outlineHeight,h=this.scrollbarHeight,t=this.size,d=this.left-h,f=this.top;c?(d-=B,c=f+b+u,b=f+a+u,a=["M",d+g,f-h-u,"L",d+g,c,"L",d,c,"L",d,b,"L",d+g,b,"L",d+g,f+t+h].concat(m?["M",d+g,c-B,"L",d+g,b+B]:[])):(a+=d+h-u,b+=d+h-u,f+=B,a=["M",d,f,"L",a,f,"L",a,f+g,"L",b,f+g,"L",b,f,"L",d+t+2*h,f].concat(m?["M",a-B,f,"L",b+B,f]:[]));this.outline[e]({d:a})},drawMasks:function(a,b,c,e){var m=this.left,u=this.top,B=this.height,g,d,h,t;c?(h=[m,m,m],t=[u,u+a,
u+b],d=[B,B,B],g=[a,b-a,this.size-b]):(h=[m,m+a,m+b],t=[u,u,u],d=[a,b-a,this.size-b],g=[B,B,B]);n(this.shades,function(a,b){a[e]({x:h[b],y:t[b],width:d[b],height:g[b]})})},renderElements:function(){var a=this,b=a.navigatorOptions,c=b.maskInside,e=a.chart,g=e.inverted,d=e.renderer,h;a.navigatorGroup=h=d.g("navigator").attr({zIndex:8,visibility:"hidden"}).add();var t={cursor:g?"ns-resize":"ew-resize"};n([!c,c,!c],function(m,c){a.shades[c]=d.rect().addClass("highcharts-navigator-mask"+(1===c?"-inside":
"-outside")).attr({fill:m?b.maskFill:"transparent"}).css(1===c&&t).add(h)});a.outline=d.path().addClass("highcharts-navigator-outline").attr({"stroke-width":b.outlineWidth,stroke:b.outlineColor}).add(h);n([0,1],function(m){a.handles[m]=d.path(a.getHandlePath(g)).attr({zIndex:7-m}).addClass("highcharts-navigator-handle highcharts-navigator-handle-"+["left","right"][m]).add(h);var c=b.handles;a.handles[m].attr({fill:c.backgroundColor,stroke:c.borderColor,"stroke-width":1}).css(t)})},update:function(a){this.destroy();
E(!0,this.chart.options.navigator,this.options,a);this.init(this.chart)},render:function(a,b,c,g){var m=this.chart,u,d,h=this.scrollbarHeight,B,t=this.xAxis;u=this.navigatorEnabled;var f,A=this.rendered;d=m.inverted;var k=m.xAxis[0].minRange;if(!this.hasDragged||y(c)){if(!l(a)||!l(b))if(A)c=0,g=t.width;else return;this.left=e(t.left,m.plotLeft+h+(d?m.plotWidth:0));this.size=f=B=e(t.len,(d?m.plotHeight:m.plotWidth)-2*h);m=d?h:B+2*h;c=e(c,t.toPixels(a,!0));g=e(g,t.toPixels(b,!0));l(c)&&Infinity!==Math.abs(c)||
(c=0,g=m);a=t.toValue(c,!0);b=t.toValue(g,!0);if(Math.abs(b-a)<k)if(this.grabbedLeft)c=t.toPixels(b-k,!0);else if(this.grabbedRight)g=t.toPixels(a+k,!0);else return;this.zoomedMax=Math.min(Math.max(c,g,0),f);this.zoomedMin=Math.min(Math.max(this.fixedWidth?this.zoomedMax-this.fixedWidth:Math.min(c,g),0),f);this.range=this.zoomedMax-this.zoomedMin;f=Math.round(this.zoomedMax);c=Math.round(this.zoomedMin);u&&(this.navigatorGroup.attr({visibility:"visible"}),A=A&&!this.hasDragged?"animate":"attr",this.drawMasks(c,
f,d,A),this.drawOutline(c,f,d,A),this.drawHandle(c,0,d,A),this.drawHandle(f,1,d,A));this.scrollbar&&(d?(d=this.top-h,u=this.left-h+(u?0:this.height),h=B+2*h):(d=this.top+(u?this.height:-h),u=this.left-h),this.scrollbar.position(u,d,m,h),this.scrollbar.setRange(this.zoomedMin/B,this.zoomedMax/B));this.rendered=!0}},addMouseEvents:function(){var a=this,b=a.chart,c=b.container,e=[],g,d;a.mouseMoveHandler=g=function(b){a.onMouseMove(b)};a.mouseUpHandler=d=function(b){a.onMouseUp(b)};e=a.getPartsEvents("mousedown");
e.push(p(c,"mousemove",g),p(x,"mouseup",d));k&&(e.push(p(c,"touchmove",g),p(x,"touchend",d)),e.concat(a.getPartsEvents("touchstart")));a.eventsToUnbind=e;a.series&&a.series[0]&&e.push(p(a.series[0].xAxis,"foundExtremes",function(){b.navigator.modifyNavigatorAxisExtremes()}))},getPartsEvents:function(a){var b=this,c=[];n(["shades","handles"],function(m){n(b[m],function(u,e){c.push(p(u.element,a,function(a){b[m+"Mousedown"](a,e)}))})});return c},shadesMousedown:function(a,b){a=this.chart.pointer.normalize(a);
var c=this.chart,m=this.xAxis,u=this.zoomedMin,e=this.left,g=this.size,d=this.range,h=a.chartX,t;c.inverted&&(h=a.chartY,e=this.top);1===b?(this.grabbedCenter=h,this.fixedWidth=d,this.dragOffset=h-u):(a=h-e-d/2,0===b?a=Math.max(0,a):2===b&&a+d>=g&&(a=g-d,t=this.getUnionExtremes().dataMax),a!==u&&(this.fixedWidth=d,b=m.toFixedRange(a,a+d,null,t),c.xAxis[0].setExtremes(Math.min(b.min,b.max),Math.max(b.min,b.max),!0,null,{trigger:"navigator"})))},handlesMousedown:function(a,b){this.chart.pointer.normalize(a);
a=this.chart;var c=a.xAxis[0],m=a.inverted&&!c.reversed||!a.inverted&&c.reversed;0===b?(this.grabbedLeft=!0,this.otherHandlePos=this.zoomedMax,this.fixedExtreme=m?c.min:c.max):(this.grabbedRight=!0,this.otherHandlePos=this.zoomedMin,this.fixedExtreme=m?c.max:c.min);a.fixedRange=null},onMouseMove:function(a){var b=this,c=b.chart,m=b.left,e=b.navigatorSize,g=b.range,d=b.dragOffset,h=c.inverted;a.touches&&0===a.touches[0].pageX||(a=c.pointer.normalize(a),c=a.chartX,h&&(m=b.top,c=a.chartY),b.grabbedLeft?
(b.hasDragged=!0,b.render(0,0,c-m,b.otherHandlePos)):b.grabbedRight?(b.hasDragged=!0,b.render(0,0,b.otherHandlePos,c-m)):b.grabbedCenter&&(b.hasDragged=!0,c<d?c=d:c>e+d-g&&(c=e+d-g),b.render(0,0,c-d,c-d+g)),b.hasDragged&&b.scrollbar&&b.scrollbar.options.liveRedraw&&(a.DOMType=a.type,setTimeout(function(){b.onMouseUp(a)},0)))},onMouseUp:function(a){var b=this.chart,c=this.xAxis,m=this.scrollbar,e,g,d=a.DOMEvent||a;(!this.hasDragged||m&&m.hasDragged)&&"scrollbar"!==a.trigger||(this.zoomedMin===this.otherHandlePos?
e=this.fixedExtreme:this.zoomedMax===this.otherHandlePos&&(g=this.fixedExtreme),this.zoomedMax===this.size&&(g=this.getUnionExtremes().dataMax),c=c.toFixedRange(this.zoomedMin,this.zoomedMax,e,g),y(c.min)&&b.xAxis[0].setExtremes(Math.min(c.min,c.max),Math.max(c.min,c.max),!0,this.hasDragged?!1:null,{trigger:"navigator",triggerOp:"navigator-drag",DOMEvent:d}));"mousemove"!==a.DOMType&&(this.grabbedLeft=this.grabbedRight=this.grabbedCenter=this.fixedWidth=this.fixedExtreme=this.otherHandlePos=this.hasDragged=
this.dragOffset=null)},removeEvents:function(){this.eventsToUnbind&&(n(this.eventsToUnbind,function(a){a()}),this.eventsToUnbind=void 0);this.removeBaseSeriesEvents()},removeBaseSeriesEvents:function(){var a=this.baseSeries||[];this.navigatorEnabled&&a[0]&&!1!==this.navigatorOptions.adaptToUpdatedData&&(n(a,function(a){f(a,"updatedData",this.updatedDataHandler)},this),a[0].xAxis&&f(a[0].xAxis,"foundExtremes",this.modifyBaseAxisExtremes))},init:function(a){var b=a.options,c=b.navigator,m=c.enabled,
g=b.scrollbar,d=g.enabled,b=m?c.height:0,t=d?g.height:0;this.handles=[];this.shades=[];this.chart=a;this.setBaseSeries();this.height=b;this.scrollbarHeight=t;this.scrollbarEnabled=d;this.navigatorEnabled=m;this.navigatorOptions=c;this.scrollbarOptions=g;this.outlineHeight=b+t;this.opposite=e(c.opposite,!m&&a.inverted);var f=this,g=f.baseSeries,d=a.xAxis.length,k=a.yAxis.length,C=g&&g[0]&&g[0].xAxis||a.xAxis[0];a.extraMargin={type:f.opposite?"plotTop":"marginBottom",value:(m||!a.inverted?f.outlineHeight:
0)+c.margin};a.inverted&&(a.extraMargin.type=f.opposite?"marginRight":"plotLeft");a.isDirtyBox=!0;f.navigatorEnabled?(f.xAxis=new z(a,E({breaks:C.options.breaks,ordinal:C.options.ordinal},c.xAxis,{id:"navigator-x-axis",yAxis:"navigator-y-axis",isX:!0,type:"datetime",index:d,offset:0,keepOrdinalPadding:!0,startOnTick:!1,endOnTick:!1,minPadding:0,maxPadding:0,zoomEnabled:!1},a.inverted?{offsets:[t,0,-t,0],width:b}:{offsets:[0,-t,0,t],height:b})),f.yAxis=new z(a,E(c.yAxis,{id:"navigator-y-axis",alignTicks:!1,
offset:0,index:k,zoomEnabled:!1},a.inverted?{width:b}:{height:b})),g||c.series.data?f.addBaseSeries():0===a.series.length&&h(a,"redraw",function(b,c){0<a.series.length&&!f.series&&(f.setBaseSeries(),a.redraw=b);b.call(a,c)}),f.renderElements(),f.addMouseEvents()):f.xAxis={translate:function(b,c){var m=a.xAxis[0],g=m.getExtremes(),e=m.len-2*t,d=A("min",m.options.min,g.dataMin),m=A("max",m.options.max,g.dataMax)-d;return c?b*m/e+d:e*(b-d)/m},toPixels:function(a){return this.translate(a)},toValue:function(a){return this.translate(a,
!0)},toFixedRange:z.prototype.toFixedRange,fake:!0};a.options.scrollbar.enabled&&(a.scrollbar=f.scrollbar=new r(a.renderer,E(a.options.scrollbar,{margin:f.navigatorEnabled?0:10,vertical:a.inverted}),a),p(f.scrollbar,"changed",function(b){var c=f.size,m=c*this.to,c=c*this.from;f.hasDragged=f.scrollbar.hasDragged;f.render(0,0,c,m);(a.options.scrollbar.liveRedraw||"mousemove"!==b.DOMType)&&setTimeout(function(){f.onMouseUp(b)})}));f.addBaseSeriesEvents();f.addChartEvents()},getUnionExtremes:function(a){var b=
this.chart.xAxis[0],c=this.xAxis,m=c.options,g=b.options,d;a&&null===b.dataMin||(d={dataMin:e(m&&m.min,A("min",g.min,b.dataMin,c.dataMin,c.min)),dataMax:e(m&&m.max,A("max",g.max,b.dataMax,c.dataMax,c.max))});return d},setBaseSeries:function(a){var b=this.chart,c;a=a||b.options&&b.options.navigator.baseSeries||0;this.series&&(this.removeBaseSeriesEvents(),n(this.series,function(a){a.destroy()}));c=this.baseSeries=[];n(b.series||[],function(b,m){(b.options.showInNavigator||(m===a||b.options.id===a)&&
!1!==b.options.showInNavigator)&&c.push(b)});this.xAxis&&!this.xAxis.fake&&this.addBaseSeries()},addBaseSeries:function(){var a=this,b=a.chart,c=a.series=[],g=a.baseSeries,d,e,h=a.navigatorOptions.series,f,t={enableMouseTracking:!1,index:null,group:"nav",padXAxis:!1,xAxis:"navigator-x-axis",yAxis:"navigator-y-axis",showInLegend:!1,stacking:!1,isInternal:!0,visible:!0};g?n(g,function(g,m){t.name="Navigator "+(m+1);d=g.options||{};f=d.navigatorOptions||{};e=E(d,t,h,f);m=f.data||h.data;a.hasNavigatorData=
a.hasNavigatorData||!!m;e.data=m||d.data&&d.data.slice(0);g.navigatorSeries=b.initSeries(e);c.push(g.navigatorSeries)}):(e=E(h,t),e.data=h.data,a.hasNavigatorData=!!e.data,c.push(b.initSeries(e)));this.addBaseSeriesEvents()},addBaseSeriesEvents:function(){var a=this,b=a.baseSeries||[];b[0]&&b[0].xAxis&&p(b[0].xAxis,"foundExtremes",this.modifyBaseAxisExtremes);!1!==this.navigatorOptions.adaptToUpdatedData&&n(b,function(b){b.xAxis&&p(b,"updatedData",this.updatedDataHandler);p(b,"remove",function(){this.navigatorSeries&&
(I(a.series,this.navigatorSeries),this.navigatorSeries.remove(!1),delete this.navigatorSeries)})},this)},modifyNavigatorAxisExtremes:function(){var a=this.xAxis,b;a.getExtremes&&(!(b=this.getUnionExtremes(!0))||b.dataMin===a.min&&b.dataMax===a.max||(a.min=b.dataMin,a.max=b.dataMax))},modifyBaseAxisExtremes:function(){var a=this.chart.navigator,b=this.getExtremes(),c=b.dataMin,g=b.dataMax,b=b.max-b.min,d=a.stickToMin,e=a.stickToMax,h,f,t=a.series&&a.series[0],A=!!this.setExtremes;this.eventArgs&&"rangeSelectorButton"===
this.eventArgs.trigger||(d&&(f=c,h=f+b),e&&(h=g,d||(f=Math.max(h-b,t&&t.xData?t.xData[0]:-Number.MAX_VALUE))),A&&(d||e)&&l(f)&&(this.min=this.userMin=f,this.max=this.userMax=h));a.stickToMin=a.stickToMax=null},updatedDataHandler:function(){var a=this.chart.navigator,b=this.navigatorSeries;a.stickToMin=l(this.xAxis.min)&&this.xAxis.min<=this.xData[0];a.stickToMax=Math.round(a.zoomedMax)>=Math.round(a.size);b&&!a.hasNavigatorData&&(b.options.pointStart=this.xData[0],b.setData(this.options.data,!1,null,
!1))},addChartEvents:function(){p(this.chart,"redraw",function(){var a=this.navigator,b=a&&(a.baseSeries&&a.baseSeries[0]&&a.baseSeries[0].xAxis||a.scrollbar&&this.xAxis[0]);b&&a.render(b.min,b.max)})},destroy:function(){this.removeEvents();this.xAxis&&(I(this.chart.xAxis,this.xAxis),I(this.chart.axes,this.xAxis));this.yAxis&&(I(this.chart.yAxis,this.yAxis),I(this.chart.axes,this.yAxis));n(this.series||[],function(a){a.destroy&&a.destroy()});n("series xAxis yAxis shades outline scrollbarTrack scrollbarRifles scrollbarGroup scrollbar navigatorGroup rendered".split(" "),
function(a){this[a]&&this[a].destroy&&this[a].destroy();this[a]=null},this);n([this.handles],function(a){w(a)},this)}};a.Navigator=F;h(z.prototype,"zoom",function(a,b,c){var g=this.chart,d=g.options,e=d.chart.zoomType,h=d.navigator,d=d.rangeSelector,f;this.isXAxis&&(h&&h.enabled||d&&d.enabled)&&("x"===e?g.resetZoomButton="blocked":"y"===e?f=!1:"xy"===e&&(g=this.previousZoom,y(b)?this.previousZoom=[this.min,this.max]:g&&(b=g[0],c=g[1],delete this.previousZoom)));return void 0!==f?f:a.call(this,b,c)});
h(D.prototype,"init",function(a,b,c){p(this,"beforeRender",function(){var a=this.options;if(a.navigator.enabled||a.scrollbar.enabled)this.scroller=this.navigator=new F(this)});a.call(this,b,c)});h(D.prototype,"setChartSize",function(a){var b=this.legend,c=this.navigator,g,d,h,f;a.apply(this,[].slice.call(arguments,1));c&&(d=b.options,h=c.xAxis,f=c.yAxis,g=c.scrollbarHeight,this.inverted?(c.left=c.opposite?this.chartWidth-g-c.height:this.spacing[3]+g,c.top=this.plotTop+g):(c.left=this.plotLeft+g,c.top=
c.navigatorOptions.top||this.chartHeight-c.height-g-this.spacing[2]-("bottom"===d.verticalAlign&&d.enabled&&!d.floating?b.legendHeight+e(d.margin,10):0)),h&&f&&(this.inverted?h.options.left=f.options.left=c.left:h.options.top=f.options.top=c.top,h.setAxisSize(),f.setAxisSize()))});h(v.prototype,"addPoint",function(a,b,c,g,e){var h=this.options.turboThreshold;h&&this.xData.length>h&&d(b,!0)&&this.chart.navigator&&q(20,!0);a.call(this,b,c,g,e)});h(D.prototype,"addSeries",function(a,b,c,g){a=a.call(this,
b,!1,g);this.navigator&&this.navigator.setBaseSeries();e(c,!0)&&this.redraw();return a});h(v.prototype,"update",function(a,b,c){a.call(this,b,!1);this.chart.navigator&&this.chart.navigator.setBaseSeries();e(c,!0)&&this.chart.redraw()});D.prototype.callbacks.push(function(a){var b=a.navigator;b&&(a=a.xAxis[0].getExtremes(),b.render(a.min,a.max))})})(J);(function(a){function F(a){this.init(a)}var p=a.addEvent,z=a.Axis,D=a.Chart,G=a.css,H=a.createElement,y=a.dateFormat,w=a.defaultOptions,x=w.global.useUTC,
n=a.defined,I=a.destroyObjectProperties,q=a.discardElement,b=a.each,c=a.extend,k=a.fireEvent,l=a.Date,d=a.isNumber,E=a.merge,e=a.pick,f=a.pInt,r=a.splat,v=a.wrap;c(w,{rangeSelector:{buttonTheme:{"stroke-width":0,width:28,height:18,padding:2,zIndex:7},height:35,inputPosition:{align:"right"},labelStyle:{color:"#666666"}}});w.lang=E(w.lang,{rangeSelectorZoom:"Zoom",rangeSelectorFrom:"From",rangeSelectorTo:"To"});F.prototype={clickButton:function(a,c){var g=this,h=g.chart,f=g.buttonOptions[a],m=h.xAxis[0],
u=h.scroller&&h.scroller.getUnionExtremes()||m||{},k=u.dataMin,l=u.dataMax,q,n=m&&Math.round(Math.min(m.max,e(l,m.max))),w=f.type,v,u=f._range,M,y,N,D=f.dataGrouping;if(null!==k&&null!==l){h.fixedRange=u;D&&(this.forcedDataGrouping=!0,z.prototype.setDataGrouping.call(m||{chart:this.chart},D,!1));if("month"===w||"year"===w)m?(w={range:f,max:n,dataMin:k,dataMax:l},q=m.minFromRange.call(w),d(w.newMax)&&(n=w.newMax)):u=f;else if(u)q=Math.max(n-u,k),n=Math.min(q+u,l);else if("ytd"===w)if(m)void 0===l&&
(k=Number.MAX_VALUE,l=Number.MIN_VALUE,b(h.series,function(a){a=a.xData;k=Math.min(a[0],k);l=Math.max(a[a.length-1],l)}),c=!1),n=g.getYTDExtremes(l,k,x),q=M=n.min,n=n.max;else{p(h,"beforeRender",function(){g.clickButton(a)});return}else"all"===w&&m&&(q=k,n=l);g.setSelected(a);m?m.setExtremes(q,n,e(c,1),null,{trigger:"rangeSelectorButton",rangeSelectorButton:f}):(v=r(h.options.xAxis)[0],N=v.range,v.range=u,y=v.min,v.min=M,p(h,"load",function(){v.range=N;v.min=y}))}},setSelected:function(a){this.selected=
this.options.selected=a},defaultButtons:[{type:"month",count:1,text:"1m"},{type:"month",count:3,text:"3m"},{type:"month",count:6,text:"6m"},{type:"ytd",text:"YTD"},{type:"year",count:1,text:"1y"},{type:"all",text:"All"}],init:function(a){var c=this,d=a.options.rangeSelector,g=d.buttons||[].concat(c.defaultButtons),e=d.selected,f=function(){var a=c.minInput,b=c.maxInput;a&&a.blur&&k(a,"blur");b&&b.blur&&k(b,"blur")};c.chart=a;c.options=d;c.buttons=[];a.extraTopMargin=d.height;c.buttonOptions=g;this.unMouseDown=
p(a.container,"mousedown",f);this.unResize=p(a,"resize",f);b(g,c.computeButtonRange);void 0!==e&&g[e]&&this.clickButton(e,!1);p(a,"load",function(){p(a.xAxis[0],"setExtremes",function(b){this.max-this.min!==a.fixedRange&&"rangeSelectorButton"!==b.trigger&&"updatedData"!==b.trigger&&c.forcedDataGrouping&&this.setDataGrouping(!1,!1)})})},updateButtonStates:function(){var a=this.chart,c=a.xAxis[0],e=Math.round(c.max-c.min),f=!c.hasVisibleSeries,a=a.scroller&&a.scroller.getUnionExtremes()||c,k=a.dataMin,
m=a.dataMax,a=this.getYTDExtremes(m,k,x),l=a.min,q=a.max,n=this.selected,p=d(n),r=this.options.allButtonsEnabled,w=this.buttons;b(this.buttonOptions,function(a,b){var d=a._range,g=a.type,h=a.count||1;a=w[b];var t=0;b=b===n;var A=d>m-k,u=d<c.minRange,C=!1,B=!1,d=d===e;("month"===g||"year"===g)&&e>=864E5*{month:28,year:365}[g]*h&&e<=864E5*{month:31,year:366}[g]*h?d=!0:"ytd"===g?(d=q-l===e,C=!b):"all"===g&&(d=c.max-c.min>=m-k,B=!b&&p&&d);g=!r&&(A||u||B||f);d=b&&d||d&&!p&&!C;g?t=3:d&&(p=!0,t=2);a.state!==
t&&a.setState(t)})},computeButtonRange:function(a){var b=a.type,c=a.count||1,d={millisecond:1,second:1E3,minute:6E4,hour:36E5,day:864E5,week:6048E5};if(d[b])a._range=d[b]*c;else if("month"===b||"year"===b)a._range=864E5*{month:30,year:365}[b]*c},setInputValue:function(a,b){var c=this.chart.options.rangeSelector,d=this[a+"Input"];n(b)&&(d.previousValue=d.HCTime,d.HCTime=b);d.value=y(c.inputEditDateFormat||"%Y-%m-%d",d.HCTime);this[a+"DateBox"].attr({text:y(c.inputDateFormat||"%b %e, %Y",d.HCTime)})},
showInput:function(a){var b=this.inputGroup,c=this[a+"DateBox"];G(this[a+"Input"],{left:b.translateX+c.x+"px",top:b.translateY+"px",width:c.width-2+"px",height:c.height-2+"px",border:"2px solid silver"})},hideInput:function(a){G(this[a+"Input"],{border:0,width:"1px",height:"1px"});this.setInputValue(a)},drawInput:function(a){function b(){var a=p.value,b=(l.inputDateParser||Date.parse)(a),c=g.xAxis[0],h=g.scroller&&g.scroller.xAxis?g.scroller.xAxis:c,m=h.dataMin,h=h.dataMax;b!==p.previousValue&&(p.previousValue=
b,d(b)||(b=a.split("-"),b=Date.UTC(f(b[0]),f(b[1])-1,f(b[2]))),d(b)&&(x||(b+=6E4*(new Date).getTimezoneOffset()),n?b>e.maxInput.HCTime?b=void 0:b<m&&(b=m):b<e.minInput.HCTime?b=void 0:b>h&&(b=h),void 0!==b&&c.setExtremes(n?b:c.min,n?c.max:b,void 0,void 0,{trigger:"rangeSelectorInput"})))}var e=this,g=e.chart,k=g.renderer.style||{},m=g.renderer,l=g.options.rangeSelector,q=e.div,n="min"===a,p,r,v=this.inputGroup;this[a+"Label"]=r=m.label(w.lang[n?"rangeSelectorFrom":"rangeSelectorTo"],this.inputGroup.offset).addClass("highcharts-range-label").attr({padding:2}).add(v);
v.offset+=r.width+5;this[a+"DateBox"]=m=m.label("",v.offset).addClass("highcharts-range-input").attr({padding:2,width:l.inputBoxWidth||90,height:l.inputBoxHeight||17,stroke:l.inputBoxBorderColor||"#cccccc","stroke-width":1,"text-align":"center"}).on("click",function(){e.showInput(a);e[a+"Input"].focus()}).add(v);v.offset+=m.width+(n?10:0);this[a+"Input"]=p=H("input",{name:a,className:"highcharts-range-selector",type:"text"},{top:g.plotTop+"px"},q);r.css(E(k,l.labelStyle));m.css(E({color:"#333333"},
k,l.inputStyle));G(p,c({position:"absolute",border:0,width:"1px",height:"1px",padding:0,textAlign:"center",fontSize:k.fontSize,fontFamily:k.fontFamily,left:"-9em"},l.inputStyle));p.onfocus=function(){e.showInput(a)};p.onblur=function(){e.hideInput(a)};p.onchange=b;p.onkeypress=function(a){13===a.keyCode&&b()}},getPosition:function(){var a=this.chart,b=a.options.rangeSelector,a=e((b.buttonPosition||{}).y,a.plotTop-a.axisOffset[0]-b.height);return{buttonTop:a,inputTop:a-10}},getYTDExtremes:function(a,
b,c){var d=new l(a),e=d[l.hcGetFullYear]();c=c?l.UTC(e,0,1):+new l(e,0,1);b=Math.max(b||0,c);d=d.getTime();return{max:Math.min(a||d,d),min:b}},render:function(a,d){var f=this,g=f.chart,h=g.renderer,m=g.container,k=g.options,l=k.exporting&&!1!==k.exporting.enabled&&k.navigation&&k.navigation.buttonOptions,q=k.rangeSelector,p=f.buttons,k=w.lang,r=f.div,r=f.inputGroup,v=q.buttonTheme,x=q.buttonPosition||{},y=q.inputEnabled,z=v&&v.states,D=g.plotLeft,E,F=this.getPosition(),G=f.group,I=f.rendered;!1!==
q.enabled&&(I||(f.group=G=h.g("range-selector-buttons").add(),f.zoomText=h.text(k.rangeSelectorZoom,e(x.x,D),15).css(q.labelStyle).add(G),E=e(x.x,D)+f.zoomText.getBBox().width+5,b(f.buttonOptions,function(a,b){p[b]=h.button(a.text,E,0,function(){f.clickButton(b);f.isActive=!0},v,z&&z.hover,z&&z.select,z&&z.disabled).attr({"text-align":"center"}).add(G);E+=p[b].width+e(q.buttonSpacing,5)}),!1!==y&&(f.div=r=H("div",null,{position:"relative",height:0,zIndex:1}),m.parentNode.insertBefore(r,m),f.inputGroup=
r=h.g("input-group").add(),r.offset=0,f.drawInput("min"),f.drawInput("max"))),f.updateButtonStates(),G[I?"animate":"attr"]({translateY:F.buttonTop}),!1!==y&&(r.align(c({y:F.inputTop,width:r.offset,x:l&&F.inputTop<(l.y||0)+l.height-g.spacing[0]?-40:0},q.inputPosition),!0,g.spacingBox),n(y)||(g=G.getBBox(),r[r.alignAttr.translateX<g.x+g.width+10?"hide":"show"]()),f.setInputValue("min",a),f.setInputValue("max",d)),f.rendered=!0)},update:function(a){var b=this.chart;E(!0,b.options.rangeSelector,a);this.destroy();
this.init(b)},destroy:function(){var a=this.minInput,b=this.maxInput,c;this.unMouseDown();this.unResize();I(this.buttons);a&&(a.onfocus=a.onblur=a.onchange=null);b&&(b.onfocus=b.onblur=b.onchange=null);for(c in this)this[c]&&"chart"!==c&&(this[c].destroy?this[c].destroy():this[c].nodeType&&q(this[c])),this[c]!==F.prototype[c]&&(this[c]=null)}};z.prototype.toFixedRange=function(a,b,c,f){var g=this.chart&&this.chart.fixedRange;a=e(c,this.translate(a,!0,!this.horiz));b=e(f,this.translate(b,!0,!this.horiz));
c=g&&(b-a)/g;.7<c&&1.3>c&&(f?a=b-g:b=a+g);d(a)||(a=b=void 0);return{min:a,max:b}};z.prototype.minFromRange=function(){var a=this.range,b={month:"Month",year:"FullYear"}[a.type],c,f=this.max,k,m,l=function(a,c){var d=new Date(a);d["set"+b](d["get"+b]()+c);return d.getTime()-a};d(a)?(c=f-a,m=a):(c=f+l(f,-a.count),this.chart&&(this.chart.fixedRange=f-c));k=e(this.dataMin,Number.MIN_VALUE);d(c)||(c=k);c<=k&&(c=k,void 0===m&&(m=l(c,a.count)),this.newMax=Math.min(c+m,this.dataMax));d(f)||(c=void 0);return c};
v(D.prototype,"init",function(a,b,c){p(this,"init",function(){this.options.rangeSelector.enabled&&(this.rangeSelector=new F(this))});a.call(this,b,c)});D.prototype.callbacks.push(function(a){function b(){c=a.xAxis[0].getExtremes();d(c.min)&&e.render(c.min,c.max)}var c,e=a.rangeSelector,f,g;e&&(g=p(a.xAxis[0],"afterSetExtremes",function(a){e.render(a.min,a.max)}),f=p(a,"redraw",b),b());p(a,"destroy",function(){e&&(f(),g())})});a.RangeSelector=F})(J);(function(a){var F=a.arrayMax,p=a.arrayMin,z=a.Axis,
D=a.Chart,G=a.defined,H=a.each,y=a.extend,w=a.format,x=a.inArray,n=a.isNumber,I=a.isString,q=a.map,b=a.merge,c=a.pick,k=a.Point,l=a.Renderer,d=a.Series,E=a.splat,e=a.SVGRenderer,f=a.VMLRenderer,r=a.wrap,v=d.prototype,g=v.init,h=v.processData,C=k.prototype.tooltipFormatter;a.StockChart=a.stockChart=function(d,e,f){var g=I(d)||d.nodeName,h=arguments[g?1:0],m=h.series,k=a.getOptions(),l,t=c(h.navigator&&h.navigator.enabled,k.navigator.enabled,!0),A=t?{startOnTick:!1,endOnTick:!1}:null,n={marker:{enabled:!1,
radius:2}},p={shadow:!1,borderWidth:0};h.xAxis=q(E(h.xAxis||{}),function(a){return b({minPadding:0,maxPadding:0,ordinal:!0,title:{text:null},labels:{overflow:"justify"},showLastLabel:!0},k.xAxis,a,{type:"datetime",categories:null},A)});h.yAxis=q(E(h.yAxis||{}),function(a){l=c(a.opposite,!0);return b({labels:{y:-2},opposite:l,showLastLabel:!1,title:{text:null}},k.yAxis,a)});h.series=null;h=b({chart:{panning:!0,pinchType:"x"},navigator:{enabled:t},scrollbar:{enabled:c(k.scrollbar.enabled,!0)},rangeSelector:{enabled:c(k.rangeSelector.enabled,
!0)},title:{text:null},tooltip:{shared:!0,crosshairs:!0},legend:{enabled:!1},plotOptions:{line:n,spline:n,area:n,areaspline:n,arearange:n,areasplinerange:n,column:p,columnrange:p,candlestick:p,ohlc:p}},h,{isStock:!0});h.series=m;return g?new D(d,h,f):new D(h,e)};r(z.prototype,"autoLabelAlign",function(a){var b=this.chart,c=this.options,b=b._labelPanes=b._labelPanes||{},d=this.options.labels;return this.chart.options.isStock&&"yAxis"===this.coll&&(c=c.top+","+c.height,!b[c]&&d.enabled)?(15===d.x&&
(d.x=0),void 0===d.align&&(d.align="right"),b[c]=this,"right"):a.call(this,[].slice.call(arguments,1))});r(z.prototype,"destroy",function(a){var b=this.chart,c=this.options&&this.options.top+","+this.options.height;c&&b._labelPanes&&b._labelPanes[c]===this&&delete b._labelPanes[c];return a.call(this,Array.prototype.slice.call(arguments,1))});r(z.prototype,"getPlotLinePath",function(a,b,d,e,f,g){var h=this,k=this.isLinked&&!this.series?this.linkedParent.series:this.series,m=h.chart,l=m.renderer,t=
h.left,p=h.top,u,r,A,v,w=[],B=[],y,z;if("colorAxis"===h.coll)return a.apply(this,[].slice.call(arguments,1));B=function(a){var b="xAxis"===a?"yAxis":"xAxis";a=h.options[b];return n(a)?[m[b][a]]:I(a)?[m.get(a)]:q(k,function(a){return a[b]})}(h.coll);H(h.isXAxis?m.yAxis:m.xAxis,function(a){if(G(a.options.id)?-1===a.options.id.indexOf("navigator"):1){var b=a.isXAxis?"yAxis":"xAxis",b=G(a.options[b])?m[b][a.options[b]]:m[b][0];h===b&&B.push(a)}});y=B.length?[]:[h.isXAxis?m.yAxis[0]:m.xAxis[0]];H(B,function(a){-1===
x(a,y)&&y.push(a)});z=c(g,h.translate(b,null,null,e));n(z)&&(h.horiz?H(y,function(a){var b;r=a.pos;v=r+a.len;u=A=Math.round(z+h.transB);if(u<t||u>t+h.width)f?u=A=Math.min(Math.max(t,u),t+h.width):b=!0;b||w.push("M",u,r,"L",A,v)}):H(y,function(a){var b;u=a.pos;A=u+a.len;r=v=Math.round(p+h.height-z);if(r<p||r>p+h.height)f?r=v=Math.min(Math.max(p,r),h.top+h.height):b=!0;b||w.push("M",u,r,"L",A,v)}));return 0<w.length?l.crispPolyLine(w,d||1):null});z.prototype.getPlotBandPath=function(a,b){b=this.getPlotLinePath(b,
null,null,!0);a=this.getPlotLinePath(a,null,null,!0);var c=[],d;if(a&&b)if(a.toString()===b.toString())c=a,c.flat=!0;else for(d=0;d<a.length;d+=6)c.push("M",a[d+1],a[d+2],"L",a[d+4],a[d+5],b[d+4],b[d+5],b[d+1],b[d+2],"z");else c=null;return c};e.prototype.crispPolyLine=function(a,b){var c;for(c=0;c<a.length;c+=6)a[c+1]===a[c+4]&&(a[c+1]=a[c+4]=Math.round(a[c+1])-b%2/2),a[c+2]===a[c+5]&&(a[c+2]=a[c+5]=Math.round(a[c+2])+b%2/2);return a};l===f&&(f.prototype.crispPolyLine=e.prototype.crispPolyLine);
r(z.prototype,"hideCrosshair",function(a,b){a.call(this,b);this.crossLabel&&(this.crossLabel=this.crossLabel.hide())});r(z.prototype,"drawCrosshair",function(a,b,d){var e,f;a.call(this,b,d);if(G(this.crosshair.label)&&this.crosshair.label.enabled&&this.cross){a=this.chart;var g=this.options.crosshair.label,h=this.horiz;e=this.opposite;f=this.left;var k=this.top,l=this.crossLabel,m,n=g.format,t="",q="inside"===this.options.tickPosition,p=!1!==this.crosshair.snap,r=0;b||(b=this.cross&&this.cross.e);
m=h?"center":e?"right"===this.labelAlign?"right":"left":"left"===this.labelAlign?"left":"center";l||(l=this.crossLabel=a.renderer.label(null,null,null,g.shape||"callout").addClass("highcharts-crosshair-label"+(this.series[0]&&" highcharts-color-"+this.series[0].colorIndex)).attr({align:g.align||m,padding:c(g.padding,8),r:c(g.borderRadius,3),zIndex:2}).add(this.labelGroup),l.attr({fill:g.backgroundColor||this.series[0]&&this.series[0].color||"#666666",stroke:g.borderColor||"","stroke-width":g.borderWidth||
0}).css(y({color:"#ffffff",fontWeight:"normal",fontSize:"11px",textAlign:"center"},g.style)));h?(m=p?d.plotX+f:b.chartX,k+=e?0:this.height):(m=e?this.width+f:0,k=p?d.plotY+k:b.chartY);n||g.formatter||(this.isDatetimeAxis&&(t="%b %d, %Y"),n="{value"+(t?":"+t:"")+"}");b=p?d[this.isXAxis?"x":"y"]:this.toValue(h?b.chartX:b.chartY);l.attr({text:n?w(n,{value:b}):g.formatter.call(this,b),x:m,y:k,visibility:"visible"});b=l.getBBox();if(h){if(q&&!e||!q&&e)k=l.y-b.height}else k=l.y-b.height/2;h?(e=f-b.x,f=
f+this.width-b.x):(e="left"===this.labelAlign?f:0,f="right"===this.labelAlign?f+this.width:a.chartWidth);l.translateX<e&&(r=e-l.translateX);l.translateX+b.width>=f&&(r=-(l.translateX+b.width-f));l.attr({x:m+r,y:k,anchorX:h?m:this.opposite?0:a.chartWidth,anchorY:h?this.opposite?a.chartHeight:0:k+b.height/2})}});v.init=function(){g.apply(this,arguments);this.setCompare(this.options.compare)};v.setCompare=function(a){this.modifyValue="value"===a||"percent"===a?function(b,c){var d=this.compareValue;if(void 0!==
b&&void 0!==d)return b="value"===a?b-d:b/d*100-(100===this.options.compareBase?0:100),c&&(c.change=b),b}:null;this.userOptions.compare=a;this.chart.hasRendered&&(this.isDirty=!0)};v.processData=function(){var a,b=-1,c,d,e,f;h.apply(this,arguments);if(this.xAxis&&this.processedYData)for(c=this.processedXData,d=this.processedYData,e=d.length,this.pointArrayMap&&(b=x("close",this.pointArrayMap),-1===b&&(b=x(this.pointValKey||"y",this.pointArrayMap))),a=0;a<e-1;a++)if(f=-1<b?d[a][b]:d[a],n(f)&&c[a+1]>=
this.xAxis.min&&0!==f){this.compareValue=f;break}};r(v,"getExtremes",function(a){var b;a.apply(this,[].slice.call(arguments,1));this.modifyValue&&(b=[this.modifyValue(this.dataMin),this.modifyValue(this.dataMax)],this.dataMin=p(b),this.dataMax=F(b))});z.prototype.setCompare=function(a,b){this.isXAxis||(H(this.series,function(b){b.setCompare(a)}),c(b,!0)&&this.chart.redraw())};k.prototype.tooltipFormatter=function(b){b=b.replace("{point.change}",(0<this.change?"+":"")+a.numberFormat(this.change,c(this.series.tooltipOptions.changeDecimals,
2)));return C.apply(this,[b])};r(d.prototype,"render",function(a){this.chart.is3d&&this.chart.is3d()||this.chart.polar||!this.xAxis||this.xAxis.isRadial||(!this.clipBox&&this.animate?(this.clipBox=b(this.chart.clipBox),this.clipBox.width=this.xAxis.len,this.clipBox.height=this.yAxis.len):this.chart[this.sharedClipKey]?this.chart[this.sharedClipKey].attr({width:this.xAxis.len,height:this.yAxis.len}):this.clipBox&&(this.clipBox.width=this.xAxis.len,this.clipBox.height=this.yAxis.len));a.call(this)})})(J)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 | 1 1 1 1 1 1 1 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* Highstock as a plugin for Highcharts
*
* (c) 2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
Axis = H.Axis,
Chart = H.Chart,
css = H.css,
dateFormat = H.dateFormat,
defined = H.defined,
each = H.each,
extend = H.extend,
noop = H.noop,
Series = H.Series,
timeUnits = H.timeUnits,
wrap = H.wrap;
/* ****************************************************************************
* Start ordinal axis logic *
*****************************************************************************/
wrap(Series.prototype, 'init', function(proceed) {
var series = this,
xAxis;
// call the original function
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
xAxis = series.xAxis;
// Destroy the extended ordinal index on updated data
if (xAxis && xAxis.options.ordinal) {
addEvent(series, 'updatedData', function() {
delete xAxis.ordinalIndex;
});
}
});
/**
* In an ordinal axis, there might be areas with dense consentrations of points, then large
* gaps between some. Creating equally distributed ticks over this entire range
* may lead to a huge number of ticks that will later be removed. So instead, break the
* positions up in segments, find the tick positions for each segment then concatenize them.
* This method is used from both data grouping logic and X axis tick position logic.
*/
wrap(Axis.prototype, 'getTimeTicks', function(proceed, normalizedInterval, min, max, startOfWeek, positions, closestDistance, findHigherRanks) {
var start = 0,
end,
segmentPositions,
higherRanks = {},
hasCrossedHigherRank,
info,
posLength,
outsideMax,
groupPositions = [],
lastGroupPosition = -Number.MAX_VALUE,
tickPixelIntervalOption = this.options.tickPixelInterval;
// The positions are not always defined, for example for ordinal positions when data
// has regular interval (#1557, #2090)
if ((!this.options.ordinal && !this.options.breaks) || !positions || positions.length < 3 || min === undefined) {
return proceed.call(this, normalizedInterval, min, max, startOfWeek);
}
// Analyze the positions array to split it into segments on gaps larger than 5 times
// the closest distance. The closest distance is already found at this point, so
// we reuse that instead of computing it again.
posLength = positions.length;
for (end = 0; end < posLength; end++) {
outsideMax = end && positions[end - 1] > max;
if (positions[end] < min) { // Set the last position before min
start = end;
}
if (end === posLength - 1 || positions[end + 1] - positions[end] > closestDistance * 5 || outsideMax) {
// For each segment, calculate the tick positions from the getTimeTicks utility
// function. The interval will be the same regardless of how long the segment is.
if (positions[end] > lastGroupPosition) { // #1475
segmentPositions = proceed.call(this, normalizedInterval, positions[start], positions[end], startOfWeek);
// Prevent duplicate groups, for example for multiple segments within one larger time frame (#1475)
while (segmentPositions.length && segmentPositions[0] <= lastGroupPosition) {
segmentPositions.shift();
}
if (segmentPositions.length) {
lastGroupPosition = segmentPositions[segmentPositions.length - 1];
}
groupPositions = groupPositions.concat(segmentPositions);
}
// Set start of next segment
start = end + 1;
}
if (outsideMax) {
break;
}
}
// Get the grouping info from the last of the segments. The info is the same for
// all segments.
info = segmentPositions.info;
// Optionally identify ticks with higher rank, for example when the ticks
// have crossed midnight.
if (findHigherRanks && info.unitRange <= timeUnits.hour) {
end = groupPositions.length - 1;
// Compare points two by two
for (start = 1; start < end; start++) {
if (dateFormat('%d', groupPositions[start]) !== dateFormat('%d', groupPositions[start - 1])) {
higherRanks[groupPositions[start]] = 'day';
hasCrossedHigherRank = true;
}
}
// If the complete array has crossed midnight, we want to mark the first
// positions also as higher rank
if (hasCrossedHigherRank) {
higherRanks[groupPositions[0]] = 'day';
}
info.higherRanks = higherRanks;
}
// Save the info
groupPositions.info = info;
// Don't show ticks within a gap in the ordinal axis, where the space between
// two points is greater than a portion of the tick pixel interval
if (findHigherRanks && defined(tickPixelIntervalOption)) { // check for squashed ticks
var length = groupPositions.length,
i = length,
itemToRemove,
translated,
translatedArr = [],
lastTranslated,
medianDistance,
distance,
distances = [];
// Find median pixel distance in order to keep a reasonably even distance between
// ticks (#748)
while (i--) {
translated = this.translate(groupPositions[i]);
if (lastTranslated) {
distances[i] = lastTranslated - translated;
}
translatedArr[i] = lastTranslated = translated;
}
distances.sort();
medianDistance = distances[Math.floor(distances.length / 2)];
if (medianDistance < tickPixelIntervalOption * 0.6) {
medianDistance = null;
}
// Now loop over again and remove ticks where needed
i = groupPositions[length - 1] > max ? length - 1 : length; // #817
lastTranslated = undefined;
while (i--) {
translated = translatedArr[i];
distance = Math.abs(lastTranslated - translated);
// #4175 - when axis is reversed, the distance, is negative but
// tickPixelIntervalOption positive, so we need to compare the same values
// Remove ticks that are closer than 0.6 times the pixel interval from the one to the right,
// but not if it is close to the median distance (#748).
if (lastTranslated && distance < tickPixelIntervalOption * 0.8 &&
(medianDistance === null || distance < medianDistance * 0.8)) {
// Is this a higher ranked position with a normal position to the right?
if (higherRanks[groupPositions[i]] && !higherRanks[groupPositions[i + 1]]) {
// Yes: remove the lower ranked neighbour to the right
itemToRemove = i + 1;
lastTranslated = translated; // #709
} else {
// No: remove this one
itemToRemove = i;
}
groupPositions.splice(itemToRemove, 1);
} else {
lastTranslated = translated;
}
}
}
return groupPositions;
});
// Extend the Axis prototype
extend(Axis.prototype, /** @lends Axis.prototype */ {
/**
* Calculate the ordinal positions before tick positions are calculated.
*/
beforeSetTickPositions: function() {
var axis = this,
len,
ordinalPositions = [],
useOrdinal = false,
dist,
extremes = axis.getExtremes(),
min = extremes.min,
max = extremes.max,
minIndex,
maxIndex,
slope,
hasBreaks = axis.isXAxis && !!axis.options.breaks,
isOrdinal = axis.options.ordinal,
ignoreHiddenSeries = axis.chart.options.chart.ignoreHiddenSeries,
i;
// apply the ordinal logic
if (isOrdinal || hasBreaks) { // #4167 YAxis is never ordinal ?
each(axis.series, function(series, i) {
if ((!ignoreHiddenSeries || series.visible !== false) && (series.takeOrdinalPosition !== false || hasBreaks)) {
// concatenate the processed X data into the existing positions, or the empty array
ordinalPositions = ordinalPositions.concat(series.processedXData);
len = ordinalPositions.length;
// remove duplicates (#1588)
ordinalPositions.sort(function(a, b) {
return a - b; // without a custom function it is sorted as strings
});
if (len) {
i = len - 1;
while (i--) {
if (ordinalPositions[i] === ordinalPositions[i + 1]) {
ordinalPositions.splice(i, 1);
}
}
}
}
});
// cache the length
len = ordinalPositions.length;
// Check if we really need the overhead of mapping axis data against the ordinal positions.
// If the series consist of evenly spaced data any way, we don't need any ordinal logic.
if (len > 2) { // two points have equal distance by default
dist = ordinalPositions[1] - ordinalPositions[0];
i = len - 1;
while (i-- && !useOrdinal) {
if (ordinalPositions[i + 1] - ordinalPositions[i] !== dist) {
useOrdinal = true;
}
}
// When zooming in on a week, prevent axis padding for weekends even though the data within
// the week is evenly spaced.
if (!axis.options.keepOrdinalPadding && (ordinalPositions[0] - min > dist || max - ordinalPositions[ordinalPositions.length - 1] > dist)) {
useOrdinal = true;
}
}
// Record the slope and offset to compute the linear values from the array index.
// Since the ordinal positions may exceed the current range, get the start and
// end positions within it (#719, #665b)
if (useOrdinal) {
// Register
axis.ordinalPositions = ordinalPositions;
// This relies on the ordinalPositions being set. Use Math.max
// and Math.min to prevent padding on either sides of the data.
minIndex = axis.ordinal2lin( // #5979
Math.max(
min,
ordinalPositions[0]
),
true
);
maxIndex = Math.max(axis.ordinal2lin(
Math.min(
max,
ordinalPositions[ordinalPositions.length - 1]
),
true
), 1); // #3339
// Set the slope and offset of the values compared to the indices in the ordinal positions
axis.ordinalSlope = slope = (max - min) / (maxIndex - minIndex);
axis.ordinalOffset = min - (minIndex * slope);
} else {
axis.ordinalPositions = axis.ordinalSlope = axis.ordinalOffset = undefined;
}
}
axis.isOrdinal = isOrdinal && useOrdinal; // #3818, #4196, #4926
axis.groupIntervalFactor = null; // reset for next run
},
/**
* Translate from a linear axis value to the corresponding ordinal axis position. If there
* are no gaps in the ordinal axis this will be the same. The translated value is the value
* that the point would have if the axis were linear, using the same min and max.
*
* @param Number val The axis value
* @param Boolean toIndex Whether to return the index in the ordinalPositions or the new value
*/
val2lin: function(val, toIndex) {
var axis = this,
ordinalPositions = axis.ordinalPositions,
ret;
if (!ordinalPositions) {
ret = val;
} else {
var ordinalLength = ordinalPositions.length,
i,
distance,
ordinalIndex;
// first look for an exact match in the ordinalpositions array
i = ordinalLength;
while (i--) {
if (ordinalPositions[i] === val) {
ordinalIndex = i;
break;
}
}
// if that failed, find the intermediate position between the two nearest values
i = ordinalLength - 1;
while (i--) {
if (val > ordinalPositions[i] || i === 0) { // interpolate
distance = (val - ordinalPositions[i]) / (ordinalPositions[i + 1] - ordinalPositions[i]); // something between 0 and 1
ordinalIndex = i + distance;
break;
}
}
ret = toIndex ?
ordinalIndex :
axis.ordinalSlope * (ordinalIndex || 0) + axis.ordinalOffset;
}
return ret;
},
/**
* Translate from linear (internal) to axis value
*
* @param Number val The linear abstracted value
* @param Boolean fromIndex Translate from an index in the ordinal positions rather than a value
*/
lin2val: function(val, fromIndex) {
var axis = this,
ordinalPositions = axis.ordinalPositions,
ret;
if (!ordinalPositions) { // the visible range contains only equally spaced values
ret = val;
} else {
var ordinalSlope = axis.ordinalSlope,
ordinalOffset = axis.ordinalOffset,
i = ordinalPositions.length - 1,
linearEquivalentLeft,
linearEquivalentRight,
distance;
// Handle the case where we translate from the index directly, used only
// when panning an ordinal axis
if (fromIndex) {
if (val < 0) { // out of range, in effect panning to the left
val = ordinalPositions[0];
} else if (val > i) { // out of range, panning to the right
val = ordinalPositions[i];
} else { // split it up
i = Math.floor(val);
distance = val - i; // the decimal
}
// Loop down along the ordinal positions. When the linear equivalent of i matches
// an ordinal position, interpolate between the left and right values.
} else {
while (i--) {
linearEquivalentLeft = (ordinalSlope * i) + ordinalOffset;
if (val >= linearEquivalentLeft) {
linearEquivalentRight = (ordinalSlope * (i + 1)) + ordinalOffset;
distance = (val - linearEquivalentLeft) / (linearEquivalentRight - linearEquivalentLeft); // something between 0 and 1
break;
}
}
}
// If the index is within the range of the ordinal positions, return the associated
// or interpolated value. If not, just return the value
return distance !== undefined && ordinalPositions[i] !== undefined ?
ordinalPositions[i] + (distance ? distance * (ordinalPositions[i + 1] - ordinalPositions[i]) : 0) :
val;
}
return ret;
},
/**
* Get the ordinal positions for the entire data set. This is necessary in chart panning
* because we need to find out what points or data groups are available outside the
* visible range. When a panning operation starts, if an index for the given grouping
* does not exists, it is created and cached. This index is deleted on updated data, so
* it will be regenerated the next time a panning operation starts.
*/
getExtendedPositions: function() {
var axis = this,
chart = axis.chart,
grouping = axis.series[0].currentDataGrouping,
ordinalIndex = axis.ordinalIndex,
key = grouping ? grouping.count + grouping.unitName : 'raw',
extremes = axis.getExtremes(),
fakeAxis,
fakeSeries;
// If this is the first time, or the ordinal index is deleted by updatedData,
// create it.
if (!ordinalIndex) {
ordinalIndex = axis.ordinalIndex = {};
}
if (!ordinalIndex[key]) {
// Create a fake axis object where the extended ordinal positions are emulated
fakeAxis = {
series: [],
chart: chart,
getExtremes: function() {
return {
min: extremes.dataMin,
max: extremes.dataMax
};
},
options: {
ordinal: true
},
val2lin: Axis.prototype.val2lin, // #2590
ordinal2lin: Axis.prototype.ordinal2lin // #6276
};
// Add the fake series to hold the full data, then apply processData to it
each(axis.series, function(series) {
fakeSeries = {
xAxis: fakeAxis,
xData: series.xData,
chart: chart,
destroyGroupedData: noop
};
fakeSeries.options = {
dataGrouping: grouping ? {
enabled: true,
forced: true,
approximation: 'open', // doesn't matter which, use the fastest
units: [
[grouping.unitName, [grouping.count]]
]
} : {
enabled: false
}
};
series.processData.apply(fakeSeries);
fakeAxis.series.push(fakeSeries);
});
// Run beforeSetTickPositions to compute the ordinalPositions
axis.beforeSetTickPositions.apply(fakeAxis);
// Cache it
ordinalIndex[key] = fakeAxis.ordinalPositions;
}
return ordinalIndex[key];
},
/**
* Find the factor to estimate how wide the plot area would have been if ordinal
* gaps were included. This value is used to compute an imagined plot width in order
* to establish the data grouping interval.
*
* A real world case is the intraday-candlestick
* example. Without this logic, it would show the correct data grouping when viewing
* a range within each day, but once moving the range to include the gap between two
* days, the interval would include the cut-away night hours and the data grouping
* would be wrong. So the below method tries to compensate by identifying the most
* common point interval, in this case days.
*
* An opposite case is presented in issue #718. We have a long array of daily data,
* then one point is appended one hour after the last point. We expect the data grouping
* not to change.
*
* In the future, if we find cases where this estimation doesn't work optimally, we
* might need to add a second pass to the data grouping logic, where we do another run
* with a greater interval if the number of data groups is more than a certain fraction
* of the desired group count.
*/
getGroupIntervalFactor: function(xMin, xMax, series) {
var i,
processedXData = series.processedXData,
len = processedXData.length,
distances = [],
median,
groupIntervalFactor = this.groupIntervalFactor;
// Only do this computation for the first series, let the other inherit it (#2416)
if (!groupIntervalFactor) {
// Register all the distances in an array
for (i = 0; i < len - 1; i++) {
distances[i] = processedXData[i + 1] - processedXData[i];
}
// Sort them and find the median
distances.sort(function(a, b) {
return a - b;
});
median = distances[Math.floor(len / 2)];
// Compensate for series that don't extend through the entire axis extent. #1675.
xMin = Math.max(xMin, processedXData[0]);
xMax = Math.min(xMax, processedXData[len - 1]);
this.groupIntervalFactor = groupIntervalFactor = (len * median) / (xMax - xMin);
}
// Return the factor needed for data grouping
return groupIntervalFactor;
},
/**
* Make the tick intervals closer because the ordinal gaps make the ticks spread out or cluster
*/
postProcessTickInterval: function(tickInterval) {
// Problem: http://jsfiddle.net/highcharts/FQm4E/1/
// This is a case where this algorithm doesn't work optimally. In this case, the
// tick labels are spread out per week, but all the gaps reside within weeks. So
// we have a situation where the labels are courser than the ordinal gaps, and
// thus the tick interval should not be altered
var ordinalSlope = this.ordinalSlope,
ret;
if (ordinalSlope) {
if (!this.options.breaks) {
ret = tickInterval / (ordinalSlope / this.closestPointRange);
} else {
ret = this.closestPointRange;
}
} else {
ret = tickInterval;
}
return ret;
}
});
// Record this to prevent overwriting by broken-axis module (#5979)
Axis.prototype.ordinal2lin = Axis.prototype.val2lin;
// Extending the Chart.pan method for ordinal axes
wrap(Chart.prototype, 'pan', function(proceed, e) {
var chart = this,
xAxis = chart.xAxis[0],
chartX = e.chartX,
runBase = false;
if (xAxis.options.ordinal && xAxis.series.length) {
var mouseDownX = chart.mouseDownX,
extremes = xAxis.getExtremes(),
dataMax = extremes.dataMax,
min = extremes.min,
max = extremes.max,
trimmedRange,
hoverPoints = chart.hoverPoints,
closestPointRange = xAxis.closestPointRange,
pointPixelWidth = xAxis.translationSlope * (xAxis.ordinalSlope || closestPointRange),
movedUnits = (mouseDownX - chartX) / pointPixelWidth, // how many ordinal units did we move?
extendedAxis = {
ordinalPositions: xAxis.getExtendedPositions()
}, // get index of all the chart's points
ordinalPositions,
searchAxisLeft,
lin2val = xAxis.lin2val,
val2lin = xAxis.val2lin,
searchAxisRight;
if (!extendedAxis.ordinalPositions) { // we have an ordinal axis, but the data is equally spaced
runBase = true;
} else if (Math.abs(movedUnits) > 1) {
// Remove active points for shared tooltip
if (hoverPoints) {
each(hoverPoints, function(point) {
point.setState();
});
}
if (movedUnits < 0) {
searchAxisLeft = extendedAxis;
searchAxisRight = xAxis.ordinalPositions ? xAxis : extendedAxis;
} else {
searchAxisLeft = xAxis.ordinalPositions ? xAxis : extendedAxis;
searchAxisRight = extendedAxis;
}
// In grouped data series, the last ordinal position represents the grouped data, which is
// to the left of the real data max. If we don't compensate for this, we will be allowed
// to pan grouped data series passed the right of the plot area.
ordinalPositions = searchAxisRight.ordinalPositions;
if (dataMax > ordinalPositions[ordinalPositions.length - 1]) {
ordinalPositions.push(dataMax);
}
// Get the new min and max values by getting the ordinal index for the current extreme,
// then add the moved units and translate back to values. This happens on the
// extended ordinal positions if the new position is out of range, else it happens
// on the current x axis which is smaller and faster.
chart.fixedRange = max - min;
trimmedRange = xAxis.toFixedRange(null, null,
lin2val.apply(searchAxisLeft, [
val2lin.apply(searchAxisLeft, [min, true]) + movedUnits, // the new index
true // translate from index
]),
lin2val.apply(searchAxisRight, [
val2lin.apply(searchAxisRight, [max, true]) + movedUnits, // the new index
true // translate from index
])
);
// Apply it if it is within the available data range
if (trimmedRange.min >= Math.min(extremes.dataMin, min) && trimmedRange.max <= Math.max(dataMax, max)) {
xAxis.setExtremes(trimmedRange.min, trimmedRange.max, true, false, {
trigger: 'pan'
});
}
chart.mouseDownX = chartX; // set new reference for next run
css(chart.container, {
cursor: 'move'
});
}
} else {
runBase = true;
}
// revert to the linear chart.pan version
if (runBase) {
// call the original function
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
}
});
/**
* Extend getGraphPath by identifying gaps in the ordinal data so that we can draw a gap in the
* line or area
*/
Series.prototype.gappedPath = function() {
var gapSize = this.options.gapSize,
points = this.points.slice(),
i = points.length - 1;
if (gapSize && i > 0) { // #5008
// extension for ordinal breaks
while (i--) {
if (points[i + 1].x - points[i].x > this.closestPointRange * gapSize) {
points.splice( // insert after this one
i + 1,
0, {
isNull: true
}
);
}
}
}
// Call base method
//return proceed.call(this, points, a, b);
return this.getGraphPath(points);
};
/* ****************************************************************************
* End ordinal axis logic *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var pick = H.pick,
wrap = H.wrap,
each = H.each,
extend = H.extend,
isArray = H.isArray,
fireEvent = H.fireEvent,
Axis = H.Axis,
Series = H.Series;
function stripArguments() {
return Array.prototype.slice.call(arguments, 1);
}
extend(Axis.prototype, {
isInBreak: function(brk, val) {
var ret,
repeat = brk.repeat || Infinity,
from = brk.from,
length = brk.to - brk.from,
test = (val >= from ? (val - from) % repeat : repeat - ((from - val) % repeat));
if (!brk.inclusive) {
ret = test < length && test !== 0;
} else {
ret = test <= length;
}
return ret;
},
isInAnyBreak: function(val, testKeep) {
var breaks = this.options.breaks,
i = breaks && breaks.length,
inbrk,
keep,
ret;
if (i) {
while (i--) {
if (this.isInBreak(breaks[i], val)) {
inbrk = true;
if (!keep) {
keep = pick(breaks[i].showPoints, this.isXAxis ? false : true);
}
}
}
if (inbrk && testKeep) {
ret = inbrk && !keep;
} else {
ret = inbrk;
}
}
return ret;
}
});
wrap(Axis.prototype, 'setTickPositions', function(proceed) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
if (this.options.breaks) {
var axis = this,
tickPositions = this.tickPositions,
info = this.tickPositions.info,
newPositions = [],
i;
for (i = 0; i < tickPositions.length; i++) {
if (!axis.isInAnyBreak(tickPositions[i])) {
newPositions.push(tickPositions[i]);
}
}
this.tickPositions = newPositions;
this.tickPositions.info = info;
}
});
wrap(Axis.prototype, 'init', function(proceed, chart, userOptions) {
var axis = this,
breaks;
// Force Axis to be not-ordinal when breaks are defined
if (userOptions.breaks && userOptions.breaks.length) {
userOptions.ordinal = false;
}
proceed.call(this, chart, userOptions);
breaks = this.options.breaks;
axis.isBroken = (isArray(breaks) && !!breaks.length);
if (axis.isBroken) {
axis.val2lin = function(val) {
var nval = val,
brk,
i;
for (i = 0; i < axis.breakArray.length; i++) {
brk = axis.breakArray[i];
if (brk.to <= val) {
nval -= brk.len;
} else if (brk.from >= val) {
break;
} else if (axis.isInBreak(brk, val)) {
nval -= (val - brk.from);
break;
}
}
return nval;
};
axis.lin2val = function(val) {
var nval = val,
brk,
i;
for (i = 0; i < axis.breakArray.length; i++) {
brk = axis.breakArray[i];
if (brk.from >= nval) {
break;
} else if (brk.to < nval) {
nval += brk.len;
} else if (axis.isInBreak(brk, nval)) {
nval += brk.len;
}
}
return nval;
};
axis.setExtremes = function(newMin, newMax, redraw, animation, eventArguments) {
// If trying to set extremes inside a break, extend it to before and after the break ( #3857 )
while (this.isInAnyBreak(newMin)) {
newMin -= this.closestPointRange;
}
while (this.isInAnyBreak(newMax)) {
newMax -= this.closestPointRange;
}
Axis.prototype.setExtremes.call(this, newMin, newMax, redraw, animation, eventArguments);
};
axis.setAxisTranslation = function(saveOld) {
Axis.prototype.setAxisTranslation.call(this, saveOld);
var breaks = axis.options.breaks,
breakArrayT = [], // Temporary one
breakArray = [],
length = 0,
inBrk,
repeat,
brk,
min = axis.userMin || axis.min,
max = axis.userMax || axis.max,
pointRangePadding = pick(axis.pointRangePadding, 0),
start,
i,
j;
// Min & max check (#4247)
for (i in breaks) {
brk = breaks[i];
repeat = brk.repeat || Infinity;
if (axis.isInBreak(brk, min)) {
min += (brk.to % repeat) - (min % repeat);
}
if (axis.isInBreak(brk, max)) {
max -= (max % repeat) - (brk.from % repeat);
}
}
// Construct an array holding all breaks in the axis
for (i in breaks) {
brk = breaks[i];
start = brk.from;
repeat = brk.repeat || Infinity;
while (start - repeat > min) {
start -= repeat;
}
while (start < min) {
start += repeat;
}
for (j = start; j < max; j += repeat) {
breakArrayT.push({
value: j,
move: 'in'
});
breakArrayT.push({
value: j + (brk.to - brk.from),
move: 'out',
size: brk.breakSize
});
}
}
breakArrayT.sort(function(a, b) {
var ret;
if (a.value === b.value) {
ret = (a.move === 'in' ? 0 : 1) - (b.move === 'in' ? 0 : 1);
} else {
ret = a.value - b.value;
}
return ret;
});
// Simplify the breaks
inBrk = 0;
start = min;
for (i in breakArrayT) {
brk = breakArrayT[i];
inBrk += (brk.move === 'in' ? 1 : -1);
if (inBrk === 1 && brk.move === 'in') {
start = brk.value;
}
if (inBrk === 0) {
breakArray.push({
from: start,
to: brk.value,
len: brk.value - start - (brk.size || 0)
});
length += brk.value - start - (brk.size || 0);
}
}
axis.breakArray = breakArray;
// Used with staticScale, and below, the actual axis length when
// breaks are substracted.
axis.unitLength = max - min - length + pointRangePadding;
fireEvent(axis, 'afterBreaks');
if (axis.options.staticScale) {
axis.transA = axis.options.staticScale;
} else {
axis.transA *= (max - axis.min + pointRangePadding) /
axis.unitLength;
}
if (pointRangePadding) {
axis.minPixelPadding = axis.transA * axis.minPointOffset;
}
axis.min = min;
axis.max = max;
};
}
});
wrap(Series.prototype, 'generatePoints', function(proceed) {
proceed.apply(this, stripArguments(arguments));
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis,
points = series.points,
point,
i = points.length,
connectNulls = series.options.connectNulls,
nullGap;
if (xAxis && yAxis && (xAxis.options.breaks || yAxis.options.breaks)) {
while (i--) {
point = points[i];
nullGap = point.y === null && connectNulls === false; // respect nulls inside the break (#4275)
if (!nullGap && (xAxis.isInAnyBreak(point.x, true) || yAxis.isInAnyBreak(point.y, true))) {
points.splice(i, 1);
if (this.data[i]) {
this.data[i].destroyElements(); // removes the graphics for this point if they exist
}
}
}
}
});
function drawPointsWrapped(proceed) {
proceed.apply(this);
this.drawBreaks(this.xAxis, ['x']);
this.drawBreaks(this.yAxis, pick(this.pointArrayMap, ['y']));
}
H.Series.prototype.drawBreaks = function(axis, keys) {
var series = this,
points = series.points,
breaks,
threshold,
eventName,
y;
if (!axis) {
return; // #5950
}
each(keys, function(key) {
breaks = axis.breakArray || [];
threshold = axis.isXAxis ? axis.min : pick(series.options.threshold, axis.min);
each(points, function(point) {
y = pick(point['stack' + key.toUpperCase()], point[key]);
each(breaks, function(brk) {
eventName = false;
if ((threshold < brk.from && y > brk.to) || (threshold > brk.from && y < brk.from)) {
eventName = 'pointBreak';
} else if ((threshold < brk.from && y > brk.from && y < brk.to) || (threshold > brk.from && y > brk.to && y < brk.from)) { // point falls inside the break
eventName = 'pointInBreak';
}
if (eventName) {
fireEvent(axis, eventName, {
point: point,
brk: brk
});
}
});
});
});
};
wrap(H.seriesTypes.column.prototype, 'drawPoints', drawPointsWrapped);
wrap(H.Series.prototype, 'drawPoints', drawPointsWrapped);
}(Highcharts));
(function() {
}());
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
Axis = H.Axis,
defaultPlotOptions = H.defaultPlotOptions,
defined = H.defined,
each = H.each,
extend = H.extend,
format = H.format,
isNumber = H.isNumber,
merge = H.merge,
pick = H.pick,
Point = H.Point,
Series = H.Series,
Tooltip = H.Tooltip,
wrap = H.wrap;
/* ****************************************************************************
* Start data grouping module *
******************************************************************************/
var seriesProto = Series.prototype,
baseProcessData = seriesProto.processData,
baseGeneratePoints = seriesProto.generatePoints,
baseDestroy = seriesProto.destroy,
commonOptions = {
approximation: 'average', // average, open, high, low, close, sum
//enabled: null, // (true for stock charts, false for basic),
//forced: undefined,
groupPixelWidth: 2,
// the first one is the point or start value, the second is the start value if we're dealing with range,
// the third one is the end value if dealing with a range
dateTimeLabelFormats: {
millisecond: ['%A, %b %e, %H:%M:%S.%L', '%A, %b %e, %H:%M:%S.%L', '-%H:%M:%S.%L'],
second: ['%A, %b %e, %H:%M:%S', '%A, %b %e, %H:%M:%S', '-%H:%M:%S'],
minute: ['%A, %b %e, %H:%M', '%A, %b %e, %H:%M', '-%H:%M'],
hour: ['%A, %b %e, %H:%M', '%A, %b %e, %H:%M', '-%H:%M'],
day: ['%A, %b %e, %Y', '%A, %b %e', '-%A, %b %e, %Y'],
week: ['Week from %A, %b %e, %Y', '%A, %b %e', '-%A, %b %e, %Y'],
month: ['%B %Y', '%B', '-%B %Y'],
year: ['%Y', '%Y', '-%Y']
}
// smoothed = false, // enable this for navigator series only
},
specificOptions = { // extends common options
line: {},
spline: {},
area: {},
areaspline: {},
column: {
approximation: 'sum',
groupPixelWidth: 10
},
arearange: {
approximation: 'range'
},
areasplinerange: {
approximation: 'range'
},
columnrange: {
approximation: 'range',
groupPixelWidth: 10
},
candlestick: {
approximation: 'ohlc',
groupPixelWidth: 10
},
ohlc: {
approximation: 'ohlc',
groupPixelWidth: 5
}
},
// units are defined in a separate array to allow complete overriding in case of a user option
defaultDataGroupingUnits = H.defaultDataGroupingUnits = [
[
'millisecond', // unit name
[1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
],
[
'second', [1, 2, 5, 10, 15, 30]
],
[
'minute', [1, 2, 5, 10, 15, 30]
],
[
'hour', [1, 2, 3, 4, 6, 8, 12]
],
[
'day', [1]
],
[
'week', [1]
],
[
'month', [1, 3, 6]
],
[
'year',
null
]
],
/**
* Define the available approximation types. The data grouping approximations takes an array
* or numbers as the first parameter. In case of ohlc, four arrays are sent in as four parameters.
* Each array consists only of numbers. In case null values belong to the group, the property
* .hasNulls will be set to true on the array.
*/
approximations = {
sum: function(arr) {
var len = arr.length,
ret;
// 1. it consists of nulls exclusively
if (!len && arr.hasNulls) {
ret = null;
// 2. it has a length and real values
} else if (len) {
ret = 0;
while (len--) {
ret += arr[len];
}
}
// 3. it has zero length, so just return undefined
// => doNothing()
return ret;
},
average: function(arr) {
var len = arr.length,
ret = approximations.sum(arr);
// If we have a number, return it divided by the length. If not, return
// null or undefined based on what the sum method finds.
if (isNumber(ret) && len) {
ret = ret / len;
}
return ret;
},
open: function(arr) {
return arr.length ? arr[0] : (arr.hasNulls ? null : undefined);
},
high: function(arr) {
return arr.length ? arrayMax(arr) : (arr.hasNulls ? null : undefined);
},
low: function(arr) {
return arr.length ? arrayMin(arr) : (arr.hasNulls ? null : undefined);
},
close: function(arr) {
return arr.length ? arr[arr.length - 1] : (arr.hasNulls ? null : undefined);
},
// ohlc and range are special cases where a multidimensional array is input and an array is output
ohlc: function(open, high, low, close) {
open = approximations.open(open);
high = approximations.high(high);
low = approximations.low(low);
close = approximations.close(close);
if (isNumber(open) || isNumber(high) || isNumber(low) || isNumber(close)) {
return [open, high, low, close];
}
// else, return is undefined
},
range: function(low, high) {
low = approximations.low(low);
high = approximations.high(high);
if (isNumber(low) || isNumber(high)) {
return [low, high];
}
// else, return is undefined
}
};
/**
* Takes parallel arrays of x and y data and groups the data into intervals defined by groupPositions, a collection
* of starting x values for each group.
*/
seriesProto.groupData = function(xData, yData, groupPositions, approximation) {
var series = this,
data = series.data,
dataOptions = series.options.data,
groupedXData = [],
groupedYData = [],
groupMap = [],
dataLength = xData.length,
pointX,
pointY,
groupedY,
handleYData = !!yData, // when grouping the fake extended axis for panning, we don't need to consider y
values = [
[],
[],
[],
[]
],
approximationFn = typeof approximation === 'function' ? approximation : approximations[approximation],
pointArrayMap = series.pointArrayMap,
pointArrayMapLength = pointArrayMap && pointArrayMap.length,
i,
pos = 0,
start = 0;
// Start with the first point within the X axis range (#2696)
for (i = 0; i <= dataLength; i++) {
if (xData[i] >= groupPositions[0]) {
break;
}
}
for (i; i <= dataLength; i++) {
// when a new group is entered, summarize and initiate the previous group
while ((groupPositions[pos + 1] !== undefined && xData[i] >= groupPositions[pos + 1]) ||
i === dataLength) { // get the last group
// get group x and y
pointX = groupPositions[pos];
series.dataGroupInfo = {
start: start,
length: values[0].length
};
groupedY = approximationFn.apply(series, values);
// push the grouped data
if (groupedY !== undefined) {
groupedXData.push(pointX);
groupedYData.push(groupedY);
groupMap.push(series.dataGroupInfo);
}
// reset the aggregate arrays
start = i;
values[0] = [];
values[1] = [];
values[2] = [];
values[3] = [];
// Advance on the group positions
pos += 1;
// don't loop beyond the last group
if (i === dataLength) {
break;
}
}
// break out
if (i === dataLength) {
break;
}
// for each raw data point, push it to an array that contains all values for this specific group
if (pointArrayMap) {
var index = series.cropStart + i,
point = (data && data[index]) || series.pointClass.prototype.applyOptions.apply({
series: series
}, [dataOptions[index]]),
j,
val;
for (j = 0; j < pointArrayMapLength; j++) {
val = point[pointArrayMap[j]];
if (isNumber(val)) {
values[j].push(val);
} else if (val === null) {
values[j].hasNulls = true;
}
}
} else {
pointY = handleYData ? yData[i] : null;
if (isNumber(pointY)) {
values[0].push(pointY);
} else if (pointY === null) {
values[0].hasNulls = true;
}
}
}
return [groupedXData, groupedYData, groupMap];
};
/**
* Extend the basic processData method, that crops the data to the current zoom
* range, with data grouping logic.
*/
seriesProto.processData = function() {
var series = this,
chart = series.chart,
options = series.options,
dataGroupingOptions = options.dataGrouping,
groupingEnabled = series.allowDG !== false && dataGroupingOptions &&
pick(dataGroupingOptions.enabled, chart.options.isStock),
visible = series.visible || !chart.options.chart.ignoreHiddenSeries,
hasGroupedData,
skip;
// run base method
series.forceCrop = groupingEnabled; // #334
series.groupPixelWidth = null; // #2110
series.hasProcessed = true; // #2692
// skip if processData returns false or if grouping is disabled (in that order)
skip = baseProcessData.apply(series, arguments) === false || !groupingEnabled;
if (!skip) {
series.destroyGroupedData();
var i,
processedXData = series.processedXData,
processedYData = series.processedYData,
plotSizeX = chart.plotSizeX,
xAxis = series.xAxis,
ordinal = xAxis.options.ordinal,
groupPixelWidth = series.groupPixelWidth = xAxis.getGroupPixelWidth && xAxis.getGroupPixelWidth();
// Execute grouping if the amount of points is greater than the limit defined in groupPixelWidth
if (groupPixelWidth) {
hasGroupedData = true;
series.isDirty = true; // force recreation of point instances in series.translate, #5699
var extremes = xAxis.getExtremes(),
xMin = extremes.min,
xMax = extremes.max,
groupIntervalFactor = (ordinal && xAxis.getGroupIntervalFactor(xMin, xMax, series)) || 1,
interval = (groupPixelWidth * (xMax - xMin) / plotSizeX) * groupIntervalFactor,
groupPositions = xAxis.getTimeTicks(
xAxis.normalizeTimeTickInterval(interval, dataGroupingOptions.units || defaultDataGroupingUnits),
Math.min(xMin, processedXData[0]), // Processed data may extend beyond axis (#4907)
Math.max(xMax, processedXData[processedXData.length - 1]),
xAxis.options.startOfWeek,
processedXData,
series.closestPointRange
),
groupedData = seriesProto.groupData.apply(series, [processedXData, processedYData, groupPositions, dataGroupingOptions.approximation]),
groupedXData = groupedData[0],
groupedYData = groupedData[1];
// prevent the smoothed data to spill out left and right, and make
// sure data is not shifted to the left
if (dataGroupingOptions.smoothed) {
i = groupedXData.length - 1;
groupedXData[i] = Math.min(groupedXData[i], xMax);
while (i-- && i > 0) {
groupedXData[i] += interval / 2;
}
groupedXData[0] = Math.max(groupedXData[0], xMin);
}
// record what data grouping values were used
series.currentDataGrouping = groupPositions.info;
series.closestPointRange = groupPositions.info.totalRange;
series.groupMap = groupedData[2];
// Make sure the X axis extends to show the first group (#2533)
// But only for visible series (#5493, #6393)
if (defined(groupedXData[0]) && groupedXData[0] < xAxis.dataMin && visible) {
if (xAxis.min === xAxis.dataMin) {
xAxis.min = groupedXData[0];
}
xAxis.dataMin = groupedXData[0];
}
// set series props
series.processedXData = groupedXData;
series.processedYData = groupedYData;
} else {
series.currentDataGrouping = series.groupMap = null;
}
series.hasGroupedData = hasGroupedData;
}
};
/**
* Destroy the grouped data points. #622, #740
*/
seriesProto.destroyGroupedData = function() {
var groupedData = this.groupedData;
// clear previous groups
each(groupedData || [], function(point, i) {
if (point) {
groupedData[i] = point.destroy ? point.destroy() : null;
}
});
this.groupedData = null;
};
/**
* Override the generatePoints method by adding a reference to grouped data
*/
seriesProto.generatePoints = function() {
baseGeneratePoints.apply(this);
// record grouped data in order to let it be destroyed the next time processData runs
this.destroyGroupedData(); // #622
this.groupedData = this.hasGroupedData ? this.points : null;
};
/**
* Override point prototype to throw a warning when trying to update grouped points
*/
wrap(Point.prototype, 'update', function(proceed) {
if (this.dataGroup) {
H.error(24);
} else {
proceed.apply(this, [].slice.call(arguments, 1));
}
});
/**
* Extend the original method, make the tooltip's header reflect the grouped range
*/
wrap(Tooltip.prototype, 'tooltipFooterHeaderFormatter', function(proceed, labelConfig, isFooter) {
var tooltip = this,
series = labelConfig.series,
options = series.options,
tooltipOptions = series.tooltipOptions,
dataGroupingOptions = options.dataGrouping,
xDateFormat = tooltipOptions.xDateFormat,
xDateFormatEnd,
xAxis = series.xAxis,
dateFormat = H.dateFormat,
currentDataGrouping,
dateTimeLabelFormats,
labelFormats,
formattedKey;
// apply only to grouped series
if (xAxis && xAxis.options.type === 'datetime' && dataGroupingOptions && isNumber(labelConfig.key)) {
// set variables
currentDataGrouping = series.currentDataGrouping;
dateTimeLabelFormats = dataGroupingOptions.dateTimeLabelFormats;
// if we have grouped data, use the grouping information to get the right format
if (currentDataGrouping) {
labelFormats = dateTimeLabelFormats[currentDataGrouping.unitName];
if (currentDataGrouping.count === 1) {
xDateFormat = labelFormats[0];
} else {
xDateFormat = labelFormats[1];
xDateFormatEnd = labelFormats[2];
}
// if not grouped, and we don't have set the xDateFormat option, get the best fit,
// so if the least distance between points is one minute, show it, but if the
// least distance is one day, skip hours and minutes etc.
} else if (!xDateFormat && dateTimeLabelFormats) {
xDateFormat = tooltip.getXDateFormat(labelConfig, tooltipOptions, xAxis);
}
// now format the key
formattedKey = dateFormat(xDateFormat, labelConfig.key);
if (xDateFormatEnd) {
formattedKey += dateFormat(xDateFormatEnd, labelConfig.key + currentDataGrouping.totalRange - 1);
}
// return the replaced format
return format(tooltipOptions[(isFooter ? 'footer' : 'header') + 'Format'], {
point: extend(labelConfig.point, {
key: formattedKey
}),
series: series
});
}
// else, fall back to the regular formatter
return proceed.call(tooltip, labelConfig, isFooter);
});
/**
* Extend the series destroyer
*/
seriesProto.destroy = function() {
var series = this,
groupedData = series.groupedData || [],
i = groupedData.length;
while (i--) {
if (groupedData[i]) {
groupedData[i].destroy();
}
}
baseDestroy.apply(series);
};
// Handle default options for data grouping. This must be set at runtime because some series types are
// defined after this.
wrap(seriesProto, 'setOptions', function(proceed, itemOptions) {
var options = proceed.call(this, itemOptions),
type = this.type,
plotOptions = this.chart.options.plotOptions,
defaultOptions = defaultPlotOptions[type].dataGrouping;
if (specificOptions[type]) { // #1284
if (!defaultOptions) {
defaultOptions = merge(commonOptions, specificOptions[type]);
}
options.dataGrouping = merge(
defaultOptions,
plotOptions.series && plotOptions.series.dataGrouping, // #1228
plotOptions[type].dataGrouping, // Set by the StockChart constructor
itemOptions.dataGrouping
);
}
if (this.chart.options.isStock) {
this.requireSorting = true;
}
return options;
});
/**
* When resetting the scale reset the hasProccessed flag to avoid taking previous data grouping
* of neighbour series into accound when determining group pixel width (#2692).
*/
wrap(Axis.prototype, 'setScale', function(proceed) {
proceed.call(this);
each(this.series, function(series) {
series.hasProcessed = false;
});
});
/**
* Get the data grouping pixel width based on the greatest defined individual width
* of the axis' series, and if whether one of the axes need grouping.
*/
Axis.prototype.getGroupPixelWidth = function() {
var series = this.series,
len = series.length,
i,
groupPixelWidth = 0,
doGrouping = false,
dataLength,
dgOptions;
// If multiple series are compared on the same x axis, give them the same
// group pixel width (#334)
i = len;
while (i--) {
dgOptions = series[i].options.dataGrouping;
if (dgOptions) {
groupPixelWidth = Math.max(groupPixelWidth, dgOptions.groupPixelWidth);
}
}
// If one of the series needs grouping, apply it to all (#1634)
i = len;
while (i--) {
dgOptions = series[i].options.dataGrouping;
if (dgOptions && series[i].hasProcessed) { // #2692
dataLength = (series[i].processedXData || series[i].data).length;
// Execute grouping if the amount of points is greater than the limit defined in groupPixelWidth
if (series[i].groupPixelWidth || dataLength > (this.chart.plotSizeX / groupPixelWidth) || (dataLength && dgOptions.forced)) {
doGrouping = true;
}
}
}
return doGrouping ? groupPixelWidth : 0;
};
/**
* Force data grouping on all the axis' series.
*/
Axis.prototype.setDataGrouping = function(dataGrouping, redraw) {
var i;
redraw = pick(redraw, true);
if (!dataGrouping) {
dataGrouping = {
forced: false,
units: null
};
}
// Axis is instantiated, update all series
if (this instanceof Axis) {
i = this.series.length;
while (i--) {
this.series[i].update({
dataGrouping: dataGrouping
}, false);
}
// Axis not yet instanciated, alter series options
} else {
each(this.chart.options.series, function(seriesOptions) {
seriesOptions.dataGrouping = dataGrouping;
}, false);
}
if (redraw) {
this.chart.redraw();
}
};
/* ****************************************************************************
* End data grouping module *
******************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var each = H.each,
Point = H.Point,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/**
* The ohlc series type.
*
* @constructor seriesTypes.ohlc
* @augments seriesTypes.column
*/
seriesType('ohlc', 'column', {
lineWidth: 1,
tooltip: {
pointFormat: '<span style="color:{point.color}">\u25CF</span> <b> {series.name}</b><br/>' +
'Open: {point.open}<br/>' +
'High: {point.high}<br/>' +
'Low: {point.low}<br/>' +
'Close: {point.close}<br/>'
},
threshold: null,
states: {
hover: {
lineWidth: 3
}
},
stickyTracking: true
//upColor: undefined
}, /** @lends seriesTypes.ohlc */ {
directTouch: false,
pointArrayMap: ['open', 'high', 'low', 'close'], // array point configs are mapped to this
toYData: function(point) { // return a plain array for speedy calculation
return [point.open, point.high, point.low, point.close];
},
pointValKey: 'high',
pointAttrToOptions: {
'stroke': 'color',
'stroke-width': 'lineWidth'
},
/**
* Postprocess mapping between options and SVG attributes
*/
pointAttribs: function(point, state) {
var attribs = seriesTypes.column.prototype.pointAttribs.call(
this,
point,
state
),
options = this.options;
delete attribs.fill;
if (!point.options.color &&
options.upColor &&
point.open < point.close
) {
attribs.stroke = options.upColor;
}
return attribs;
},
/**
* Translate data points from raw values x and y to plotX and plotY
*/
translate: function() {
var series = this,
yAxis = series.yAxis,
hasModifyValue = !!series.modifyValue,
translated = ['plotOpen', 'plotHigh', 'plotLow', 'plotClose', 'yBottom']; // translate OHLC for
seriesTypes.column.prototype.translate.apply(series);
// Do the translation
each(series.points, function(point) {
each([point.open, point.high, point.low, point.close, point.low], function(value, i) {
if (value !== null) {
if (hasModifyValue) {
value = series.modifyValue(value);
}
point[translated[i]] = yAxis.toPixels(value, true);
}
});
});
},
/**
* Draw the data points
*/
drawPoints: function() {
var series = this,
points = series.points,
chart = series.chart;
each(points, function(point) {
var plotOpen,
plotClose,
crispCorr,
halfWidth,
path,
graphic = point.graphic,
crispX,
isNew = !graphic;
if (point.plotY !== undefined) {
// Create and/or update the graphic
if (!graphic) {
point.graphic = graphic = chart.renderer.path()
.add(series.group);
}
graphic.attr(series.pointAttribs(point, point.selected && 'select')); // #3897
// crisp vector coordinates
crispCorr = (graphic.strokeWidth() % 2) / 2;
crispX = Math.round(point.plotX) - crispCorr; // #2596
halfWidth = Math.round(point.shapeArgs.width / 2);
// the vertical stem
path = [
'M',
crispX, Math.round(point.yBottom),
'L',
crispX, Math.round(point.plotY)
];
// open
if (point.open !== null) {
plotOpen = Math.round(point.plotOpen) + crispCorr;
path.push(
'M',
crispX,
plotOpen,
'L',
crispX - halfWidth,
plotOpen
);
}
// close
if (point.close !== null) {
plotClose = Math.round(point.plotClose) + crispCorr;
path.push(
'M',
crispX,
plotClose,
'L',
crispX + halfWidth,
plotClose
);
}
graphic[isNew ? 'attr' : 'animate']({
d: path
})
.addClass(point.getClassName(), true);
}
});
},
animate: null // Disable animation
/**
* @constructor seriesTypes.ohlc.prototype.pointClass
* @extends {Point}
*/
}, /** @lends seriesTypes.ohlc.prototype.pointClass.prototype */ {
/**
* Extend the parent method by adding up or down to the class name.
*/
getClassName: function() {
return Point.prototype.getClassName.call(this) +
(this.open < this.close ? ' highcharts-point-up' : ' highcharts-point-down');
}
});
/* ****************************************************************************
* End OHLC series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var defaultPlotOptions = H.defaultPlotOptions,
each = H.each,
merge = H.merge,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes;
/**
* The candlestick series type.
*
* @constructor seriesTypes.candlestick
* @augments seriesTypes.ohlc
*/
seriesType('candlestick', 'ohlc', merge(defaultPlotOptions.column, {
states: {
hover: {
lineWidth: 2
}
},
tooltip: defaultPlotOptions.ohlc.tooltip,
threshold: null,
lineColor: '#000000',
lineWidth: 1,
upColor: '#ffffff',
stickyTracking: true
// upLineColor: null
}), /** @lends seriesTypes.candlestick */ {
/**
* Postprocess mapping between options and SVG attributes
*/
pointAttribs: function(point, state) {
var attribs = seriesTypes.column.prototype.pointAttribs.call(this, point, state),
options = this.options,
isUp = point.open < point.close,
stroke = options.lineColor || this.color,
stateOptions;
attribs['stroke-width'] = options.lineWidth;
attribs.fill = point.options.color || (isUp ? (options.upColor || this.color) : this.color);
attribs.stroke = point.lineColor || (isUp ? (options.upLineColor || stroke) : stroke);
// Select or hover states
if (state) {
stateOptions = options.states[state];
attribs.fill = stateOptions.color || attribs.fill;
attribs.stroke = stateOptions.lineColor || attribs.stroke;
attribs['stroke-width'] =
stateOptions.lineWidth || attribs['stroke-width'];
}
return attribs;
},
/**
* Draw the data points
*/
drawPoints: function() {
var series = this, //state = series.state,
points = series.points,
chart = series.chart;
each(points, function(point) {
var graphic = point.graphic,
plotOpen,
plotClose,
topBox,
bottomBox,
hasTopWhisker,
hasBottomWhisker,
crispCorr,
crispX,
path,
halfWidth,
isNew = !graphic;
if (point.plotY !== undefined) {
if (!graphic) {
point.graphic = graphic = chart.renderer.path()
.add(series.group);
}
graphic
.attr(series.pointAttribs(point, point.selected && 'select')) // #3897
.shadow(series.options.shadow);
// Crisp vector coordinates
crispCorr = (graphic.strokeWidth() % 2) / 2;
crispX = Math.round(point.plotX) - crispCorr; // #2596
plotOpen = point.plotOpen;
plotClose = point.plotClose;
topBox = Math.min(plotOpen, plotClose);
bottomBox = Math.max(plotOpen, plotClose);
halfWidth = Math.round(point.shapeArgs.width / 2);
hasTopWhisker = Math.round(topBox) !== Math.round(point.plotY);
hasBottomWhisker = bottomBox !== point.yBottom;
topBox = Math.round(topBox) + crispCorr;
bottomBox = Math.round(bottomBox) + crispCorr;
// Create the path. Due to a bug in Chrome 49, the path is first instanciated
// with no values, then the values pushed. For unknown reasons, instanciated
// the path array with all the values would lead to a crash when updating
// frequently (#5193).
path = [];
path.push(
'M',
crispX - halfWidth, bottomBox,
'L',
crispX - halfWidth, topBox,
'L',
crispX + halfWidth, topBox,
'L',
crispX + halfWidth, bottomBox,
'Z', // Use a close statement to ensure a nice rectangle #2602
'M',
crispX, topBox,
'L',
crispX, hasTopWhisker ? Math.round(point.plotY) : topBox, // #460, #2094
'M',
crispX, bottomBox,
'L',
crispX, hasBottomWhisker ? Math.round(point.yBottom) : bottomBox // #460, #2094
);
graphic[isNew ? 'attr' : 'animate']({
d: path
})
.addClass(point.getClassName(), true);
}
});
}
});
/* ****************************************************************************
* End Candlestick series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
each = H.each,
merge = H.merge,
noop = H.noop,
Renderer = H.Renderer,
Series = H.Series,
seriesType = H.seriesType,
seriesTypes = H.seriesTypes,
SVGRenderer = H.SVGRenderer,
TrackerMixin = H.TrackerMixin,
VMLRenderer = H.VMLRenderer,
symbols = SVGRenderer.prototype.symbols,
stableSort = H.stableSort;
/**
* The flags series type.
*
* @constructor seriesTypes.flags
* @augments seriesTypes.column
*/
seriesType('flags', 'column', {
pointRange: 0, // #673
//radius: 2,
shape: 'flag',
stackDistance: 12,
textAlign: 'center',
tooltip: {
pointFormat: '{point.text}<br/>'
},
threshold: null,
y: -30,
fillColor: '#ffffff',
// lineColor: color,
lineWidth: 1,
states: {
hover: {
lineColor: '#000000',
fillColor: '#ccd6eb'
}
},
style: {
fontSize: '11px',
fontWeight: 'bold'
}
}, /** @lends seriesTypes.flags.prototype */ {
sorted: false,
noSharedTooltip: true,
allowDG: false,
takeOrdinalPosition: false, // #1074
trackerGroups: ['markerGroup'],
forceCrop: true,
/**
* Inherit the initialization from base Series.
*/
init: Series.prototype.init,
/**
* Get presentational attributes
*/
pointAttribs: function(point, state) {
var options = this.options,
color = (point && point.color) || this.color,
lineColor = options.lineColor,
lineWidth = (point && point.lineWidth),
fill = (point && point.fillColor) || options.fillColor;
if (state) {
fill = options.states[state].fillColor;
lineColor = options.states[state].lineColor;
lineWidth = options.states[state].lineWidth;
}
return {
'fill': fill || color,
'stroke': lineColor || color,
'stroke-width': lineWidth || options.lineWidth || 0
};
},
/**
* Extend the translate method by placing the point on the related series
*/
translate: function() {
seriesTypes.column.prototype.translate.apply(this);
var series = this,
options = series.options,
chart = series.chart,
points = series.points,
cursor = points.length - 1,
point,
lastPoint,
optionsOnSeries = options.onSeries,
onSeries = optionsOnSeries && chart.get(optionsOnSeries),
onKey = options.onKey || 'y',
step = onSeries && onSeries.options.step,
onData = onSeries && onSeries.points,
i = onData && onData.length,
xAxis = series.xAxis,
yAxis = series.yAxis,
xAxisExt = xAxis.getExtremes(),
xOffset = 0,
leftPoint,
lastX,
rightPoint,
currentDataGrouping;
// relate to a master series
if (onSeries && onSeries.visible && i) {
xOffset = (onSeries.pointXOffset || 0) + (onSeries.barW || 0) / 2;
currentDataGrouping = onSeries.currentDataGrouping;
lastX = onData[i - 1].x + (currentDataGrouping ? currentDataGrouping.totalRange : 0); // #2374
// sort the data points
stableSort(points, function(a, b) {
return (a.x - b.x);
});
onKey = 'plot' + onKey[0].toUpperCase() + onKey.substr(1);
while (i-- && points[cursor]) {
point = points[cursor];
leftPoint = onData[i];
if (leftPoint.x <= point.x && leftPoint[onKey] !== undefined) {
if (point.x <= lastX) { // #803
point.plotY = leftPoint[onKey];
// interpolate between points, #666
if (leftPoint.x < point.x && !step) {
rightPoint = onData[i + 1];
if (rightPoint && rightPoint[onKey] !== undefined) {
point.plotY +=
((point.x - leftPoint.x) / (rightPoint.x - leftPoint.x)) * // the distance ratio, between 0 and 1
(rightPoint[onKey] - leftPoint[onKey]); // the y distance
}
}
}
cursor--;
i++; // check again for points in the same x position
if (cursor < 0) {
break;
}
}
}
}
// Add plotY position and handle stacking
each(points, function(point, i) {
var stackIndex;
// Undefined plotY means the point is either on axis, outside series
// range or hidden series. If the series is outside the range of the
// x axis it should fall through with an undefined plotY, but then
// we must remove the shapeArgs (#847).
if (point.plotY === undefined) {
if (point.x >= xAxisExt.min && point.x <= xAxisExt.max) {
// we're inside xAxis range
point.plotY = chart.chartHeight - xAxis.bottom -
(xAxis.opposite ? xAxis.height : 0) +
xAxis.offset - yAxis.top; // #3517
} else {
point.shapeArgs = {}; // 847
}
}
point.plotX += xOffset; // #2049
// if multiple flags appear at the same x, order them into a stack
lastPoint = points[i - 1];
if (lastPoint && lastPoint.plotX === point.plotX) {
if (lastPoint.stackIndex === undefined) {
lastPoint.stackIndex = 0;
}
stackIndex = lastPoint.stackIndex + 1;
}
point.stackIndex = stackIndex; // #3639
});
},
/**
* Draw the markers
*/
drawPoints: function() {
var series = this,
points = series.points,
chart = series.chart,
renderer = chart.renderer,
plotX,
plotY,
options = series.options,
optionsY = options.y,
shape,
i,
point,
graphic,
stackIndex,
anchorX,
anchorY,
outsideRight,
yAxis = series.yAxis;
i = points.length;
while (i--) {
point = points[i];
outsideRight = point.plotX > series.xAxis.len;
plotX = point.plotX;
stackIndex = point.stackIndex;
shape = point.options.shape || options.shape;
plotY = point.plotY;
if (plotY !== undefined) {
plotY = point.plotY + optionsY - (stackIndex !== undefined && stackIndex * options.stackDistance);
}
anchorX = stackIndex ? undefined : point.plotX; // skip connectors for higher level stacked points
anchorY = stackIndex ? undefined : point.plotY;
graphic = point.graphic;
// Only draw the point if y is defined and the flag is within the visible area
if (plotY !== undefined && plotX >= 0 && !outsideRight) {
// Create the flag
if (!graphic) {
graphic = point.graphic = renderer.label(
'',
null,
null,
shape,
null,
null,
options.useHTML
)
.attr(series.pointAttribs(point))
.css(merge(options.style, point.style))
.attr({
align: shape === 'flag' ? 'left' : 'center',
width: options.width,
height: options.height,
'text-align': options.textAlign
})
.addClass('highcharts-point')
.add(series.markerGroup);
// Add reference to the point for tracker (#6303)
if (point.graphic.div) {
point.graphic.div.point = point;
}
graphic.shadow(options.shadow);
}
if (plotX > 0) { // #3119
plotX -= graphic.strokeWidth() % 2; // #4285
}
// Plant the flag
graphic.attr({
text: point.options.title || options.title || 'A',
x: plotX,
y: plotY,
anchorX: anchorX,
anchorY: anchorY
});
// Set the tooltip anchor position
point.tooltipPos = chart.inverted ? [yAxis.len + yAxis.pos - chart.plotLeft - plotY, series.xAxis.len - plotX] : [plotX, plotY + yAxis.pos - chart.plotTop]; // #6327
} else if (graphic) {
point.graphic = graphic.destroy();
}
}
// Might be a mix of SVG and HTML and we need events for both (#6303)
if (options.useHTML) {
H.wrap(series.markerGroup, 'on', function(proceed) {
return H.SVGElement.prototype.on.apply(
proceed.apply(this, [].slice.call(arguments, 1)), // for HTML
[].slice.call(arguments, 1)); // and for SVG
});
}
},
/**
* Extend the column trackers with listeners to expand and contract stacks
*/
drawTracker: function() {
var series = this,
points = series.points;
TrackerMixin.drawTrackerPoint.apply(this);
// Bring each stacked flag up on mouse over, this allows readability of vertically
// stacked elements as well as tight points on the x axis. #1924.
each(points, function(point) {
var graphic = point.graphic;
if (graphic) {
addEvent(graphic.element, 'mouseover', function() {
// Raise this point
if (point.stackIndex > 0 && !point.raised) {
point._y = graphic.y;
graphic.attr({
y: point._y - 8
});
point.raised = true;
}
// Revert other raised points
each(points, function(otherPoint) {
if (otherPoint !== point && otherPoint.raised && otherPoint.graphic) {
otherPoint.graphic.attr({
y: otherPoint._y
});
otherPoint.raised = false;
}
});
});
}
});
},
animate: noop, // Disable animation
buildKDTree: noop,
setClip: noop
});
// create the flag icon with anchor
symbols.flag = function(x, y, w, h, options) {
var anchorX = (options && options.anchorX) || x,
anchorY = (options && options.anchorY) || y;
return [
'M', anchorX, anchorY,
'L', x, y + h,
x, y,
x + w, y,
x + w, y + h,
x, y + h,
'Z'
];
};
// create the circlepin and squarepin icons with anchor
each(['circle', 'square'], function(shape) {
symbols[shape + 'pin'] = function(x, y, w, h, options) {
var anchorX = options && options.anchorX,
anchorY = options && options.anchorY,
path,
labelTopOrBottomY;
// For single-letter flags, make sure circular flags are not taller than their width
if (shape === 'circle' && h > w) {
x -= Math.round((h - w) / 2);
w = h;
}
path = symbols[shape](x, y, w, h);
if (anchorX && anchorY) {
// if the label is below the anchor, draw the connecting line from the top edge of the label
// otherwise start drawing from the bottom edge
labelTopOrBottomY = (y > anchorY) ? y : y + h;
path.push('M', anchorX, labelTopOrBottomY, 'L', anchorX, anchorY);
}
return path;
};
});
// The symbol callbacks are generated on the SVGRenderer object in all browsers. Even
// VML browsers need this in order to generate shapes in export. Now share
// them with the VMLRenderer.
if (Renderer === VMLRenderer) {
each(['flag', 'circlepin', 'squarepin'], function(shape) {
VMLRenderer.prototype.symbols[shape] = symbols[shape];
});
}
/* ****************************************************************************
* End Flags series code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
Axis = H.Axis,
correctFloat = H.correctFloat,
defaultOptions = H.defaultOptions,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
doc = H.doc,
each = H.each,
fireEvent = H.fireEvent,
hasTouch = H.hasTouch,
isTouchDevice = H.isTouchDevice,
merge = H.merge,
pick = H.pick,
removeEvent = H.removeEvent,
svg = H.svg,
wrap = H.wrap,
swapXY;
var defaultScrollbarOptions = {
//enabled: true
height: isTouchDevice ? 20 : 14,
// trackBorderRadius: 0
barBorderRadius: 0,
buttonBorderRadius: 0,
liveRedraw: svg && !isTouchDevice,
margin: 10,
minWidth: 6,
//showFull: true,
//size: null,
step: 0.2,
zIndex: 3,
barBackgroundColor: '#cccccc',
barBorderWidth: 1,
barBorderColor: '#cccccc',
buttonArrowColor: '#333333',
buttonBackgroundColor: '#e6e6e6',
buttonBorderColor: '#cccccc',
buttonBorderWidth: 1,
rifleColor: '#333333',
trackBackgroundColor: '#f2f2f2',
trackBorderColor: '#f2f2f2',
trackBorderWidth: 1
};
defaultOptions.scrollbar = merge(true, defaultScrollbarOptions, defaultOptions.scrollbar);
/**
* When we have vertical scrollbar, rifles and arrow in buttons should be rotated.
* The same method is used in Navigator's handles, to rotate them.
* @param {Array} path - path to be rotated
* @param {Boolean} vertical - if vertical scrollbar, swap x-y values
*/
H.swapXY = swapXY = function(path, vertical) {
var i,
len = path.length,
temp;
if (vertical) {
for (i = 0; i < len; i += 3) {
temp = path[i + 1];
path[i + 1] = path[i + 2];
path[i + 2] = temp;
}
}
return path;
};
/**
* A reusable scrollbar, internally used in Highstock's navigator and optionally
* on individual axes.
*
* @class
* @param {Object} renderer
* @param {Object} options
* @param {Object} chart
*/
function Scrollbar(renderer, options, chart) { // docs
this.init(renderer, options, chart);
}
Scrollbar.prototype = {
init: function(renderer, options, chart) {
this.scrollbarButtons = [];
this.renderer = renderer;
this.userOptions = options;
this.options = merge(defaultScrollbarOptions, options);
this.chart = chart;
this.size = pick(this.options.size, this.options.height); // backward compatibility
// Init
if (options.enabled) {
this.render();
this.initEvents();
this.addEvents();
}
},
/**
* Render scrollbar with all required items.
*/
render: function() {
var scroller = this,
renderer = scroller.renderer,
options = scroller.options,
size = scroller.size,
group;
// Draw the scrollbar group
scroller.group = group = renderer.g('scrollbar').attr({
zIndex: options.zIndex,
translateY: -99999
}).add();
// Draw the scrollbar track:
scroller.track = renderer.rect()
.addClass('highcharts-scrollbar-track')
.attr({
x: 0,
r: options.trackBorderRadius || 0,
height: size,
width: size
}).add(group);
scroller.track.attr({
fill: options.trackBackgroundColor,
stroke: options.trackBorderColor,
'stroke-width': options.trackBorderWidth
});
this.trackBorderWidth = scroller.track.strokeWidth();
scroller.track.attr({
y: -this.trackBorderWidth % 2 / 2
});
// Draw the scrollbar itself
scroller.scrollbarGroup = renderer.g().add(group);
scroller.scrollbar = renderer.rect()
.addClass('highcharts-scrollbar-thumb')
.attr({
height: size,
width: size,
r: options.barBorderRadius || 0
}).add(scroller.scrollbarGroup);
scroller.scrollbarRifles = renderer.path(
swapXY([
'M', -3, size / 4,
'L', -3, 2 * size / 3,
'M',
0, size / 4,
'L',
0, 2 * size / 3,
'M',
3, size / 4,
'L',
3, 2 * size / 3
], options.vertical))
.addClass('highcharts-scrollbar-rifles')
.add(scroller.scrollbarGroup);
scroller.scrollbar.attr({
fill: options.barBackgroundColor,
stroke: options.barBorderColor,
'stroke-width': options.barBorderWidth
});
scroller.scrollbarRifles.attr({
stroke: options.rifleColor,
'stroke-width': 1
});
scroller.scrollbarStrokeWidth = scroller.scrollbar.strokeWidth();
scroller.scrollbarGroup.translate(-scroller.scrollbarStrokeWidth % 2 / 2, -scroller.scrollbarStrokeWidth % 2 / 2);
// Draw the buttons:
scroller.drawScrollbarButton(0);
scroller.drawScrollbarButton(1);
},
/**
* Position the scrollbar, method called from a parent with defined dimensions
* @param {Number} x - x-position on the chart
* @param {Number} y - y-position on the chart
* @param {Number} width - width of the scrollbar
* @param {Number} height - height of the scorllbar
*/
position: function(x, y, width, height) {
var scroller = this,
options = scroller.options,
vertical = options.vertical,
xOffset = height,
yOffset = 0,
method = scroller.rendered ? 'animate' : 'attr';
scroller.x = x;
scroller.y = y + this.trackBorderWidth;
scroller.width = width; // width with buttons
scroller.height = height;
scroller.xOffset = xOffset;
scroller.yOffset = yOffset;
// If Scrollbar is a vertical type, swap options:
if (vertical) {
scroller.width = scroller.yOffset = width = yOffset = scroller.size;
scroller.xOffset = xOffset = 0;
scroller.barWidth = height - width * 2; // width without buttons
scroller.x = x = x + scroller.options.margin;
} else {
scroller.height = scroller.xOffset = height = xOffset = scroller.size;
scroller.barWidth = width - height * 2; // width without buttons
scroller.y = scroller.y + scroller.options.margin;
}
// Set general position for a group:
scroller.group[method]({
translateX: x,
translateY: scroller.y
});
// Resize background/track:
scroller.track[method]({
width: width,
height: height
});
// Move right/bottom button ot it's place:
scroller.scrollbarButtons[1][method]({
translateX: vertical ? 0 : width - xOffset,
translateY: vertical ? height - yOffset : 0
});
},
/**
* Draw the scrollbar buttons with arrows
* @param {Number} index 0 is left, 1 is right
*/
drawScrollbarButton: function(index) {
var scroller = this,
renderer = scroller.renderer,
scrollbarButtons = scroller.scrollbarButtons,
options = scroller.options,
size = scroller.size,
group,
tempElem;
group = renderer.g().add(scroller.group);
scrollbarButtons.push(group);
// Create a rectangle for the scrollbar button
tempElem = renderer.rect()
.addClass('highcharts-scrollbar-button')
.add(group);
// Presentational attributes
tempElem.attr({
stroke: options.buttonBorderColor,
'stroke-width': options.buttonBorderWidth,
fill: options.buttonBackgroundColor
});
// Place the rectangle based on the rendered stroke width
tempElem.attr(tempElem.crisp({
x: -0.5,
y: -0.5,
width: size + 1, // +1 to compensate for crispifying in rect method
height: size + 1,
r: options.buttonBorderRadius
}, tempElem.strokeWidth()));
// Button arrow
tempElem = renderer
.path(swapXY([
'M',
size / 2 + (index ? -1 : 1),
size / 2 - 3,
'L',
size / 2 + (index ? -1 : 1),
size / 2 + 3,
'L',
size / 2 + (index ? 2 : -2),
size / 2
], options.vertical))
.addClass('highcharts-scrollbar-arrow')
.add(scrollbarButtons[index]);
tempElem.attr({
fill: options.buttonArrowColor
});
},
/**
* Set scrollbar size, with a given scale.
* @param {Number} from - scale (0-1) where bar should start
* @param {Number} to - scale (0-1) where bar should end
*/
setRange: function(from, to) {
var scroller = this,
options = scroller.options,
vertical = options.vertical,
minWidth = options.minWidth,
fullWidth = scroller.barWidth,
fromPX,
toPX,
newPos,
newSize,
newRiflesPos,
method = this.rendered && !this.hasDragged ? 'animate' : 'attr';
if (!defined(fullWidth)) {
return;
}
from = Math.max(from, 0);
fromPX = Math.ceil(fullWidth * from);
toPX = fullWidth * Math.min(to, 1);
scroller.calculatedWidth = newSize = correctFloat(toPX - fromPX);
// We need to recalculate position, if minWidth is used
if (newSize < minWidth) {
fromPX = (fullWidth - minWidth + newSize) * from;
newSize = minWidth;
}
newPos = Math.floor(fromPX + scroller.xOffset + scroller.yOffset);
newRiflesPos = newSize / 2 - 0.5; // -0.5 -> rifle line width / 2
// Store current position:
scroller.from = from;
scroller.to = to;
if (!vertical) {
scroller.scrollbarGroup[method]({
translateX: newPos
});
scroller.scrollbar[method]({
width: newSize
});
scroller.scrollbarRifles[method]({
translateX: newRiflesPos
});
scroller.scrollbarLeft = newPos;
scroller.scrollbarTop = 0;
} else {
scroller.scrollbarGroup[method]({
translateY: newPos
});
scroller.scrollbar[method]({
height: newSize
});
scroller.scrollbarRifles[method]({
translateY: newRiflesPos
});
scroller.scrollbarTop = newPos;
scroller.scrollbarLeft = 0;
}
if (newSize <= 12) {
scroller.scrollbarRifles.hide();
} else {
scroller.scrollbarRifles.show(true);
}
// Show or hide the scrollbar based on the showFull setting
if (options.showFull === false) {
if (from <= 0 && to >= 1) {
scroller.group.hide();
} else {
scroller.group.show();
}
}
scroller.rendered = true;
},
/**
* Init events methods, so we have an access to the Scrollbar itself
*/
initEvents: function() {
var scroller = this;
/**
* Event handler for the mouse move event.
*/
scroller.mouseMoveHandler = function(e) {
var normalizedEvent = scroller.chart.pointer.normalize(e),
options = scroller.options,
direction = options.vertical ? 'chartY' : 'chartX',
initPositions = scroller.initPositions,
scrollPosition,
chartPosition,
change;
// In iOS, a mousemove event with e.pageX === 0 is fired when holding the finger
// down in the center of the scrollbar. This should be ignored.
if (scroller.grabbedCenter && (!e.touches || e.touches[0][direction] !== 0)) { // #4696, scrollbar failed on Android
chartPosition = scroller.cursorToScrollbarPosition(normalizedEvent)[direction];
scrollPosition = scroller[direction];
change = chartPosition - scrollPosition;
scroller.hasDragged = true;
scroller.updatePosition(initPositions[0] + change, initPositions[1] + change);
if (scroller.hasDragged) {
fireEvent(scroller, 'changed', {
from: scroller.from,
to: scroller.to,
trigger: 'scrollbar',
DOMType: e.type,
DOMEvent: e
});
}
}
};
/**
* Event handler for the mouse up event.
*/
scroller.mouseUpHandler = function(e) {
if (scroller.hasDragged) {
fireEvent(scroller, 'changed', {
from: scroller.from,
to: scroller.to,
trigger: 'scrollbar',
DOMType: e.type,
DOMEvent: e
});
}
scroller.grabbedCenter = scroller.hasDragged = scroller.chartX = scroller.chartY = null;
};
scroller.mouseDownHandler = function(e) {
var normalizedEvent = scroller.chart.pointer.normalize(e),
mousePosition = scroller.cursorToScrollbarPosition(normalizedEvent);
scroller.chartX = mousePosition.chartX;
scroller.chartY = mousePosition.chartY;
scroller.initPositions = [scroller.from, scroller.to];
scroller.grabbedCenter = true;
};
scroller.buttonToMinClick = function(e) {
var range = correctFloat(scroller.to - scroller.from) * scroller.options.step;
scroller.updatePosition(correctFloat(scroller.from - range), correctFloat(scroller.to - range));
fireEvent(scroller, 'changed', {
from: scroller.from,
to: scroller.to,
trigger: 'scrollbar',
DOMEvent: e
});
};
scroller.buttonToMaxClick = function(e) {
var range = (scroller.to - scroller.from) * scroller.options.step;
scroller.updatePosition(scroller.from + range, scroller.to + range);
fireEvent(scroller, 'changed', {
from: scroller.from,
to: scroller.to,
trigger: 'scrollbar',
DOMEvent: e
});
};
scroller.trackClick = function(e) {
var normalizedEvent = scroller.chart.pointer.normalize(e),
range = scroller.to - scroller.from,
top = scroller.y + scroller.scrollbarTop,
left = scroller.x + scroller.scrollbarLeft;
if ((scroller.options.vertical && normalizedEvent.chartY > top) ||
(!scroller.options.vertical && normalizedEvent.chartX > left)) {
// On the top or on the left side of the track:
scroller.updatePosition(scroller.from + range, scroller.to + range);
} else {
// On the bottom or the right side of the track:
scroller.updatePosition(scroller.from - range, scroller.to - range);
}
fireEvent(scroller, 'changed', {
from: scroller.from,
to: scroller.to,
trigger: 'scrollbar',
DOMEvent: e
});
};
},
/**
* Get normalized (0-1) cursor position over the scrollbar
* @param {Event} normalizedEvent - normalized event, with chartX and chartY values
* @return {Object} Local position {chartX, chartY}
*/
cursorToScrollbarPosition: function(normalizedEvent) {
var scroller = this,
options = scroller.options,
minWidthDifference = options.minWidth > scroller.calculatedWidth ? options.minWidth : 0; // minWidth distorts translation
return {
chartX: (normalizedEvent.chartX - scroller.x - scroller.xOffset) / (scroller.barWidth - minWidthDifference),
chartY: (normalizedEvent.chartY - scroller.y - scroller.yOffset) / (scroller.barWidth - minWidthDifference)
};
},
/**
* Update position option in the Scrollbar, with normalized 0-1 scale
*/
updatePosition: function(from, to) {
if (to > 1) {
from = correctFloat(1 - correctFloat(to - from));
to = 1;
}
if (from < 0) {
to = correctFloat(to - from);
from = 0;
}
this.from = from;
this.to = to;
},
/**
* Update the scrollbar with new options
*/
update: function(options) {
this.destroy();
this.init(this.chart.renderer, merge(true, this.options, options), this.chart);
},
/**
* Set up the mouse and touch events for the Scrollbar
*/
addEvents: function() {
var buttonsOrder = this.options.inverted ? [1, 0] : [0, 1],
buttons = this.scrollbarButtons,
bar = this.scrollbarGroup.element,
track = this.track.element,
mouseDownHandler = this.mouseDownHandler,
mouseMoveHandler = this.mouseMoveHandler,
mouseUpHandler = this.mouseUpHandler,
_events;
// Mouse events
_events = [
[buttons[buttonsOrder[0]].element, 'click', this.buttonToMinClick],
[buttons[buttonsOrder[1]].element, 'click', this.buttonToMaxClick],
[track, 'click', this.trackClick],
[bar, 'mousedown', mouseDownHandler],
[doc, 'mousemove', mouseMoveHandler],
[doc, 'mouseup', mouseUpHandler]
];
// Touch events
if (hasTouch) {
_events.push(
[bar, 'touchstart', mouseDownHandler], [doc, 'touchmove', mouseMoveHandler], [doc, 'touchend', mouseUpHandler]
);
}
// Add them all
each(_events, function(args) {
addEvent.apply(null, args);
});
this._events = _events;
},
/**
* Removes the event handlers attached previously with addEvents.
*/
removeEvents: function() {
each(this._events, function(args) {
removeEvent.apply(null, args);
});
this._events = undefined;
},
/**
* Destroys allocated elements.
*/
destroy: function() {
var scroller = this.chart.scroller;
// Disconnect events added in addEvents
this.removeEvents();
// Destroy properties
each(['track', 'scrollbarRifles', 'scrollbar', 'scrollbarGroup', 'group'], function(prop) {
if (this[prop] && this[prop].destroy) {
this[prop] = this[prop].destroy();
}
}, this);
if (scroller && this === scroller.scrollbar) { // #6421, chart may have more scrollbars
scroller.scrollbar = null;
// Destroy elements in collection
destroyObjectProperties(scroller.scrollbarButtons);
}
}
};
/**
* Wrap axis initialization and create scrollbar if enabled:
*/
wrap(Axis.prototype, 'init', function(proceed) {
var axis = this;
proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
if (axis.options.scrollbar && axis.options.scrollbar.enabled) {
// Predefined options:
axis.options.scrollbar.vertical = !axis.horiz;
axis.options.startOnTick = axis.options.endOnTick = false;
axis.scrollbar = new Scrollbar(axis.chart.renderer, axis.options.scrollbar, axis.chart);
addEvent(axis.scrollbar, 'changed', function(e) {
var unitedMin = Math.min(pick(axis.options.min, axis.min), axis.min, axis.dataMin),
unitedMax = Math.max(pick(axis.options.max, axis.max), axis.max, axis.dataMax),
range = unitedMax - unitedMin,
to,
from;
if ((axis.horiz && !axis.reversed) || (!axis.horiz && axis.reversed)) {
to = unitedMin + range * this.to;
from = unitedMin + range * this.from;
} else {
// y-values in browser are reversed, but this also applies for reversed horizontal axis:
to = unitedMin + range * (1 - this.from);
from = unitedMin + range * (1 - this.to);
}
axis.setExtremes(from, to, true, false, e);
});
}
});
/**
* Wrap rendering axis, and update scrollbar if one is created:
*/
wrap(Axis.prototype, 'render', function(proceed) {
var axis = this,
scrollMin = Math.min(pick(axis.options.min, axis.min), axis.min, axis.dataMin),
scrollMax = Math.max(pick(axis.options.max, axis.max), axis.max, axis.dataMax),
scrollbar = axis.scrollbar,
offsetsIndex,
from,
to;
proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
if (scrollbar) {
if (axis.horiz) {
scrollbar.position(
axis.left,
axis.top + axis.height + 2 + axis.chart.scrollbarsOffsets[1] +
(axis.opposite ? 0 : axis.axisTitleMargin + axis.offset),
axis.width,
axis.height
);
offsetsIndex = 1;
} else {
scrollbar.position(
axis.left + axis.width + 2 + axis.chart.scrollbarsOffsets[0] +
(axis.opposite ? axis.axisTitleMargin + axis.offset : 0),
axis.top,
axis.width,
axis.height
);
offsetsIndex = 0;
}
if ((!axis.opposite && !axis.horiz) || (axis.opposite && axis.horiz)) {
axis.chart.scrollbarsOffsets[offsetsIndex] +=
axis.scrollbar.size + axis.scrollbar.options.margin;
}
if (isNaN(scrollMin) || isNaN(scrollMax) || !defined(axis.min) || !defined(axis.max)) {
scrollbar.setRange(0, 0); // default action: when there is not extremes on the axis, but scrollbar exists, make it full size
} else {
from = (axis.min - scrollMin) / (scrollMax - scrollMin);
to = (axis.max - scrollMin) / (scrollMax - scrollMin);
if ((axis.horiz && !axis.reversed) || (!axis.horiz && axis.reversed)) {
scrollbar.setRange(from, to);
} else {
scrollbar.setRange(1 - to, 1 - from); // inverse vertical axis
}
}
}
});
/**
* Make space for a scrollbar
*/
wrap(Axis.prototype, 'getOffset', function(proceed) {
var axis = this,
index = axis.horiz ? 2 : 1,
scrollbar = axis.scrollbar;
proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
if (scrollbar) {
axis.chart.scrollbarsOffsets = [0, 0]; // reset scrollbars offsets
axis.chart.axisOffset[index] += scrollbar.size + scrollbar.options.margin;
}
});
/**
* Destroy scrollbar when connected to the specific axis
*/
wrap(Axis.prototype, 'destroy', function(proceed) {
if (this.scrollbar) {
this.scrollbar = this.scrollbar.destroy();
}
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
});
H.Scrollbar = Scrollbar;
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
/* ****************************************************************************
* Start Navigator code *
*****************************************************************************/
var addEvent = H.addEvent,
Axis = H.Axis,
Chart = H.Chart,
color = H.color,
defaultDataGroupingUnits = H.defaultDataGroupingUnits,
defaultOptions = H.defaultOptions,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
doc = H.doc,
each = H.each,
erase = H.erase,
error = H.error,
extend = H.extend,
grep = H.grep,
hasTouch = H.hasTouch,
isNumber = H.isNumber,
isObject = H.isObject,
merge = H.merge,
pick = H.pick,
removeEvent = H.removeEvent,
Scrollbar = H.Scrollbar,
Series = H.Series,
seriesTypes = H.seriesTypes,
wrap = H.wrap,
swapXY = H.swapXY,
units = [].concat(defaultDataGroupingUnits), // copy
defaultSeriesType,
// Finding the min or max of a set of variables where we don't know if they are defined,
// is a pattern that is repeated several places in Highcharts. Consider making this
// a global utility method.
numExt = function(extreme) {
var numbers = grep(arguments, isNumber);
if (numbers.length) {
return Math[extreme].apply(0, numbers);
}
};
// add more resolution to units
units[4] = ['day', [1, 2, 3, 4]]; // allow more days
units[5] = ['week', [1, 2, 3]]; // allow more weeks
defaultSeriesType = seriesTypes.areaspline === undefined ? 'line' : 'areaspline';
extend(defaultOptions, {
navigator: {
//enabled: true,
height: 40,
margin: 25,
maskInside: true,
handles: {
backgroundColor: '#f2f2f2',
borderColor: '#999999'
},
maskFill: color('#6685c2').setOpacity(0.3).get(),
outlineColor: '#cccccc',
outlineWidth: 1,
series: {
type: defaultSeriesType,
color: '#335cad',
fillOpacity: 0.05,
lineWidth: 1,
compare: null,
dataGrouping: {
approximation: 'average',
enabled: true,
groupPixelWidth: 2,
smoothed: true,
units: units
},
dataLabels: {
enabled: false,
zIndex: 2 // #1839
},
id: 'highcharts-navigator-series',
className: 'highcharts-navigator-series',
lineColor: null, // Allow color setting while disallowing default candlestick setting (#4602)
marker: {
enabled: false
},
pointRange: 0,
shadow: false,
threshold: null
},
//top: undefined,
//opposite: undefined,
xAxis: {
className: 'highcharts-navigator-xaxis',
tickLength: 0,
lineWidth: 0,
gridLineColor: '#e6e6e6',
gridLineWidth: 1,
tickPixelInterval: 200,
labels: {
align: 'left',
style: {
color: '#999999'
},
x: 3,
y: -4
},
crosshair: false
},
yAxis: {
className: 'highcharts-navigator-yaxis',
gridLineWidth: 0,
startOnTick: false,
endOnTick: false,
minPadding: 0.1,
maxPadding: 0.1,
labels: {
enabled: false
},
crosshair: false,
title: {
text: null
},
tickLength: 0,
tickWidth: 0
}
}
});
/**
* The Navigator class
* @param {Object} chart - Chart object
* @class
*/
function Navigator(chart) {
this.init(chart);
}
Navigator.prototype = {
/**
* Draw one of the handles on the side of the zoomed range in the navigator
* @param {Number} x The x center for the handle
* @param {Number} index 0 for left and 1 for right
* @param {Boolean} inverted flag for chart.inverted
* @param {String} verb use 'animate' or 'attr'
*/
drawHandle: function(x, index, inverted, verb) {
var navigator = this;
// Place it
navigator.handles[index][verb](inverted ? {
translateX: Math.round(navigator.left + navigator.height / 2 - 8),
translateY: Math.round(navigator.top + parseInt(x, 10) + 0.5)
} : {
translateX: Math.round(navigator.left + parseInt(x, 10)),
translateY: Math.round(navigator.top + navigator.height / 2 - 8)
});
},
/**
* Draw one of the handles on the side of the zoomed range in the navigator
* @param {Boolean} inverted flag for chart.inverted
* @returns {Array} Path to be used in a handle
*/
getHandlePath: function(inverted) {
return swapXY([
'M', -4.5, 0.5,
'L',
3.5, 0.5,
'L',
3.5, 15.5,
'L', -4.5, 15.5,
'L', -4.5, 0.5,
'M', -1.5, 4,
'L', -1.5, 12,
'M',
0.5, 4,
'L',
0.5, 12
], inverted);
},
/**
* Render outline around the zoomed range
* @param {Number} zoomedMin in pixels position where zoomed range starts
* @param {Number} zoomedMax in pixels position where zoomed range ends
* @param {Boolean} inverted flag if chart is inverted
* @param {String} verb use 'animate' or 'attr'
*/
drawOutline: function(zoomedMin, zoomedMax, inverted, verb) {
var navigator = this,
maskInside = navigator.navigatorOptions.maskInside,
outlineWidth = navigator.outline.strokeWidth(),
halfOutline = outlineWidth / 2,
outlineCorrection = (outlineWidth % 2) / 2, // #5800
outlineHeight = navigator.outlineHeight,
scrollbarHeight = navigator.scrollbarHeight,
navigatorSize = navigator.size,
left = navigator.left - scrollbarHeight,
navigatorTop = navigator.top,
verticalMin,
path;
if (inverted) {
left -= halfOutline;
verticalMin = navigatorTop + zoomedMax + outlineCorrection;
zoomedMax = navigatorTop + zoomedMin + outlineCorrection;
path = [
'M',
left + outlineHeight,
navigatorTop - scrollbarHeight - outlineCorrection, // top edge
'L',
left + outlineHeight,
verticalMin, // top right of zoomed range
'L',
left,
verticalMin, // top left of z.r.
'L',
left,
zoomedMax, // bottom left of z.r.
'L',
left + outlineHeight,
zoomedMax, // bottom right of z.r.
'L',
left + outlineHeight,
navigatorTop + navigatorSize + scrollbarHeight // bottom edge
].concat(maskInside ? [
'M',
left + outlineHeight,
verticalMin - halfOutline, // upper left of zoomed range
'L',
left + outlineHeight,
zoomedMax + halfOutline // upper right of z.r.
] : []);
} else {
zoomedMin += left + scrollbarHeight - outlineCorrection;
zoomedMax += left + scrollbarHeight - outlineCorrection;
navigatorTop += halfOutline;
path = [
'M',
left,
navigatorTop, // left
'L',
zoomedMin,
navigatorTop, // upper left of zoomed range
'L',
zoomedMin,
navigatorTop + outlineHeight, // lower left of z.r.
'L',
zoomedMax,
navigatorTop + outlineHeight, // lower right of z.r.
'L',
zoomedMax,
navigatorTop, // upper right of z.r.
'L',
left + navigatorSize + scrollbarHeight * 2,
navigatorTop // right
].concat(maskInside ? [
'M',
zoomedMin - halfOutline,
navigatorTop, // upper left of zoomed range
'L',
zoomedMax + halfOutline,
navigatorTop // upper right of z.r.
] : []);
}
navigator.outline[verb]({
d: path
});
},
/**
* Render outline around the zoomed range
* @param {Number} zoomedMin in pixels position where zoomed range starts
* @param {Number} zoomedMax in pixels position where zoomed range ends
* @param {Boolean} inverted flag if chart is inverted
* @param {String} verb use 'animate' or 'attr'
*/
drawMasks: function(zoomedMin, zoomedMax, inverted, verb) {
var navigator = this,
left = navigator.left,
top = navigator.top,
navigatorHeight = navigator.height,
height,
width,
x,
y;
// Determine rectangle position & size
// According to (non)inverted position:
if (inverted) {
x = [left, left, left];
y = [top, top + zoomedMin, top + zoomedMax];
width = [navigatorHeight, navigatorHeight, navigatorHeight];
height = [
zoomedMin,
zoomedMax - zoomedMin,
navigator.size - zoomedMax
];
} else {
x = [left, left + zoomedMin, left + zoomedMax];
y = [top, top, top];
width = [
zoomedMin,
zoomedMax - zoomedMin,
navigator.size - zoomedMax
];
height = [navigatorHeight, navigatorHeight, navigatorHeight];
}
each(navigator.shades, function(shade, i) {
shade[verb]({
x: x[i],
y: y[i],
width: width[i],
height: height[i]
});
});
},
/**
* Generate DOM elements for a navigator:
* - main navigator group
* - all shades
* - outline
* - handles
*/
renderElements: function() {
var navigator = this,
navigatorOptions = navigator.navigatorOptions,
maskInside = navigatorOptions.maskInside,
chart = navigator.chart,
inverted = chart.inverted,
renderer = chart.renderer,
navigatorGroup;
// Create the main navigator group
navigator.navigatorGroup = navigatorGroup = renderer.g('navigator')
.attr({
zIndex: 8,
visibility: 'hidden'
})
.add();
var mouseCursor = {
cursor: inverted ? 'ns-resize' : 'ew-resize'
};
// Create masks, each mask will get events and fill:
each([!maskInside, maskInside, !maskInside], function(hasMask, index) {
navigator.shades[index] = renderer.rect()
.addClass('highcharts-navigator-mask' +
(index === 1 ? '-inside' : '-outside'))
.attr({
fill: hasMask ? navigatorOptions.maskFill : 'transparent'
})
.css(index === 1 && mouseCursor)
.add(navigatorGroup);
});
// Create the outline:
navigator.outline = renderer.path()
.addClass('highcharts-navigator-outline')
.attr({
'stroke-width': navigatorOptions.outlineWidth,
stroke: navigatorOptions.outlineColor
})
.add(navigatorGroup);
// Create the handlers:
each([0, 1], function(index) {
navigator.handles[index] = renderer
.path(navigator.getHandlePath(inverted))
// zIndex = 6 for right handle, 7 for left.
// Can't be 10, because of the tooltip in inverted chart #2908
.attr({
zIndex: 7 - index
})
.addClass(
'highcharts-navigator-handle highcharts-navigator-handle-' + ['left', 'right'][index]
).add(navigatorGroup);
var handlesOptions = navigatorOptions.handles;
navigator.handles[index]
.attr({
fill: handlesOptions.backgroundColor,
stroke: handlesOptions.borderColor,
'stroke-width': 1
})
.css(mouseCursor);
});
},
/**
* Update navigator
* @param {Object} options Options to merge in when updating navigator
*/
update: function(options) {
this.destroy();
var chartOptions = this.chart.options;
merge(true, chartOptions.navigator, this.options, options);
this.init(this.chart);
},
/**
* Render the navigator
* @param {Number} min X axis value minimum
* @param {Number} max X axis value maximum
* @param {Number} pxMin Pixel value minimum
* @param {Number} pxMax Pixel value maximum
*/
render: function(min, max, pxMin, pxMax) {
var navigator = this,
chart = navigator.chart,
navigatorWidth,
scrollbarLeft,
scrollbarTop,
scrollbarHeight = navigator.scrollbarHeight,
navigatorSize,
xAxis = navigator.xAxis,
navigatorEnabled = navigator.navigatorEnabled,
zoomedMin,
zoomedMax,
rendered = navigator.rendered,
inverted = chart.inverted,
verb,
newMin,
newMax,
minRange = chart.xAxis[0].minRange;
// Don't redraw while moving the handles (#4703).
if (this.hasDragged && !defined(pxMin)) {
return;
}
// Don't render the navigator until we have data (#486, #4202, #5172).
if (!isNumber(min) || !isNumber(max)) {
// However, if navigator was already rendered, we may need to resize
// it. For example hidden series, but visible navigator (#6022).
if (rendered) {
pxMin = 0;
pxMax = xAxis.width;
} else {
return;
}
}
navigator.left = pick(
xAxis.left,
// in case of scrollbar only, without navigator
chart.plotLeft + scrollbarHeight + (inverted ? chart.plotWidth : 0)
);
navigator.size = zoomedMax = navigatorSize = pick(
xAxis.len,
(inverted ? chart.plotHeight : chart.plotWidth) - 2 * scrollbarHeight
);
if (inverted) {
navigatorWidth = scrollbarHeight;
} else {
navigatorWidth = navigatorSize + 2 * scrollbarHeight;
}
// Get the pixel position of the handles
pxMin = pick(pxMin, xAxis.toPixels(min, true));
pxMax = pick(pxMax, xAxis.toPixels(max, true));
if (!isNumber(pxMin) || Math.abs(pxMin) === Infinity) { // Verify (#1851, #2238)
pxMin = 0;
pxMax = navigatorWidth;
}
// Are we below the minRange? (#2618, #6191)
newMin = xAxis.toValue(pxMin, true);
newMax = xAxis.toValue(pxMax, true);
if (Math.abs(newMax - newMin) < minRange) {
if (this.grabbedLeft) {
pxMin = xAxis.toPixels(newMax - minRange, true);
} else if (this.grabbedRight) {
pxMax = xAxis.toPixels(newMin + minRange, true);
} else {
return;
}
}
// Handles are allowed to cross, but never exceed the plot area
navigator.zoomedMax = Math.min(Math.max(pxMin, pxMax, 0), zoomedMax);
navigator.zoomedMin = Math.min(
Math.max(
navigator.fixedWidth ?
navigator.zoomedMax - navigator.fixedWidth :
Math.min(pxMin, pxMax),
0
),
zoomedMax
);
navigator.range = navigator.zoomedMax - navigator.zoomedMin;
zoomedMax = Math.round(navigator.zoomedMax);
zoomedMin = Math.round(navigator.zoomedMin);
if (navigatorEnabled) {
navigator.navigatorGroup.attr({
visibility: 'visible'
});
// Place elements
verb = rendered && !navigator.hasDragged ? 'animate' : 'attr';
navigator.drawMasks(zoomedMin, zoomedMax, inverted, verb);
navigator.drawOutline(zoomedMin, zoomedMax, inverted, verb);
navigator.drawHandle(zoomedMin, 0, inverted, verb);
navigator.drawHandle(zoomedMax, 1, inverted, verb);
}
if (navigator.scrollbar) {
if (inverted) {
scrollbarTop = navigator.top - scrollbarHeight;
scrollbarLeft = navigator.left - scrollbarHeight +
(navigatorEnabled ? 0 : navigator.height);
scrollbarHeight = navigatorSize + 2 * scrollbarHeight;
} else {
scrollbarTop = navigator.top +
(navigatorEnabled ? navigator.height : -scrollbarHeight);
scrollbarLeft = navigator.left - scrollbarHeight;
}
// Reposition scrollbar
navigator.scrollbar.position(
scrollbarLeft,
scrollbarTop,
navigatorWidth,
scrollbarHeight
);
// Keep scale 0-1
navigator.scrollbar.setRange(
// Use real value, not rounded because range can be very small (#1716)
navigator.zoomedMin / navigatorSize,
navigator.zoomedMax / navigatorSize
);
}
navigator.rendered = true;
},
/**
* Set up the mouse and touch events for the navigator
*/
addMouseEvents: function() {
var navigator = this,
chart = navigator.chart,
container = chart.container,
eventsToUnbind = [],
mouseMoveHandler,
mouseUpHandler;
/**
* Create mouse events' handlers.
* Make them as separate functions to enable wrapping them:
*/
navigator.mouseMoveHandler = mouseMoveHandler = function(e) {
navigator.onMouseMove(e);
};
navigator.mouseUpHandler = mouseUpHandler = function(e) {
navigator.onMouseUp(e);
};
// Add shades and handles mousedown events
eventsToUnbind = navigator.getPartsEvents('mousedown');
// Add mouse move and mouseup events. These are bind to doc/container,
// because Navigator.grabbedSomething flags are stored in mousedown events:
eventsToUnbind.push(
addEvent(container, 'mousemove', mouseMoveHandler),
addEvent(doc, 'mouseup', mouseUpHandler)
);
// Touch events
if (hasTouch) {
eventsToUnbind.push(
addEvent(container, 'touchmove', mouseMoveHandler),
addEvent(doc, 'touchend', mouseUpHandler)
);
eventsToUnbind.concat(navigator.getPartsEvents('touchstart'));
}
navigator.eventsToUnbind = eventsToUnbind;
// Data events
if (navigator.series && navigator.series[0]) {
eventsToUnbind.push(
addEvent(navigator.series[0].xAxis, 'foundExtremes', function() {
chart.navigator.modifyNavigatorAxisExtremes();
})
);
}
},
/**
* Generate events for handles and masks
* @param {String} eventName Event name handler, 'mousedown' or 'touchstart'
* @returns {Array} An array of arrays: [DOMElement, eventName, callback].
*/
getPartsEvents: function(eventName) {
var navigator = this,
events = [];
each(['shades', 'handles'], function(name) {
each(navigator[name], function(navigatorItem, index) {
events.push(
addEvent(
navigatorItem.element,
eventName,
function(e) {
navigator[name + 'Mousedown'](e, index);
}
)
);
});
});
return events;
},
/**
* Mousedown on a shaded mask, either:
* - will be stored for future drag&drop
* - will directly shift to a new range
*
* @param {Object} e Mouse event
* @param {Number} index Index of a mask in Navigator.shades array
*/
shadesMousedown: function(e, index) {
e = this.chart.pointer.normalize(e);
var navigator = this,
chart = navigator.chart,
xAxis = navigator.xAxis,
zoomedMin = navigator.zoomedMin,
navigatorPosition = navigator.left,
navigatorSize = navigator.size,
range = navigator.range,
chartX = e.chartX,
fixedMax,
ext,
left;
// For inverted chart, swap some options:
if (chart.inverted) {
chartX = e.chartY;
navigatorPosition = navigator.top;
}
if (index === 1) {
// Store information for drag&drop
navigator.grabbedCenter = chartX;
navigator.fixedWidth = range;
navigator.dragOffset = chartX - zoomedMin;
} else {
// Shift the range by clicking on shaded areas
left = chartX - navigatorPosition - range / 2;
if (index === 0) {
left = Math.max(0, left);
} else if (index === 2 && left + range >= navigatorSize) {
left = navigatorSize - range;
fixedMax = navigator.getUnionExtremes().dataMax; // #2293, #3543
}
if (left !== zoomedMin) { // it has actually moved
navigator.fixedWidth = range; // #1370
ext = xAxis.toFixedRange(left, left + range, null, fixedMax);
chart.xAxis[0].setExtremes(
Math.min(ext.min, ext.max),
Math.max(ext.min, ext.max),
true,
null, // auto animation
{
trigger: 'navigator'
}
);
}
}
},
/**
* Mousedown on a handle mask.
* Will store necessary information for drag&drop.
*
* @param {Object} e Mouse event
* @param {Number} index Index of a handle in Navigator.handles array
*/
handlesMousedown: function(e, index) {
e = this.chart.pointer.normalize(e);
var navigator = this,
chart = navigator.chart,
baseXAxis = chart.xAxis[0],
// For reversed axes, min and max are chagned,
// so the other extreme should be stored
reverse = (chart.inverted && !baseXAxis.reversed) ||
(!chart.inverted && baseXAxis.reversed);
if (index === 0) {
// Grab the left handle
navigator.grabbedLeft = true;
navigator.otherHandlePos = navigator.zoomedMax;
navigator.fixedExtreme = reverse ? baseXAxis.min : baseXAxis.max;
} else {
// Grab the right handle
navigator.grabbedRight = true;
navigator.otherHandlePos = navigator.zoomedMin;
navigator.fixedExtreme = reverse ? baseXAxis.max : baseXAxis.min;
}
chart.fixedRange = null;
},
/**
* Mouse move event based on x/y mouse position.
* @param {Object} e Mouse event
*/
onMouseMove: function(e) {
var navigator = this,
chart = navigator.chart,
left = navigator.left,
navigatorSize = navigator.navigatorSize,
range = navigator.range,
dragOffset = navigator.dragOffset,
inverted = chart.inverted,
chartX;
// In iOS, a mousemove event with e.pageX === 0 is fired when holding the finger
// down in the center of the scrollbar. This should be ignored.
if (!e.touches || e.touches[0].pageX !== 0) { // #4696, scrollbar failed on Android
e = chart.pointer.normalize(e);
chartX = e.chartX;
// Swap some options for inverted chart
if (inverted) {
left = navigator.top;
chartX = e.chartY;
}
// Drag left handle or top handle
if (navigator.grabbedLeft) {
navigator.hasDragged = true;
navigator.render(
0,
0,
chartX - left,
navigator.otherHandlePos
);
// Drag right handle or bottom handle
} else if (navigator.grabbedRight) {
navigator.hasDragged = true;
navigator.render(
0,
0,
navigator.otherHandlePos,
chartX - left
);
// Drag scrollbar or open area in navigator
} else if (navigator.grabbedCenter) {
navigator.hasDragged = true;
if (chartX < dragOffset) { // outside left
chartX = dragOffset;
} else if (chartX > navigatorSize + dragOffset - range) { // outside right
chartX = navigatorSize + dragOffset - range;
}
navigator.render(
0,
0,
chartX - dragOffset,
chartX - dragOffset + range
);
}
if (navigator.hasDragged && navigator.scrollbar && navigator.scrollbar.options.liveRedraw) {
e.DOMType = e.type; // DOMType is for IE8 because it can't read type async
setTimeout(function() {
navigator.onMouseUp(e);
}, 0);
}
}
},
/**
* Mouse up event based on x/y mouse position.
* @param {Object} e Mouse event
*/
onMouseUp: function(e) {
var navigator = this,
chart = navigator.chart,
xAxis = navigator.xAxis,
scrollbar = navigator.scrollbar,
fixedMin,
fixedMax,
ext,
DOMEvent = e.DOMEvent || e;
if (
// MouseUp is called for both, navigator and scrollbar (that order),
// which causes calling afterSetExtremes twice. Prevent first call
// by checking if scrollbar is going to set new extremes (#6334)
(navigator.hasDragged && (!scrollbar || !scrollbar.hasDragged)) ||
e.trigger === 'scrollbar'
) {
// When dragging one handle, make sure the other one doesn't change
if (navigator.zoomedMin === navigator.otherHandlePos) {
fixedMin = navigator.fixedExtreme;
} else if (navigator.zoomedMax === navigator.otherHandlePos) {
fixedMax = navigator.fixedExtreme;
}
// Snap to right edge (#4076)
if (navigator.zoomedMax === navigator.size) {
fixedMax = navigator.getUnionExtremes().dataMax;
}
ext = xAxis.toFixedRange(
navigator.zoomedMin,
navigator.zoomedMax,
fixedMin,
fixedMax
);
if (defined(ext.min)) {
chart.xAxis[0].setExtremes(
Math.min(ext.min, ext.max),
Math.max(ext.min, ext.max),
true,
navigator.hasDragged ? false : null, // Run animation when clicking buttons, scrollbar track etc, but not when dragging handles or scrollbar
{
trigger: 'navigator',
triggerOp: 'navigator-drag',
DOMEvent: DOMEvent // #1838
}
);
}
}
if (e.DOMType !== 'mousemove') {
navigator.grabbedLeft = navigator.grabbedRight =
navigator.grabbedCenter = navigator.fixedWidth =
navigator.fixedExtreme = navigator.otherHandlePos =
navigator.hasDragged = navigator.dragOffset = null;
}
},
/**
* Removes the event handlers attached previously with addEvents.
*/
removeEvents: function() {
if (this.eventsToUnbind) {
each(this.eventsToUnbind, function(unbind) {
unbind();
});
this.eventsToUnbind = undefined;
}
this.removeBaseSeriesEvents();
},
/**
* Remove data events.
*/
removeBaseSeriesEvents: function() {
var baseSeries = this.baseSeries || [];
if (this.navigatorEnabled && baseSeries[0] && this.navigatorOptions.adaptToUpdatedData !== false) {
each(baseSeries, function(series) {
removeEvent(series, 'updatedData', this.updatedDataHandler);
}, this);
// We only listen for extremes-events on the first baseSeries
if (baseSeries[0].xAxis) {
removeEvent(baseSeries[0].xAxis, 'foundExtremes', this.modifyBaseAxisExtremes);
}
}
},
/**
* Initiate the Navigator object
*/
init: function(chart) {
var chartOptions = chart.options,
navigatorOptions = chartOptions.navigator,
navigatorEnabled = navigatorOptions.enabled,
scrollbarOptions = chartOptions.scrollbar,
scrollbarEnabled = scrollbarOptions.enabled,
height = navigatorEnabled ? navigatorOptions.height : 0,
scrollbarHeight = scrollbarEnabled ? scrollbarOptions.height : 0;
this.handles = [];
this.shades = [];
this.chart = chart;
this.setBaseSeries();
this.height = height;
this.scrollbarHeight = scrollbarHeight;
this.scrollbarEnabled = scrollbarEnabled;
this.navigatorEnabled = navigatorEnabled;
this.navigatorOptions = navigatorOptions;
this.scrollbarOptions = scrollbarOptions;
this.outlineHeight = height + scrollbarHeight;
this.opposite = pick(navigatorOptions.opposite, !navigatorEnabled && chart.inverted); // #6262
var navigator = this,
baseSeries = navigator.baseSeries,
xAxisIndex = chart.xAxis.length,
yAxisIndex = chart.yAxis.length,
baseXaxis = baseSeries && baseSeries[0] && baseSeries[0].xAxis || chart.xAxis[0];
// Make room for the navigator, can be placed around the chart:
chart.extraMargin = {
type: navigator.opposite ? 'plotTop' : 'marginBottom',
value: (navigatorEnabled || !chart.inverted ? navigator.outlineHeight : 0) + navigatorOptions.margin
};
if (chart.inverted) {
chart.extraMargin.type = navigator.opposite ? 'marginRight' : 'plotLeft';
}
chart.isDirtyBox = true;
if (navigator.navigatorEnabled) {
// an x axis is required for scrollbar also
navigator.xAxis = new Axis(chart, merge({
// inherit base xAxis' break and ordinal options
breaks: baseXaxis.options.breaks,
ordinal: baseXaxis.options.ordinal
}, navigatorOptions.xAxis, {
id: 'navigator-x-axis',
yAxis: 'navigator-y-axis',
isX: true,
type: 'datetime',
index: xAxisIndex,
offset: 0,
keepOrdinalPadding: true, // #2436
startOnTick: false,
endOnTick: false,
minPadding: 0,
maxPadding: 0,
zoomEnabled: false
}, chart.inverted ? {
offsets: [scrollbarHeight, 0, -scrollbarHeight, 0],
width: height
} : {
offsets: [0, -scrollbarHeight, 0, scrollbarHeight],
height: height
}));
navigator.yAxis = new Axis(chart, merge(navigatorOptions.yAxis, {
id: 'navigator-y-axis',
alignTicks: false,
offset: 0,
index: yAxisIndex,
zoomEnabled: false
}, chart.inverted ? {
width: height
} : {
height: height
}));
// If we have a base series, initialize the navigator series
if (baseSeries || navigatorOptions.series.data) {
navigator.addBaseSeries();
// If not, set up an event to listen for added series
} else if (chart.series.length === 0) {
wrap(chart, 'redraw', function(proceed, animation) {
// We've got one, now add it as base and reset chart.redraw
if (chart.series.length > 0 && !navigator.series) {
navigator.setBaseSeries();
chart.redraw = proceed; // reset
}
proceed.call(chart, animation);
});
}
// Render items, so we can bind events to them:
navigator.renderElements();
// Add mouse events
navigator.addMouseEvents();
// in case of scrollbar only, fake an x axis to get translation
} else {
navigator.xAxis = {
translate: function(value, reverse) {
var axis = chart.xAxis[0],
ext = axis.getExtremes(),
scrollTrackWidth = axis.len - 2 * scrollbarHeight,
min = numExt('min', axis.options.min, ext.dataMin),
valueRange = numExt('max', axis.options.max, ext.dataMax) - min;
return reverse ?
// from pixel to value
(value * valueRange / scrollTrackWidth) + min :
// from value to pixel
scrollTrackWidth * (value - min) / valueRange;
},
toPixels: function(value) {
return this.translate(value);
},
toValue: function(value) {
return this.translate(value, true);
},
toFixedRange: Axis.prototype.toFixedRange,
fake: true
};
}
// Initialize the scrollbar
if (chart.options.scrollbar.enabled) {
chart.scrollbar = navigator.scrollbar = new Scrollbar(
chart.renderer,
merge(chart.options.scrollbar, {
margin: navigator.navigatorEnabled ? 0 : 10,
vertical: chart.inverted
}),
chart
);
addEvent(navigator.scrollbar, 'changed', function(e) {
var range = navigator.size,
to = range * this.to,
from = range * this.from;
navigator.hasDragged = navigator.scrollbar.hasDragged;
navigator.render(0, 0, from, to);
if (chart.options.scrollbar.liveRedraw || e.DOMType !== 'mousemove') {
setTimeout(function() {
navigator.onMouseUp(e);
});
}
});
}
// Add data events
navigator.addBaseSeriesEvents();
// Add redraw events
navigator.addChartEvents();
},
/**
* Get the union data extremes of the chart - the outer data extremes of the base
* X axis and the navigator axis.
* @param {boolean} returnFalseOnNoBaseSeries - as the param says.
*/
getUnionExtremes: function(returnFalseOnNoBaseSeries) {
var baseAxis = this.chart.xAxis[0],
navAxis = this.xAxis,
navAxisOptions = navAxis.options,
baseAxisOptions = baseAxis.options,
ret;
if (!returnFalseOnNoBaseSeries || baseAxis.dataMin !== null) {
ret = {
dataMin: pick( // #4053
navAxisOptions && navAxisOptions.min,
numExt(
'min',
baseAxisOptions.min,
baseAxis.dataMin,
navAxis.dataMin,
navAxis.min
)
),
dataMax: pick(
navAxisOptions && navAxisOptions.max,
numExt(
'max',
baseAxisOptions.max,
baseAxis.dataMax,
navAxis.dataMax,
navAxis.max
)
)
};
}
return ret;
},
/**
* Set the base series. With a bit of modification we should be able to make
* this an API method to be called from the outside
* @param {Object} baseSeriesOptions - series options for a navigator
*/
setBaseSeries: function(baseSeriesOptions) {
var chart = this.chart,
baseSeries;
baseSeriesOptions = baseSeriesOptions || chart.options && chart.options.navigator.baseSeries || 0;
// If we're resetting, remove the existing series
if (this.series) {
this.removeBaseSeriesEvents();
each(this.series, function(s) {
s.destroy();
});
}
baseSeries = this.baseSeries = [];
// Iterate through series and add the ones that should be shown in navigator
each(chart.series || [], function(series, i) {
if (series.options.showInNavigator || (i === baseSeriesOptions || series.options.id === baseSeriesOptions) &&
series.options.showInNavigator !== false) {
baseSeries.push(series);
}
});
// When run after render, this.xAxis already exists
if (this.xAxis && !this.xAxis.fake) {
this.addBaseSeries();
}
},
/*
* Add base series to the navigator.
*/
addBaseSeries: function() {
var navigator = this,
chart = navigator.chart,
navigatorSeries = navigator.series = [],
baseSeries = navigator.baseSeries,
baseOptions,
mergedNavSeriesOptions,
chartNavigatorOptions = navigator.navigatorOptions.series,
baseNavigatorOptions,
navSeriesMixin = {
enableMouseTracking: false,
index: null, // #6162
group: 'nav', // for columns
padXAxis: false,
xAxis: 'navigator-x-axis',
yAxis: 'navigator-y-axis',
showInLegend: false,
stacking: false, // #4823
isInternal: true,
visible: true
};
// Go through each base series and merge the options to create new series
if (baseSeries) {
each(baseSeries, function(base, i) {
navSeriesMixin.name = 'Navigator ' + (i + 1);
baseOptions = base.options || {};
baseNavigatorOptions = baseOptions.navigatorOptions || {};
mergedNavSeriesOptions = merge(baseOptions, navSeriesMixin, chartNavigatorOptions, baseNavigatorOptions);
// Merge data separately. Do a slice to avoid mutating the navigator options from base series (#4923).
var navigatorSeriesData = baseNavigatorOptions.data || chartNavigatorOptions.data;
navigator.hasNavigatorData = navigator.hasNavigatorData || !!navigatorSeriesData;
mergedNavSeriesOptions.data = navigatorSeriesData || baseOptions.data && baseOptions.data.slice(0);
// Add the series
base.navigatorSeries = chart.initSeries(mergedNavSeriesOptions);
navigatorSeries.push(base.navigatorSeries);
});
} else {
// No base series, build from mixin and chart wide options
mergedNavSeriesOptions = merge(chartNavigatorOptions, navSeriesMixin);
mergedNavSeriesOptions.data = chartNavigatorOptions.data;
navigator.hasNavigatorData = !!mergedNavSeriesOptions.data;
navigatorSeries.push(chart.initSeries(mergedNavSeriesOptions));
}
this.addBaseSeriesEvents();
},
/**
* Add data events.
* For example when main series is updated we need to recalculate extremes
*/
addBaseSeriesEvents: function() {
var navigator = this,
baseSeries = navigator.baseSeries || [];
// Bind modified extremes event to first base's xAxis only. In event of > 1 base-xAxes, the navigator will ignore those.
if (baseSeries[0] && baseSeries[0].xAxis) {
addEvent(baseSeries[0].xAxis, 'foundExtremes', this.modifyBaseAxisExtremes);
}
if (this.navigatorOptions.adaptToUpdatedData !== false) {
// Respond to updated data in the base series.
// Abort if lazy-loading data from the server.
each(baseSeries, function(base) {
if (base.xAxis) {
addEvent(base, 'updatedData', this.updatedDataHandler);
}
// Handle series removal
addEvent(base, 'remove', function() {
if (this.navigatorSeries) {
erase(navigator.series, this.navigatorSeries);
this.navigatorSeries.remove(false);
delete this.navigatorSeries;
}
});
}, this);
}
},
/**
* Set the navigator x axis extremes to reflect the total. The navigator extremes
* should always be the extremes of the union of all series in the chart as
* well as the navigator series.
*/
modifyNavigatorAxisExtremes: function() {
var xAxis = this.xAxis,
unionExtremes;
if (xAxis.getExtremes) {
unionExtremes = this.getUnionExtremes(true);
if (unionExtremes && (unionExtremes.dataMin !== xAxis.min || unionExtremes.dataMax !== xAxis.max)) {
xAxis.min = unionExtremes.dataMin;
xAxis.max = unionExtremes.dataMax;
}
}
},
/**
* Hook to modify the base axis extremes with information from the Navigator
*/
modifyBaseAxisExtremes: function() {
var baseXAxis = this,
navigator = baseXAxis.chart.navigator,
baseExtremes = baseXAxis.getExtremes(),
baseMin = baseExtremes.min,
baseMax = baseExtremes.max,
baseDataMin = baseExtremes.dataMin,
baseDataMax = baseExtremes.dataMax,
range = baseMax - baseMin,
stickToMin = navigator.stickToMin,
stickToMax = navigator.stickToMax,
newMax,
newMin,
navigatorSeries = navigator.series && navigator.series[0],
hasSetExtremes = !!baseXAxis.setExtremes,
// When the extremes have been set by range selector button, don't stick to min or max.
// The range selector buttons will handle the extremes. (#5489)
unmutable = baseXAxis.eventArgs && baseXAxis.eventArgs.trigger === 'rangeSelectorButton';
if (!unmutable) {
// If the zoomed range is already at the min, move it to the right as new data
// comes in
if (stickToMin) {
newMin = baseDataMin;
newMax = newMin + range;
}
// If the zoomed range is already at the max, move it to the right as new data
// comes in
if (stickToMax) {
newMax = baseDataMax;
if (!stickToMin) { // if stickToMin is true, the new min value is set above
newMin = Math.max(
newMax - range,
navigatorSeries && navigatorSeries.xData ?
navigatorSeries.xData[0] : -Number.MAX_VALUE
);
}
}
// Update the extremes
if (hasSetExtremes && (stickToMin || stickToMax)) {
if (isNumber(newMin)) {
baseXAxis.min = baseXAxis.userMin = newMin;
baseXAxis.max = baseXAxis.userMax = newMax;
}
}
}
// Reset
navigator.stickToMin = navigator.stickToMax = null;
},
/**
* Handler for updated data on the base series. When data is modified, the navigator series
* must reflect it. This is called from the Chart.redraw function before axis and series
* extremes are computed.
*/
updatedDataHandler: function() {
var navigator = this.chart.navigator,
baseSeries = this,
navigatorSeries = this.navigatorSeries;
// Detect whether the zoomed area should stick to the minimum or maximum. If the current
// axis minimum falls outside the new updated dataset, we must adjust.
navigator.stickToMin = isNumber(baseSeries.xAxis.min) && (baseSeries.xAxis.min <= baseSeries.xData[0]);
// If the scrollbar is scrolled all the way to the right, keep right as new data
// comes in.
navigator.stickToMax = Math.round(navigator.zoomedMax) >= Math.round(navigator.size);
// Set the navigator series data to the new data of the base series
if (navigatorSeries && !navigator.hasNavigatorData) {
navigatorSeries.options.pointStart = baseSeries.xData[0];
navigatorSeries.setData(baseSeries.options.data, false, null, false); // #5414
}
},
/**
* Add chart events, like redrawing navigator, when chart requires that.
*/
addChartEvents: function() {
addEvent(this.chart, 'redraw', function() {
// Move the scrollbar after redraw, like after data updata even if axes don't redraw
var navigator = this.navigator,
xAxis = navigator && (
navigator.baseSeries &&
navigator.baseSeries[0] &&
navigator.baseSeries[0].xAxis ||
navigator.scrollbar && this.xAxis[0]
); // #5709
if (xAxis) {
navigator.render(xAxis.min, xAxis.max);
}
});
},
/**
* Destroys allocated elements.
*/
destroy: function() {
// Disconnect events added in addEvents
this.removeEvents();
if (this.xAxis) {
erase(this.chart.xAxis, this.xAxis);
erase(this.chart.axes, this.xAxis);
}
if (this.yAxis) {
erase(this.chart.yAxis, this.yAxis);
erase(this.chart.axes, this.yAxis);
}
// Destroy series
each(this.series || [], function(s) {
if (s.destroy) {
s.destroy();
}
});
// Destroy properties
each([
'series', 'xAxis', 'yAxis', 'shades', 'outline', 'scrollbarTrack',
'scrollbarRifles', 'scrollbarGroup', 'scrollbar', 'navigatorGroup',
'rendered'
], function(prop) {
if (this[prop] && this[prop].destroy) {
this[prop].destroy();
}
this[prop] = null;
}, this);
// Destroy elements in collection
each([this.handles], function(coll) {
destroyObjectProperties(coll);
}, this);
}
};
H.Navigator = Navigator;
/**
* For Stock charts, override selection zooming with some special features because
* X axis zooming is already allowed by the Navigator and Range selector.
*/
wrap(Axis.prototype, 'zoom', function(proceed, newMin, newMax) {
var chart = this.chart,
chartOptions = chart.options,
zoomType = chartOptions.chart.zoomType,
previousZoom,
navigator = chartOptions.navigator,
rangeSelector = chartOptions.rangeSelector,
ret;
if (this.isXAxis && ((navigator && navigator.enabled) ||
(rangeSelector && rangeSelector.enabled))) {
// For x only zooming, fool the chart.zoom method not to create the zoom button
// because the property already exists
if (zoomType === 'x') {
chart.resetZoomButton = 'blocked';
// For y only zooming, ignore the X axis completely
} else if (zoomType === 'y') {
ret = false;
// For xy zooming, record the state of the zoom before zoom selection, then when
// the reset button is pressed, revert to this state
} else if (zoomType === 'xy') {
previousZoom = this.previousZoom;
if (defined(newMin)) {
this.previousZoom = [this.min, this.max];
} else if (previousZoom) {
newMin = previousZoom[0];
newMax = previousZoom[1];
delete this.previousZoom;
}
}
}
return ret !== undefined ? ret : proceed.call(this, newMin, newMax);
});
// Initialize navigator for stock charts
wrap(Chart.prototype, 'init', function(proceed, options, callback) {
addEvent(this, 'beforeRender', function() {
var options = this.options;
if (options.navigator.enabled || options.scrollbar.enabled) {
this.scroller = this.navigator = new Navigator(this);
}
});
proceed.call(this, options, callback);
});
/**
* For stock charts, extend the Chart.setChartSize method so that we can set the final top position
* of the navigator once the height of the chart, including the legend, is determined. #367.
* We can't use Chart.getMargins, because labels offsets are not calculated yet.
*/
wrap(Chart.prototype, 'setChartSize', function(proceed) {
var legend = this.legend,
navigator = this.navigator,
scrollbarHeight,
legendOptions,
xAxis,
yAxis;
proceed.apply(this, [].slice.call(arguments, 1));
if (navigator) {
legendOptions = legend.options;
xAxis = navigator.xAxis;
yAxis = navigator.yAxis;
scrollbarHeight = navigator.scrollbarHeight;
// Compute the top position
if (this.inverted) {
navigator.left = navigator.opposite ?
this.chartWidth - scrollbarHeight - navigator.height :
this.spacing[3] + scrollbarHeight;
navigator.top = this.plotTop + scrollbarHeight;
} else {
navigator.left = this.plotLeft + scrollbarHeight;
navigator.top = navigator.navigatorOptions.top ||
this.chartHeight - navigator.height - scrollbarHeight - this.spacing[2] -
(legendOptions.verticalAlign === 'bottom' && legendOptions.enabled && !legendOptions.floating ?
legend.legendHeight + pick(legendOptions.margin, 10) : 0);
}
if (xAxis && yAxis) { // false if navigator is disabled (#904)
if (this.inverted) {
xAxis.options.left = yAxis.options.left = navigator.left;
} else {
xAxis.options.top = yAxis.options.top = navigator.top;
}
xAxis.setAxisSize();
yAxis.setAxisSize();
}
}
});
// Pick up badly formatted point options to addPoint
wrap(Series.prototype, 'addPoint', function(proceed, options, redraw, shift, animation) {
var turboThreshold = this.options.turboThreshold;
if (turboThreshold && this.xData.length > turboThreshold && isObject(options, true) && this.chart.navigator) {
error(20, true);
}
proceed.call(this, options, redraw, shift, animation);
});
// Handle adding new series
wrap(Chart.prototype, 'addSeries', function(proceed, options, redraw, animation) {
var series = proceed.call(this, options, false, animation);
if (this.navigator) {
this.navigator.setBaseSeries(); // Recompute which series should be shown in navigator, and add them
}
if (pick(redraw, true)) {
this.redraw();
}
return series;
});
// Handle updating series
wrap(Series.prototype, 'update', function(proceed, newOptions, redraw) {
proceed.call(this, newOptions, false);
if (this.chart.navigator) {
this.chart.navigator.setBaseSeries();
}
if (pick(redraw, true)) {
this.chart.redraw();
}
});
Chart.prototype.callbacks.push(function(chart) {
var extremes,
navigator = chart.navigator;
// Initiate the navigator
if (navigator) {
extremes = chart.xAxis[0].getExtremes();
navigator.render(extremes.min, extremes.max);
}
});
/* ****************************************************************************
* End Navigator code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var addEvent = H.addEvent,
Axis = H.Axis,
Chart = H.Chart,
css = H.css,
createElement = H.createElement,
dateFormat = H.dateFormat,
defaultOptions = H.defaultOptions,
useUTC = defaultOptions.global.useUTC,
defined = H.defined,
destroyObjectProperties = H.destroyObjectProperties,
discardElement = H.discardElement,
each = H.each,
extend = H.extend,
fireEvent = H.fireEvent,
HCDate = H.Date,
isNumber = H.isNumber,
merge = H.merge,
pick = H.pick,
pInt = H.pInt,
splat = H.splat,
wrap = H.wrap;
/* ****************************************************************************
* Start Range Selector code *
*****************************************************************************/
extend(defaultOptions, {
rangeSelector: {
// allButtonsEnabled: false,
// enabled: true,
// buttons: {Object}
// buttonSpacing: 0,
buttonTheme: {
'stroke-width': 0,
width: 28,
height: 18,
padding: 2,
zIndex: 7 // #484, #852
},
height: 35, // reserved space for buttons and input
inputPosition: {
align: 'right'
},
// inputDateFormat: '%b %e, %Y',
// inputEditDateFormat: '%Y-%m-%d',
// inputEnabled: true,
// selected: undefined,
// inputStyle: {},
labelStyle: {
color: '#666666'
}
}
});
defaultOptions.lang = merge(defaultOptions.lang, {
rangeSelectorZoom: 'Zoom',
rangeSelectorFrom: 'From',
rangeSelectorTo: 'To'
});
/**
* The range selector.
* @class
* @param {Object} chart
*/
function RangeSelector(chart) {
// Run RangeSelector
this.init(chart);
}
RangeSelector.prototype = {
/**
* The method to run when one of the buttons in the range selectors is clicked
* @param {Number} i The index of the button
* @param {Object} rangeOptions
* @param {Boolean} redraw
*/
clickButton: function(i, redraw) {
var rangeSelector = this,
chart = rangeSelector.chart,
rangeOptions = rangeSelector.buttonOptions[i],
baseAxis = chart.xAxis[0],
unionExtremes = (chart.scroller && chart.scroller.getUnionExtremes()) || baseAxis || {},
dataMin = unionExtremes.dataMin,
dataMax = unionExtremes.dataMax,
newMin,
newMax = baseAxis && Math.round(Math.min(baseAxis.max, pick(dataMax, baseAxis.max))), // #1568
type = rangeOptions.type,
baseXAxisOptions,
range = rangeOptions._range,
rangeMin,
minSetting,
rangeSetting,
ctx,
ytdExtremes,
dataGrouping = rangeOptions.dataGrouping;
if (dataMin === null || dataMax === null) { // chart has no data, base series is removed
return;
}
// Set the fixed range before range is altered
chart.fixedRange = range;
// Apply dataGrouping associated to button
if (dataGrouping) {
this.forcedDataGrouping = true;
Axis.prototype.setDataGrouping.call(baseAxis || {
chart: this.chart
}, dataGrouping, false);
}
// Apply range
if (type === 'month' || type === 'year') {
if (!baseAxis) {
// This is set to the user options and picked up later when the axis is instantiated
// so that we know the min and max.
range = rangeOptions;
} else {
ctx = {
range: rangeOptions,
max: newMax,
dataMin: dataMin,
dataMax: dataMax
};
newMin = baseAxis.minFromRange.call(ctx);
if (isNumber(ctx.newMax)) {
newMax = ctx.newMax;
}
}
// Fixed times like minutes, hours, days
} else if (range) {
newMin = Math.max(newMax - range, dataMin);
newMax = Math.min(newMin + range, dataMax);
} else if (type === 'ytd') {
// On user clicks on the buttons, or a delayed action running from the beforeRender
// event (below), the baseAxis is defined.
if (baseAxis) {
// When "ytd" is the pre-selected button for the initial view, its calculation
// is delayed and rerun in the beforeRender event (below). When the series
// are initialized, but before the chart is rendered, we have access to the xData
// array (#942).
if (dataMax === undefined) {
dataMin = Number.MAX_VALUE;
dataMax = Number.MIN_VALUE;
each(chart.series, function(series) {
var xData = series.xData; // reassign it to the last item
dataMin = Math.min(xData[0], dataMin);
dataMax = Math.max(xData[xData.length - 1], dataMax);
});
redraw = false;
}
ytdExtremes = rangeSelector.getYTDExtremes(dataMax, dataMin, useUTC);
newMin = rangeMin = ytdExtremes.min;
newMax = ytdExtremes.max;
// "ytd" is pre-selected. We don't yet have access to processed point and extremes data
// (things like pointStart and pointInterval are missing), so we delay the process (#942)
} else {
addEvent(chart, 'beforeRender', function() {
rangeSelector.clickButton(i);
});
return;
}
} else if (type === 'all' && baseAxis) {
newMin = dataMin;
newMax = dataMax;
}
rangeSelector.setSelected(i);
// Update the chart
if (!baseAxis) {
// Axis not yet instanciated. Temporarily set min and range
// options and remove them on chart load (#4317).
baseXAxisOptions = splat(chart.options.xAxis)[0];
rangeSetting = baseXAxisOptions.range;
baseXAxisOptions.range = range;
minSetting = baseXAxisOptions.min;
baseXAxisOptions.min = rangeMin;
addEvent(chart, 'load', function resetMinAndRange() {
baseXAxisOptions.range = rangeSetting;
baseXAxisOptions.min = minSetting;
});
} else {
// Existing axis object. Set extremes after render time.
baseAxis.setExtremes(
newMin,
newMax,
pick(redraw, 1),
null, // auto animation
{
trigger: 'rangeSelectorButton',
rangeSelectorButton: rangeOptions
}
);
}
},
/**
* Set the selected option. This method only sets the internal flag, it doesn't
* update the buttons or the actual zoomed range.
*/
setSelected: function(selected) {
this.selected = this.options.selected = selected;
},
/**
* The default buttons for pre-selecting time frames
*/
defaultButtons: [{
type: 'month',
count: 1,
text: '1m'
}, {
type: 'month',
count: 3,
text: '3m'
}, {
type: 'month',
count: 6,
text: '6m'
}, {
type: 'ytd',
text: 'YTD'
}, {
type: 'year',
count: 1,
text: '1y'
}, {
type: 'all',
text: 'All'
}],
/**
* Initialize the range selector
*/
init: function(chart) {
var rangeSelector = this,
options = chart.options.rangeSelector,
buttonOptions = options.buttons || [].concat(rangeSelector.defaultButtons),
selectedOption = options.selected,
blurInputs = function() {
var minInput = rangeSelector.minInput,
maxInput = rangeSelector.maxInput;
if (minInput && minInput.blur) { //#3274 in some case blur is not defined
fireEvent(minInput, 'blur'); //#3274
}
if (maxInput && maxInput.blur) { //#3274 in some case blur is not defined
fireEvent(maxInput, 'blur'); //#3274
}
};
rangeSelector.chart = chart;
rangeSelector.options = options;
rangeSelector.buttons = [];
chart.extraTopMargin = options.height;
rangeSelector.buttonOptions = buttonOptions;
this.unMouseDown = addEvent(chart.container, 'mousedown', blurInputs);
this.unResize = addEvent(chart, 'resize', blurInputs);
// Extend the buttonOptions with actual range
each(buttonOptions, rangeSelector.computeButtonRange);
// zoomed range based on a pre-selected button index
if (selectedOption !== undefined && buttonOptions[selectedOption]) {
this.clickButton(selectedOption, false);
}
addEvent(chart, 'load', function() {
// If a data grouping is applied to the current button, release it when extremes change
addEvent(chart.xAxis[0], 'setExtremes', function(e) {
if (this.max - this.min !== chart.fixedRange && e.trigger !== 'rangeSelectorButton' &&
e.trigger !== 'updatedData' && rangeSelector.forcedDataGrouping) {
this.setDataGrouping(false, false);
}
});
});
},
/**
* Dynamically update the range selector buttons after a new range has been set
*/
updateButtonStates: function() {
var rangeSelector = this,
chart = this.chart,
baseAxis = chart.xAxis[0],
actualRange = Math.round(baseAxis.max - baseAxis.min),
hasNoData = !baseAxis.hasVisibleSeries,
day = 24 * 36e5, // A single day in milliseconds
unionExtremes = (chart.scroller && chart.scroller.getUnionExtremes()) || baseAxis,
dataMin = unionExtremes.dataMin,
dataMax = unionExtremes.dataMax,
ytdExtremes = rangeSelector.getYTDExtremes(dataMax, dataMin, useUTC),
ytdMin = ytdExtremes.min,
ytdMax = ytdExtremes.max,
selected = rangeSelector.selected,
selectedExists = isNumber(selected),
allButtonsEnabled = rangeSelector.options.allButtonsEnabled,
buttons = rangeSelector.buttons;
each(rangeSelector.buttonOptions, function(rangeOptions, i) {
var range = rangeOptions._range,
type = rangeOptions.type,
count = rangeOptions.count || 1,
button = buttons[i],
state = 0,
disable,
select,
isSelected = i === selected,
// Disable buttons where the range exceeds what is allowed in the current view
isTooGreatRange = range > dataMax - dataMin,
// Disable buttons where the range is smaller than the minimum range
isTooSmallRange = range < baseAxis.minRange,
// Do not select the YTD button if not explicitly told so
isYTDButNotSelected = false,
// Disable the All button if we're already showing all
isAllButAlreadyShowingAll = false,
isSameRange = range === actualRange;
// Months and years have a variable range so we check the extremes
if (
(type === 'month' || type === 'year') &&
(actualRange >= {
month: 28,
year: 365
}[type] * day * count) &&
(actualRange <= {
month: 31,
year: 366
}[type] * day * count)
) {
isSameRange = true;
} else if (type === 'ytd') {
isSameRange = (ytdMax - ytdMin) === actualRange;
isYTDButNotSelected = !isSelected;
} else if (type === 'all') {
isSameRange = baseAxis.max - baseAxis.min >= dataMax - dataMin;
isAllButAlreadyShowingAll = !isSelected && selectedExists && isSameRange;
}
// The new zoom area happens to match the range for a button - mark it selected.
// This happens when scrolling across an ordinal gap. It can be seen in the intraday
// demos when selecting 1h and scroll across the night gap.
disable = (!allButtonsEnabled &&
(
isTooGreatRange ||
isTooSmallRange ||
isAllButAlreadyShowingAll ||
hasNoData
)
);
select = (
(isSelected && isSameRange) ||
(isSameRange && !selectedExists && !isYTDButNotSelected)
);
if (disable) {
state = 3;
} else if (select) {
selectedExists = true; // Only one button can be selected
state = 2;
}
// If state has changed, update the button
if (button.state !== state) {
button.setState(state);
}
});
},
/**
* Compute and cache the range for an individual button
*/
computeButtonRange: function(rangeOptions) {
var type = rangeOptions.type,
count = rangeOptions.count || 1,
// these time intervals have a fixed number of milliseconds, as opposed
// to month, ytd and year
fixedTimes = {
millisecond: 1,
second: 1000,
minute: 60 * 1000,
hour: 3600 * 1000,
day: 24 * 3600 * 1000,
week: 7 * 24 * 3600 * 1000
};
// Store the range on the button object
if (fixedTimes[type]) {
rangeOptions._range = fixedTimes[type] * count;
} else if (type === 'month' || type === 'year') {
rangeOptions._range = {
month: 30,
year: 365
}[type] * 24 * 36e5 * count;
}
},
/**
* Set the internal and displayed value of a HTML input for the dates
* @param {String} name
* @param {Number} time
*/
setInputValue: function(name, time) {
var options = this.chart.options.rangeSelector,
input = this[name + 'Input'];
if (defined(time)) {
input.previousValue = input.HCTime;
input.HCTime = time;
}
input.value = dateFormat(
options.inputEditDateFormat || '%Y-%m-%d',
input.HCTime
);
this[name + 'DateBox'].attr({
text: dateFormat(options.inputDateFormat || '%b %e, %Y', input.HCTime)
});
},
showInput: function(name) {
var inputGroup = this.inputGroup,
dateBox = this[name + 'DateBox'];
css(this[name + 'Input'], {
left: (inputGroup.translateX + dateBox.x) + 'px',
top: inputGroup.translateY + 'px',
width: (dateBox.width - 2) + 'px',
height: (dateBox.height - 2) + 'px',
border: '2px solid silver'
});
},
hideInput: function(name) {
css(this[name + 'Input'], {
border: 0,
width: '1px',
height: '1px'
});
this.setInputValue(name);
},
/**
* Draw either the 'from' or the 'to' HTML input box of the range selector
* @param {Object} name
*/
drawInput: function(name) {
var rangeSelector = this,
chart = rangeSelector.chart,
chartStyle = chart.renderer.style || {},
renderer = chart.renderer,
options = chart.options.rangeSelector,
lang = defaultOptions.lang,
div = rangeSelector.div,
isMin = name === 'min',
input,
label,
dateBox,
inputGroup = this.inputGroup;
function updateExtremes() {
var inputValue = input.value,
value = (options.inputDateParser || Date.parse)(inputValue),
chartAxis = chart.xAxis[0],
dataAxis = chart.scroller && chart.scroller.xAxis ? chart.scroller.xAxis : chartAxis,
dataMin = dataAxis.dataMin,
dataMax = dataAxis.dataMax;
if (value !== input.previousValue) {
input.previousValue = value;
// If the value isn't parsed directly to a value by the browser's Date.parse method,
// like YYYY-MM-DD in IE, try parsing it a different way
if (!isNumber(value)) {
value = inputValue.split('-');
value = Date.UTC(pInt(value[0]), pInt(value[1]) - 1, pInt(value[2]));
}
if (isNumber(value)) {
// Correct for timezone offset (#433)
if (!useUTC) {
value = value + new Date().getTimezoneOffset() * 60 * 1000;
}
// Validate the extremes. If it goes beyound the data min or max, use the
// actual data extreme (#2438).
if (isMin) {
if (value > rangeSelector.maxInput.HCTime) {
value = undefined;
} else if (value < dataMin) {
value = dataMin;
}
} else {
if (value < rangeSelector.minInput.HCTime) {
value = undefined;
} else if (value > dataMax) {
value = dataMax;
}
}
// Set the extremes
if (value !== undefined) {
chartAxis.setExtremes(
isMin ? value : chartAxis.min,
isMin ? chartAxis.max : value,
undefined,
undefined, {
trigger: 'rangeSelectorInput'
}
);
}
}
}
}
// Create the text label
this[name + 'Label'] = label = renderer.label(lang[isMin ? 'rangeSelectorFrom' : 'rangeSelectorTo'], this.inputGroup.offset)
.addClass('highcharts-range-label')
.attr({
padding: 2
})
.add(inputGroup);
inputGroup.offset += label.width + 5;
// Create an SVG label that shows updated date ranges and and records click events that
// bring in the HTML input.
this[name + 'DateBox'] = dateBox = renderer.label('', inputGroup.offset)
.addClass('highcharts-range-input')
.attr({
padding: 2,
width: options.inputBoxWidth || 90,
height: options.inputBoxHeight || 17,
stroke: options.inputBoxBorderColor || '#cccccc',
'stroke-width': 1,
'text-align': 'center'
})
.on('click', function() {
rangeSelector.showInput(name); // If it is already focused, the onfocus event doesn't fire (#3713)
rangeSelector[name + 'Input'].focus();
})
.add(inputGroup);
inputGroup.offset += dateBox.width + (isMin ? 10 : 0);
// Create the HTML input element. This is rendered as 1x1 pixel then set to the right size
// when focused.
this[name + 'Input'] = input = createElement('input', {
name: name,
className: 'highcharts-range-selector',
type: 'text'
}, {
top: chart.plotTop + 'px' // prevent jump on focus in Firefox
}, div);
// Styles
label.css(merge(chartStyle, options.labelStyle));
dateBox.css(merge({
color: '#333333'
}, chartStyle, options.inputStyle));
css(input, extend({
position: 'absolute',
border: 0,
width: '1px', // Chrome needs a pixel to see it
height: '1px',
padding: 0,
textAlign: 'center',
fontSize: chartStyle.fontSize,
fontFamily: chartStyle.fontFamily,
left: '-9em' // #4798
}, options.inputStyle));
// Blow up the input box
input.onfocus = function() {
rangeSelector.showInput(name);
};
// Hide away the input box
input.onblur = function() {
rangeSelector.hideInput(name);
};
// handle changes in the input boxes
input.onchange = updateExtremes;
input.onkeypress = function(event) {
// IE does not fire onchange on enter
if (event.keyCode === 13) {
updateExtremes();
}
};
},
/**
* Get the position of the range selector buttons and inputs. This can be overridden from outside for custom positioning.
*/
getPosition: function() {
var chart = this.chart,
options = chart.options.rangeSelector,
buttonTop = pick((options.buttonPosition || {}).y, chart.plotTop - chart.axisOffset[0] - options.height);
return {
buttonTop: buttonTop,
inputTop: buttonTop - 10
};
},
/**
* Get the extremes of YTD.
* Will choose dataMax if its value is lower than the current timestamp.
* Will choose dataMin if its value is higher than the timestamp for
* the start of current year.
* @param {number} dataMax
* @param {number} dataMin
* @return {object} Returns min and max for the YTD
*/
getYTDExtremes: function(dataMax, dataMin, useUTC) {
var min,
now = new HCDate(dataMax),
year = now[HCDate.hcGetFullYear](),
startOfYear = useUTC ? HCDate.UTC(year, 0, 1) : +new HCDate(year, 0, 1); // eslint-disable-line new-cap
min = Math.max(dataMin || 0, startOfYear);
now = now.getTime();
return {
max: Math.min(dataMax || now, now),
min: min
};
},
/**
* Render the range selector including the buttons and the inputs. The first time render
* is called, the elements are created and positioned. On subsequent calls, they are
* moved and updated.
* @param {Number} min X axis minimum
* @param {Number} max X axis maximum
*/
render: function(min, max) {
var rangeSelector = this,
chart = rangeSelector.chart,
renderer = chart.renderer,
container = chart.container,
chartOptions = chart.options,
navButtonOptions = chartOptions.exporting && chartOptions.exporting.enabled !== false &&
chartOptions.navigation && chartOptions.navigation.buttonOptions,
options = chartOptions.rangeSelector,
buttons = rangeSelector.buttons,
lang = defaultOptions.lang,
div = rangeSelector.div,
inputGroup = rangeSelector.inputGroup,
buttonTheme = options.buttonTheme,
buttonPosition = options.buttonPosition || {},
inputEnabled = options.inputEnabled,
states = buttonTheme && buttonTheme.states,
plotLeft = chart.plotLeft,
buttonLeft,
pos = this.getPosition(),
buttonGroup = rangeSelector.group,
buttonBBox,
rendered = rangeSelector.rendered;
if (options.enabled === false) {
return;
}
// create the elements
if (!rendered) {
rangeSelector.group = buttonGroup = renderer.g('range-selector-buttons').add();
rangeSelector.zoomText = renderer.text(lang.rangeSelectorZoom, pick(buttonPosition.x, plotLeft), 15)
.css(options.labelStyle)
.add(buttonGroup);
// button starting position
buttonLeft = pick(buttonPosition.x, plotLeft) + rangeSelector.zoomText.getBBox().width + 5;
each(rangeSelector.buttonOptions, function(rangeOptions, i) {
buttons[i] = renderer.button(
rangeOptions.text,
buttonLeft,
0,
function() {
rangeSelector.clickButton(i);
rangeSelector.isActive = true;
},
buttonTheme,
states && states.hover,
states && states.select,
states && states.disabled
)
.attr({
'text-align': 'center'
})
.add(buttonGroup);
// increase button position for the next button
buttonLeft += buttons[i].width + pick(options.buttonSpacing, 5);
});
// first create a wrapper outside the container in order to make
// the inputs work and make export correct
if (inputEnabled !== false) {
rangeSelector.div = div = createElement('div', null, {
position: 'relative',
height: 0,
zIndex: 1 // above container
});
container.parentNode.insertBefore(div, container);
// Create the group to keep the inputs
rangeSelector.inputGroup = inputGroup = renderer.g('input-group')
.add();
inputGroup.offset = 0;
rangeSelector.drawInput('min');
rangeSelector.drawInput('max');
}
}
rangeSelector.updateButtonStates();
// Set or update the group position
buttonGroup[rendered ? 'animate' : 'attr']({
translateY: pos.buttonTop
});
if (inputEnabled !== false) {
// Update the alignment to the updated spacing box
inputGroup.align(extend({
y: pos.inputTop,
width: inputGroup.offset,
// Detect collision with the exporting buttons
x: navButtonOptions && (pos.inputTop < (navButtonOptions.y || 0) + navButtonOptions.height - chart.spacing[0]) ?
-40 : 0
}, options.inputPosition), true, chart.spacingBox);
// Hide if overlapping - inputEnabled is null or undefined
if (!defined(inputEnabled)) {
buttonBBox = buttonGroup.getBBox();
inputGroup[inputGroup.alignAttr.translateX < buttonBBox.x + buttonBBox.width + 10 ? 'hide' : 'show']();
}
// Set or reset the input values
rangeSelector.setInputValue('min', min);
rangeSelector.setInputValue('max', max);
}
rangeSelector.rendered = true;
},
/**
* Update the range selector with new options
*/
update: function(options) {
var chart = this.chart;
merge(true, chart.options.rangeSelector, options);
this.destroy();
this.init(chart);
},
/**
* Destroys allocated elements.
*/
destroy: function() {
var minInput = this.minInput,
maxInput = this.maxInput,
key;
this.unMouseDown();
this.unResize();
// Destroy elements in collections
destroyObjectProperties(this.buttons);
// Clear input element events
if (minInput) {
minInput.onfocus = minInput.onblur = minInput.onchange = null;
}
if (maxInput) {
maxInput.onfocus = maxInput.onblur = maxInput.onchange = null;
}
// Destroy HTML and SVG elements
for (key in this) {
if (this[key] && key !== 'chart') {
if (this[key].destroy) { // SVGElement
this[key].destroy();
} else if (this[key].nodeType) { // HTML element
discardElement(this[key]);
}
}
if (this[key] !== RangeSelector.prototype[key]) {
this[key] = null;
}
}
}
};
/**
* Add logic to normalize the zoomed range in order to preserve the pressed state of range selector buttons
*/
Axis.prototype.toFixedRange = function(pxMin, pxMax, fixedMin, fixedMax) {
var fixedRange = this.chart && this.chart.fixedRange,
newMin = pick(fixedMin, this.translate(pxMin, true, !this.horiz)),
newMax = pick(fixedMax, this.translate(pxMax, true, !this.horiz)),
changeRatio = fixedRange && (newMax - newMin) / fixedRange;
// If the difference between the fixed range and the actual requested range is
// too great, the user is dragging across an ordinal gap, and we need to release
// the range selector button.
if (changeRatio > 0.7 && changeRatio < 1.3) {
if (fixedMax) {
newMin = newMax - fixedRange;
} else {
newMax = newMin + fixedRange;
}
}
if (!isNumber(newMin)) { // #1195
newMin = newMax = undefined;
}
return {
min: newMin,
max: newMax
};
};
/**
* Get the axis min value based on the range option and the current max. For
* stock charts this is extended via the {@link RangeSelector} so that if the
* selected range is a multiple of months or years, it is compensated for
* various month lengths.
*
* @return {number} The new minimum value.
*/
Axis.prototype.minFromRange = function() {
var rangeOptions = this.range,
type = rangeOptions.type,
timeName = {
month: 'Month',
year: 'FullYear'
}[type],
min,
max = this.max,
dataMin,
range,
// Get the true range from a start date
getTrueRange = function(base, count) {
var date = new Date(base);
date['set' + timeName](date['get' + timeName]() + count);
return date.getTime() - base;
};
if (isNumber(rangeOptions)) {
min = max - rangeOptions;
range = rangeOptions;
} else {
min = max + getTrueRange(max, -rangeOptions.count);
// Let the fixedRange reflect initial settings (#5930)
if (this.chart) {
this.chart.fixedRange = max - min;
}
}
dataMin = pick(this.dataMin, Number.MIN_VALUE);
if (!isNumber(min)) {
min = dataMin;
}
if (min <= dataMin) {
min = dataMin;
if (range === undefined) { // #4501
range = getTrueRange(min, rangeOptions.count);
}
this.newMax = Math.min(min + range, this.dataMax);
}
if (!isNumber(max)) {
min = undefined;
}
return min;
};
// Initialize scroller for stock charts
wrap(Chart.prototype, 'init', function(proceed, options, callback) {
addEvent(this, 'init', function() {
if (this.options.rangeSelector.enabled) {
this.rangeSelector = new RangeSelector(this);
}
});
proceed.call(this, options, callback);
});
Chart.prototype.callbacks.push(function(chart) {
var extremes,
rangeSelector = chart.rangeSelector,
unbindRender,
unbindSetExtremes;
function renderRangeSelector() {
extremes = chart.xAxis[0].getExtremes();
if (isNumber(extremes.min)) {
rangeSelector.render(extremes.min, extremes.max);
}
}
if (rangeSelector) {
// redraw the scroller on setExtremes
unbindSetExtremes = addEvent(
chart.xAxis[0],
'afterSetExtremes',
function(e) {
rangeSelector.render(e.min, e.max);
}
);
// redraw the scroller chart resize
unbindRender = addEvent(chart, 'redraw', renderRangeSelector);
// do it now
renderRangeSelector();
}
// Remove resize/afterSetExtremes at chart destroy
addEvent(chart, 'destroy', function destroyEvents() {
if (rangeSelector) {
unbindRender();
unbindSetExtremes();
}
});
});
H.RangeSelector = RangeSelector;
/* ****************************************************************************
* End Range Selector code *
*****************************************************************************/
}(Highcharts));
(function(H) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
var arrayMax = H.arrayMax,
arrayMin = H.arrayMin,
Axis = H.Axis,
Chart = H.Chart,
defined = H.defined,
each = H.each,
extend = H.extend,
format = H.format,
inArray = H.inArray,
isNumber = H.isNumber,
isString = H.isString,
map = H.map,
merge = H.merge,
pick = H.pick,
Point = H.Point,
Renderer = H.Renderer,
Series = H.Series,
splat = H.splat,
SVGRenderer = H.SVGRenderer,
VMLRenderer = H.VMLRenderer,
wrap = H.wrap,
seriesProto = Series.prototype,
seriesInit = seriesProto.init,
seriesProcessData = seriesProto.processData,
pointTooltipFormatter = Point.prototype.tooltipFormatter;
/**
* A wrapper for Chart with all the default values for a Stock chart
*/
H.StockChart = H.stockChart = function(a, b, c) {
var hasRenderToArg = isString(a) || a.nodeName,
options = arguments[hasRenderToArg ? 1 : 0],
seriesOptions = options.series, // to increase performance, don't merge the data
defaultOptions = H.getOptions(),
opposite,
// Always disable startOnTick:true on the main axis when the navigator
// is enabled (#1090)
navigatorEnabled = pick(
options.navigator && options.navigator.enabled,
defaultOptions.navigator.enabled,
true
),
disableStartOnTick = navigatorEnabled ? {
startOnTick: false,
endOnTick: false
} : null,
lineOptions = {
marker: {
enabled: false,
radius: 2
}
// gapSize: 0
},
columnOptions = {
shadow: false,
borderWidth: 0
};
// apply X axis options to both single and multi y axes
options.xAxis = map(splat(options.xAxis || {}), function(xAxisOptions) {
return merge({ // defaults
minPadding: 0,
maxPadding: 0,
ordinal: true,
title: {
text: null
},
labels: {
overflow: 'justify'
},
showLastLabel: true
},
defaultOptions.xAxis, // #3802
xAxisOptions, // user options
{ // forced options
type: 'datetime',
categories: null
},
disableStartOnTick
);
});
// apply Y axis options to both single and multi y axes
options.yAxis = map(splat(options.yAxis || {}), function(yAxisOptions) {
opposite = pick(yAxisOptions.opposite, true);
return merge({ // defaults
labels: {
y: -2
},
opposite: opposite,
showLastLabel: false,
title: {
text: null
}
},
defaultOptions.yAxis, // #3802
yAxisOptions // user options
);
});
options.series = null;
options = merge({
chart: {
panning: true,
pinchType: 'x'
},
navigator: {
enabled: navigatorEnabled
},
scrollbar: {
// #4988 - check if setOptions was called
enabled: pick(defaultOptions.scrollbar.enabled, true)
},
rangeSelector: {
// #4988 - check if setOptions was called
enabled: pick(defaultOptions.rangeSelector.enabled, true)
},
title: {
text: null
},
tooltip: {
shared: true,
crosshairs: true
},
legend: {
enabled: false
},
plotOptions: {
line: lineOptions,
spline: lineOptions,
area: lineOptions,
areaspline: lineOptions,
arearange: lineOptions,
areasplinerange: lineOptions,
column: columnOptions,
columnrange: columnOptions,
candlestick: columnOptions,
ohlc: columnOptions
}
},
options, // user's options
{ // forced options
isStock: true // internal flag
}
);
options.series = seriesOptions;
return hasRenderToArg ?
new Chart(a, options, c) :
new Chart(options, b);
};
// Override the automatic label alignment so that the first Y axis' labels
// are drawn on top of the grid line, and subsequent axes are drawn outside
wrap(Axis.prototype, 'autoLabelAlign', function(proceed) {
var chart = this.chart,
options = this.options,
panes = chart._labelPanes = chart._labelPanes || {},
key,
labelOptions = this.options.labels;
if (this.chart.options.isStock && this.coll === 'yAxis') {
key = options.top + ',' + options.height;
if (!panes[key] && labelOptions.enabled) { // do it only for the first Y axis of each pane
if (labelOptions.x === 15) { // default
labelOptions.x = 0;
}
if (labelOptions.align === undefined) {
labelOptions.align = 'right';
}
panes[key] = this;
return 'right';
}
}
return proceed.call(this, [].slice.call(arguments, 1));
});
// Clear axis from label panes (#6071)
wrap(Axis.prototype, 'destroy', function(proceed) {
var chart = this.chart,
key = this.options && (this.options.top + ',' + this.options.height);
if (key && chart._labelPanes && chart._labelPanes[key] === this) {
delete chart._labelPanes[key];
}
return proceed.call(this, Array.prototype.slice.call(arguments, 1));
});
// Override getPlotLinePath to allow for multipane charts
wrap(Axis.prototype, 'getPlotLinePath', function(proceed, value, lineWidth, old, force, translatedValue) {
var axis = this,
series = (this.isLinked && !this.series ? this.linkedParent.series : this.series),
chart = axis.chart,
renderer = chart.renderer,
axisLeft = axis.left,
axisTop = axis.top,
x1,
y1,
x2,
y2,
result = [],
axes = [], //#3416 need a default array
axes2,
uniqueAxes,
transVal;
/**
* Return the other axis based on either the axis option or on related series.
*/
function getAxis(coll) {
var otherColl = coll === 'xAxis' ? 'yAxis' : 'xAxis',
opt = axis.options[otherColl];
// Other axis indexed by number
if (isNumber(opt)) {
return [chart[otherColl][opt]];
}
// Other axis indexed by id (like navigator)
if (isString(opt)) {
return [chart.get(opt)];
}
// Auto detect based on existing series
return map(series, function(s) {
return s[otherColl];
});
}
// Ignore in case of color Axis. #3360, #3524
if (axis.coll === 'colorAxis') {
return proceed.apply(this, [].slice.call(arguments, 1));
}
// Get the related axes based on series
axes = getAxis(axis.coll);
// Get the related axes based options.*Axis setting #2810
axes2 = (axis.isXAxis ? chart.yAxis : chart.xAxis);
each(axes2, function(A) {
if (defined(A.options.id) ? A.options.id.indexOf('navigator') === -1 : true) {
var a = (A.isXAxis ? 'yAxis' : 'xAxis'),
rax = (defined(A.options[a]) ? chart[a][A.options[a]] : chart[a][0]);
if (axis === rax) {
axes.push(A);
}
}
});
// Remove duplicates in the axes array. If there are no axes in the axes array,
// we are adding an axis without data, so we need to populate this with grid
// lines (#2796).
uniqueAxes = axes.length ? [] : [axis.isXAxis ? chart.yAxis[0] : chart.xAxis[0]]; //#3742
each(axes, function(axis2) {
if (inArray(axis2, uniqueAxes) === -1) {
uniqueAxes.push(axis2);
}
});
transVal = pick(translatedValue, axis.translate(value, null, null, old));
if (isNumber(transVal)) {
if (axis.horiz) {
each(uniqueAxes, function(axis2) {
var skip;
y1 = axis2.pos;
y2 = y1 + axis2.len;
x1 = x2 = Math.round(transVal + axis.transB);
if (x1 < axisLeft || x1 > axisLeft + axis.width) { // outside plot area
if (force) {
x1 = x2 = Math.min(Math.max(axisLeft, x1), axisLeft + axis.width);
} else {
skip = true;
}
}
if (!skip) {
result.push('M', x1, y1, 'L', x2, y2);
}
});
} else {
each(uniqueAxes, function(axis2) {
var skip;
x1 = axis2.pos;
x2 = x1 + axis2.len;
y1 = y2 = Math.round(axisTop + axis.height - transVal);
if (y1 < axisTop || y1 > axisTop + axis.height) { // outside plot area
if (force) {
y1 = y2 = Math.min(Math.max(axisTop, y1), axis.top + axis.height);
} else {
skip = true;
}
}
if (!skip) {
result.push('M', x1, y1, 'L', x2, y2);
}
});
}
}
return result.length > 0 ?
renderer.crispPolyLine(result, lineWidth || 1) :
null; //#3557 getPlotLinePath in regular Highcharts also returns null
});
// Override getPlotBandPath to allow for multipane charts
Axis.prototype.getPlotBandPath = function(from, to) {
var toPath = this.getPlotLinePath(to, null, null, true),
path = this.getPlotLinePath(from, null, null, true),
result = [],
i;
if (path && toPath) {
if (path.toString() === toPath.toString()) {
// #6166
result = path;
result.flat = true;
} else {
// Go over each subpath
for (i = 0; i < path.length; i += 6) {
result.push(
'M', path[i + 1], path[i + 2],
'L', path[i + 4], path[i + 5],
toPath[i + 4], toPath[i + 5],
toPath[i + 1], toPath[i + 2],
'z'
);
}
}
} else { // outside the axis area
result = null;
}
return result;
};
// Function to crisp a line with multiple segments
SVGRenderer.prototype.crispPolyLine = function(points, width) {
// points format: ['M', 0, 0, 'L', 100, 0]
// normalize to a crisp line
var i;
for (i = 0; i < points.length; i = i + 6) {
if (points[i + 1] === points[i + 4]) {
// Substract due to #1129. Now bottom and left axis gridlines behave the same.
points[i + 1] = points[i + 4] = Math.round(points[i + 1]) - (width % 2 / 2);
}
if (points[i + 2] === points[i + 5]) {
points[i + 2] = points[i + 5] = Math.round(points[i + 2]) + (width % 2 / 2);
}
}
return points;
};
if (Renderer === VMLRenderer) {
VMLRenderer.prototype.crispPolyLine = SVGRenderer.prototype.crispPolyLine;
}
// Wrapper to hide the label
wrap(Axis.prototype, 'hideCrosshair', function(proceed, i) {
proceed.call(this, i);
if (this.crossLabel) {
this.crossLabel = this.crossLabel.hide();
}
});
// Wrapper to draw the label
wrap(Axis.prototype, 'drawCrosshair', function(proceed, e, point) {
// Draw the crosshair
proceed.call(this, e, point);
// Check if the label has to be drawn
if (!defined(this.crosshair.label) || !this.crosshair.label.enabled || !this.cross) {
return;
}
var chart = this.chart,
options = this.options.crosshair.label, // the label's options
horiz = this.horiz, // axis orientation
opposite = this.opposite, // axis position
left = this.left, // left position
top = this.top, // top position
crossLabel = this.crossLabel, // reference to the svgElement
posx,
posy,
crossBox,
formatOption = options.format,
formatFormat = '',
limit,
align,
tickInside = this.options.tickPosition === 'inside',
snap = this.crosshair.snap !== false,
value,
offset = 0;
// Use last available event (#5287)
if (!e) {
e = this.cross && this.cross.e;
}
align = (horiz ? 'center' : opposite ?
(this.labelAlign === 'right' ? 'right' : 'left') :
(this.labelAlign === 'left' ? 'left' : 'center'));
// If the label does not exist yet, create it.
if (!crossLabel) {
crossLabel = this.crossLabel = chart.renderer.label(null, null, null, options.shape || 'callout')
.addClass('highcharts-crosshair-label' +
(this.series[0] && ' highcharts-color-' + this.series[0].colorIndex))
.attr({
align: options.align || align,
padding: pick(options.padding, 8),
r: pick(options.borderRadius, 3),
zIndex: 2
})
.add(this.labelGroup);
// Presentational
crossLabel
.attr({
fill: options.backgroundColor ||
(this.series[0] && this.series[0].color) || '#666666',
stroke: options.borderColor || '',
'stroke-width': options.borderWidth || 0
})
.css(extend({
color: '#ffffff',
fontWeight: 'normal',
fontSize: '11px',
textAlign: 'center'
}, options.style));
}
if (horiz) {
posx = snap ? point.plotX + left : e.chartX;
posy = top + (opposite ? 0 : this.height);
} else {
posx = opposite ? this.width + left : 0;
posy = snap ? point.plotY + top : e.chartY;
}
if (!formatOption && !options.formatter) {
if (this.isDatetimeAxis) {
formatFormat = '%b %d, %Y';
}
formatOption = '{value' + (formatFormat ? ':' + formatFormat : '') + '}';
}
// Show the label
value = snap ? point[this.isXAxis ? 'x' : 'y'] : this.toValue(horiz ? e.chartX : e.chartY);
crossLabel.attr({
text: formatOption ? format(formatOption, {
value: value
}) : options.formatter.call(this, value),
x: posx,
y: posy,
visibility: 'visible'
});
crossBox = crossLabel.getBBox();
// now it is placed we can correct its position
if (horiz) {
if ((tickInside && !opposite) || (!tickInside && opposite)) {
posy = crossLabel.y - crossBox.height;
}
} else {
posy = crossLabel.y - (crossBox.height / 2);
}
// check the edges
if (horiz) {
limit = {
left: left - crossBox.x,
right: left + this.width - crossBox.x
};
} else {
limit = {
left: this.labelAlign === 'left' ? left : 0,
right: this.labelAlign === 'right' ? left + this.width : chart.chartWidth
};
}
// left edge
if (crossLabel.translateX < limit.left) {
offset = limit.left - crossLabel.translateX;
}
// right edge
if (crossLabel.translateX + crossBox.width >= limit.right) {
offset = -(crossLabel.translateX + crossBox.width - limit.right);
}
// show the crosslabel
crossLabel.attr({
x: posx + offset,
y: posy,
// First set x and y, then anchorX and anchorY, when box is actually calculated, #5702
anchorX: horiz ? posx : (this.opposite ? 0 : chart.chartWidth),
anchorY: horiz ? (this.opposite ? chart.chartHeight : 0) : posy + crossBox.height / 2
});
});
/* ****************************************************************************
* Start value compare logic *
*****************************************************************************/
/**
* Extend series.init by adding a method to modify the y value used for plotting
* on the y axis. This method is called both from the axis when finding dataMin
* and dataMax, and from the series.translate method.
*/
seriesProto.init = function() {
// Call base method
seriesInit.apply(this, arguments);
// Set comparison mode
this.setCompare(this.options.compare);
};
/**
* The setCompare method can be called also from the outside after render time
*/
seriesProto.setCompare = function(compare) {
// Set or unset the modifyValue method
this.modifyValue = (compare === 'value' || compare === 'percent') ? function(value, point) {
var compareValue = this.compareValue;
if (value !== undefined && compareValue !== undefined) { // #2601, #5814
// Get the modified value
if (compare === 'value') {
value -= compareValue;
// Compare percent
} else {
value = 100 * (value / compareValue) -
(this.options.compareBase === 100 ? 0 : 100);
}
// record for tooltip etc.
if (point) {
point.change = value;
}
return value;
}
} : null;
// Survive to export, #5485
this.userOptions.compare = compare;
// Mark dirty
if (this.chart.hasRendered) {
this.isDirty = true;
}
};
/**
* Extend series.processData by finding the first y value in the plot area,
* used for comparing the following values
*/
seriesProto.processData = function() {
var series = this,
i,
keyIndex = -1,
processedXData,
processedYData,
length,
compareValue;
// call base method
seriesProcessData.apply(this, arguments);
if (series.xAxis && series.processedYData) { // not pies
// local variables
processedXData = series.processedXData;
processedYData = series.processedYData;
length = processedYData.length;
// For series with more than one value (range, OHLC etc), compare against
// close or the pointValKey (#4922, #3112)
if (series.pointArrayMap) {
// Use close if present (#3112)
keyIndex = inArray('close', series.pointArrayMap);
if (keyIndex === -1) {
keyIndex = inArray(series.pointValKey || 'y', series.pointArrayMap);
}
}
// find the first value for comparison
for (i = 0; i < length - 1; i++) {
compareValue = keyIndex > -1 ?
processedYData[i][keyIndex] :
processedYData[i];
if (isNumber(compareValue) && processedXData[i + 1] >= series.xAxis.min && compareValue !== 0) {
series.compareValue = compareValue;
break;
}
}
}
};
/**
* Modify series extremes
*/
wrap(seriesProto, 'getExtremes', function(proceed) {
var extremes;
proceed.apply(this, [].slice.call(arguments, 1));
if (this.modifyValue) {
extremes = [this.modifyValue(this.dataMin), this.modifyValue(this.dataMax)];
this.dataMin = arrayMin(extremes);
this.dataMax = arrayMax(extremes);
}
});
/**
* Add a utility method, setCompare, to the Y axis
*/
Axis.prototype.setCompare = function(compare, redraw) {
if (!this.isXAxis) {
each(this.series, function(series) {
series.setCompare(compare);
});
if (pick(redraw, true)) {
this.chart.redraw();
}
}
};
/**
* Extend the tooltip formatter by adding support for the point.change variable
* as well as the changeDecimals option
*/
Point.prototype.tooltipFormatter = function(pointFormat) {
var point = this;
pointFormat = pointFormat.replace(
'{point.change}',
(point.change > 0 ? '+' : '') +
H.numberFormat(point.change, pick(point.series.tooltipOptions.changeDecimals, 2))
);
return pointTooltipFormatter.apply(this, [pointFormat]);
};
/* ****************************************************************************
* End value compare logic *
*****************************************************************************/
/**
* Extend the Series prototype to create a separate series clip box. This is
* related to using multiple panes, and a future pane logic should incorporate
* this feature (#2754).
*/
wrap(Series.prototype, 'render', function(proceed) {
// Only do this on not 3d (#2939, #5904) nor polar (#6057) charts, and only
// if the series type handles clipping in the animate method (#2975).
if (!(this.chart.is3d && this.chart.is3d()) &&
!this.chart.polar &&
this.xAxis &&
!this.xAxis.isRadial // Gauge, #6192
) {
// First render, initial clip box
if (!this.clipBox && this.animate) {
this.clipBox = merge(this.chart.clipBox);
this.clipBox.width = this.xAxis.len;
this.clipBox.height = this.yAxis.len;
// On redrawing, resizing etc, update the clip rectangle
} else if (this.chart[this.sharedClipKey]) {
this.chart[this.sharedClipKey].attr({
width: this.xAxis.len,
height: this.yAxis.len
});
// #3111
} else if (this.clipBox) {
this.clipBox.width = this.xAxis.len;
this.clipBox.height = this.yAxis.len;
}
}
proceed.call(this);
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
(c) 2014 Highsoft AS
Authors: Jon Arild Nygard / Oystein Moseng
License: www.highcharts.com/license
*/
(function(q){"object"===typeof module&&module.exports?module.exports=q:q(Highcharts)})(function(q){(function(g){var q=g.seriesType,l=g.seriesTypes,E=g.map,v=g.merge,y=g.extend,z=g.noop,p=g.each,x=g.grep,F=g.isNumber,A=g.isString,k=g.pick,u=g.Series,G=g.stableSort,B=g.Color,H=function(a,b,c){var d;c=c||this;for(d in a)a.hasOwnProperty(d)&&b.call(c,a[d],d,a)},C=function(a,b,c,d){d=d||this;a=a||[];p(a,function(e,f){c=b.call(d,c,e,f,a)});return c},w=function(a,b,c){c=c||this;a=b.call(c,a);!1!==a&&w(a,
b,c)};q("treemap","scatter",{showInLegend:!1,marker:!1,dataLabels:{enabled:!0,defer:!1,verticalAlign:"middle",formatter:function(){return this.point.name||this.point.id},inside:!0},tooltip:{headerFormat:"",pointFormat:"\x3cb\x3e{point.name}\x3c/b\x3e: {point.value}\x3c/b\x3e\x3cbr/\x3e"},ignoreHiddenPoint:!0,layoutAlgorithm:"sliceAndDice",layoutStartingDirection:"vertical",alternateStartingDirection:!1,levelIsConstant:!0,drillUpButton:{position:{align:"right",x:-10,y:10}},borderColor:"#e6e6e6",borderWidth:1,
opacity:.15,states:{hover:{borderColor:"#999999",brightness:l.heatmap?0:.1,opacity:.75,shadow:!1}}},{pointArrayMap:["value"],axisTypes:l.heatmap?["xAxis","yAxis","colorAxis"]:["xAxis","yAxis"],optionalAxis:"colorAxis",getSymbol:z,parallelArrays:["x","y","value","colorValue"],colorKey:"colorValue",translateColors:l.heatmap&&l.heatmap.prototype.translateColors,trackerGroups:["group","dataLabelsGroup"],getListOfParents:function(a,b){a=C(a,function(a,b,e){b=k(b.parent,"");void 0===a[b]&&(a[b]=[]);a[b].push(e);
return a},{});H(a,function(a,d,e){""!==d&&-1===g.inArray(d,b)&&(p(a,function(a){e[""].push(a)}),delete e[d])});return a},getTree:function(){var a=E(this.data,function(a){return a.id}),a=this.getListOfParents(this.data,a);this.nodeMap=[];return this.buildNode("",-1,0,a,null)},init:function(a,b){u.prototype.init.call(this,a,b);this.options.allowDrillToNode&&g.addEvent(this,"click",this.onClickDrillToNode)},buildNode:function(a,b,c,d,e){var f=this,h=[],D=f.points[b],m;p(d[a]||[],function(b){m=f.buildNode(f.points[b].id,
b,c+1,d,a);h.push(m)});b={id:a,i:b,children:h,level:c,parent:e,visible:!1};f.nodeMap[b.id]=b;D&&(D.node=b);return b},setTreeValues:function(a){var b=this,c=b.options,d=0,e=[],f,h=b.points[a.i];w(b.nodeMap[b.rootNode],function(a){var c=!1,e=a.parent;a.visible=!0;if(e||""===e)c=b.nodeMap[e];return c});w(b.nodeMap[b.rootNode].children,function(a){var b=!1;p(a,function(a){a.visible=!0;a.children.length&&(b=(b||[]).concat(a.children))});return b});p(a.children,function(a){a=b.setTreeValues(a);e.push(a);
a.ignore?w(a.children,function(a){var b=!1;p(a,function(a){y(a,{ignore:!0,isLeaf:!1,visible:!1});a.children.length&&(b=(b||[]).concat(a.children))});return b}):d+=a.val});G(e,function(a,b){return a.sortIndex-b.sortIndex});f=k(h&&h.options.value,d);h&&(h.value=f);y(a,{children:e,childrenTotal:d,ignore:!(k(h&&h.visible,!0)&&0<f),isLeaf:a.visible&&!d,levelDynamic:c.levelIsConstant?a.level:a.level-b.nodeMap[b.rootNode].level,name:k(h&&h.name,""),sortIndex:k(h&&h.sortIndex,-f),val:f});return a},calculateChildrenAreas:function(a,
b){var c=this,d=c.options,e=this.levelMap[a.levelDynamic+1],f=k(c[e&&e.layoutAlgorithm]&&e.layoutAlgorithm,d.layoutAlgorithm),h=d.alternateStartingDirection,g=[];a=x(a.children,function(a){return!a.ignore});e&&e.layoutStartingDirection&&(b.direction="vertical"===e.layoutStartingDirection?0:1);g=c[f](b,a);p(a,function(a,e){e=g[e];a.values=v(e,{val:a.childrenTotal,direction:h?1-b.direction:b.direction});a.pointValues=v(e,{x:e.x/c.axisRatio,width:e.width/c.axisRatio});a.children.length&&c.calculateChildrenAreas(a,
a.values)})},setPointValues:function(){var a=this,b=a.xAxis,c=a.yAxis;p(a.points,function(d){var e=d.node,f=e.pointValues,h,g,m;m=(a.pointAttribs(d)["stroke-width"]||0)%2/2;f&&e.visible?(e=Math.round(b.translate(f.x,0,0,0,1))-m,h=Math.round(b.translate(f.x+f.width,0,0,0,1))-m,g=Math.round(c.translate(f.y,0,0,0,1))-m,f=Math.round(c.translate(f.y+f.height,0,0,0,1))-m,d.shapeType="rect",d.shapeArgs={x:Math.min(e,h),y:Math.min(g,f),width:Math.abs(h-e),height:Math.abs(f-g)},d.plotX=d.shapeArgs.x+d.shapeArgs.width/
2,d.plotY=d.shapeArgs.y+d.shapeArgs.height/2):(delete d.plotX,delete d.plotY)})},setColorRecursive:function(a,b,c){var d=this,e,f;a&&(e=d.points[a.i],f=d.levelMap[a.levelDynamic],b=k(e&&e.options.color,f&&f.color,b,d.color),c=k(e&&e.options.colorIndex,f&&f.colorIndex,c,d.colorIndex),e&&(e.color=b,e.colorIndex=c),a.children.length&&p(a.children,function(a){d.setColorRecursive(a,b,c)}))},algorithmGroup:function(a,b,c,d){this.height=a;this.width=b;this.plot=d;this.startDirection=this.direction=c;this.lH=
this.nH=this.lW=this.nW=this.total=0;this.elArr=[];this.lP={total:0,lH:0,nH:0,lW:0,nW:0,nR:0,lR:0,aspectRatio:function(a,b){return Math.max(a/b,b/a)}};this.addElement=function(a){this.lP.total=this.elArr[this.elArr.length-1];this.total+=a;0===this.direction?(this.lW=this.nW,this.lP.lH=this.lP.total/this.lW,this.lP.lR=this.lP.aspectRatio(this.lW,this.lP.lH),this.nW=this.total/this.height,this.lP.nH=this.lP.total/this.nW,this.lP.nR=this.lP.aspectRatio(this.nW,this.lP.nH)):(this.lH=this.nH,this.lP.lW=
this.lP.total/this.lH,this.lP.lR=this.lP.aspectRatio(this.lP.lW,this.lH),this.nH=this.total/this.width,this.lP.nW=this.lP.total/this.nH,this.lP.nR=this.lP.aspectRatio(this.lP.nW,this.nH));this.elArr.push(a)};this.reset=function(){this.lW=this.nW=0;this.elArr=[];this.total=0}},algorithmCalcPoints:function(a,b,c,d){var e,f,h,g,m=c.lW,k=c.lH,n=c.plot,l,r=0,t=c.elArr.length-1;b?(m=c.nW,k=c.nH):l=c.elArr[c.elArr.length-1];p(c.elArr,function(a){if(b||r<t)0===c.direction?(e=n.x,f=n.y,h=m,g=a/h):(e=n.x,f=
n.y,g=k,h=a/g),d.push({x:e,y:f,width:h,height:g}),0===c.direction?n.y+=g:n.x+=h;r+=1});c.reset();0===c.direction?c.width-=m:c.height-=k;n.y=n.parent.y+(n.parent.height-c.height);n.x=n.parent.x+(n.parent.width-c.width);a&&(c.direction=1-c.direction);b||c.addElement(l)},algorithmLowAspectRatio:function(a,b,c){var d=[],e=this,f,g={x:b.x,y:b.y,parent:b},k=0,m=c.length-1,l=new this.algorithmGroup(b.height,b.width,b.direction,g);p(c,function(c){f=c.val/b.val*b.height*b.width;l.addElement(f);l.lP.nR>l.lP.lR&&
e.algorithmCalcPoints(a,!1,l,d,g);k===m&&e.algorithmCalcPoints(a,!0,l,d,g);k+=1});return d},algorithmFill:function(a,b,c){var d=[],e,f=b.direction,g=b.x,k=b.y,m=b.width,l=b.height,n,q,r,t;p(c,function(c){e=c.val/b.val*b.height*b.width;n=g;q=k;0===f?(t=l,r=e/t,m-=r,g+=r):(r=m,t=e/r,l-=t,k+=t);d.push({x:n,y:q,width:r,height:t});a&&(f=1-f)});return d},strip:function(a,b){return this.algorithmLowAspectRatio(!1,a,b)},squarified:function(a,b){return this.algorithmLowAspectRatio(!0,a,b)},sliceAndDice:function(a,
b){return this.algorithmFill(!0,a,b)},stripes:function(a,b){return this.algorithmFill(!1,a,b)},translate:function(){var a=this.rootNode=k(this.rootNode,this.options.rootId,""),b,c;u.prototype.translate.call(this);this.levelMap=C(this.options.levels,function(a,b){a[b.level]=b;return a},{});c=this.tree=this.getTree();b=this.nodeMap[a];""===a||b&&b.children.length||(this.drillToNode("",!1),a=this.rootNode,b=this.nodeMap[a]);this.setTreeValues(c);this.axisRatio=this.xAxis.len/this.yAxis.len;this.nodeMap[""].pointValues=
a={x:0,y:0,width:100,height:100};this.nodeMap[""].values=a=v(a,{width:a.width*this.axisRatio,direction:"vertical"===this.options.layoutStartingDirection?0:1,val:c.val});this.calculateChildrenAreas(c,a);this.colorAxis?this.translateColors():this.options.colorByPoint||this.setColorRecursive(this.tree);this.options.allowDrillToNode&&(b=b.pointValues,this.xAxis.setExtremes(b.x,b.x+b.width,!1),this.yAxis.setExtremes(b.y,b.y+b.height,!1),this.xAxis.setScale(),this.yAxis.setScale());this.setPointValues()},
drawDataLabels:function(){var a=this,b=x(a.points,function(a){return a.node.visible}),c,d;p(b,function(b){d=a.levelMap[b.node.levelDynamic];c={style:{}};b.node.isLeaf||(c.enabled=!1);d&&d.dataLabels&&(c=v(c,d.dataLabels),a._hasPointLabels=!0);b.shapeArgs&&(c.style.width=b.shapeArgs.width,b.dataLabel&&b.dataLabel.css({width:b.shapeArgs.width+"px"}));b.dlOptions=v(c,b.options.dataLabels)});u.prototype.drawDataLabels.call(this)},alignDataLabel:function(a){l.column.prototype.alignDataLabel.apply(this,
arguments);a.dataLabel&&a.dataLabel.attr({zIndex:a.node.zIndex+1})},pointAttribs:function(a,b){var c=this.levelMap[a.node.levelDynamic]||{},d=this.options,e=b&&d.states[b]||{},f=a.getClassName();a={stroke:a.borderColor||c.borderColor||e.borderColor||d.borderColor,"stroke-width":k(a.borderWidth,c.borderWidth,e.borderWidth,d.borderWidth),dashstyle:a.borderDashStyle||c.borderDashStyle||e.borderDashStyle||d.borderDashStyle,fill:a.color||this.color};-1!==f.indexOf("highcharts-above-level")?(a.fill="none",
a["stroke-width"]=0):-1!==f.indexOf("highcharts-internal-node-interactive")?(b=k(e.opacity,d.opacity),a.fill=B(a.fill).setOpacity(b).get(),a.cursor="pointer"):-1!==f.indexOf("highcharts-internal-node")?a.fill="none":b&&(a.fill=B(a.fill).brighten(e.brightness).get());return a},drawPoints:function(){var a=this,b=x(a.points,function(a){return a.node.visible});p(b,function(b){var c="levelGroup-"+b.node.levelDynamic;a[c]||(a[c]=a.chart.renderer.g(c).attr({zIndex:1E3-b.node.levelDynamic}).add(a.group));
b.group=a[c]});l.column.prototype.drawPoints.call(this);a.options.allowDrillToNode&&p(b,function(b){b.graphic&&(b.drillId=a.options.interactByLeaf?a.drillToByLeaf(b):a.drillToByGroup(b))})},onClickDrillToNode:function(a){var b=(a=a.point)&&a.drillId;A(b)&&(a.setState(""),this.drillToNode(b))},drillToByGroup:function(a){var b=!1;1!==a.node.level-this.nodeMap[this.rootNode].level||a.node.isLeaf||(b=a.id);return b},drillToByLeaf:function(a){var b=!1;if(a.node.parent!==this.rootNode&&a.node.isLeaf)for(a=
a.node;!b;)a=this.nodeMap[a.parent],a.parent===this.rootNode&&(b=a.id);return b},drillUp:function(){var a=this.nodeMap[this.rootNode];a&&A(a.parent)&&this.drillToNode(a.parent)},drillToNode:function(a,b){var c=this.nodeMap[a];this.rootNode=a;""===a?this.drillUpButton=this.drillUpButton.destroy():this.showDrillUpButton(c&&c.name||a);this.isDirty=!0;k(b,!0)&&this.chart.redraw()},showDrillUpButton:function(a){var b=this;a=a||"\x3c Back";var c=b.options.drillUpButton,d,e;c.text&&(a=c.text);this.drillUpButton?
this.drillUpButton.attr({text:a}).align():(e=(d=c.theme)&&d.states,this.drillUpButton=this.chart.renderer.button(a,null,null,function(){b.drillUp()},d,e&&e.hover,e&&e.select).attr({align:c.position.align,zIndex:7}).add().align(c.position,!1,c.relativeTo||"plotBox"))},buildKDTree:z,drawLegendSymbol:g.LegendSymbolMixin.drawRectangle,getExtremes:function(){u.prototype.getExtremes.call(this,this.colorValueData);this.valueMin=this.dataMin;this.valueMax=this.dataMax;u.prototype.getExtremes.call(this)},
getExtremesFromAll:!0,bindAxes:function(){var a={endOnTick:!1,gridLineWidth:0,lineWidth:0,min:0,dataMin:0,minPadding:0,max:100,dataMax:100,maxPadding:0,startOnTick:!1,title:null,tickPositions:[]};u.prototype.bindAxes.call(this);g.extend(this.yAxis.options,a);g.extend(this.xAxis.options,a)}},{getClassName:function(){var a=g.Point.prototype.getClassName.call(this),b=this.series,c=b.options;this.node.level<=b.nodeMap[b.rootNode].level?a+=" highcharts-above-level":this.node.isLeaf||k(c.interactByLeaf,
!c.allowDrillToNode)?this.node.isLeaf||(a+=" highcharts-internal-node"):a+=" highcharts-internal-node-interactive";return a},isValid:function(){return F(this.value)},setState:function(a){g.Point.prototype.setState.call(this,a);this.graphic&&this.graphic.attr({zIndex:"hover"===a?1:0})},setVisible:l.pie.prototype.pointClass.prototype.setVisible})})(q)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2014 Highsoft AS
* Authors: Jon Arild Nygard / Oystein Moseng
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2014 Highsoft AS
* Authors: Jon Arild Nygard / Oystein Moseng
*
* License: www.highcharts.com/license
*/
var seriesType = H.seriesType,
seriesTypes = H.seriesTypes,
map = H.map,
merge = H.merge,
extend = H.extend,
noop = H.noop,
each = H.each,
grep = H.grep,
isNumber = H.isNumber,
isString = H.isString,
pick = H.pick,
Series = H.Series,
stableSort = H.stableSort,
color = H.Color,
eachObject = function(list, func, context) {
var key;
context = context || this;
for (key in list) {
if (list.hasOwnProperty(key)) {
func.call(context, list[key], key, list);
}
}
},
reduce = function(arr, func, previous, context) {
context = context || this;
arr = arr || []; // @note should each be able to handle empty values automatically?
each(arr, function(current, i) {
previous = func.call(context, previous, current, i, arr);
});
return previous;
},
// @todo find correct name for this function.
// @todo Similar to reduce, this function is likely redundant
recursive = function(item, func, context) {
var next;
context = context || this;
next = func.call(context, item);
if (next !== false) {
recursive(next, func, context);
}
};
// The Treemap series type
seriesType('treemap', 'scatter', {
showInLegend: false,
marker: false,
dataLabels: {
enabled: true,
defer: false,
verticalAlign: 'middle',
formatter: function() { // #2945
return this.point.name || this.point.id;
},
inside: true
},
tooltip: {
headerFormat: '',
pointFormat: '<b>{point.name}</b>: {point.value}</b><br/>'
},
ignoreHiddenPoint: true,
layoutAlgorithm: 'sliceAndDice',
layoutStartingDirection: 'vertical',
alternateStartingDirection: false,
levelIsConstant: true,
drillUpButton: {
position: {
align: 'right',
x: -10,
y: 10
}
},
// Presentational options
borderColor: '#e6e6e6',
borderWidth: 1,
opacity: 0.15,
states: {
hover: {
borderColor: '#999999',
brightness: seriesTypes.heatmap ? 0 : 0.1,
opacity: 0.75,
shadow: false
}
}
// Prototype members
}, {
pointArrayMap: ['value'],
axisTypes: seriesTypes.heatmap ? ['xAxis', 'yAxis', 'colorAxis'] : ['xAxis', 'yAxis'],
optionalAxis: 'colorAxis',
getSymbol: noop,
parallelArrays: ['x', 'y', 'value', 'colorValue'],
colorKey: 'colorValue', // Point color option key
translateColors: seriesTypes.heatmap && seriesTypes.heatmap.prototype.translateColors,
trackerGroups: ['group', 'dataLabelsGroup'],
/**
* Creates an object map from parent id to childrens index.
* @param {Array} data List of points set in options.
* @param {string} data[].parent Parent id of point.
* @param {Array} ids List of all point ids.
* @return {Object} Map from parent id to children index in data.
*/
getListOfParents: function(data, ids) {
var listOfParents = reduce(data, function(prev, curr, i) {
var parent = pick(curr.parent, '');
if (prev[parent] === undefined) {
prev[parent] = [];
}
prev[parent].push(i);
return prev;
}, {});
// If parent does not exist, hoist parent to root of tree.
eachObject(listOfParents, function(children, parent, list) {
if ((parent !== '') && (H.inArray(parent, ids) === -1)) {
each(children, function(child) {
list[''].push(child);
});
delete list[parent];
}
});
return listOfParents;
},
/**
* Creates a tree structured object from the series points
*/
getTree: function() {
var series = this,
allIds = map(this.data, function(d) {
return d.id;
}),
parentList = series.getListOfParents(this.data, allIds);
series.nodeMap = [];
return series.buildNode('', -1, 0, parentList, null);
},
init: function(chart, options) {
var series = this;
Series.prototype.init.call(series, chart, options);
if (series.options.allowDrillToNode) {
H.addEvent(series, 'click', series.onClickDrillToNode);
}
},
buildNode: function(id, i, level, list, parent) {
var series = this,
children = [],
point = series.points[i],
node,
child;
// Actions
each((list[id] || []), function(i) {
child = series.buildNode(series.points[i].id, i, (level + 1), list, id);
children.push(child);
});
node = {
id: id,
i: i,
children: children,
level: level,
parent: parent,
visible: false // @todo move this to better location
};
series.nodeMap[node.id] = node;
if (point) {
point.node = node;
}
return node;
},
setTreeValues: function(tree) {
var series = this,
options = series.options,
childrenTotal = 0,
children = [],
val,
point = series.points[tree.i];
// Parents of the root node is by default visible
recursive(series.nodeMap[series.rootNode], function(node) {
var next = false,
p = node.parent;
node.visible = true;
if (p || p === '') {
next = series.nodeMap[p];
}
return next;
});
// Children of the root node is by default visible
recursive(series.nodeMap[series.rootNode].children, function(children) {
var next = false;
each(children, function(child) {
child.visible = true;
if (child.children.length) {
next = (next || []).concat(child.children);
}
});
return next;
});
// First give the children some values
each(tree.children, function(child) {
child = series.setTreeValues(child);
children.push(child);
if (!child.ignore) {
childrenTotal += child.val;
} else {
// @todo Add predicate to avoid looping already ignored children
recursive(child.children, function(children) {
var next = false;
each(children, function(node) {
extend(node, {
ignore: true,
isLeaf: false,
visible: false
});
if (node.children.length) {
next = (next || []).concat(node.children);
}
});
return next;
});
}
});
// Sort the children
stableSort(children, function(a, b) {
return a.sortIndex - b.sortIndex;
});
// Set the values
val = pick(point && point.options.value, childrenTotal);
if (point) {
point.value = val;
}
extend(tree, {
children: children,
childrenTotal: childrenTotal,
// Ignore this node if point is not visible
ignore: !(pick(point && point.visible, true) && (val > 0)),
isLeaf: tree.visible && !childrenTotal,
levelDynamic: (options.levelIsConstant ? tree.level : (tree.level - series.nodeMap[series.rootNode].level)),
name: pick(point && point.name, ''),
sortIndex: pick(point && point.sortIndex, -val),
val: val
});
return tree;
},
/**
* Recursive function which calculates the area for all children of a node.
* @param {Object} node The node which is parent to the children.
* @param {Object} area The rectangular area of the parent.
*/
calculateChildrenAreas: function(parent, area) {
var series = this,
options = series.options,
level = this.levelMap[parent.levelDynamic + 1],
algorithm = pick((series[level && level.layoutAlgorithm] && level.layoutAlgorithm), options.layoutAlgorithm),
alternate = options.alternateStartingDirection,
childrenValues = [],
children;
// Collect all children which should be included
children = grep(parent.children, function(n) {
return !n.ignore;
});
if (level && level.layoutStartingDirection) {
area.direction = level.layoutStartingDirection === 'vertical' ? 0 : 1;
}
childrenValues = series[algorithm](area, children);
each(children, function(child, index) {
var values = childrenValues[index];
child.values = merge(values, {
val: child.childrenTotal,
direction: (alternate ? 1 - area.direction : area.direction)
});
child.pointValues = merge(values, {
x: (values.x / series.axisRatio),
width: (values.width / series.axisRatio)
});
// If node has children, then call method recursively
if (child.children.length) {
series.calculateChildrenAreas(child, child.values);
}
});
},
setPointValues: function() {
var series = this,
xAxis = series.xAxis,
yAxis = series.yAxis;
each(series.points, function(point) {
var node = point.node,
values = node.pointValues,
x1,
x2,
y1,
y2,
crispCorr = 0;
// Get the crisp correction in classic mode. For this to work in
// styled mode, we would need to first add the shape (without x, y,
// width and height), then read the rendered stroke width using
// point.graphic.strokeWidth(), then modify and apply the shapeArgs.
// This applies also to column series, but the downside is
// performance and code complexity.
crispCorr = (
(series.pointAttribs(point)['stroke-width'] || 0) % 2
) / 2;
// Points which is ignored, have no values.
if (values && node.visible) {
x1 = Math.round(xAxis.translate(values.x, 0, 0, 0, 1)) - crispCorr;
x2 = Math.round(xAxis.translate(values.x + values.width, 0, 0, 0, 1)) - crispCorr;
y1 = Math.round(yAxis.translate(values.y, 0, 0, 0, 1)) - crispCorr;
y2 = Math.round(yAxis.translate(values.y + values.height, 0, 0, 0, 1)) - crispCorr;
// Set point values
point.shapeType = 'rect';
point.shapeArgs = {
x: Math.min(x1, x2),
y: Math.min(y1, y2),
width: Math.abs(x2 - x1),
height: Math.abs(y2 - y1)
};
point.plotX = point.shapeArgs.x + (point.shapeArgs.width / 2);
point.plotY = point.shapeArgs.y + (point.shapeArgs.height / 2);
} else {
// Reset visibility
delete point.plotX;
delete point.plotY;
}
});
},
setColorRecursive: function(node, color, colorIndex) {
var series = this,
point,
level;
if (node) {
point = series.points[node.i];
level = series.levelMap[node.levelDynamic];
// Select either point color, level color or inherited color.
color = pick(
point && point.options.color,
level && level.color,
color,
series.color
);
colorIndex = pick(
point && point.options.colorIndex,
level && level.colorIndex,
colorIndex,
series.colorIndex
);
if (point) {
point.color = color;
point.colorIndex = colorIndex;
}
// Do it all again with the children
if (node.children.length) {
each(node.children, function(child) {
series.setColorRecursive(child, color, colorIndex);
});
}
}
},
algorithmGroup: function(h, w, d, p) {
this.height = h;
this.width = w;
this.plot = p;
this.direction = d;
this.startDirection = d;
this.total = 0;
this.nW = 0;
this.lW = 0;
this.nH = 0;
this.lH = 0;
this.elArr = [];
this.lP = {
total: 0,
lH: 0,
nH: 0,
lW: 0,
nW: 0,
nR: 0,
lR: 0,
aspectRatio: function(w, h) {
return Math.max((w / h), (h / w));
}
};
this.addElement = function(el) {
this.lP.total = this.elArr[this.elArr.length - 1];
this.total = this.total + el;
if (this.direction === 0) {
// Calculate last point old aspect ratio
this.lW = this.nW;
this.lP.lH = this.lP.total / this.lW;
this.lP.lR = this.lP.aspectRatio(this.lW, this.lP.lH);
// Calculate last point new aspect ratio
this.nW = this.total / this.height;
this.lP.nH = this.lP.total / this.nW;
this.lP.nR = this.lP.aspectRatio(this.nW, this.lP.nH);
} else {
// Calculate last point old aspect ratio
this.lH = this.nH;
this.lP.lW = this.lP.total / this.lH;
this.lP.lR = this.lP.aspectRatio(this.lP.lW, this.lH);
// Calculate last point new aspect ratio
this.nH = this.total / this.width;
this.lP.nW = this.lP.total / this.nH;
this.lP.nR = this.lP.aspectRatio(this.lP.nW, this.nH);
}
this.elArr.push(el);
};
this.reset = function() {
this.nW = 0;
this.lW = 0;
this.elArr = [];
this.total = 0;
};
},
algorithmCalcPoints: function(directionChange, last, group, childrenArea) {
var pX,
pY,
pW,
pH,
gW = group.lW,
gH = group.lH,
plot = group.plot,
keep,
i = 0,
end = group.elArr.length - 1;
if (last) {
gW = group.nW;
gH = group.nH;
} else {
keep = group.elArr[group.elArr.length - 1];
}
each(group.elArr, function(p) {
if (last || (i < end)) {
if (group.direction === 0) {
pX = plot.x;
pY = plot.y;
pW = gW;
pH = p / pW;
} else {
pX = plot.x;
pY = plot.y;
pH = gH;
pW = p / pH;
}
childrenArea.push({
x: pX,
y: pY,
width: pW,
height: pH
});
if (group.direction === 0) {
plot.y = plot.y + pH;
} else {
plot.x = plot.x + pW;
}
}
i = i + 1;
});
// Reset variables
group.reset();
if (group.direction === 0) {
group.width = group.width - gW;
} else {
group.height = group.height - gH;
}
plot.y = plot.parent.y + (plot.parent.height - group.height);
plot.x = plot.parent.x + (plot.parent.width - group.width);
if (directionChange) {
group.direction = 1 - group.direction;
}
// If not last, then add uncalculated element
if (!last) {
group.addElement(keep);
}
},
algorithmLowAspectRatio: function(directionChange, parent, children) {
var childrenArea = [],
series = this,
pTot,
plot = {
x: parent.x,
y: parent.y,
parent: parent
},
direction = parent.direction,
i = 0,
end = children.length - 1,
group = new this.algorithmGroup(parent.height, parent.width, direction, plot); // eslint-disable-line new-cap
// Loop through and calculate all areas
each(children, function(child) {
pTot = (parent.width * parent.height) * (child.val / parent.val);
group.addElement(pTot);
if (group.lP.nR > group.lP.lR) {
series.algorithmCalcPoints(directionChange, false, group, childrenArea, plot);
}
// If last child, then calculate all remaining areas
if (i === end) {
series.algorithmCalcPoints(directionChange, true, group, childrenArea, plot);
}
i = i + 1;
});
return childrenArea;
},
algorithmFill: function(directionChange, parent, children) {
var childrenArea = [],
pTot,
direction = parent.direction,
x = parent.x,
y = parent.y,
width = parent.width,
height = parent.height,
pX,
pY,
pW,
pH;
each(children, function(child) {
pTot = (parent.width * parent.height) * (child.val / parent.val);
pX = x;
pY = y;
if (direction === 0) {
pH = height;
pW = pTot / pH;
width = width - pW;
x = x + pW;
} else {
pW = width;
pH = pTot / pW;
height = height - pH;
y = y + pH;
}
childrenArea.push({
x: pX,
y: pY,
width: pW,
height: pH
});
if (directionChange) {
direction = 1 - direction;
}
});
return childrenArea;
},
strip: function(parent, children) {
return this.algorithmLowAspectRatio(false, parent, children);
},
squarified: function(parent, children) {
return this.algorithmLowAspectRatio(true, parent, children);
},
sliceAndDice: function(parent, children) {
return this.algorithmFill(true, parent, children);
},
stripes: function(parent, children) {
return this.algorithmFill(false, parent, children);
},
translate: function() {
var series = this,
rootId = series.rootNode = pick(series.rootNode, series.options.rootId, ''),
rootNode,
pointValues,
seriesArea,
tree,
val;
// Call prototype function
Series.prototype.translate.call(series);
// Create a object map from level to options
series.levelMap = reduce(series.options.levels, function(arr, item) {
arr[item.level] = item;
return arr;
}, {});
tree = series.tree = series.getTree(); // @todo Only if series.isDirtyData is true
rootNode = series.nodeMap[rootId];
if (
rootId !== '' &&
(!rootNode || !rootNode.children.length)
) {
series.drillToNode('', false);
rootId = series.rootNode;
rootNode = series.nodeMap[rootId];
}
series.setTreeValues(tree);
// Calculate plotting values.
series.axisRatio = (series.xAxis.len / series.yAxis.len);
series.nodeMap[''].pointValues = pointValues = {
x: 0,
y: 0,
width: 100,
height: 100
};
series.nodeMap[''].values = seriesArea = merge(pointValues, {
width: (pointValues.width * series.axisRatio),
direction: (series.options.layoutStartingDirection === 'vertical' ? 0 : 1),
val: tree.val
});
series.calculateChildrenAreas(tree, seriesArea);
// Logic for point colors
if (series.colorAxis) {
series.translateColors();
} else if (!series.options.colorByPoint) {
series.setColorRecursive(series.tree);
}
// Update axis extremes according to the root node.
if (series.options.allowDrillToNode) {
val = rootNode.pointValues;
series.xAxis.setExtremes(val.x, val.x + val.width, false);
series.yAxis.setExtremes(val.y, val.y + val.height, false);
series.xAxis.setScale();
series.yAxis.setScale();
}
// Assign values to points.
series.setPointValues();
},
/**
* Extend drawDataLabels with logic to handle custom options related to the treemap series:
* - Points which is not a leaf node, has dataLabels disabled by default.
* - Options set on series.levels is merged in.
* - Width of the dataLabel is set to match the width of the point shape.
*/
drawDataLabels: function() {
var series = this,
points = grep(series.points, function(n) {
return n.node.visible;
}),
options,
level;
each(points, function(point) {
level = series.levelMap[point.node.levelDynamic];
// Set options to new object to avoid problems with scope
options = {
style: {}
};
// If not a leaf, then label should be disabled as default
if (!point.node.isLeaf) {
options.enabled = false;
}
// If options for level exists, include them as well
if (level && level.dataLabels) {
options = merge(options, level.dataLabels);
series._hasPointLabels = true;
}
// Set dataLabel width to the width of the point shape.
if (point.shapeArgs) {
options.style.width = point.shapeArgs.width;
if (point.dataLabel) {
point.dataLabel.css({
width: point.shapeArgs.width + 'px'
});
}
}
// Merge custom options with point options
point.dlOptions = merge(options, point.options.dataLabels);
});
Series.prototype.drawDataLabels.call(this);
},
/**
* Over the alignment method by setting z index
*/
alignDataLabel: function(point) {
seriesTypes.column.prototype.alignDataLabel.apply(this, arguments);
if (point.dataLabel) {
point.dataLabel.attr({
zIndex: point.node.zIndex + 1
});
}
},
/**
* Get presentational attributes
*/
pointAttribs: function(point, state) {
var level = this.levelMap[point.node.levelDynamic] || {},
options = this.options,
attr,
stateOptions = (state && options.states[state]) || {},
className = point.getClassName(),
opacity;
// Set attributes by precedence. Point trumps level trumps series. Stroke width uses pick
// because it can be 0.
attr = {
'stroke': point.borderColor || level.borderColor || stateOptions.borderColor || options.borderColor,
'stroke-width': pick(point.borderWidth, level.borderWidth, stateOptions.borderWidth, options.borderWidth),
'dashstyle': point.borderDashStyle || level.borderDashStyle || stateOptions.borderDashStyle || options.borderDashStyle,
'fill': point.color || this.color
};
// Hide levels above the current view
if (className.indexOf('highcharts-above-level') !== -1) {
attr.fill = 'none';
attr['stroke-width'] = 0;
// Nodes with children that accept interaction
} else if (className.indexOf('highcharts-internal-node-interactive') !== -1) {
opacity = pick(stateOptions.opacity, options.opacity);
attr.fill = color(attr.fill).setOpacity(opacity).get();
attr.cursor = 'pointer';
// Hide nodes that have children
} else if (className.indexOf('highcharts-internal-node') !== -1) {
attr.fill = 'none';
} else if (state) {
// Brighten and hoist the hover nodes
attr.fill = color(attr.fill).brighten(stateOptions.brightness).get();
}
return attr;
},
/**
* Extending ColumnSeries drawPoints
*/
drawPoints: function() {
var series = this,
points = grep(series.points, function(n) {
return n.node.visible;
});
each(points, function(point) {
var groupKey = 'levelGroup-' + point.node.levelDynamic;
if (!series[groupKey]) {
series[groupKey] = series.chart.renderer.g(groupKey)
.attr({
zIndex: 1000 - point.node.levelDynamic // @todo Set the zIndex based upon the number of levels, instead of using 1000
})
.add(series.group);
}
point.group = series[groupKey];
});
// Call standard drawPoints
seriesTypes.column.prototype.drawPoints.call(this);
// If drillToNode is allowed, set a point cursor on clickables & add drillId to point
if (series.options.allowDrillToNode) {
each(points, function(point) {
if (point.graphic) {
point.drillId = series.options.interactByLeaf ? series.drillToByLeaf(point) : series.drillToByGroup(point);
}
});
}
},
/**
* Add drilling on the suitable points
*/
onClickDrillToNode: function(event) {
var series = this,
point = event.point,
drillId = point && point.drillId;
// If a drill id is returned, add click event and cursor.
if (isString(drillId)) {
point.setState(''); // Remove hover
series.drillToNode(drillId);
}
},
/**
* Finds the drill id for a parent node.
* Returns false if point should not have a click event
* @param {Object} point
* @return {string || boolean} Drill to id or false when point should not have a click event
*/
drillToByGroup: function(point) {
var series = this,
drillId = false;
if ((point.node.level - series.nodeMap[series.rootNode].level) === 1 && !point.node.isLeaf) {
drillId = point.id;
}
return drillId;
},
/**
* Finds the drill id for a leaf node.
* Returns false if point should not have a click event
* @param {Object} point
* @return {string || boolean} Drill to id or false when point should not have a click event
*/
drillToByLeaf: function(point) {
var series = this,
drillId = false,
nodeParent;
if ((point.node.parent !== series.rootNode) && (point.node.isLeaf)) {
nodeParent = point.node;
while (!drillId) {
nodeParent = series.nodeMap[nodeParent.parent];
if (nodeParent.parent === series.rootNode) {
drillId = nodeParent.id;
}
}
}
return drillId;
},
drillUp: function() {
var series = this,
node = series.nodeMap[series.rootNode];
if (node && isString(node.parent)) {
series.drillToNode(node.parent);
}
},
drillToNode: function(id, redraw) {
var series = this,
nodeMap = series.nodeMap,
node = nodeMap[id];
series.rootNode = id;
if (id === '') {
series.drillUpButton = series.drillUpButton.destroy();
} else {
series.showDrillUpButton((node && node.name || id));
}
this.isDirty = true; // Force redraw
if (pick(redraw, true)) {
this.chart.redraw();
}
},
showDrillUpButton: function(name) {
var series = this,
backText = (name || '< Back'),
buttonOptions = series.options.drillUpButton,
attr,
states;
if (buttonOptions.text) {
backText = buttonOptions.text;
}
if (!this.drillUpButton) {
attr = buttonOptions.theme;
states = attr && attr.states;
this.drillUpButton = this.chart.renderer.button(
backText,
null,
null,
function() {
series.drillUp();
},
attr,
states && states.hover,
states && states.select
)
.attr({
align: buttonOptions.position.align,
zIndex: 7
})
.add()
.align(buttonOptions.position, false, buttonOptions.relativeTo || 'plotBox');
} else {
this.drillUpButton.attr({
text: backText
})
.align();
}
},
buildKDTree: noop,
drawLegendSymbol: H.LegendSymbolMixin.drawRectangle,
getExtremes: function() {
// Get the extremes from the value data
Series.prototype.getExtremes.call(this, this.colorValueData);
this.valueMin = this.dataMin;
this.valueMax = this.dataMax;
// Get the extremes from the y data
Series.prototype.getExtremes.call(this);
},
getExtremesFromAll: true,
bindAxes: function() {
var treeAxis = {
endOnTick: false,
gridLineWidth: 0,
lineWidth: 0,
min: 0,
dataMin: 0,
minPadding: 0,
max: 100,
dataMax: 100,
maxPadding: 0,
startOnTick: false,
title: null,
tickPositions: []
};
Series.prototype.bindAxes.call(this);
H.extend(this.yAxis.options, treeAxis);
H.extend(this.xAxis.options, treeAxis);
}
// Point class
}, {
getClassName: function() {
var className = H.Point.prototype.getClassName.call(this),
series = this.series,
options = series.options;
// Above the current level
if (this.node.level <= series.nodeMap[series.rootNode].level) {
className += ' highcharts-above-level';
} else if (!this.node.isLeaf && !pick(options.interactByLeaf, !options.allowDrillToNode)) {
className += ' highcharts-internal-node-interactive';
} else if (!this.node.isLeaf) {
className += ' highcharts-internal-node';
}
return className;
},
isValid: function() {
return isNumber(this.value);
},
setState: function(state) {
H.Point.prototype.setState.call(this, state);
// Graphic does not exist when point is not visible.
if (this.graphic) {
this.graphic.attr({
zIndex: state === 'hover' ? 1 : 0
});
}
},
setVisible: seriesTypes.pie.prototype.pointClass.prototype.setVisible
});
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1 1 | /*
Highcharts JS v5.0.10 (2017-03-31)
X-range series
(c) 2010-2017 Torstein Honsi, Lars A. V. Cabrera
--- WORK IN PROGRESS ---
License: www.highcharts.com/license
*/
(function(h){"object"===typeof module&&module.exports?module.exports=h:h(Highcharts)})(function(h){(function(e){var h=e.getOptions().plotOptions,x=e.Color,l=e.seriesTypes.column,g=e.each,m=e.extendClass,u=e.isNumber,t=e.isObject,r=e.merge,n=e.pick,v=e.seriesTypes,y=e.wrap,z=e.Axis,w=e.Point,A=e.Series;h.xrange=r(h.column,{tooltip:{pointFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e {series.name}: \x3cb\x3e{point.yCategory}\x3c/b\x3e\x3cbr/\x3e'}});v.xrange=m(l,{pointClass:m(w,
{getLabelConfig:function(){var d=w.prototype.getLabelConfig.call(this);d.x2=this.x2;d.yCategory=this.yCategory=this.series.yAxis.categories&&this.series.yAxis.categories[this.y];return d}}),type:"xrange",forceDL:!0,parallelArrays:["x","x2","y"],requireSorting:!1,animate:v.line.prototype.animate,getColumnMetrics:function(){function d(){g(k.series,function(c){var d=c.xAxis;c.xAxis=c.yAxis;c.yAxis=d})}var b,k=this.chart;d();this.yAxis.closestPointRange=1;b=l.prototype.getColumnMetrics.call(this);d();
return b},cropData:function(d,b,k,c){b=A.prototype.cropData.call(this,this.x2Data,b,k,c);b.xData=d.slice(b.start,b.end);return b},translate:function(){l.prototype.translate.apply(this,arguments);var d=this.xAxis,b=this.columnMetrics,k=this.options.minPointLength||0;g(this.points,function(c){var f=c.plotX,a=n(c.x2,c.x+(c.len||0)),a=d.toPixels(a,!0),e=a-f,p;k&&(p=k-e,0>p&&(p=0),f-=p/2,a+=p/2);f=Math.max(f,-10);a=Math.min(Math.max(a,-10),d.len+10);a<f&&(a=f);c.shapeArgs={x:f,y:c.plotY+b.offset,width:a-
f,height:b.width};c.tooltipPos[0]+=e/2;c.tooltipPos[1]-=b.width/2;if(a=c.partialFill)t(a)&&(a=a.amount),u(a)||(a=0),f=c.shapeArgs,c.partShapeArgs={x:f.x,y:f.y+1,width:f.width*a,height:f.height-2}})},drawPoints:function(){var d=this,b=this.chart,e=d.options,c=b.renderer,f=b.pointCount<(e.animationLimit||250)?"animate":"attr";g(d.points,function(a){var b=a.graphic,k=a.shapeType,h=a.shapeArgs,g=a.partShapeArgs,l=d.options,q=a.partialFill,m=a.selected&&"select",n=e.stacking&&!e.borderRadius;if(u(a.plotY)&&
null!==a.y){if(b){if(a.graphicOriginal[f](r(h)),g)a.graphicOverlay[f](r(g))}else a.graphic=b=c.g("point").attr({"class":a.getClassName()}).add(a.group||d.group),a.graphicOriginal=c[k](h).addClass("highcharts-partfill-original").add(b),g&&(a.graphicOverlay=c[k](g).addClass("highcharts-partfill-overlay").add(b));a.graphicOriginal.attr(d.pointAttribs(a,m)).shadow(e.shadow,null,n);g&&(t(q)||(q={}),t(l.partialFill)&&(q=r(q,l.partialFill)),b=q.fill||x(d.color).brighten(-.3).get("rgb"),a.graphicOverlay.attr(d.pointAttribs(a,
m)).attr("fill",b).attr("stroke-width",0).shadow(e.shadow,null,n))}else b&&(a.graphic=b.destroy())})}});y(z.prototype,"getSeriesExtremes",function(e){var b=this.series,d,c;e.call(this);this.isXAxis&&"xrange"===b.type&&(d=n(this.dataMax,Number.MIN_VALUE),g(this.series,function(b){g(b.x2Data||[],function(a){a>d&&(d=a,c=!0)})}),c&&(this.dataMax=d))})})(h)});
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | 1 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
* X-range series
*
* (c) 2010-2017 Torstein Honsi, Lars A. V. Cabrera
*
* --- WORK IN PROGRESS ---
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(H) {
/**
* (c) 2014-2017 Highsoft AS
* Authors: Torstein Honsi, Lars A. V. Cabrera
*
* License: www.highcharts.com/license
*/
var defaultPlotOptions = H.getOptions().plotOptions,
color = H.Color,
columnType = H.seriesTypes.column,
each = H.each,
extendClass = H.extendClass,
isNumber = H.isNumber,
isObject = H.isObject,
merge = H.merge,
pick = H.pick,
seriesTypes = H.seriesTypes,
wrap = H.wrap,
Axis = H.Axis,
Point = H.Point,
Series = H.Series,
pointFormat = '<span style="color:{point.color}">' +
'\u25CF' +
'</span> {series.name}: <b>{point.yCategory}</b><br/>',
xrange = 'xrange';
defaultPlotOptions.xrange = merge(defaultPlotOptions.column, {
tooltip: {
pointFormat: pointFormat
}
});
seriesTypes.xrange = extendClass(columnType, {
pointClass: extendClass(Point, {
// Add x2 and yCategory to the available properties for tooltip formats
getLabelConfig: function() {
var cfg = Point.prototype.getLabelConfig.call(this);
cfg.x2 = this.x2;
cfg.yCategory = this.yCategory = this.series.yAxis.categories && this.series.yAxis.categories[this.y];
return cfg;
}
}),
type: xrange,
forceDL: true,
parallelArrays: ['x', 'x2', 'y'],
requireSorting: false,
animate: seriesTypes.line.prototype.animate,
/**
* Borrow the column series metrics, but with swapped axes. This gives free access
* to features like groupPadding, grouping, pointWidth etc.
*/
getColumnMetrics: function() {
var metrics,
chart = this.chart;
function swapAxes() {
each(chart.series, function(s) {
var xAxis = s.xAxis;
s.xAxis = s.yAxis;
s.yAxis = xAxis;
});
}
swapAxes();
this.yAxis.closestPointRange = 1;
metrics = columnType.prototype.getColumnMetrics.call(this);
swapAxes();
return metrics;
},
/**
* Override cropData to show a point where x is outside visible range
* but x2 is outside.
*/
cropData: function(xData, yData, min, max) {
// Replace xData with x2Data to find the appropriate cropStart
var cropData = Series.prototype.cropData,
crop = cropData.call(this, this.x2Data, yData, min, max);
// Re-insert the cropped xData
crop.xData = xData.slice(crop.start, crop.end);
return crop;
},
translate: function() {
columnType.prototype.translate.apply(this, arguments);
var series = this,
xAxis = series.xAxis,
metrics = series.columnMetrics,
minPointLength = series.options.minPointLength || 0;
each(series.points, function(point) {
var plotX = point.plotX,
posX = pick(point.x2, point.x + (point.len || 0)),
plotX2 = xAxis.toPixels(posX, true),
width = plotX2 - plotX,
widthDifference,
shapeArgs,
partialFill;
if (minPointLength) {
widthDifference = minPointLength - width;
if (widthDifference < 0) {
widthDifference = 0;
}
plotX -= widthDifference / 2;
plotX2 += widthDifference / 2;
}
plotX = Math.max(plotX, -10);
plotX2 = Math.min(Math.max(plotX2, -10), xAxis.len + 10);
if (plotX2 < plotX) { // #6107
plotX2 = plotX;
}
point.shapeArgs = {
x: plotX,
y: point.plotY + metrics.offset,
width: plotX2 - plotX,
height: metrics.width
};
point.tooltipPos[0] += width / 2;
point.tooltipPos[1] -= metrics.width / 2;
// Add a partShapeArgs to the point, based on the shapeArgs property
partialFill = point.partialFill;
if (partialFill) {
// Get the partial fill amount
if (isObject(partialFill)) {
partialFill = partialFill.amount;
}
// If it was not a number, assume 0
if (!isNumber(partialFill)) {
partialFill = 0;
}
shapeArgs = point.shapeArgs;
point.partShapeArgs = {
x: shapeArgs.x,
y: shapeArgs.y + 1,
width: shapeArgs.width * partialFill,
height: shapeArgs.height - 2
};
}
});
},
drawPoints: function() {
var series = this,
chart = this.chart,
options = series.options,
renderer = chart.renderer,
animationLimit = options.animationLimit || 250,
verb = chart.pointCount < animationLimit ? 'animate' : 'attr';
// draw the columns
each(series.points, function(point) {
var plotY = point.plotY,
graphic = point.graphic,
type = point.shapeType,
shapeArgs = point.shapeArgs,
partShapeArgs = point.partShapeArgs,
seriesOpts = series.options,
pfOptions = point.partialFill,
fill,
state = point.selected && 'select',
cutOff = options.stacking && !options.borderRadius;
if (isNumber(plotY) && point.y !== null) {
if (graphic) { // update
point.graphicOriginal[verb](
merge(shapeArgs)
);
if (partShapeArgs) {
point.graphicOverlay[verb](
merge(partShapeArgs)
);
}
} else {
point.graphic = graphic = renderer.g('point')
.attr({
'class': point.getClassName()
})
.add(point.group || series.group);
point.graphicOriginal = renderer[type](shapeArgs)
.addClass('highcharts-partfill-original')
.add(graphic);
if (partShapeArgs) {
point.graphicOverlay = renderer[type](partShapeArgs)
.addClass('highcharts-partfill-overlay')
.add(graphic);
}
}
// Presentational
point.graphicOriginal
.attr(series.pointAttribs(point, state))
.shadow(options.shadow, null, cutOff);
if (partShapeArgs) {
// Ensure pfOptions is an object
if (!isObject(pfOptions)) {
pfOptions = {};
}
if (isObject(seriesOpts.partialFill)) {
pfOptions = merge(pfOptions, seriesOpts.partialFill);
}
fill = pfOptions.fill ||
color(series.color).brighten(-0.3).get('rgb');
point.graphicOverlay
.attr(series.pointAttribs(point, state))
.attr('fill', fill)
.attr('stroke-width', 0)
.shadow(options.shadow, null, cutOff);
}
} else if (graphic) {
point.graphic = graphic.destroy(); // #1269
}
});
}
});
/**
* Max x2 should be considered in xAxis extremes
*/
wrap(Axis.prototype, 'getSeriesExtremes', function(proceed) {
var axis = this,
series = axis.series,
dataMax,
modMax;
proceed.call(this);
if (axis.isXAxis && series.type === xrange) {
dataMax = pick(axis.dataMax, Number.MIN_VALUE);
each(this.series, function(series) {
each(series.x2Data || [], function(val) {
if (val > dataMax) {
dataMax = val;
modMax = true;
}
});
});
if (modMax) {
axis.dataMax = dataMax;
}
}
});
}(Highcharts));
}));
|
| File | Statements | Branches | Functions | Lines | |||||
|---|---|---|---|---|---|---|---|---|---|
| dark-blue.js | 42.86% | (3 / 7) | 75% | (3 / 4) | 33.33% | (1 / 3) | 42.86% | (3 / 7) | |
| dark-green.js | 42.86% | (3 / 7) | 75% | (3 / 4) | 33.33% | (1 / 3) | 42.86% | (3 / 7) | |
| dark-unica.js | 37.5% | (3 / 8) | 75% | (3 / 4) | 33.33% | (1 / 3) | 37.5% | (3 / 8) | |
| gray.js | 42.86% | (3 / 7) | 75% | (3 / 4) | 33.33% | (1 / 3) | 42.86% | (3 / 7) | |
| grid-light.js | 37.5% | (3 / 8) | 75% | (3 / 4) | 33.33% | (1 / 3) | 37.5% | (3 / 8) | |
| grid.js | 42.86% | (3 / 7) | 75% | (3 / 4) | 33.33% | (1 / 3) | 42.86% | (3 / 7) | |
| sand-signika.js | 27.27% | (3 / 11) | 75% | (3 / 4) | 25% | (1 / 4) | 27.27% | (3 / 11) | |
| skies.js | 42.86% | (3 / 7) | 75% | (3 / 4) | 33.33% | (1 / 3) | 42.86% | (3 / 7) |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(Highcharts) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*
* Dark blue theme for Highcharts JS
* @author Torstein Honsi
*/
Highcharts.theme = {
colors: ['#DDDF0D', '#55BF3B', '#DF5353', '#7798BF', '#aaeeee', '#ff0066', '#eeaaee',
'#55BF3B', '#DF5353', '#7798BF', '#aaeeee'
],
chart: {
backgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 1,
y2: 1
},
stops: [
[0, 'rgb(48, 48, 96)'],
[1, 'rgb(0, 0, 0)']
]
},
borderColor: '#000000',
borderWidth: 2,
className: 'dark-container',
plotBackgroundColor: 'rgba(255, 255, 255, .1)',
plotBorderColor: '#CCCCCC',
plotBorderWidth: 1
},
title: {
style: {
color: '#C0C0C0',
font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
}
},
subtitle: {
style: {
color: '#666666',
font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
}
},
xAxis: {
gridLineColor: '#333333',
gridLineWidth: 1,
labels: {
style: {
color: '#A0A0A0'
}
},
lineColor: '#A0A0A0',
tickColor: '#A0A0A0',
title: {
style: {
color: '#CCC',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
yAxis: {
gridLineColor: '#333333',
labels: {
style: {
color: '#A0A0A0'
}
},
lineColor: '#A0A0A0',
minorTickInterval: null,
tickColor: '#A0A0A0',
tickWidth: 1,
title: {
style: {
color: '#CCC',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
tooltip: {
backgroundColor: 'rgba(0, 0, 0, 0.75)',
style: {
color: '#F0F0F0'
}
},
toolbar: {
itemStyle: {
color: 'silver'
}
},
plotOptions: {
line: {
dataLabels: {
color: '#CCC'
},
marker: {
lineColor: '#333'
}
},
spline: {
marker: {
lineColor: '#333'
}
},
scatter: {
marker: {
lineColor: '#333'
}
},
candlestick: {
lineColor: 'white'
}
},
legend: {
itemStyle: {
font: '9pt Trebuchet MS, Verdana, sans-serif',
color: '#A0A0A0'
},
itemHoverStyle: {
color: '#FFF'
},
itemHiddenStyle: {
color: '#444'
}
},
credits: {
style: {
color: '#666'
}
},
labels: {
style: {
color: '#CCC'
}
},
navigation: {
buttonOptions: {
symbolStroke: '#DDDDDD',
hoverSymbolStroke: '#FFFFFF',
theme: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#606060'],
[0.6, '#333333']
]
},
stroke: '#000000'
}
}
},
// scroll charts
rangeSelector: {
buttonTheme: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
stroke: '#000000',
style: {
color: '#CCC',
fontWeight: 'bold'
},
states: {
hover: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#BBB'],
[0.6, '#888']
]
},
stroke: '#000000',
style: {
color: 'white'
}
},
select: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.1, '#000'],
[0.3, '#333']
]
},
stroke: '#000000',
style: {
color: 'yellow'
}
}
}
},
inputStyle: {
backgroundColor: '#333',
color: 'silver'
},
labelStyle: {
color: 'silver'
}
},
navigator: {
handles: {
backgroundColor: '#666',
borderColor: '#AAA'
},
outlineColor: '#CCC',
maskFill: 'rgba(16, 16, 16, 0.5)',
series: {
color: '#7798BF',
lineColor: '#A6C7ED'
}
},
scrollbar: {
barBackgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
barBorderColor: '#CCC',
buttonArrowColor: '#CCC',
buttonBackgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
buttonBorderColor: '#CCC',
rifleColor: '#FFF',
trackBackgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, '#000'],
[1, '#333']
]
},
trackBorderColor: '#666'
},
// special colors for some of the
legendBackgroundColor: 'rgba(0, 0, 0, 0.5)',
background2: 'rgb(35, 35, 70)',
dataLabelsColor: '#444',
textColor: '#C0C0C0',
maskColor: 'rgba(255,255,255,0.3)'
};
// Apply the theme
Highcharts.setOptions(Highcharts.theme);
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(Highcharts) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*
* Dark blue theme for Highcharts JS
* @author Torstein Honsi
*/
Highcharts.theme = {
colors: ['#DDDF0D', '#55BF3B', '#DF5353', '#7798BF', '#aaeeee', '#ff0066', '#eeaaee',
'#55BF3B', '#DF5353', '#7798BF', '#aaeeee'
],
chart: {
backgroundColor: {
linearGradient: [0, 0, 250, 500],
stops: [
[0, 'rgb(48, 96, 48)'],
[1, 'rgb(0, 0, 0)']
]
},
borderColor: '#000000',
borderWidth: 2,
className: 'dark-container',
plotBackgroundColor: 'rgba(255, 255, 255, .1)',
plotBorderColor: '#CCCCCC',
plotBorderWidth: 1
},
title: {
style: {
color: '#C0C0C0',
font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
}
},
subtitle: {
style: {
color: '#666666',
font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
}
},
xAxis: {
gridLineColor: '#333333',
gridLineWidth: 1,
labels: {
style: {
color: '#A0A0A0'
}
},
lineColor: '#A0A0A0',
tickColor: '#A0A0A0',
title: {
style: {
color: '#CCC',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
yAxis: {
gridLineColor: '#333333',
labels: {
style: {
color: '#A0A0A0'
}
},
lineColor: '#A0A0A0',
minorTickInterval: null,
tickColor: '#A0A0A0',
tickWidth: 1,
title: {
style: {
color: '#CCC',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
tooltip: {
backgroundColor: 'rgba(0, 0, 0, 0.75)',
style: {
color: '#F0F0F0'
}
},
toolbar: {
itemStyle: {
color: 'silver'
}
},
plotOptions: {
line: {
dataLabels: {
color: '#CCC'
},
marker: {
lineColor: '#333'
}
},
spline: {
marker: {
lineColor: '#333'
}
},
scatter: {
marker: {
lineColor: '#333'
}
},
candlestick: {
lineColor: 'white'
}
},
legend: {
itemStyle: {
font: '9pt Trebuchet MS, Verdana, sans-serif',
color: '#A0A0A0'
},
itemHoverStyle: {
color: '#FFF'
},
itemHiddenStyle: {
color: '#444'
}
},
credits: {
style: {
color: '#666'
}
},
labels: {
style: {
color: '#CCC'
}
},
navigation: {
buttonOptions: {
symbolStroke: '#DDDDDD',
hoverSymbolStroke: '#FFFFFF',
theme: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#606060'],
[0.6, '#333333']
]
},
stroke: '#000000'
}
}
},
// scroll charts
rangeSelector: {
buttonTheme: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
stroke: '#000000',
style: {
color: '#CCC',
fontWeight: 'bold'
},
states: {
hover: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#BBB'],
[0.6, '#888']
]
},
stroke: '#000000',
style: {
color: 'white'
}
},
select: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.1, '#000'],
[0.3, '#333']
]
},
stroke: '#000000',
style: {
color: 'yellow'
}
}
}
},
inputStyle: {
backgroundColor: '#333',
color: 'silver'
},
labelStyle: {
color: 'silver'
}
},
navigator: {
handles: {
backgroundColor: '#666',
borderColor: '#AAA'
},
outlineColor: '#CCC',
maskFill: 'rgba(16, 16, 16, 0.5)',
series: {
color: '#7798BF',
lineColor: '#A6C7ED'
}
},
scrollbar: {
barBackgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
barBorderColor: '#CCC',
buttonArrowColor: '#CCC',
buttonBackgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
buttonBorderColor: '#CCC',
rifleColor: '#FFF',
trackBackgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, '#000'],
[1, '#333']
]
},
trackBorderColor: '#666'
},
// special colors for some of the
legendBackgroundColor: 'rgba(0, 0, 0, 0.5)',
background2: 'rgb(35, 35, 70)',
dataLabelsColor: '#444',
textColor: '#C0C0C0',
maskColor: 'rgba(255,255,255,0.3)'
};
// Apply the theme
Highcharts.setOptions(Highcharts.theme);
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(Highcharts) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*
* Dark theme for Highcharts JS
* @author Torstein Honsi
*/
/* global document */
// Load the fonts
Highcharts.createElement('link', {
href: 'https://fonts.googleapis.com/css?family=Unica+One',
rel: 'stylesheet',
type: 'text/css'
}, null, document.getElementsByTagName('head')[0]);
Highcharts.theme = {
colors: ['#2b908f', '#90ee7e', '#f45b5b', '#7798BF', '#aaeeee', '#ff0066', '#eeaaee',
'#55BF3B', '#DF5353', '#7798BF', '#aaeeee'
],
chart: {
backgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 1,
y2: 1
},
stops: [
[0, '#2a2a2b'],
[1, '#3e3e40']
]
},
style: {
fontFamily: '\'Unica One\', sans-serif'
},
plotBorderColor: '#606063'
},
title: {
style: {
color: '#E0E0E3',
textTransform: 'uppercase',
fontSize: '20px'
}
},
subtitle: {
style: {
color: '#E0E0E3',
textTransform: 'uppercase'
}
},
xAxis: {
gridLineColor: '#707073',
labels: {
style: {
color: '#E0E0E3'
}
},
lineColor: '#707073',
minorGridLineColor: '#505053',
tickColor: '#707073',
title: {
style: {
color: '#A0A0A3'
}
}
},
yAxis: {
gridLineColor: '#707073',
labels: {
style: {
color: '#E0E0E3'
}
},
lineColor: '#707073',
minorGridLineColor: '#505053',
tickColor: '#707073',
tickWidth: 1,
title: {
style: {
color: '#A0A0A3'
}
}
},
tooltip: {
backgroundColor: 'rgba(0, 0, 0, 0.85)',
style: {
color: '#F0F0F0'
}
},
plotOptions: {
series: {
dataLabels: {
color: '#B0B0B3'
},
marker: {
lineColor: '#333'
}
},
boxplot: {
fillColor: '#505053'
},
candlestick: {
lineColor: 'white'
},
errorbar: {
color: 'white'
}
},
legend: {
itemStyle: {
color: '#E0E0E3'
},
itemHoverStyle: {
color: '#FFF'
},
itemHiddenStyle: {
color: '#606063'
}
},
credits: {
style: {
color: '#666'
}
},
labels: {
style: {
color: '#707073'
}
},
drilldown: {
activeAxisLabelStyle: {
color: '#F0F0F3'
},
activeDataLabelStyle: {
color: '#F0F0F3'
}
},
navigation: {
buttonOptions: {
symbolStroke: '#DDDDDD',
theme: {
fill: '#505053'
}
}
},
// scroll charts
rangeSelector: {
buttonTheme: {
fill: '#505053',
stroke: '#000000',
style: {
color: '#CCC'
},
states: {
hover: {
fill: '#707073',
stroke: '#000000',
style: {
color: 'white'
}
},
select: {
fill: '#000003',
stroke: '#000000',
style: {
color: 'white'
}
}
}
},
inputBoxBorderColor: '#505053',
inputStyle: {
backgroundColor: '#333',
color: 'silver'
},
labelStyle: {
color: 'silver'
}
},
navigator: {
handles: {
backgroundColor: '#666',
borderColor: '#AAA'
},
outlineColor: '#CCC',
maskFill: 'rgba(255,255,255,0.1)',
series: {
color: '#7798BF',
lineColor: '#A6C7ED'
},
xAxis: {
gridLineColor: '#505053'
}
},
scrollbar: {
barBackgroundColor: '#808083',
barBorderColor: '#808083',
buttonArrowColor: '#CCC',
buttonBackgroundColor: '#606063',
buttonBorderColor: '#606063',
rifleColor: '#FFF',
trackBackgroundColor: '#404043',
trackBorderColor: '#404043'
},
// special colors for some of the
legendBackgroundColor: 'rgba(0, 0, 0, 0.5)',
background2: '#505053',
dataLabelsColor: '#B0B0B3',
textColor: '#C0C0C0',
contrastTextColor: '#F0F0F3',
maskColor: 'rgba(255,255,255,0.3)'
};
// Apply the theme
Highcharts.setOptions(Highcharts.theme);
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(Highcharts) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*
* Gray theme for Highcharts JS
* @author Torstein Honsi
*/
Highcharts.theme = {
colors: ['#DDDF0D', '#7798BF', '#55BF3B', '#DF5353', '#aaeeee', '#ff0066', '#eeaaee',
'#55BF3B', '#DF5353', '#7798BF', '#aaeeee'
],
chart: {
backgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, 'rgb(96, 96, 96)'],
[1, 'rgb(16, 16, 16)']
]
},
borderWidth: 0,
borderRadius: 0,
plotBackgroundColor: null,
plotShadow: false,
plotBorderWidth: 0
},
title: {
style: {
color: '#FFF',
font: '16px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
},
subtitle: {
style: {
color: '#DDD',
font: '12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
},
xAxis: {
gridLineWidth: 0,
lineColor: '#999',
tickColor: '#999',
labels: {
style: {
color: '#999',
fontWeight: 'bold'
}
},
title: {
style: {
color: '#AAA',
font: 'bold 12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
}
},
yAxis: {
alternateGridColor: null,
minorTickInterval: null,
gridLineColor: 'rgba(255, 255, 255, .1)',
minorGridLineColor: 'rgba(255,255,255,0.07)',
lineWidth: 0,
tickWidth: 0,
labels: {
style: {
color: '#999',
fontWeight: 'bold'
}
},
title: {
style: {
color: '#AAA',
font: 'bold 12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
}
},
legend: {
itemStyle: {
color: '#CCC'
},
itemHoverStyle: {
color: '#FFF'
},
itemHiddenStyle: {
color: '#333'
}
},
labels: {
style: {
color: '#CCC'
}
},
tooltip: {
backgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, 'rgba(96, 96, 96, .8)'],
[1, 'rgba(16, 16, 16, .8)']
]
},
borderWidth: 0,
style: {
color: '#FFF'
}
},
plotOptions: {
series: {
nullColor: '#444444'
},
line: {
dataLabels: {
color: '#CCC'
},
marker: {
lineColor: '#333'
}
},
spline: {
marker: {
lineColor: '#333'
}
},
scatter: {
marker: {
lineColor: '#333'
}
},
candlestick: {
lineColor: 'white'
}
},
toolbar: {
itemStyle: {
color: '#CCC'
}
},
navigation: {
buttonOptions: {
symbolStroke: '#DDDDDD',
hoverSymbolStroke: '#FFFFFF',
theme: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#606060'],
[0.6, '#333333']
]
},
stroke: '#000000'
}
}
},
// scroll charts
rangeSelector: {
buttonTheme: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
stroke: '#000000',
style: {
color: '#CCC',
fontWeight: 'bold'
},
states: {
hover: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#BBB'],
[0.6, '#888']
]
},
stroke: '#000000',
style: {
color: 'white'
}
},
select: {
fill: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.1, '#000'],
[0.3, '#333']
]
},
stroke: '#000000',
style: {
color: 'yellow'
}
}
}
},
inputStyle: {
backgroundColor: '#333',
color: 'silver'
},
labelStyle: {
color: 'silver'
}
},
navigator: {
handles: {
backgroundColor: '#666',
borderColor: '#AAA'
},
outlineColor: '#CCC',
maskFill: 'rgba(16, 16, 16, 0.5)',
series: {
color: '#7798BF',
lineColor: '#A6C7ED'
}
},
scrollbar: {
barBackgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
barBorderColor: '#CCC',
buttonArrowColor: '#CCC',
buttonBackgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0.4, '#888'],
[0.6, '#555']
]
},
buttonBorderColor: '#CCC',
rifleColor: '#FFF',
trackBackgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, '#000'],
[1, '#333']
]
},
trackBorderColor: '#666'
},
// special colors for some of the demo examples
legendBackgroundColor: 'rgba(48, 48, 48, 0.8)',
background2: 'rgb(70, 70, 70)',
dataLabelsColor: '#444',
textColor: '#E0E0E0',
maskColor: 'rgba(255,255,255,0.3)'
};
// Apply the theme
Highcharts.setOptions(Highcharts.theme);
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(Highcharts) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*
* Grid-light theme for Highcharts JS
* @author Torstein Honsi
*/
/* global document */
// Load the fonts
Highcharts.createElement('link', {
href: 'https://fonts.googleapis.com/css?family=Dosis:400,600',
rel: 'stylesheet',
type: 'text/css'
}, null, document.getElementsByTagName('head')[0]);
Highcharts.theme = {
colors: ['#7cb5ec', '#f7a35c', '#90ee7e', '#7798BF', '#aaeeee', '#ff0066', '#eeaaee',
'#55BF3B', '#DF5353', '#7798BF', '#aaeeee'
],
chart: {
backgroundColor: null,
style: {
fontFamily: 'Dosis, sans-serif'
}
},
title: {
style: {
fontSize: '16px',
fontWeight: 'bold',
textTransform: 'uppercase'
}
},
tooltip: {
borderWidth: 0,
backgroundColor: 'rgba(219,219,216,0.8)',
shadow: false
},
legend: {
itemStyle: {
fontWeight: 'bold',
fontSize: '13px'
}
},
xAxis: {
gridLineWidth: 1,
labels: {
style: {
fontSize: '12px'
}
}
},
yAxis: {
minorTickInterval: 'auto',
title: {
style: {
textTransform: 'uppercase'
}
},
labels: {
style: {
fontSize: '12px'
}
}
},
plotOptions: {
candlestick: {
lineColor: '#404048'
}
},
// General
background2: '#F0F0EA'
};
// Apply the theme
Highcharts.setOptions(Highcharts.theme);
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(Highcharts) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*
* Grid theme for Highcharts JS
* @author Torstein Honsi
*/
Highcharts.theme = {
colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
chart: {
backgroundColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 1,
y2: 1
},
stops: [
[0, 'rgb(255, 255, 255)'],
[1, 'rgb(240, 240, 255)']
]
},
borderWidth: 2,
plotBackgroundColor: 'rgba(255, 255, 255, .9)',
plotShadow: true,
plotBorderWidth: 1
},
title: {
style: {
color: '#000',
font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
}
},
subtitle: {
style: {
color: '#666666',
font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
}
},
xAxis: {
gridLineWidth: 1,
lineColor: '#000',
tickColor: '#000',
labels: {
style: {
color: '#000',
font: '11px Trebuchet MS, Verdana, sans-serif'
}
},
title: {
style: {
color: '#333',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
yAxis: {
minorTickInterval: 'auto',
lineColor: '#000',
lineWidth: 1,
tickWidth: 1,
tickColor: '#000',
labels: {
style: {
color: '#000',
font: '11px Trebuchet MS, Verdana, sans-serif'
}
},
title: {
style: {
color: '#333',
fontWeight: 'bold',
fontSize: '12px',
fontFamily: 'Trebuchet MS, Verdana, sans-serif'
}
}
},
legend: {
itemStyle: {
font: '9pt Trebuchet MS, Verdana, sans-serif',
color: 'black'
},
itemHoverStyle: {
color: '#039'
},
itemHiddenStyle: {
color: 'gray'
}
},
labels: {
style: {
color: '#99b'
}
},
navigation: {
buttonOptions: {
theme: {
stroke: '#CCCCCC'
}
}
}
};
// Apply the theme
Highcharts.setOptions(Highcharts.theme);
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(Highcharts) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*
* Sand-Signika theme for Highcharts JS
* @author Torstein Honsi
*/
/* global document */
// Load the fonts
Highcharts.createElement('link', {
href: 'https://fonts.googleapis.com/css?family=Signika:400,700',
rel: 'stylesheet',
type: 'text/css'
}, null, document.getElementsByTagName('head')[0]);
// Add the background image to the container
Highcharts.wrap(Highcharts.Chart.prototype, 'getContainer', function(proceed) {
proceed.call(this);
this.container.style.background = 'url(http://www.highcharts.com/samples/graphics/sand.png)';
});
Highcharts.theme = {
colors: ['#f45b5b', '#8085e9', '#8d4654', '#7798BF', '#aaeeee', '#ff0066', '#eeaaee',
'#55BF3B', '#DF5353', '#7798BF', '#aaeeee'
],
chart: {
backgroundColor: null,
style: {
fontFamily: 'Signika, serif'
}
},
title: {
style: {
color: 'black',
fontSize: '16px',
fontWeight: 'bold'
}
},
subtitle: {
style: {
color: 'black'
}
},
tooltip: {
borderWidth: 0
},
legend: {
itemStyle: {
fontWeight: 'bold',
fontSize: '13px'
}
},
xAxis: {
labels: {
style: {
color: '#6e6e70'
}
}
},
yAxis: {
labels: {
style: {
color: '#6e6e70'
}
}
},
plotOptions: {
series: {
shadow: true
},
candlestick: {
lineColor: '#404048'
},
map: {
shadow: false
}
},
// Highstock specific
navigator: {
xAxis: {
gridLineColor: '#D0D0D8'
}
},
rangeSelector: {
buttonTheme: {
fill: 'white',
stroke: '#C0C0C8',
'stroke-width': 1,
states: {
select: {
fill: '#D0D0D8'
}
}
}
},
scrollbar: {
trackBorderColor: '#C0C0C8'
},
// General
background2: '#E0E0E8'
};
// Apply the theme
Highcharts.setOptions(Highcharts.theme);
}(Highcharts));
}));
|
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | 1 1 1 | /**
* @license Highcharts JS v5.0.10 (2017-03-31)
*
* (c) 2009-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function(factory) {
Eif (typeof module === 'object' && module.exports) {
module.exports = factory;
} else {
factory(Highcharts);
}
}(function(Highcharts) {
(function(Highcharts) {
/**
* (c) 2010-2017 Torstein Honsi
*
* License: www.highcharts.com/license
*
* Skies theme for Highcharts JS
* @author Torstein Honsi
*/
Highcharts.theme = {
colors: ['#514F78', '#42A07B', '#9B5E4A', '#72727F', '#1F949A', '#82914E', '#86777F', '#42A07B'],
chart: {
className: 'skies',
borderWidth: 0,
plotShadow: true,
plotBackgroundImage: 'http://www.highcharts.com/demo/gfx/skies.jpg',
plotBackgroundColor: {
linearGradient: [0, 0, 250, 500],
stops: [
[0, 'rgba(255, 255, 255, 1)'],
[1, 'rgba(255, 255, 255, 0)']
]
},
plotBorderWidth: 1
},
title: {
style: {
color: '#3E576F',
font: '16px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
},
subtitle: {
style: {
color: '#6D869F',
font: '12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
},
xAxis: {
gridLineWidth: 0,
lineColor: '#C0D0E0',
tickColor: '#C0D0E0',
labels: {
style: {
color: '#666',
fontWeight: 'bold'
}
},
title: {
style: {
color: '#666',
font: '12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
}
},
yAxis: {
alternateGridColor: 'rgba(255, 255, 255, .5)',
lineColor: '#C0D0E0',
tickColor: '#C0D0E0',
tickWidth: 1,
labels: {
style: {
color: '#666',
fontWeight: 'bold'
}
},
title: {
style: {
color: '#666',
font: '12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'
}
}
},
legend: {
itemStyle: {
font: '9pt Trebuchet MS, Verdana, sans-serif',
color: '#3E576F'
},
itemHoverStyle: {
color: 'black'
},
itemHiddenStyle: {
color: 'silver'
}
},
labels: {
style: {
color: '#3E576F'
}
}
};
// Apply the theme
Highcharts.setOptions(Highcharts.theme);
}(Highcharts));
}));
|